WIFI not getting open when application in KIOSK Mode. Wear OS - android

I am developing a KIOSK Mode stand alone application for Wear OS(Samsung Watch 4, Wear OS 3.5). For KIOSK mode I am using device owner permission using ADB and used device [DevicePolicyManager][1] class to handle hardware button and status bar etc.
My Issue is, I am not able to open System WIFI settings which navigate to outside of KIOSK mode.
Just for your information I can open system bluetooth settings without disabling KIOSK mode. One more information: case 3 code work perfectly if your KIOSK mode is disable
I tried:
Case1.
context.startActivity(Intent("com.google.android.clockwork.settings.connectivity.wifi.ADD_NETWORK_SETTINGS"))
I can see something gets opened and closed automatically.
Case 2.
val intent = Intent(Settings.ACTION_WIFI_SETTINGS)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
intent.addCategory(Intent.CATEGORY_LAUNCHER)
startActivity(intent)
Case 3.
startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
If any one have any idea or workaround. Much appreciate your inputs!

Finally I achieved it by whitelisted packagename.
devicePolicyManager!!.setLockTaskPackages(deviceAdmin, arrayOf("our.own.package.name","com.google.android.apps.wearable.settings"))
After whitelisted in KIOSK mode. now it will work!
startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))

Related

Android:Disable popup window when entering kiosk mode

I have an Android application which uses Kioskmode. When the app start the screen below appears. My question is : Can I disable displaying the screen below that the screen is pinned ? I do not want to display the overlay when entering kiosk mode.
Yea that's possible. You'll need to make your App a device owner for this purpose.
Set up Admin Receiver in manifest
Run: adb shell dpm set-device-owner com.package.name/.AdminReceiver
Look here:
http://wenchaojiang.github.io/blog/realise-Android-kiosk-mode/ - really helpful
https://sureshjoshi.com/mobile/android-kiosk-mode-without-root/
https://developer.android.com/work/dpc/dedicated-devices/cookbook#java - if you want to make you kiosk mode app more secure

How to prevent phone from going to idle mode

I've developed an application that streams music (via internet connection) using service and having trubles streaming content without phone going idle.
While i was developing my application each time i tried case mentioned below the music was reproducing fine.
Use case : search song, select song from results, play song, screen off -> auto play next song from result list
I'm developing using real device - Huawei Mate 20 Lite - OS v8.01 so while debugging it gotta use USB cabel.
Like i said following the use case above while hooked on USB the auto play while screen off works good. The case it doesn't work good is when the cable is not connected (only mobile data turned on).
What I've figured out is that phone when connected on USB is probably keeping the device awake and it doesn't go to idle mode while when not connected after around 5mins the device probably shuts down processes that cost energy or it shuts down connection to mobile data i'm not sure and there's where i need you guys.
Also I've tested app using HTC U Play - OS v6.0 and the streaming goes smooth without interrupts while screen off and phone wasn't touched for 10+mins.
Also I've tried to acquire wakelock inside oncreate and without releasing it just to see if it helps and it doesn't.
pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
wl.acquire();
This problem you are facing can be due to the fact that after Andriod 6.0, all apps are getting optimized for optimizing the battery usage.
If you really think, the reason behind the application to go killed is inactivity. Then, probably, its because of battery optimization software itself.
You can enable another permission while installing the app on the device where you can update the list of unoptimized app by adding an entry for your app.
Originally, you will be able to do the manual settings by following below instruction.
. Head for the ‘Settings‘ app and then ‘Battery‘
. On the ‘three dots‘ menu, top right, you’ll find ‘Battery optimisation‘.
. Here you’ll see a list of all applications which shouldn’t be ‘optimised‘ (for which read ‘can be handled by Doze and App Standby’) – by default the list is usually very small, with almost all apps enabled for ‘optimisation’. Which is fine for general users, but if, like me, you want a few applications to live outside of the new battery optimisations, then tap on the ‘Not optimised‘ pick list and choose ‘All apps‘
. As you’d expect, every application on your phone is listed (this may be quite long) – swipe down until you find the application(s) that you particularly want to always keep running. Tap on the application name
. From the two choices, check the box for ‘Don’t optimise‘.

How to lock LTE_ONLY mode?

I am working on an application that has a requirement to lock the RAT on devices. I just want to lock only two modes i.e. "LTE Only" or "WCDMA Only".
We can do this without using an app from phone dial app by running ##4636## and choosing Phone Information and the "LTE Only" or "WCDMA Only".
I have also tried QXDM to set these values on NV Item 10 but it doesn't persist on reboot. So if some one have good knowledge of QXDM and share that knowledge then it would be really helpful.
My final goal is to do this from Android application that has root access.

Setup Wi-Fi from an Android app

Android app which i am developing has some modes like:
Kiosk Mode
Normal Mode
Semi-Kiosk Mode
Now my question is while my app is running in a Kiosk mode it will blocks all the other apps to open/make himself on the top. So user is unable to go to the settings screen.
I want a way to provide a Wi-Fi settings within my app so that user can do:
Search for the Wi-Fi nearby
Select and provide the password
Can see which Wi-Fi node is connected
Any help will be appreciated.
I know this is a bit old, but just in case it saves someone a little bit of research in the future this is a solution that I came up with for a similar use case.
Just use the activity that Android provides for managing wifi (without the user seeing the rest of the settings) by manually assembling an intent like so:
Intent intent = new Intent("com.android.net.wifi.SETUP_WIFI_NETWORK");
intent.setComponent(ComponentName.unflattenFromString("com.android.settings/com.android.settings.wifi.WifiSetupActivity"));
intent.addCategory("android.intent.category.DEFAULT");
startActivity(intent);

Airplane mode toggle in Android 4.3

I'm facing a problem in android version 4.3 to control airplane mode by code.For this I converted the user app into system using system/ app mover application available in google play.Once the user enables the airplane mode, the background service have the control to check the airplane mode and reset it to off state and send the broadcast changes to the device.Below the snippet I implemented in my code to keep the airplane mode state in off.But it fails in android version 4.3. It throws an exception called "permission denied". Let me know is these any additional permission need to added in manifest or else let me know your suggestions on these issue to fixed.
try {
Settings.Global.putInt(context.getContentResolver(),
"airplane_mode_on", 0);
isAirplaneModeOn = isAirplaneModeOn(context);
Intent localIntent2 = new Intent(
"android.intent.action.AIRPLANE_MODE");
localIntent2.putExtra("state", isAirplaneModeOn);
context.sendBroadcast(localIntent2);
} catch (Exception e) {
Log.v("TAG",
e.toString() + "\n" + e.getMessage());
}
Moving an App into the /system/app folder does not turn it into a System App - it simply makes the App uninstallable because /system is normally mounted read-only.
What you are trying to do requires full System App privileges. You can only get these by signing your app with the same key used to sign the original firmware Apps - the platform key. In other words, you need access to whoever built the version of Android you are running on and get them to sign your APK.
Actually you cannot do it starting from Android 4.2. Because that settings was relocated here from either Settings.System or Settings.Secure. But on previous vesions it works fine.
http://developer.android.com/about/versions/android-4.2.html
If your app is currently making changes to settings previously defined
in Settings.System (such as AIRPLANE_MODE_ON), then you should expect
that doing so will no longer work on a device running Android 4.2 or
higher if those settings were moved to Settings.Global.
Related question on StackOverflow

Categories

Resources