return false;
}
}
+
+ /**
+ * @hide
+ * Return if this user is a managed profile of another user. An admin can become the profile
+ * owner of a managed profile with {@link #ACTION_PROVISION_MANAGED_PROFILE} and of a managed
+ * user with {@link #ACTION_PROVISION_MANAGED_USER}.
+ * @param admin Which profile owner this request is associated with.
+ * @return if this user is a managed profile of another user.
+ */
+ public boolean isManagedProfile(@NonNull ComponentName admin) {
+ try {
+ return mService.isManagedProfile(admin);
+ } catch (RemoteException re) {
+ Log.w(TAG, "Failed talking with device policy service", re);
+ return false;
+ }
+ }
+
+ /**
+ * @hide
+ * Return if this user is a system-only user. An admin can manage a device from a system only
+ * user by calling {@link #ACTION_PROVISION_MANAGED_SHAREABLE_DEVICE}.
+ * @param admin Which device owner this request is associated with.
+ * @return if this user is a system-only user.
+ */
+ public boolean isSystemOnlyUser(@NonNull ComponentName admin) {
+ try {
+ return mService.isSystemOnlyUser(admin);
+ } catch (RemoteException re) {
+ Log.w(TAG, "Failed talking with device policy service", re);
+ return false;
+ }
+ }
}
boolean isProvisioningAllowed(String action);
void setKeepUninstalledPackages(in ComponentName admin,in List<String> packageList);
List<String> getKeepUninstalledPackages(in ComponentName admin);
+ boolean isManagedProfile(in ComponentName admin);
+ boolean isSystemOnlyUser(in ComponentName admin);
}
final int targetSdkVersion = ai == null ? 0 : ai.targetSdkVersion;
return targetSdkVersion;
}
+
+ @Override
+ public boolean isManagedProfile(ComponentName admin) {
+ synchronized (this) {
+ getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ }
+ final int callingUserId = mInjector.userHandleGetCallingUserId();
+ final UserInfo user;
+ long ident = mInjector.binderClearCallingIdentity();
+ try {
+ user = mUserManager.getUserInfo(callingUserId);
+ } finally {
+ mInjector.binderRestoreCallingIdentity(ident);
+ }
+ return user != null && user.isManagedProfile();
+ }
+
+ @Override
+ public boolean isSystemOnlyUser(ComponentName admin) {
+ synchronized (this) {
+ getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
+ }
+ final int callingUserId = mInjector.userHandleGetCallingUserId();
+ return UserManager.isSplitSystemUser() && callingUserId == UserHandle.USER_SYSTEM;
+ }
+
}