I'm writing an app to disconnect the phone entirely from the outside. i.e. only local activities are allowed. Things like data, wifi, phone calls, text message are all disabled.
I understand that with MDM one can (probably) change the passcode and lock the phone, which will basically achieve the same thing. But still I'd like to know if one can write such a program on Android.
I assume a possibility would be to put the phone in airplane mode. But sadly this isn't possible anymore, as written in Official Android 4.2 API Documentation.
Some device settings defined by Settings.System are now read-only. If
your app attempts to write changes to settings defined in
Settings.System that have moved to Settings.Global, the write
operation will silently fail when running on Android 4.2 and higher.
Even if your value for android:targetSdkVersion and
android:minSdkVersion is lower than 17, your app is not able to modify
the settings that have moved to Settings.Global when running on
Android 4.2 and higher.
I recently tried to implemented something like this, but the only way would be to deactivate everything manually (from what I found)
Related
KitKat had the Settings > WiFi > Advanced WiFi option to set the priority as shown.
This isn't present on my Nexus Lollipop and Marshmallow devices. I see there is an App available, but I'd like to know if there is some onboard way I missed to manage these, and if not, what the thinking was behind its removal.
This works on my CyanogenMOD 13 device, which I have come to believe should work on Lollipop and Marshmellow devices as well:
In your Wi-Fi settings, tap the overflow icon, select "Saved networks". Tap the overflow icon again, disable "Automatic priority". You can now re-order your networks by dragging the signal icon up or down.
Let me know how/if it works for L & M!
This is not exactly ordered prioritization, however I found I was able to give preference to one SSID over another by using the data usage setting. By setting HomeWiFi as Unmetered and FreeCableProviderWifi as Metered my phone effectively prioritizes my home network. This solved my problem so I hope this solution helps other even if it doesn't directly answer the question
I realize this is an old post, but looking for something else I stumbled upon this:
On a rooted device you can manually edit the wpa_supplicant.conf file, usually stored in data/misc/wifi. Use a standard text editor.
In this file all saved networks are described in structures like
network={
ssid="network-name"
other_key=other_value
priority=priority-value
}
Higher values in priority mean higher priority. Priorities don't have to be unique. Only if you know that you have multiple stored networks for the same location you should consider giving them different priority values like 0 for the least wanted network and 9 for the most wanted one; you get the idea.
Tools:
There are also some tools available for rooted phones that can help you here. One that I use is GravityBox offering a busload of very helpful tweaks and tools for your phone. You need to have the XPosed framework (>> http://repo.xposed.info/) installed to use GravityBox (>> http://repo.xposed.info/module-overview, then search for GravityBox; be sure to pick the version suitable for your Android version)
There are other tools as well but I can't say anything about them. My opinion is: be careful with tools that are abler to fiddle with sensitive data; if they can change priorities they also can read the network passwords stored in wpa_supplicant.conf...
I was trying to achieve this on stock Nougat 7.1.1 on a Nexus 5x. I edited the properties in the /data/misc/wi-fi/wpa_supplicant.conf file using a text editor. It worked perfectly. You need root access to edit this file however.
To save energy of my mobile device my app should turn off animation of system operation android. How can I turn off animation of system operation android programmatically? Does there exist some broadcast receiver for listen this action?
I mean that if you want more performance in your android you can go settings ("Menu-Settings-Display-Animation-NO ANIMATIONS")... I want know how do this programmatically...
While I seem to recall that there might have been this option in old versions of Android, this option does not appear in newer ones. For example, my Galaxy Nexus does not have this option.
With respect to controlling window animations programmatically, the only options for those that I see (e.g., ANIMATOR_DURATION_SCALE) are now in Settings.Global as of Android 4.2 and cannot be modified by ordinary SDK apps. You might be able to control them in earlier versions of Android, though it is unclear what settings directly translate into your Settings option.
Moreover, if you have evidence that changing these values will materially "save energy of [your] mobile device", please post it.
My app is using VoicemailContract functionality that's available in API 14 and higher to insert voicemail messages into the phone's call log. However, some phones seem to have that functionality disabled, even in API versions higher thatn 14. Samsung Galaxy Note 2 is a perfect example of this. So, when the new VM message is inserted into the database, it won't show up in the call log (but this works perfectly on most other phones). So, it seems that Samsung disabled that functionality on that phone somehow, and I'd like to be able to detect that at runtime so that I can hide that option in my app's settings if it isn't available.
Have you tried checking the status?
http://developer.android.com/reference/android/provider/VoicemailContract.Status.html
Vendors can really implement almost anything they want on their phones (which makes android development very annoying) however I think the status should be set to something that is "not okay" on phones that will ignore your api calls.
Since the sdk version 4.2 it seems like it's no longer possible to modify airplane-mode on devices since google has moved this setting to Settings.Global which is read-only.
Has anyone been able to bypass this without and kind of rooting?
My apps primary function is to enable airplane-mode when the screen is turned off, and this stopped working since 4.2.
Just want to double check that my assessment is correct and that my app is dead starting from android 4.2 and above.
References:
http://developer.android.com/reference/android/provider/Settings.Global.html#AIRPLANE_MODE_ON
Just want to double check that my assessment is correct and that my app is dead starting from android 4.2 and above.
Yes. Or, to put it another way, if there is a back-door way to modify this setting, it represents a security hole, which will eventually get closed, much like the enable/disable GPS restriction that has existed for 3+ years.
I know you explicitly ask for a solution without rooting, but if you have a rooted device there is at least the (kind of) official solution to move your app into folder /system/app. Then it is possible to write into Settings.Global:
Settings.Global.putInt(context.getContentResolver(), Global.AIRPLANE_MODE_ON, mode ? 1 : 0);
Have a look of how to toggle airplane mode for 4.2
and how to move your app into /system/app here. I use this for my toggle widget Mini Status (source code link).
AFAIK there is absolutely no way to detect the moment when app gets uninstalled.
I am currently writing an app which should among else toggle on/off 3G data. It went ok before 2.3 with ITelephony reflection calls, but from Android 2.3 this is not possible.
So I had to resort to APNDroid-style way of adding suffixes to APNs in content://telephony/carriers. This seems to work, but I stumble on the same problem as APNDroid has: since we can't detect when the app is removed, all the suffixes will remain if the user first turns off 3G with the app and then uninstalls the app.
This is an ugly and dangerous solution, because the end user may be left with all APNs broken.
It's possible to detect uninstallation from another application, but how would one force the user to install another application to just monitor the first one? It seems there is no way from 2.3 on to write a 3G-managing app.
Any ideas?
AFAIK there is absolutely no way to detect the moment when app gets uninstalled.
Correct.
I am currently writing an app which should among else toggle on/off 3G data. It went ok before 2.3 with ITelephony reflection calls, but from Android 2.3 this is not possible.
Which means that you should not be implementing the app as an SDK application. You should have not implemented the app using "ITelephony reflection calls", either.
This is an ugly and dangerous solution, because the end user may be left with all APNs broken.
Which means that you should not be implementing the app as an SDK application.
how would one force the user to install another application to just monitor the first one?
You can't.
It seems there is no way from 2.3 on to write a 3G-managing app.
Correct.
You are welcome to try to contribute changes to the AOSP Settings application, or create a new firmware application, that offers the features you seek.