使用Android Management API策略时,Android信息亭模式无法正常工作 [英] Android Kiosk mode not working when using Android Management API Policy

查看:179
本文介绍了使用Android Management API策略时,Android信息亭模式无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在尝试使用一种专用的专用应用程序+设备,以信息亭模式+自动启动的方式工作。该应用程序本身是用Nativescript(使用Angular)构建的,因此不是本机Java,但是仍然可以通过管理接收器等正常处理。



当我们使用 adb 设置设备所有者,信息亭模式将按预期工作。

  adb shell dpm set-device-owner com.domain.app/.DeviceAdminReceiver 

使用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:[
and roid.intent.action.MAIN
],
categories:[
android.intent.category.HOME,
android.intent.category.DEFAULT
]
}
],
dataRoamingDisabled:是,
kioskCustomLauncherEnabled:是
}

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>
<元数据
android:name = android.app.device_admin
android:resource = @ xml / admin_permissions />
<意图过滤器>
< 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>

当我通过AMAPI在单个设备上执行GET时。

  {
name: enterprises / LC00mpaqaj / devices / 3e26eac6be79d049,
managementMode: DEVICE_OWNER,
状态:活动,
appliedState:活动,
policyCompliant:是,
nonComplianceDetails:[
{
settingName: persistentPreferredActivities,
nonComplianceReason: INVALID_VALUE,
packageName: com.domain.app
}
]。 。

因此,似乎不喜欢 persistentPreferredActivities ,但我一直在尝试尝试在此中型信息亭文章,以及实际的 Google信息亭政策示例



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

  receiverActivity: com.domain.app/.DeviceAdminReceiver,
receiverActivity: com.domain.app,
receiverActivity: com.domain.app/.com.domain.app.DeviceAdminReceiver,

所以我的问题:为什么我不能让android kiosk模式与我的策略一起使用,但在亚行上可以正常使用? / p>

半相关,我无法使用Google Play测试音轨来测试可能的分辨率,因此我不得不将更改推送到产品音轨,这使得我的开发周期相当长/艰苦。

解决方案

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



我的两分钱:)


So I'm trying to get a single use, dedicated app + device to work in kiosk mode + auto launch. The app itself is built in Nativescript (with Angular), so not native Java, however this is still handled via an admin receiver etc as normal.

When we use adb to set the device owner, kiosk mode works as expected.

adb shell dpm set-device-owner com.domain.app/.DeviceAdminReceiver

When we use an Android Management policy to enrol the device and auto install, the kiosk mode is never initiated correctly.

{
  "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
}

AndroidManifest.xml - the part relevant to the admin receiver

<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>

When I do a GET on the individual device via the AMAPI it shows..

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

So it seems to not be liking the persistentPreferredActivities, however I have been playing around trying examples I have found both on this medium kiosk article, as well as the actual google kiosk policy examples.

Based on those examples I have tried using various receiverActivity alternative formats, and still no joy:

"receiverActivity": "com.domain.app/.DeviceAdminReceiver",
"receiverActivity": "com.domain.app",
"receiverActivity": "com.domain.app/.com.domain.app.DeviceAdminReceiver",

So my question: Why can I not get android kiosk mode to work with my policy, but it works fine with ADB?

Semi related, I can't use google play test tracks in testing my possible resolutions, so I am having to push changes to prod track, which makes my development cycle fairly long / arduous.

解决方案

I'm not an Android Management API expert, but did you try without the kioskCustomLauncherEnabled parameter? In the test I've run with it, it launches Google's own Kiosk app, maybe preventing your activity to launch.

My two cents :)

这篇关于使用Android Management API策略时,Android信息亭模式无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆