简体   繁体   English

如何为设备所有者配置自定义Android Google安装向导?

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

--Use case: - 使用案例:

1-System app apk in priv-app folder to be used as device owner. 在priv-app文件夹中的1-System app apk将用作设备所有者。

2-User starts up device and Google setup wizard comes up. 2 - 用户启动设备并启动Google安装向导。

3-Immediately starts device provisioning activity. 3 - 立即启动设备配置活动。

--Things that used to work: - 以前工作的事情:

This method used to work on Android 6.0 Marshmallow using the action intent: 此方法过去使用动作意图在Android 6.0 Marshmallow上工作:

<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. 更新到Android 8.1 Oreo后,此方法不再有效。 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. OwnerActivity仅在设置向导完成后显示,这是无用的,因为设备已由用户配置且无法再次提供。

Is there any newer way of doing this so that my OwnerActivity shows up first to provision the device? 有没有更新的方法这样做,以便我的OwnerActivity首先显示配置设备? What is changed in Oreo? 奥利奥有什么变化?

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. 1.至少早在Oreo上就推荐使用android.intent.action.DEVICE_INITIALIZATION_WIZARD 2. Package Manager Service has had changes to reference the setup wizard. 2.程序包管理器服务已进行更改以引用设置向导。 The new approach appears to be the category android.intent.category.SETUP_WIZARD which your manifest definition lacks. 新方法似乎是您的清单定义缺少的android.intent.category.SETUP_WIZARD类别。

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 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. 因此,就像Nougat一样,Android不支持将多个设置向导链接在一起。 For your specific problem of how to setup the device admin I have 2 suggestions. 对于您如何设置设备管理员的具体问题,我有2条建议。

  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. 如果您关心CDD和CTS,那么您应该让您的用户完成他们不断更新的Google设备所有者配置流程。
  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. 如果您不关心这一点,并且您只希望您的构建始终拥有设备所有者,只需在框架中进行更改或添加一些始终在设置向导之前运行的系统二进制文件,该向导将为您设置设备所有者应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM