Device owner调研

一.什么是Device owner?

Device Owner 是在设备上以管理员身份运行的应用程序.
 此应用可以使用 DevicePolicyManager类中 的编程方法 来控制设备上的配置,安全性和其他应用程序。 可以将Device owner视为具有特殊权限的Device Admin。
 
 
Android提供了三种设备管理方案,Device Administration(设备管理员), Profile Owner(配置文件所有者)和 Device Owner(设备所有者)。这三种权限管理策略的能力大小依次增加 为 DeviceAdmin < ProfileOwner < DeviceOwner。 同样的,要将一个应用设置成为这些管理设备,需要的权限也依次增加。应用需要最大的授权才能成为Device Owner,Device Owner具有设备的最高权限.
 
 
1.DeviceAdmin是Android2.2引入的方案,通过用户授权自己的应用设备管理权限后,可以在代码中修改一些系统设置,主要的功能是围绕锁屏这一块对权限比较“敏感”的区域。Android系统在同一时间可以拥有多个Device Admin程序,并且可以有多个同时处于激活状态。
由于设备管理员不太适合支持当今的企业要求,因此我们建议客户和合作伙伴从现在开始采用托管设备和工作资料模式来管理其设备。为了支持此过渡并将资源集中于Android当前的管理功能,官方在Android 9.0版本中弃用了用于企业的设备管理员,并在Android 10.0版本中删除了这些功能。Device Administration 在Android9.0(Android Pie)被废弃,Google推荐企业管理使用Profile Owner或Device Owner。
DeviceAdmin功能有 比如设置锁屏方式、恢复出厂设置、设置密码、强制清除密码,修改密码等操作。
 
 
2.ProfileOwner 译为配置文件所有者,在Android5.0系统推出。ProfileOwner涵盖了所有DeviceAdmin用户的管理能力,并且额外添加了很多管理权限。Android系统只能设置一个Profile Owner程序,并且该程序在设置为ProfileOwner后不能取消,应用不能卸载,唯一可以取消的途径是恢复出厂设置。
ProfileOwner 具有功能有: 包含DeviceAdmin的功能 截屏截图\设置组织名\应用授权\设置应用是否可以卸载\静音\设置内容提供者\禁用特定用户\隐藏应用\清除应用限制\开启和禁止来电\挂起应用\获取应用所有权限\安装与卸载证书\锁屏密码重置
 
 
3.DeviceOwner 译为设备所有者,在Android5.0系统推出。DeviceOwner涵盖了DeviceAdmin用户的所有管理能力,也涵盖了ProfileOwner的所有管理能力,并且额外拥有在设备上创建和移除二级用户以及配置全局设置的能力。您的设备所有者应用可以使用 DevicePolicyManager 类中的方法对托管设备上的配置、安全性和应用进行精细控制。一台设备在同一时间只能有一名活动的设备所有者。 要部署和激活设备所有者,您必须在设备处于未配置状态.
 

 

二.Device owner的功能

 
功能有: 包含Device Admin和Profile Owner的功能, 连带有重启设备/获取wifi/设置状态栏/设置系统更新策略/创建切换删除用户/设置全局HTTP代理/蓝牙获取联系人等.
 
总的来说就是:
启用或禁用硬件功能,例如相机或指纹传感器
启用或禁用软件功能,例如锁屏(键盘锁),通知,小部件,可见的应用程序(将它们隐藏或取消隐藏),设备启动时使用的凭据或设备加密
配置密码策略
在设备上配置用户帐户
配置网络参数,CA证书和VPN信息
擦除设备(恢复出厂设置)或外部存储设备上的内容
设置全局设置,例如飞行模式,GPS,蓝牙,漫游等。
切换用户
清除当前设备所有者
 
 
 

 

Device Admin, Profile Owner 和 Device Owner的功能区别?

The Android Device Administrator was introduced back in Android 2.2. It included support for the DevicePolicyManager class, along with the DeviceAdminReceiver and DeviceAdminInfo classes. The Device Owner app is a Device Administrator. A Profile Owner app is also a Device Administrator. But, the Device Owner can perform functions that a Profile Owner cannot. You can think of a Device Owner as a Device Administrator with special privileges. Even the semantics of some normal API methods change for a Device Owner. For example, any activity can call startLockTask(), but it only enables full kiosk mode for the Device Owner.
 
Android Device Admin 是在Android 2.2中引入的。它包括对DevicePolicyManager类以及DeviceAdminReceiver和DeviceAdminInfo类的支持。Device Owner应用是设备管理员。Profile Owner应用程序也是设备管理员。但是,Device Owner可以执行Profile Owner无法执行的功能。您可以将Device Owner视为具有特殊特权的设备管理员。甚至某些常规API方法的语义对于Device Owner 也会发生变化。例如,任何活动都可以调用startLockTask(),但它仅为设备所有者启用完全信息亭模式。
 
 
 
A Device Owner and a Profile Owner can perform many of the same functions, and the functionality of both may indeed be provided by a single app (like a Device Policy Controller (DPC) from your EMM provider). Profile Owner functionality is usually utilized on a device that has both work and personal data. The Profile Owner app creates a user profile on the device that separates the work data from personal data. The apps that are installed on the device in the work profile contain the Android for Work “briefcase” badge in order to distinguish those work apps from personal apps. Devices with both personal and work profiles fall into either the BYOD (Bring Your Own Device) or COPE (Corporate Owned, Personally Enabled) device classes.
 
A Device Owner can perform some functions that a Profile Owner cannot. It can disable Wi-Fi and Bluetooth, wipe device data, configure kiosk applications (whitelist “lock task” packages), and more. In other words, for corporate-liable devices that have no personal data, you want to configure a Device Owner, rather than a Profile Owner. Some apps, like EMM Agents (DPCs), may be written to function as both Device Owner and Profile Owner. See this Google developer information for more details on Profile and Device Owner.
 
设备所有者和配置文件所有者可以执行许多相同的功能,并且两者的功能确实可以由单个应用程序提供(例如,您的EMM提供程序中的设备策略控制器(DPC))。配置文件所有者功能通常在同时具有工作和个人数据的设备上使用。Profile Owner应用程序在设备上创建一个用户配置文件,以将工作数据与个人数据分开。在工作资料中设备上安装的应用程序包含Android for Work“公文包”徽章,以便将这些工作应用程序与个人应用程序区分开。
 设备所有者可以执行配置文件所有者无法执行的某些功能。它可以禁用Wi-Fi和蓝牙,擦除设备数据,配置信息亭应用程序(白名单“锁定任务”软件包)等。换句话说,对于没有个人数据的企业责任设备,您需要配置设备所有者而不是配置文件所有者。某些应用程序(例如EMM代理(DPC))可能会编写为既充当设备所有者又充当配置文件所有者。有关个人资料和设备所有者的更多详细信息,请参见此Google开发者信息。
 
什么是设备策略控制器(DPC)?
设备策略控制器是在Android设备上管理公司策略的应用程序。 它可以实现配置文件所有者,设备所有者或两者。 有时称为设备EMM代理,它是EMM提供程序中的应用程序,对设备实施安全性和使用限制。
 
 

.创建Device Owner

1.基本配置

在res/xml目录下新建device_admin.xml文件;
 
注册一个广播继承DeviceAdminReceiver;
 
在清单文件里注册广播;
 
 

2.激活DeviceOwner的三种方式

    a. 利用NFC功能在手机初始化的时候发送一个DeviceOwner应用到手机上。
 
    b. 利用ADB命令。
    adb shell dpm set-device-owner com.xjli.deviceownerdemo/.MyDeviceOwnerReceiver
 
    c. 在已root设备上进行,先在/data/system/目录下创建一个device_owner.xml文件。
    内容如下 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
    <device-owner package="your owner app packagename" />
    然后重启设备,一定要注意在重启设备之前安装好你的DeviceOwner应用,否则会出现无法启动的BUG
 
 
 

四.DevicePolicyManager

 
种设备管理方案 都是调用 DevicePolicyManager 类 从而调用 IDevicePolicyManager .aidl 设备 策略服务的内部 IPC 接口。
 
获取DevicePolicyManager实例对象
(DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
 
reboot(ComponentName admin);重启设备
getWifiMacAddress( ComponentName admin);获取wifi Mac地址
setStatusBarDisabled(ComponentName admin, boolean disabled);禁用或启用状态栏
setKeyguardDisabled(ComponentName admin, boolean disabled) 将锁屏模式设置为None,当用户设置了密码时无效
resetPassword(String password, int flags);修改锁屏密码
setSystemUpdatePolicy(ComponentName admin, SystemUpdatePolicy policy)  设置系统更新策略
SystemUpdatePolicy getSystemUpdatePolicy(); 获取系统更新策略
setGlobalSetting(ComponentName admin, String setting, String value) 设置系统设置中Global相关的属性 如:Settings.BLUETOOTH_ON 蓝牙是否启用/禁用
setCameraDisabled(@NonNull ComponentName admin, boolean disabled) 停用相机 禁止使用所有设备摄像头
createUser(@NonNull ComponentName admin, String name) 用户管理
setUninstallBlocked(@NonNull ComponentName admin, String packageName, boolean uninstallBlocked) 禁止卸载应用
setScreenCaptureDisabled(@NonNull ComponentName admin, boolean disabled); 禁止截图
等....
 

 

五.Device Owner的代码展示

 
见DeviceOwnerDemo ,参考DeviceAdmin简单实践  http://floatingmuseum.github.io/2016/07/device-admin-practice
 

 
参考链接:
Android DeviceOwner 应用的能力  https://blog.csdn.net/visionliao/article/details/84767383
一键设置 DeviceAdmin/ProfileOwner/DeviceOwner 应用  https://blog.csdn.net/visionliao/article/details/84768035
Android Device Administration 应用的能力 https://blog.csdn.net/visionliao/article/details/84766876
Android ProfileOwner 应用的能力 https://blog.csdn.net/visionliao/article/details/84767136
什么是设备策略控制器(DPC)? https://support.google.com/work/android/answer/6192678?hl=en
Android极速开发之设备管理器(DevicePolicyManager) https://www.jianshu.com/p/8934d47aed3b
DeviceOwner设备所有者配置   https://www.jianshu.com/p/5b1a552b5040
 
 
更多Android系统和应用开发的讨论,可以加入我
 
 
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值