Not able to understand WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, which is introduced in Android M. .However the definition in android developer site is very ambiguous.Please anyone clarify about this varible
WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN - is the defined user wifi configuration state (true means its locked, false means its changeable).
from android documentation :
http://developer.android.com/reference/android/provider/Settings.Global.html
This setting controls whether WiFi configurations created by a Device
Owner app should be locked down (that is, be editable or removable
only by the Device Owner App, not even by Settings app).
since Marshmallow this configurations have been changed and now are accessible only if you produce your own configuration per application using specific API's.
please refer to Android 6.0 Changes.
https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html
Your apps can now change the state of WifiConfiguration objects only
if you created these objects. You are not permitted to modify or
delete WifiConfiguration objects created by the user or by other apps.
hope it clarifies a bit.
Related
We are developing a locked down "kiosk-style" Android app on a stock Samsung tablet, which is mounted in customer vehicles. We would like to be able to allow customers to edit their wifi settings, without giving them access to the rest of the Settings app (e.g. Launcher, accounts, etc)
We have been able to launch the Wifi Settings activity, but it allows the user to go into other areas.
I'm not sure whether it's possible to create a custom interface for connecting to wifi, but even if it were possible, this seems fragile and a lot of work for something quite simple.
Is there any way to solve this well?
I would create a device policy controller app that is provisioned on the device as a device owner using Android Enterprise (Android for Work) APIs.
https://developers.google.com/android/work/dpc/build-dpc
As a device owner, you can set your app in lock task mode which is generally used for kiosks.
https://developer.android.com/work/cosu.html
Then, you can set user restrictions:
addUserRestriction api
user restrictions list
The user restrictions don't cover everything in the settings app, but the coverage is pretty good.
Then I would provision it using NFC or QR code reader from the Google Setup Wizard welcome screen.
https://github.com/googlesamples/android-NfcProvisioning
You might want to also look at existing open source EMM/MDM implementations that already exist such as WSO2.
Other references:
How to enable task locking in Android 5.0 production devices
How to make sure there is only one app
I was also working on Kiosk Type applications and we have to give options for Change wifi and Display Settings So we have used these commands on Button click for Wifi And Display
Settings
btnWifiSetting.setOnClickListener {
startActivityForResult( Intent(android.provider.Settings.ACTION_WIFI_SETTINGS), 0);
}
And For Display Setting
btnDisplay.setOnClickListener {
startActivityForResult(Intent(android.provider.Settings.ACTION_DISPLAY_SETTINGS),0)
}
And you can also check the full list of Available Commands here
https://ourcodeworld.com/articles/read/318/how-to-open-android-settings-programmatically-with-java
try LineAgeOS
https://lineageos.org/
Your requirement needs to access OS System level, this way you have access and customize the WIFI settings before releasing the phone itself
can you try this way.
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager.isWifiEnabled()) {
wifiManager.setWifiEnabled(false);
Tools_WiFi.setImageResource(R.drawable.tool_wifi_off);
} else {
wifiManager.setWifiEnabled(true);
Tools_WiFi.setImageResource(R.drawable.tool_wifi_on);
}
You can try this:
startActivityForResult(new Intent(Settings.ACTION_WIFI_SETTINGS), 0);
Hope it helps you.
My app is working fine, until Android 5.0.2 doesn't allow third party app to connect to HID device over Bluetooth low energy.
myGatt.setCharacteristicNotification(gattChar, true);
06-01 17:39:35.356: W/BluetoothGatt(21599):
java.lang.SecurityException: Need BLUETOOTH_PRIVILEGED permission:Neither
user 10157 nor current process has android.permission.BLUETOOTH_PRIVILEGED.
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
BLUETOOTH_PRIVILEGED permission doesn't work on a third party app. It's only for system or manufacturer apps.
The latest changes from Android note:
Enforce BLUETOOTH_PRIVILEGED permission for HID-over-GATT
https://android.googlesource.com/platform/packages/apps/Bluetooth/+/02bebee
Code snippet:
private static final UUID[] HID_UUIDS = {
UUID.fromString("00002A4A-0000-1000-8000-00805F9B34FB"),
UUID.fromString("00002A4B-0000-1000-8000-00805F9B34FB"),
UUID.fromString("00002A4C-0000-1000-8000-00805F9B34FB"),
UUID.fromString("00002A4D-0000-1000-8000-00805F9B34FB") };
if (isHidUuid(charUuid)) enforcePrivilegedPermission();
My question: is there a way to overwrite HID_UUIDS or enforcePrivilegedPermission? Can I use reflection to by pass it?
Every times Android released a new version, it breaks the previous code.
Thanks!
The question is old, but still worth answering.
The HID (and FIDO https://fidoalliance.org/) service is protected and indeed requires system permission source. Only apps signed with the system key may use this service, that is only Bluetooth settings. This is to ensure that 3rd party apps are not able to listen to keys typed on a wireless keyboards, as all notifications and indications are transferred to all BluetoothGatt objects. Without this protection you would be able to connect to a HID device (you still can), enable notifications using gatt.setCharacteristicNotification(.., true) and receive updates whenever a key is typed. With a bit of knowledge about Report characteristics you can then get all the keys and mouse positions, including passwords, etc. So it's not a break, but a bug fix. On KitKat you still may do this.
The only solution is to compile your own AOSP Android version and sign your app with the same key. Otherwise it would be useless protection.
Btw, starting form Android 8 or perhaps earlier you don't get SecurityException. The call just returns true as if any other and you never get any callback.
This might have been changed here: https://android.googlesource.com/platform/packages/apps/Bluetooth/+/32dc7a6b919375aede777f3c821fa316d85449ae%5E%21/#F2
What i am looking for, is a way to switch between existing profiles under some specific user, using DevicePolicyManager Class for android lollipop.
I googled it from last two days but doesn't get a way to make it happen. I also looked on some previously asked questions on Stack-overflow and other similar forums but not found anything useful. It would be great for me, if any one can atleast answer me whether am looking for something impossible, or is there some other alternative way to do that, like by calling settings intent or similar.
Also there is method switchUser(ComponentName admin, UserHandle userHandle) in DevicePolicyManager class to switch in between users. But similar is not exist for profiles.
Thank You.
I don't think that is possible. However, I don't understand why you want to switch between profiles. If the managed profile is set up, the app which started the provisioning process is copied to the profile and set as profile owner app. The profile owner app runs then in its own process. You cannot switch from the primary user app to the managed process.
Perhaps you could explain why you want to change to a profile.
Edit:
Definition of Device Owner and Profile Owner:
Is it possible to have a "Profile Owner" app in Android Lollipop that is not co-present
The DeviceOwner example shows how the Device Owner is set up on Android. http://android-developers.blogspot.co.at/2015/04/new-android-code-samples.html
Another good post about provisioning a Device Owner with NFC: Device Owner on Android 5.0 (and others) whitout rooted devices, device provisioning by NFC
You can set a Device Owner using the command line tool dpm:
How to make my app a device owner?
After your app (widget) is Device Owner you can use the method switchUser of the DevicePoliyManager to switch between user profiles. The UserManager provides you with a list of all profiles on the device.
UserManager um = (UserManager) getSystemService(USER_SERVICE);
List<UserHandle> userProfiles = um.getUserProfiles();
I want to read the DeveloperSettings like - Bluetooth HCI snoop capture enabled/disabled.
Does Android provide an API for user applications to read this information. Is there a listener to which user space app can register and get a callback when value of DeveloperSettings change?
AFAIK you can access some of the properties on the Settings using for example :Settings.Secure.getInt(getContentResolver(),Settings.Secure.BLUETOOTH_ON,0);
I'm not sure about all the features available for developers. Also some of them need root to be modified.
I am trying to work on a project which requires to take backup of complete android configration say wifi connection list and pwd's, ringtone, screen brightness, bookmarks, etc. Is there any common place that android stores them or do we individually need to extract them and revert then in case of lost phone or factory reset?