【问题标题】:Device Admin API, how to be a device owner?Device Admin API,如何成为设备所有者?
【发布时间】:2023-03-27 17:55:01
【问题描述】:

我想使用DevicePolicyManager 方法:setSecureSetting。此方法需要配置文件或设备所有者:

由配置文件或设备所有者调用以更新 Settings.Secure 设置。

我的应用程序已激活设备管理,因为当我调用 isAdminActive 时它返回 true。

但是当我打电话给setSecureSetting 时,我遇到了异常:

E/DevicePolicyUtility( 9901): java.lang.SecurityException: Admin ComponentInfo{com.xxxx/com.xxxx.MyDeviceAdminReceiver} does not own the profile
E/DevicePolicyUtility( 9901):   at android.os.Parcel.readException(Parcel.java:1546)
E/DevicePolicyUtility( 9901):   at android.os.Parcel.readException(Parcel.java:1499)
E/DevicePolicyUtility( 9901):   at android.app.admin.IDevicePolicyManager$Stub$Proxy.setSecureSetting(IDevicePolicyManager.java:4300)
E/DevicePolicyUtility( 9901):   at android.app.admin.DevicePolicyManager.setSecureSetting(DevicePolicyManager.java:3399)

那么,如何成为 API 的设备所有者? 我在http://developer.android.com/guide/topics/admin/device-admin.htmlhttp://developer.android.com/reference/android/app/admin/DevicePolicyManager.html 中找不到


我在 API 级别 23 上试试这个:

Intent intent = new Intent(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE);
intent.putExtra(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,ctx.getPackageName());
if (intent.resolveActivity(ctx.getPackageManager()) != null) {
    ctx.startActivity(intent);
} else {
    Toast.makeText(ctx, "Stopping.", Toast.LENGTH_SHORT).show();
}

我收到消息:

【问题讨论】:

    标签: android


    【解决方案1】:

    要成为设备所有者,有两种可能性

    dpm set-device-owner:将给定组件设置为活动管理员,并且 它的包作为设备所有者。

    感谢 Florent Dupont:http://florent-dupont.blogspot.fr/2015/01/android-shell-command-dpm-device-policy.html

    【讨论】:

      猜你喜欢
      • 2014-02-06
      • 1970-01-01
      • 2015-07-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-27
      • 2021-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多