QUESTION
Is there any way to instruct (programmatically or otherwise) an Android tablet not to allow any user interactions until my app is automatically launched?
BACKGROUND
I have my Android device running in Kiosk mode. My app is the "device owner". The end-goal is to have a kiosk-type interface at a public setting (using an Android tablet). Everything works fine, in the sense that:
(a) When the device is re-booted, my app (which is the "device owner") will launch automatically
(b) Once my app is launched, it is full screen and navigation etc. is disabled, so no back button. The user can't quit the app
THE ISSUE
When the tablet re-boots, it takes 73 seconds before my app is automatically launched. Presumably my app does not get the BOOT_COMPLETED signal until this time.
During this time, any unauthorized person can access the device apps and settings - which is not good!
The only way I can think of preventing this is to set the Screen Lock Mode to PIN, or similar, so that a code is required to unlock the tablet. But if I do this, the app does NOT launch automatically - the screen will stay locked forever. When I eventually enter the code, then it takes about 73 seconds before my app is launched.
So, if I install my tablet in a public kiosk type setup, I have a security issue if the tablet is reset, or caused to reset in some way.
Any suggestions appreciated, thanks.
IMPLEMENTATION
My implementation is based on a lot of other posts: (and described in a previous post by me: here)
I have defined the receiver:
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class StartOnBootupReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent activityIntent = new Intent(context, MainActivity.class);
context.startActivity(activityIntent);
}
}
}
And in the AndroidManifest.xml file:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
and
<receiver android:name=".StartOnBootupReceiver"
android:exported="false"
>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
I then factory reset the tablet and used adb to set my app as the "device owner"
And I have set my app up as the launcher, in the manifest file:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
UPDATE
In trying to get this working, I have been making code changes, and factory resetting the tablet quite a few times a day. This morning, the "kiosk" worked a lot better - it only took about 10 seconds to launch the app, and I couldn't get access to the other apps on the device during those 10 seconds.
This was with NO code changes by me... so TIME might have been a factor.
So, of course I did another factory reset and set everything up, to see if there had been some magic 'fix'. Now it's back to about 73 seconds, and allows me access to the apps during this time. I left it for an hour - same result. So I will leave it over night and see if that "fixes" the issue. Not really sure what else to say / do!