Search code examples
androidkioskkiosk-modekindle-fire

startLockTask not working with Kiosk mode and Fire OS


I own a Kindle Fire with Fire OS version 5.1.4

I set my app as a Device Administrator and it worked well (my app shown the little toast saying "yeah I am the administrator" :) )

The problem is that calling startLockTask has no effect at all: the annoying green screen pinning dialog will appear anyway and the app is not locked.

My goal is to develop a kiosk app but as for now the user can simply drag the status bar and leave the app..

Are there any workarounds?

This is my onCreate:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ComponentName deviceAdmin = new ComponentName(this, KioskSystemEventsReceiver.class);
    DevicePolicyManager mDpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (!mDpm.isAdminActive(deviceAdmin)) {
        Toast.makeText(this, "WARNING: i'm not the device admin", Toast.LENGTH_LONG).show();
        // not shown
    }

    if (mDpm.isDeviceOwnerApp(getPackageName())) {
        mDpm.setLockTaskPackages(deviceAdmin, new String[]{getPackageName()});
    } else {
        Toast.makeText(this, "WARNING: i'm not the device owner", Toast.LENGTH_LONG).show();
        // not shown
    }
    startLockTask();
    [...]

Solution

  • My conclusions:

    It seems that you can't set your app as the device owner since the Kindle Fire is always already provisioned even right after a factory reset.

    If your app can't be the device owner, it won't be able to startLockTask without user intervention.

    The only way would be to root the device and gain permissions..