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

3

11

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?

Edbert answered 17/1, 2018 at 14:25 Comment(2)
Requirements #2 and #3 are requirements of a device, not an app.Bickart
I would look away from developing device lockdown solution as it is a product in itself, it is cheaper to buy existing solutions. In my case some customers use 42gears.com/products/surelock/surelock-android to enable kiosk mode, it says they support Oreo as well. In addition they wrap devices with protective shell as well.Rubberneck
W
5

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

Watering answered 31/1, 2018 at 8:4 Comment(2)
Hello, its saying "Variable process is already defined in the scope"Plastered
In the hideNavigationBar() method, because are 2 variables with the same names: process and osPlastered
A
4

Take a look at Android Management API, seems more can't be done without custom device firmware.

Aciniform answered 25/1, 2018 at 17:1 Comment(0)
U
2

Can you design and then deploy your app as DeviceOwner? This gives you the greatest possibilities on the device, but deployment can be painful depending on the context: not suitable for a public release, but doable if you can manage the devices fleet.

Usia answered 27/1, 2018 at 3:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.