使用 Android Management API Policy 时 Android Kiosk 模式不起作用

Hor*_*rse 5 android kiosk device-admin cosu android-management-api

所以我试图让一个一次性使用的专用应用程序 + 设备在自助服务终端模式 + 自动启动下工作。应用程序本身是用 Nativescript(使用 Angular)构建的,所以不是原生 Java,但是这仍然是通过管理接收器等正常处理的。

当我们adb用来设置设备所有者时,kiosk 模式按预期工作。

adb shell dpm set-device-owner com.domain.app/.DeviceAdminReceiver
Run Code Online (Sandbox Code Playgroud)

当我们使用 Android 管理策略注册设备并自动安装时,自助服务终端模式永远不会正确启动。

{
  "name": "enterprises/LC00mpaqaj/policies/policy1",
  "version": "12",
  "applications": [
    {
      "packageName": "com.domain.app",
      "installType": "FORCE_INSTALLED",
      "lockTaskAllowed": true,
      "defaultPermissionPolicy": "GRANT"
    }
  ],
  "persistentPreferredActivities": [
    {
      "receiverActivity": "com.domain.app/.DeviceAdminReceiver",
      "actions": [
        "android.intent.action.MAIN"
      ],
      "categories": [
        "android.intent.category.HOME",
        "android.intent.category.DEFAULT"
      ]
    }
  ],
  "dataRoamingDisabled": true,
  "kioskCustomLauncherEnabled": true
}
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml - 与管理接收器相关的部分

<receiver
    android:name=".DeviceAdminReceiver"
    android:lockTaskMode="if_whitelisted"
    android:description="@string/admin_description"
    android:label="@string/app_name"
    android:permission="android.permission.BIND_DEVICE_ADMIN">
    <meta-data
        android:name="android.app.device_admin"
        android:resource="@xml/admin_permissions" />
    <intent-filter>
        <action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
        <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>
</receiver>
Run Code Online (Sandbox Code Playgroud)

当我通过 AMAPI 在单个设备上执行 GET 时,它显示..

{
  "name": "enterprises/LC00mpaqaj/devices/3e26eac6be79d049",
  "managementMode": "DEVICE_OWNER",
  "state": "ACTIVE",
  "appliedState": "ACTIVE",
  "policyCompliant": true,
  "nonComplianceDetails": [
    {
      "settingName": "persistentPreferredActivities",
      "nonComplianceReason": "INVALID_VALUE",
      "packageName": "com.domain.app"
    }
  ],...
Run Code Online (Sandbox Code Playgroud)

所以它似乎不喜欢persistentPreferredActivities,但是我一直在尝试尝试我在这篇中型信息亭文章中找到的示例,以及实际的google kiosk 政策示例

基于这些示例,我尝试使用各种receiverActivity替代格式,但仍然没有乐趣:

"receiverActivity": "com.domain.app/.DeviceAdminReceiver",
"receiverActivity": "com.domain.app",
"receiverActivity": "com.domain.app/.com.domain.app.DeviceAdminReceiver",
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:为什么我不能让 android kiosk 模式与我的政策一起工作,但它可以与 ADB 一起工作?

半相关,我不能使用 google play 测试轨道来测试我可能的分辨率,所以我不得不将更改推送到 prod 轨道,这使我的开发周期相当长/艰巨。

小智 4

我不是 Android Management API 专家,但是您是否尝试过不使用该kioskCustomLauncherEnabled参数?在我使用它运行的测试中,它启动了 Google 自己的 Kiosk 应用程序,可能会阻止您的活动启动。

我的两分钱:)