Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run an Android App in Kiosk Mode, keep Safe Mode disabled and prevent the device from Hard Reset?

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:

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

  2. Disable or set the password to safe mode to avoid usage of system apps or built-in apps (youtube, video player, music app, etc.).

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

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

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

  1. We cannot prevent any device from hard reset as it is mostly done after the phone is switched off leaving the apps with no control. But there is an expensive alternative. We can use a COSU device and design a custom firmware. More details about COSU are available on below links. https://developer.android.com/work/cosu.html https://developers.google.com/android/work/requirements/cosu

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?

like image 746
ketan dhopeshwarkar Avatar asked Jan 17 '18 14:01

ketan dhopeshwarkar


People also ask

How do I bypass Android kiosk mode?

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.

How do I run Android apps in safe mode?

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.

Can you run an Android tablet in kiosk mode?

Yes! Nearly any Android device with a touchscreen can be run in kiosk mode.

What is ProKiosk 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.


1 Answers

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

like image 77
Anu Martin Avatar answered Oct 19 '22 08:10

Anu Martin