如何让我的应用程序的设备拥有者?我的、应用程序、设备

由网友(风将我们吹散.)分享简介:的device策略管理器API文档和的Andr​​oid 5.0概述都提到了一些关于设备所有者应用。我如何设置我的应用程序作为的设备所有者的?The device policy manager API docs and the android 5.0 overview both mention something a...

的device策略管理器API文档和的Andr​​oid 5.0概述都提到了一些关于设备所有者应用。我如何设置我的应用程序作为的设备所有者的?

The device policy manager API docs and the android 5.0 overview both mention something about a device owner app. How can I setup my app as a device owner?

编辑: 是否有任何其他方式比生根和NFC(如果可用),请分享一下。

Is there any other ways than rooting and NFC if available please share.

推荐答案

实际上,有一种方法比其他NFC和生根将应用程序设置为设备所有者的应用程序。 你可以使用 DPM 命令行工具,从亚行的shell。

There's actually a way other than NFC and rooting to set an application as a device owner app. You could use the dpm command line tool from an adb shell.

用法:

usage: dpm [subcommand] [options]
usage: dpm set-device-owner <COMPONENT>
usage: dpm set-profile-owner <COMPONENT> <USER_ID>

dpm set-device-owner: Sets the given component as active admin, and its package as device owner.
dpm set-profile-owner: Sets the given component as active admin and profile owner for an existing user.

更新:的 DPM 实用程序是非常简单的实际。它的目标是创造下的 /data/system/device_owner.xml 的所谓的新文件的 device_owner.xml 的引用的设备/档案所有者的应用程序。

UPDATE : The dpm utility is really simple actually. Its goal is to create a new file called device_owner.xml under /data/system/device_owner.xml that references the Device/Profile owner apps.

Android平台,然后读取这个文件来检查哪些应用程序被认为是一个的设备所有者或档案所有者应用的。

The Android platform is then reading this file to check which application is considered as a Device Owner or Profile Owner App.

在一个植根设备,你确实可以create该文件自己,但由于 DPM 工具是做什么的,你最好使用它(DRY原则):

On a rooted device, you could indeed create this file by yourself, but since the dpm tool is doing it, you'd better use it (DRY principle) :

例如通过的Runtime.exec()命令:

Runtime.getRuntime().exec("dpm set-device-owner com.test.my_device_owner_app");

另请注意,这个工具也是工作只有在不考虑设置为用户(确保没有考虑在设定的设置>帐户的),使用前。

来源和更多信息的的Android shell命令工具:设备策略管理器

阅读全文

相关推荐

最新文章