Modify AIRPLANE_MODE_ON on Android 4.2 (and above) - android

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).

Related

Flutter - To detect the device was previously rebooted

I would like to detect whether the device (Android and ios) has been previously rebooted before opening the apps. I noticed that there would be many possible ways to achieve it if we could rely on the device clock's time like what has been elaborated here. My concern would be; the device clock can be changed, and the apps can work in offline mode.
Android
My idea would be to store a boolean variable using Android SharedPreferences after device has been rebooted, and set as true. Then check the variable after user opens the apps. If true, then we can confirm that the device is previously rebooted, else not.
ios
I have no idea on how to implement it for ios, but the link above might gives me a hint.
Solution that might works in both platform (not try yet)
If RAM usage cleared after device restart, then I would assume that if RAM usage is on certain level,the device has been rebooted.
Of all the possible ways to achieve the objective, I would prefer to use existing package. But I would happy if you can give your feedbacks for the above ideas.
So my questions would be :
I hate to reinvent the wheel, so any existing Flutter package or any other library which can't be found on https://pub.dev/packages that can be used to detect whether the device has been previously rebooted before opening the apps?
Is there any other possible solution that I missed which already have in Flutter architecture to solve the issue?
Update
I've found a package called boot_completed which only supported on Android.
..and I've found an interesting feature for Android running API level 24
BOOT_COUNT. Horray!

Android: disconnect the phone entirely

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)

Setting WiFi priority on Android Lollipop or later via Settings UI

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.

how to check if another app is minimized or open in android?

I have seen many solutions to check if our own app is minimized,running or background.but is there a way to check if another app package is running or minimized so that based on that we can run a code.like an app-locker.Here we need to turn off network for a certain apps according to the user selection on installed apps in device, so when that selected apps are on foreground, network should be disabled when the selected apps are closed or minimized.then enable the network.
Will it be compliant with Google play if we make such an app? because somewhere i read they don't allow apps that interfere with other apps.so confused.
TL;DR: Google doesn't want you to do this, and you shouldn't try.
The old hack that relied on ActivityManager#getRecentTasks() to find out which app is in the foreground was disabled starting in Android 5.0.
App lockers that work on Lollipop are using a new hack involving ActivityManager#getRunningAppProcesses(). How it works is described in this answer. This hack is reportedly broken on Android M.
There's a new UsageStats API from which you might be able to glean a bit of info, but it requires a permission that can only be granted by a system activity. It's documented that this system activity may not be present on all devices. Samsung and LG are among the manufacturers that have reportedly removed this activity from their Lollipop devices, so only system apps will ever be able to use UsageStats.
The bottom line is that Google has shown their commitment to preventing what you're trying to do. Even if you find a temporary solution, you can bet that it will stop working in a future Android version. Eventually, Google will close all the loopholes and your app will be permanently broken. So it's probably a waste of time to write a new app that depends on this capability.

How turning off animation of system operation android programmatically

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.

Categories

Resources