简体   繁体   中英

Unknown admin: ComponentInfo. Device owner not able to set using command dpm set-device-owner

I have done everithing needed to set device admin. but when I run "dpm set-device-owner " always get unknown admin: Component info. I wnat to execute below code. Every time i get security exception when i run below code

   DevicePolicyManager deviceManager = ((DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE));
   deviceManager.installCaCert(localComponent, ret);

From your question, i see you are referring to 2 different things: device admin and device owner.

  1. "I have done everything needed to set device admin"

What does everything mean? You asked from the code, doing the intent and waiting for the response as in this example? Is it a proper way to get the response from Device Admin by onActivityResult

Have you tried the command from adb: dpm set-active-admin com.your.package/.your.device.admin.receiver ?

  1. "but when I run "dpm set-device-owner " always get unknown admin: Component info"

This is on top of device admin, with higher privileges. You do not need to be device owner to install a certificate, it can be done by requesting the user to approve it as here: Programmatically add a certificate authority while keeping Android system SSL certificates or using an api from a vendor, like Samsung Knox or LG.

You can always (if device allows it, only for testing) to enable your app as device owner by doing dpm set-active-owner com.your.package/.your.device.admin.receiver

https://developers.google.com/android/work/prov-devices - documentation on how to provision your device with Device owner without ADB (end user devices)

DPM actions:

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

dpm set-active-admin: Sets the given component as active admin for an existing user.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM