How to run Android App in Kiosk Mode, keep Safe Mode disabled and prevent the device from Hard Reset?
I have following 3 requirements for my app:
Show only specific apps to school students in the normal mode of the device. This can be possible by disabling default launcher and enabling kiosk launcher.
Disable or set the password to safe mode to avoid usage of system apps or built-in apps (youtube, video player, music app, etc.).
Restrict hard reset of a device by disabling long press of hard keys (power button, volume buttons) of a device.
I have interpreted these requirements and came up with below detailed understanding.
We can redesign the school students app to make itself a launcher app which will run in kiosk mode. That implies we will not require any other (trial version) launcher apps.
We can disable safe mode access to the system or third-party apps via the AppLock app or similar other apps. It will work only up to Android Marshmallow 6.0. But there is an Android imposed limitation – it won’t work on Nougat / Oreo devices. Alternatively, we tried to handle the power button key press for preventing the device from going into safe mode. But Android doesn't allow the access or listen to power key press from our app as per this link and various other.
IMPORTANT NOTE FOR ANDROID 7.0 (NOUGAT) AND 8.0 (OREO) - link here
As per MMGuardian App, at this time, Safe Mode Lock cannot be enabled for phones running on Android 7.0 or 8.0. If an older phone for which Safe Mode Lock was previously enabled is updated to these versions of Android, the Safe Mode Lock function will become disabled.
Can someone help me to add more thoughts to it for me to understand this situation in more details?
Am I going in the right direction? or Have I detailed it correctly?
To exit from kiosk mode while the app is open, Go to Kiosk Lockdown > Android Kiosk Lockdown > Kiosk Exit Settings > Check the options Allow manually exiting kiosk mode and Exit manually from kiosk mode while an app is open.
While the device is powered on, press and hold down the power key. In the pop-up menu, press the Power key. touch and hold Power off until the Reboot to safe mode message appears. Tap OK to restart in safe mode.
Yes! Nearly any Android device with a touchscreen can be run in kiosk mode.
ProKiosk Mode is Samsung's advanced solution for transforming Samsung off-the-shelf devices into purpose-built appliances. ProKiosk Mode can restrict device operations to a single specific application or group of applications and limits unwanted device activity.
100% Kiosk Mode impossible.
Restrict hard reset : The hard reset option is a part of bootloader, so it's hard to prevent device getting factory reset,
I had solution, but only works if the device rooted
Restrict hard reset : copy your apk file to system/app, when device got restored Android will automatically reinstall all apps from system/app folder
Disable System APP : to disable system apps or any apps run a shell command
pm disable <package name>
Interpret Volume Keys : To run this you don't need root access, Use this code in your Activity Class
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
// TODO Auto-generated method stub
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
{
// Do what ever you want
}
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP))
{
// Do what ever you want
}
return true;
}
Bonus disable navigation bar and status bar
To Hide
private void hideNavigationBar(){
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("pm disable com.android.systemui\n");
os.flush();
try {
Process process = null;
process = Runtime.getRuntime().exec("su");
DataOutputStream osReboot = new DataOutputStream(process.getOutputStream());
osReboot.writeBytes("reboot\n");
osReboot.flush();
process.waitFor();
}
catch (IOException e) {
e.printStackTrace();
}
catch (InterruptedException e) {
e.printStackTrace();
}
}catch (IOException e) {
e.printStackTrace();
}
}
Restore back to normal
private void showNavigationBar(){
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("pm enable com.android.systemui\n");
os.flush();
os.writeBytes("reboot\n");
os.flush();
process.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Note : Device will reboot after running shell commands
Your playing with root, so you and your own, If any doubt please command before start coding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With