我有几台设备通过 NFC 配置了设备所有者权限,不涉及 EMM,所有策略均由我的 DPC 设置,在配置期间下载。此时我没有设置谷歌帐户。
手动添加 google 帐户后,所有设备都可以访问 Google Play Store Work Apps(目前仅包含 Google Apps 应用程序),但不能访问常规 Play Store。
有没有办法可以停止将设备限制为 Work Apps Play 商店并授予他们完全访问权限?如果可能的话,我想根本不管理该帐户,而只做诸如禁止恢复出厂设置和更改 WiFi、通话、短信等之类的事情......
这些是我用我的 DPC 设置的政策,也许我误解了他们中的一些人的作用?
public static void setDefaultPolicies(Context context, boolean active) {
ComponentName componentName = DeviceAdminReceiver.getComponentName(context);
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(DEVICE_POLICY_SERVICE);
setUserRestriction(dpm, componentName, UserManager.DISALLOW_FACTORY_RESET, active);
setUserRestriction(dpm, componentName, UserManager.DISALLOW_ADD_USER, active);
setUserRestriction(dpm, componentName, UserManager.DISALLOW_REMOVE_USER, active);
setUserRestriction(dpm, componentName, UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA, active);
//setUserRestriction(dpm, componentName, UserManager.DISALLOW_ADJUST_VOLUME, active);
//no disabling of wifi and stuff.
setUserRestriction(dpm, componentName, UserManager.DISALLOW_CONFIG_WIFI, active);
setUserRestriction(dpm, componentName, UserManager.DISALLOW_NETWORK_RESET, active);
//setUserRestriction(dpm, componentName, UserManager.DISALLOW_);
setUserRestriction(dpm, componentName, UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES, active);
//no calls and sms.
setUserRestriction(dpm, componentName, UserManager.DISALLOW_SMS, active);
setUserRestriction(dpm, componentName, UserManager.DISALLOW_OUTGOING_CALLS, active);
// set System Update policy
if (active) {
dpm.setSystemUpdatePolicy(componentName,
SystemUpdatePolicy.createWindowedInstallPolicy(60, 120));
} else {
dpm.setSystemUpdatePolicy(componentName, null);
}
// set this Activity as a lock task package
// dpm.setLockTaskPackages(componentName,
// active ? new String[]{context.getPackageName()} : new String[]{});
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MAIN);
intentFilter.addCategory(Intent.CATEGORY_HOME);
intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
if (active) {
// set app as home intent receiver so that it is started
// on reboot
dpm.addPersistentPreferredActivity(
componentName, intentFilter, new ComponentName(
context.getPackageName(), MainActivity.class.getName()));
} else {
dpm.clearPackagePersistentPreferredActivities(
componentName, context.getPackageName());
}
}
private static void setUserRestriction(DevicePolicyManager dpm, ComponentName componentName, String restriction, boolean disallow) {
if (disallow) {
dpm.addUserRestriction(componentName,
restriction);
} else {
dpm.clearUserRestriction(componentName,
restriction);
}
}
我知道可以通过 EMM Api 授予用户对 Play Store 应用程序的访问权限,但是我不能使用 EMM。