设置所有者设备应用程序后,为什么不能创建受限制的个人资料? [英] Why can't I create a restricted profile when an owner device app is set?

查看:190
本文介绍了设置所有者设备应用程序后,为什么不能创建受限制的个人资料?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近注意到,设置了 Device Owner(设备所有者)应用程序后,就无法创建受限制的配置文件.

I recently noticed that when a Device Owner application is set, it's not possible to create a restricted profile.

第一种情况:未设置我的设备所有者应用程序.
Settings> Users 中:我可以添加用户或个人资料" ,然后在 User 受限个人资料之间进行选择em>.

First case : When my device owner app is not set.
From Settings>Users : I can "Add user or Profile", and then choose between a User or a Restricted Profile.

第二种情况:设置了我的设备所有者应用程序 .
Settings> Users :我只能添加用户" ,然后得到创建新用户的确认.在第二种情况下,无法创建受限制的配置文件.

Second case : When my device owner app is set.
From Settings>Users : I can only "Add user", and then i get the confirmation to create a new user. In this second case, it's not possible to create a restricted profile.

我想知道为什么在这种情况下不可用,以及在这种情况下如何创建受限制的配置文件?
我的问题的第二部分是:如何使用现有的

I'd like to know why it's not available in this case and how I could possibly create a restricted profile in this case ?
The second part of my question is : how can I programmatically create a restricted profile - or an equivalent behavior - using the existing DevicePolicyManager API (as far as I can see, there's no public API to create restricted profile) ?

更新: 我制作了一个示例应用程序来说明这一点.可以在 Github 上使用.

UPDATE: I made a sample app to illustrate this. It's available on Github.

复制步骤:

  • 编译应用
  • 将应用程序上传到您的设备
  • 使用dpm命令行工具adb shell dpm set-device-owner com.mytest.minimalistdeviceowner/.DeviceAdminRcvr将应用程序设置为设备所有者.
  • 在设置">用户"中检查是否无法创建配置文件
  • 通过在应用程序中单击取消设置设备所有者",将应用程序设置为设备所有者.
  • 在设置">用户"中检查创建的内容是否可用
  • Compile the app
  • Upload the application to your device
  • Set the application as device owner using dpm command line tool: adb shell dpm set-device-owner com.mytest.minimalistdeviceowner/.DeviceAdminRcvr.
  • Check that the creation of profile is not available in Settings>Users
  • Unset the application as device owner by clicking, in the app, on "Unset Device Owner".
  • Check that the creation is now available in Settings>Users

推荐答案

受限配置文件不适用于具有设备所有者的平板电脑或手机.显示在设置"应用程序源代码中,该源代码可用

Restricted profiles are not available for tablets with a device owner, or phones. It's shown in the Settings app source code available here :

DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
                Context.DEVICE_POLICY_SERVICE);
// No restricted profiles for tablets with a device owner, or phones.
if (dpm.getDeviceOwner() != null || Utils.isVoiceCapable(context)) {
    mCanAddRestrictedProfile = false;
    mAddUser.setTitle(R.string.user_add_user_menu);
}

所以这不是bug,而是功能.为避免干扰您的设备所有者应用,可能已将其禁用. 您应该意识到这一点,并且由于您拥有设备所有者应用程序的强大功能,这意味着您必须通过此设备所有者应用程序来自己限制用户.

So that's not a bug, but a functionnality. It's probably disabled to avoid to interfere with your Device Owner App. You should be aware of that and because you have more power with your Device Owner App, means you’ll have to restrict your user by yourself from this Device Owner App.

为此,您可以使用通过DevicePolicyManager.addUserRestriction()DevicePolicyManager.setGlobalSetting()DevicePolicyManager.setSecureSetting()提供的所有限制API来配置设置,还可以使用DevicePolicyManager.setApplicationHidden()来限制用户对应用程序的访问.

To do that, you could use all restrictions API provided through DevicePolicyManager.addUserRestriction(), DevicePolicyManager.setGlobalSetting(), DevicePolicyManager.setSecureSetting() to configure settings, and also DevicePolicyManager.setApplicationHidden() to limit applications access for your user.

这篇关于设置所有者设备应用程序后,为什么不能创建受限制的个人资料?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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