Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize Android Google Setup Wizard for device owner provisioning?

Tags:

java

android

--Use case:

1-System app apk in priv-app folder to be used as device owner.

2-User starts up device and Google setup wizard comes up.

3-Immediately starts device provisioning activity.

--Things that used to work:

This method used to work on Android 6.0 Marshmallow using the action intent:

<activity android:theme="@style/InvisibleNoTitle" android:name="OwnerActivity" android:launchMode="singleTop" android:immersive="true">
    <intent-filter android:priority="5">
        <action android:name="android.intent.action.MAIN" />
        <action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

without any problem.

After updating to Android 8.1 Oreo, this method no longer works. The OwnerActivity shows up only after setup wizard finishes which is useless since device is already provisioned by user and can't be provision again.

Is there any newer way of doing this so that my OwnerActivity shows up first to provision the device? What is changed in Oreo?

like image 998
Sam Matt Avatar asked Oct 17 '22 00:10

Sam Matt


1 Answers

This is a bit late for an answer, and without talking to Google it's a little hard to see what the design decisions have been. However, what we can know is what's changed. 1. android.intent.action.DEVICE_INITIALIZATION_WIZARD is deprecated atleast as early as Oreo. 2. Package Manager Service has had changes to reference the setup wizard. The new approach appears to be the category android.intent.category.SETUP_WIZARD which your manifest definition lacks.

Reading the comments around the code (which you can find below) we see this log:

            Slog.e(TAG, "There should probably be exactly one setup wizard; found " + matches.size()
                + ": matches=" + matches);

https://android.googlesource.com/platform/frameworks/base/+/nougat-mr2.3-release/services/core/java/com/android/server/pm/PackageManagerService.java#17872

So it seems like as of Nougat, Android doesn't support having multiple setup wizards that are chained together. For your specific problem of how to setup the device admin I have 2 suggestions.

  1. If you care about CDD and CTS then you should get your users to go through the Google device owner provisioning process which they keep updated.
  2. If you don't care about that and you just want your build to always have a device owner, just make changes in the frameworks or add some system binary that always runs before the setup wizard which will set your device owner application for you.
like image 106
Andrew T. Avatar answered Nov 14 '22 06:11

Andrew T.