Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5172,6 +5172,7 @@ package android.app.admin { method public void addPersistentPreferredActivity(android.content.ComponentName, android.content.IntentFilter, android.content.ComponentName); method public void addUserRestriction(android.content.ComponentName, java.lang.String); method public void clearCrossProfileIntentFilters(android.content.ComponentName); method public void clearDeviceOwnerApp(); method public void clearPackagePersistentPreferredActivities(android.content.ComponentName, java.lang.String); method public void clearUserRestriction(android.content.ComponentName, java.lang.String); method public android.os.UserHandle createUser(android.content.ComponentName, java.lang.String); core/java/android/app/admin/DevicePolicyManager.java +17 −0 Original line number Diff line number Diff line Loading @@ -1821,6 +1821,23 @@ public class DevicePolicyManager { return isDeviceOwnerApp(packageName); } /** * Clears the current device owner. The caller must be the device owner. * * This function should be used cautiously as once it is called it cannot * be undone. The device owner can only be set as a part of device setup * before setup completes. */ public void clearDeviceOwnerApp() { if (mService != null) { try { mService.clearDeviceOwner(mContext.getPackageName()); } catch (RemoteException re) { Log.w(TAG, "Failed to clear device owner"); } } } /** @hide */ public String getDeviceOwner() { if (mService != null) { Loading core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,7 @@ interface IDevicePolicyManager { boolean isDeviceOwner(String packageName); String getDeviceOwner(); String getDeviceOwnerName(); void clearDeviceOwner(String packageName); boolean setProfileOwner(String packageName, String ownerName, int userHandle); String getProfileOwner(int userHandle); Loading services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java +4 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,10 @@ public class DeviceOwner { mDeviceOwner = new OwnerInfo(ownerName, packageName); } void clearDeviceOwner() { mDeviceOwner = null; } void setProfileOwner(String packageName, String ownerName, int userId) { mProfileOwners.put(userId, new OwnerInfo(ownerName, packageName)); } Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +32 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.net.ConnectivityManager; import android.content.pm.PackageManager.NameNotFoundException; import android.net.ProxyInfo; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -3097,6 +3098,37 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return null; } @Override public void clearDeviceOwner(String packageName) { if (packageName == null) { throw new NullPointerException("packageName is null"); } try { int uid = mContext.getPackageManager().getPackageUid(packageName, 0); if (uid != Binder.getCallingUid()) { throw new SecurityException("Invalid packageName"); } } catch (NameNotFoundException e) { throw new SecurityException(e); } if (!isDeviceOwner(packageName)) { throw new SecurityException("clearDeviceOwner can only be called by the device owner"); } synchronized (this) { long ident = Binder.clearCallingIdentity(); try { mUserManager.setUserRestrictions(new Bundle(), new UserHandle(UserHandle.USER_OWNER)); if (mDeviceOwner != null) { mDeviceOwner.clearDeviceOwner(); mDeviceOwner.writeOwnerFile(); } } finally { Binder.restoreCallingIdentity(ident); } } } @Override public boolean setProfileOwner(String packageName, String ownerName, int userHandle) { if (!mHasFeature) { Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5172,6 +5172,7 @@ package android.app.admin { method public void addPersistentPreferredActivity(android.content.ComponentName, android.content.IntentFilter, android.content.ComponentName); method public void addUserRestriction(android.content.ComponentName, java.lang.String); method public void clearCrossProfileIntentFilters(android.content.ComponentName); method public void clearDeviceOwnerApp(); method public void clearPackagePersistentPreferredActivities(android.content.ComponentName, java.lang.String); method public void clearUserRestriction(android.content.ComponentName, java.lang.String); method public android.os.UserHandle createUser(android.content.ComponentName, java.lang.String);
core/java/android/app/admin/DevicePolicyManager.java +17 −0 Original line number Diff line number Diff line Loading @@ -1821,6 +1821,23 @@ public class DevicePolicyManager { return isDeviceOwnerApp(packageName); } /** * Clears the current device owner. The caller must be the device owner. * * This function should be used cautiously as once it is called it cannot * be undone. The device owner can only be set as a part of device setup * before setup completes. */ public void clearDeviceOwnerApp() { if (mService != null) { try { mService.clearDeviceOwner(mContext.getPackageName()); } catch (RemoteException re) { Log.w(TAG, "Failed to clear device owner"); } } } /** @hide */ public String getDeviceOwner() { if (mService != null) { Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,7 @@ interface IDevicePolicyManager { boolean isDeviceOwner(String packageName); String getDeviceOwner(); String getDeviceOwnerName(); void clearDeviceOwner(String packageName); boolean setProfileOwner(String packageName, String ownerName, int userHandle); String getProfileOwner(int userHandle); Loading
services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java +4 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,10 @@ public class DeviceOwner { mDeviceOwner = new OwnerInfo(ownerName, packageName); } void clearDeviceOwner() { mDeviceOwner = null; } void setProfileOwner(String packageName, String ownerName, int userId) { mProfileOwners.put(userId, new OwnerInfo(ownerName, packageName)); } Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +32 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.net.ConnectivityManager; import android.content.pm.PackageManager.NameNotFoundException; import android.net.ProxyInfo; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -3097,6 +3098,37 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return null; } @Override public void clearDeviceOwner(String packageName) { if (packageName == null) { throw new NullPointerException("packageName is null"); } try { int uid = mContext.getPackageManager().getPackageUid(packageName, 0); if (uid != Binder.getCallingUid()) { throw new SecurityException("Invalid packageName"); } } catch (NameNotFoundException e) { throw new SecurityException(e); } if (!isDeviceOwner(packageName)) { throw new SecurityException("clearDeviceOwner can only be called by the device owner"); } synchronized (this) { long ident = Binder.clearCallingIdentity(); try { mUserManager.setUserRestrictions(new Bundle(), new UserHandle(UserHandle.USER_OWNER)); if (mDeviceOwner != null) { mDeviceOwner.clearDeviceOwner(); mDeviceOwner.writeOwnerFile(); } } finally { Binder.restoreCallingIdentity(ident); } } } @Override public boolean setProfileOwner(String packageName, String ownerName, int userHandle) { if (!mHasFeature) { Loading