How to read DeveloperSettings in Android - android

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.

Related

Change Android Networkscore / force Android to choose certain network

as far as I understood Android uses the NetworkScore class to select between available networks. Every available network is assigned with various flags and the Connectivity module in AOSP uses the policy logic for network selection found in the NetworkRanker class to determine from those flags, which network to choose.
I also got that it is not possible to directly select the network operator from API (for security reasons).
Would it be possible to change those flags programmatically (after set by NetworkScore) to "force" a certain network to be selected by the system?
Would it be possible to change the policy logic in the NetworkRanker class to block Network operators of a certain country?

Set preferred network type

I want Android source code to set preferred network type from my android application.
I can read preferred network by following code.
Settings.Global.getString(context.getContentResolver(),Settings.Global.NETWORK_PREFERENCE)
Because of user privacy and security, apps are not allowed to change the preferred network type
check out this answer: Change mobile network mode (gsm, wcdma, auto)
When you'll scroll the above link, you'll find this answer. But when you'll go to your AndroidStudio and start adding the permissions to your AndroidManifest.xml file, you'll come across this :
Which says that the permission is granted only to the system apps.

Read Preferred Network Type Setting

I am trying to read the Preferred network type setting from the device. But nowhere android API's are available.
Use case:
Trying to read the Preferred network type and connected network type so that if the device has LTE enabled and the user is forcefully switched back to the lower network(3G,2G); then there should be a notification sent to the user.
I have checked the system setting code, But it's deprecated.
Settings.Secure.getString(getApplicationContext().getContentResolver(),
Settings.System.NETWORK_PREFERENCE);
Is there any alternate way to read the system secured settings(By reflection?).
And Also is it possible to write back the setting with the user permission?
Help is much appreciated.
I think the right code is:
Settings.Global.getString(context.getContentResolver(),Settings.Global.NETWORK_PREFERENCE)

Not able to understand WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN functionality

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.

Settings management from code

I just want to ask you if you anyone knows how to change the Setting
available in:
Settings->Wireless Settings->Mobile Network from code or
Setting: Settings->Wireless Settings->Mobile Network Settings->Network
operators->Select Automatically?
I had been unable to find a property that match this setting in the
Settings.System / Settings.Secure classes.
Is there any alternative way to "turn on/off" the MOBILE
connectivity ?
The reason I need to solve this is to workaround the
bug occur during transitioning from WIFI to MOBILE that do not enable
CELL data automatically.
I think support for this sort of thing(changing settings from code) was removed/deprecated in the newer versions of the SDK; it is not advisable. What I've said is based on Dan Morill's Blog titled: Future Proofing your Android Apps
Eitherways, generally, you would write:
Settings.System.putString(getContentResolver(), <Settings.System.CONST>, <value>);
and have the following permission in your maifest: android.permission.WRITE_SETTINGS
The List of Settings.System.CONST can be found in the official documentation: see here

Categories

Resources