Mark clearDeviceOwnerApp/clearProfileOwner as deprecated
Bug: 33175679 Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest frameworks-services Change-Id: I05e10638d838ccf8dc67b7a01b3ffeb7cbea8500
This commit is contained in:
@@ -6199,9 +6199,9 @@ package android.app.admin {
|
||||
method public void addUserRestriction(android.content.ComponentName, java.lang.String);
|
||||
method public boolean bindDeviceAdminServiceAsUser(android.content.ComponentName, android.content.Intent, android.content.ServiceConnection, int, android.os.UserHandle);
|
||||
method public void clearCrossProfileIntentFilters(android.content.ComponentName);
|
||||
method public void clearDeviceOwnerApp(java.lang.String);
|
||||
method public deprecated void clearDeviceOwnerApp(java.lang.String);
|
||||
method public void clearPackagePersistentPreferredActivities(android.content.ComponentName, java.lang.String);
|
||||
method public void clearProfileOwner(android.content.ComponentName);
|
||||
method public deprecated void clearProfileOwner(android.content.ComponentName);
|
||||
method public boolean clearResetPasswordToken(android.content.ComponentName);
|
||||
method public void clearUserRestriction(android.content.ComponentName, java.lang.String);
|
||||
method public android.content.Intent createAdminSupportIntent(java.lang.String);
|
||||
|
||||
@@ -6404,9 +6404,9 @@ package android.app.admin {
|
||||
method public void addUserRestriction(android.content.ComponentName, java.lang.String);
|
||||
method public boolean bindDeviceAdminServiceAsUser(android.content.ComponentName, android.content.Intent, android.content.ServiceConnection, int, android.os.UserHandle);
|
||||
method public void clearCrossProfileIntentFilters(android.content.ComponentName);
|
||||
method public void clearDeviceOwnerApp(java.lang.String);
|
||||
method public deprecated void clearDeviceOwnerApp(java.lang.String);
|
||||
method public void clearPackagePersistentPreferredActivities(android.content.ComponentName, java.lang.String);
|
||||
method public void clearProfileOwner(android.content.ComponentName);
|
||||
method public deprecated void clearProfileOwner(android.content.ComponentName);
|
||||
method public boolean clearResetPasswordToken(android.content.ComponentName);
|
||||
method public void clearUserRestriction(android.content.ComponentName, java.lang.String);
|
||||
method public android.content.Intent createAdminSupportIntent(java.lang.String);
|
||||
|
||||
@@ -6216,9 +6216,9 @@ package android.app.admin {
|
||||
method public void addUserRestriction(android.content.ComponentName, java.lang.String);
|
||||
method public boolean bindDeviceAdminServiceAsUser(android.content.ComponentName, android.content.Intent, android.content.ServiceConnection, int, android.os.UserHandle);
|
||||
method public void clearCrossProfileIntentFilters(android.content.ComponentName);
|
||||
method public void clearDeviceOwnerApp(java.lang.String);
|
||||
method public deprecated void clearDeviceOwnerApp(java.lang.String);
|
||||
method public void clearPackagePersistentPreferredActivities(android.content.ComponentName, java.lang.String);
|
||||
method public void clearProfileOwner(android.content.ComponentName);
|
||||
method public deprecated void clearProfileOwner(android.content.ComponentName);
|
||||
method public boolean clearResetPasswordToken(android.content.ComponentName);
|
||||
method public void clearUserRestriction(android.content.ComponentName, java.lang.String);
|
||||
method public android.content.Intent createAdminSupportIntent(java.lang.String);
|
||||
|
||||
@@ -4545,12 +4545,22 @@ public class DevicePolicyManager {
|
||||
/**
|
||||
* 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.
|
||||
* a part of device setup, before it completes.
|
||||
* <p>
|
||||
* While some policies previously set by the device owner will be cleared by this method, it is
|
||||
* a best-effort process and some other policies will still remain in place after the device
|
||||
* owner is cleared.
|
||||
*
|
||||
* @param packageName The package name of the device owner.
|
||||
* @throws SecurityException if the caller is not in {@code packageName} or {@code packageName}
|
||||
* does not own the current device owner component.
|
||||
*
|
||||
* @deprecated This method is expected to be used for testing purposes only. The device owner
|
||||
* will lose control of the device and its data after calling it. In order to protect any
|
||||
* sensitive data that remains on the device, it is advised that the device owner factory resets
|
||||
* the device instead of calling this method. See {@link #wipeData(int)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void clearDeviceOwnerApp(String packageName) {
|
||||
throwIfParentInstance("clearDeviceOwnerApp");
|
||||
if (mService != null) {
|
||||
@@ -4672,15 +4682,23 @@ public class DevicePolicyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the active profile owner and removes all user restrictions. The caller must be from
|
||||
* the same package as the active profile owner for this user, otherwise a SecurityException
|
||||
* will be thrown.
|
||||
* Clears the active profile owner. The caller must be the profile owner of this user, otherwise
|
||||
* a SecurityException will be thrown. This method is not available to managed profile owners.
|
||||
* <p>
|
||||
* This doesn't work for managed profile owners.
|
||||
* While some policies previously set by the profile owner will be cleared by this method, it is
|
||||
* a best-effort process and some other policies will still remain in place after the profile
|
||||
* owner is cleared.
|
||||
*
|
||||
* @param admin The component to remove as the profile owner.
|
||||
* @throws SecurityException if {@code admin} is not an active profile owner.
|
||||
* @throws SecurityException if {@code admin} is not an active profile owner, or the method is
|
||||
* being called from a managed profile.
|
||||
*
|
||||
* @deprecated This method is expected to be used for testing purposes only. The profile owner
|
||||
* will lose control of the user and its data after calling it. In order to protect any
|
||||
* sensitive data that remains on this user, it is advised that the profile owner deletes it
|
||||
* instead of calling this method. See {@link #wipeData(int)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void clearProfileOwner(@NonNull ComponentName admin) {
|
||||
throwIfParentInstance("clearProfileOwner");
|
||||
if (mService != null) {
|
||||
|
||||
@@ -6625,14 +6625,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
if (!mHasFeature) {
|
||||
return;
|
||||
}
|
||||
final UserHandle callingUser = mInjector.binderGetCallingUserHandle();
|
||||
final int userId = callingUser.getIdentifier();
|
||||
Preconditions.checkNotNull(who, "ComponentName is null");
|
||||
|
||||
final int userId = mInjector.userHandleGetCallingUserId();
|
||||
enforceNotManagedProfile(userId, "clear profile owner");
|
||||
enforceUserUnlocked(userId);
|
||||
// Check if this is the profile owner who is calling
|
||||
final ActiveAdmin admin =
|
||||
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
|
||||
synchronized (this) {
|
||||
// Check if this is the profile owner who is calling
|
||||
final ActiveAdmin admin =
|
||||
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
|
||||
|
||||
final long ident = mInjector.binderClearCallingIdentity();
|
||||
try {
|
||||
clearProfileOwnerLocked(admin, userId);
|
||||
|
||||
Reference in New Issue
Block a user