如何在Android DPM中删除set-device-owner? [英] How to remove set-device-owner in Android DPM?

查看:1322
本文介绍了如何在Android DPM中删除set-device-owner?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过以下链接,我已使用ADB成为应用程序设备所有者:
如何使我的应用成为设备所有者?

I have made an app device owner using ADB, by following this link : How to make my app a device owner?

但是现在,我无法还原此内容。

but now, I'm not able to revert this.

在设备管理选项卡中,此选项被禁用。无法更改此应用的值。

In the device administration Tab, this option is disabled. Not able to change the value of this app.

推荐答案

通过在AndroidManifest中指定android:testOnly = true属性。 xml,则可以使用以下方法卸载应用程序或删除管理员:

By specifying the android:testOnly="true" attribute in the AndroidManifest.xml it will be possible to uninstall the app or remove admin with:

adb shell dpm remove-active-admin package.name/MyDeviceAdminReceiver

但是在生产设备上,不应包含此属性,并且该应用将是非测试管理员。从那时起,如果不清除擦除/恢复出厂设置,将无法删除它或卸载应用程序。

But on a production device, this attribute should not be included and the app will be a non-test admin. From that point, it will not be possible to remove it or uninstall the application without wipe/factory reset.

值得庆幸的是,当使用相同的密钥对应用程序进行签名并且版本代码等于或大于以下版本时,可以进行更新:

Thankfully, updates can be done when the app is signed with the same key and when the version code is equal or greater:

adb install -r path / to / kiosk.apk

如果您想获得要以编程方式删除生产设备上的管理员和应用程序,您必须进行一些新的更改来重新安装它。首先,如果您在device_admin_receiver.xml中具有< wipe-data \> 权限,可以通过编程方式擦除数据,

If you would like to get rid of admin and application on a production device programatically you have to reinstall it with a few new changes. Firstly you can wipe data programmatically if you have permission <wipe-data \> in device_admin_receiver.xml with:

devicePolicyManager.wipeData(DevicePolicyManager.WIPE_RESET_PROTECTION_DATA)

如果您没有此权限,则应使用新版本不启动LockTask并从以下默认Home应用程序列表中删除其软件包:

If you don’t have this permission new version should not start LockTask and remove its package from default Home app list with:

devicePolicyManager.clearPackagePersistentPreferredActivities(adminComponentName,packageName)

然后您可以手动转到设置以执行擦除/恢复出厂设置。

You could then manually go to Settings to perform a wipe/factory reset.

上找到的信息href = https://snow.dog/blog/kiosk-mode-android rel = noreferrer> https://snow.dog/blog/kiosk-mode-android

这篇关于如何在Android DPM中删除set-device-owner?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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