summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java12
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl2
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java15
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerServiceShellCommand.java3
-rw-r--r--services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java22
5 files changed, 23 insertions, 31 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 5769728b7602..65265da1038a 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -8969,7 +8969,7 @@ public class DevicePolicyManager {
try {
final int myUserId = myUserId();
mService.setActiveAdmin(admin, false, myUserId);
- return mService.setProfileOwner(admin, ownerName, myUserId);
+ return mService.setProfileOwner(admin, myUserId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -9031,20 +9031,16 @@ public class DevicePolicyManager {
* - the caller is SYSTEM_UID.
* - or the caller is the shell uid, and there are no accounts on the specified user.
* @param admin the component name to be registered as profile owner.
- * @param ownerName the human readable name of the organisation associated with this DPM.
* @param userHandle the userId to set the profile owner for.
* @return whether the component was successfully registered as the profile owner.
* @throws IllegalArgumentException if admin is null, the package isn't installed, or the
* preconditions mentioned are not met.
*/
- public boolean setProfileOwner(@NonNull ComponentName admin, @Deprecated String ownerName,
- int userHandle) throws IllegalArgumentException {
+ public boolean setProfileOwner(@NonNull ComponentName admin, int userHandle)
+ throws IllegalArgumentException {
if (mService != null) {
try {
- if (ownerName == null) {
- ownerName = "";
- }
- return mService.setProfileOwner(admin, ownerName, userHandle);
+ return mService.setProfileOwner(admin, userHandle);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index ab8d50ba9b66..75bfc2554442 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -175,7 +175,7 @@ interface IDevicePolicyManager {
void clearDeviceOwner(String packageName);
int getDeviceOwnerUserId();
- boolean setProfileOwner(in ComponentName who, String ownerName, int userHandle);
+ boolean setProfileOwner(in ComponentName who, int userHandle);
ComponentName getProfileOwnerAsUser(int userHandle);
ComponentName getProfileOwnerOrDeviceOwnerSupervisionComponent(in UserHandle userHandle);
boolean isSupervisionComponent(in ComponentName who);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 360653c66c0e..c9fa84ca1acf 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -8793,9 +8793,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
});
}
- // TODO(b/240562946): Remove owner name from API parameters.
@Override
- public boolean setProfileOwner(ComponentName who, String ownerName, int userHandle) {
+ public boolean setProfileOwner(ComponentName who, int userHandle) {
if (!mHasFeature) {
logMissingFeatureAction("Cannot set " + ComponentName.flattenToShortString(who)
+ " as profile owner for user " + userHandle);
@@ -10816,9 +10815,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
// Set admin.
setActiveAdmin(profileOwner, /* refreshing= */ true, userId);
- final String ownerName = getProfileOwnerNameUnchecked(
- Process.myUserHandle().getIdentifier());
- setProfileOwner(profileOwner, ownerName, userId);
+ setProfileOwner(profileOwner, userId);
synchronized (getLockObject()) {
DevicePolicyData policyData = getUserData(userId);
@@ -17657,8 +17654,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
maybeInstallDevicePolicyManagementRoleHolderInUser(userInfo.id);
installExistingAdminPackage(userInfo.id, admin.getPackageName());
- if (!enableAdminAndSetProfileOwner(
- userInfo.id, caller.getUserId(), admin, provisioningParams.getOwnerName())) {
+ if (!enableAdminAndSetProfileOwner(userInfo.id, caller.getUserId(), admin)) {
throw new ServiceSpecificException(
ERROR_SETTING_PROFILE_OWNER_FAILED,
"Error setting profile owner.");
@@ -17847,10 +17843,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
private boolean enableAdminAndSetProfileOwner(
- @UserIdInt int userId, @UserIdInt int callingUserId, ComponentName adminComponent,
- String ownerName) {
+ @UserIdInt int userId, @UserIdInt int callingUserId, ComponentName adminComponent) {
enableAndSetActiveAdmin(userId, callingUserId, adminComponent);
- return setProfileOwner(adminComponent, ownerName, userId);
+ return setProfileOwner(adminComponent, userId);
}
private void enableAndSetActiveAdmin(
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerServiceShellCommand.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerServiceShellCommand.java
index f19dcdea7dce..43432258045c 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerServiceShellCommand.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerServiceShellCommand.java
@@ -50,6 +50,7 @@ final class DevicePolicyManagerServiceShellCommand extends ShellCommand {
private final DevicePolicyManagerService mService;
private int mUserId = UserHandle.USER_SYSTEM;
+ //TODO(b/240562946): remove mName once it is not used by setDeviceOwner
private String mName = "";
private ComponentName mComponent;
private boolean mSetDoOnly;
@@ -287,7 +288,7 @@ final class DevicePolicyManagerServiceShellCommand extends ShellCommand {
mService.setActiveAdmin(mComponent, /* refreshing= */ true, mUserId);
try {
- if (!mService.setProfileOwner(mComponent, mName, mUserId)) {
+ if (!mService.setProfileOwner(mComponent, mUserId)) {
throw new RuntimeException("Can't set component "
+ mComponent.flattenToShortString() + " as profile owner for user "
+ mUserId);
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index 4a363c2d62e3..171b895b93aa 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -402,7 +402,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
// PO needs to be a DA.
dpm.setActiveAdmin(admin, /*replace=*/ false);
// Fire!
- assertThat(dpm.setProfileOwner(admin, "owner-name", CALLER_USER_HANDLE)).isTrue();
+ assertThat(dpm.setProfileOwner(admin, CALLER_USER_HANDLE)).isTrue();
// Check
assertThat(dpm.getProfileOwnerAsUser(CALLER_USER_HANDLE)).isEqualTo(admin);
});
@@ -1074,7 +1074,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
dpm.setActiveAdmin(admin2, /* refreshing= */ true, UserHandle.USER_SYSTEM);
assertExpectException(IllegalStateException.class,
/* messageRegex= */ "already has a device owner",
- () -> dpm.setProfileOwner(admin2, "owner-name", UserHandle.USER_SYSTEM));
+ () -> dpm.setProfileOwner(admin2, UserHandle.USER_SYSTEM));
// DO admin can't be deactivated.
dpm.removeActiveAdmin(admin1);
@@ -1098,7 +1098,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
dpm.setActiveAdmin(admin2, /* refreshing= */ true, CALLER_USER_HANDLE);
assertExpectException(IllegalStateException.class,
/* messageRegex= */ "profile owner is already set",
- () -> dpm.setProfileOwner(admin2, "owner-name", CALLER_USER_HANDLE));
+ () -> dpm.setProfileOwner(admin2, CALLER_USER_HANDLE));
// DO admin can't be deactivated.
dpm.removeActiveAdmin(admin1);
@@ -1603,13 +1603,13 @@ public class DevicePolicyManagerTest extends DpmTestBase {
// Package doesn't exist and caller is not system
assertExpectException(SecurityException.class,
/* messageRegex= */ "Calling identity is not authorized",
- () -> dpm.setProfileOwner(admin1, "owner-name", UserHandle.USER_SYSTEM));
+ () -> dpm.setProfileOwner(admin1, UserHandle.USER_SYSTEM));
// Package exists, but caller is not system
setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
assertExpectException(SecurityException.class,
/* messageRegex= */ "Calling identity is not authorized",
- () -> dpm.setProfileOwner(admin1, "owner-name", UserHandle.USER_SYSTEM));
+ () -> dpm.setProfileOwner(admin1, UserHandle.USER_SYSTEM));
}
@Test
@@ -2683,7 +2683,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
() -> dpm.getWifiMacAddress(admin1));
// Test 3. Caller has PO, but not DO.
- assertThat(dpm.setProfileOwner(admin1, null, UserHandle.USER_SYSTEM)).isTrue();
+ assertThat(dpm.setProfileOwner(admin1, UserHandle.USER_SYSTEM)).isTrue();
assertExpectException(SecurityException.class,
/* messageRegex= */ INVALID_CALLING_IDENTITY_MSG,
() -> dpm.getWifiMacAddress(admin1));
@@ -2735,7 +2735,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
INVALID_CALLING_IDENTITY_MSG, () -> dpm.reboot(admin1));
// Set admin1 as PO.
- assertThat(dpm.setProfileOwner(admin1, null, UserHandle.USER_SYSTEM)).isTrue();
+ assertThat(dpm.setProfileOwner(admin1, UserHandle.USER_SYSTEM)).isTrue();
assertExpectException(SecurityException.class, /* messageRegex= */
INVALID_CALLING_IDENTITY_MSG, () -> dpm.reboot(admin1));
@@ -3231,7 +3231,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_UID);
dpm.setActiveAdmin(admin1, false);
- assertThat(dpm.setProfileOwner(admin1, null, CALLER_USER_HANDLE)).isTrue();
+ assertThat(dpm.setProfileOwner(admin1, CALLER_USER_HANDLE)).isTrue();
mContext.callerPermissions.removeAll(OWNER_SETUP_PERMISSIONS);
}
@@ -3241,7 +3241,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
setUpPackageManagerForAdmin(admin1, DpmMockContext.SYSTEM_UID);
dpm.setActiveAdmin(admin1, false);
- assertThat(dpm.setProfileOwner(admin1, null, UserHandle.USER_SYSTEM)).isTrue();
+ assertThat(dpm.setProfileOwner(admin1, UserHandle.USER_SYSTEM)).isTrue();
mContext.callerPermissions.removeAll(OWNER_SETUP_PERMISSIONS);
}
@@ -3764,7 +3764,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
mContext.callerPermissions.addAll(OWNER_SETUP_PERMISSIONS);
setUpPackageManagerForFakeAdmin(admin1, managedProfileAdminUid, admin1);
dpm.setActiveAdmin(admin1, false, userId);
- assertThat(dpm.setProfileOwner(admin1, null, userId)).isFalse();
+ assertThat(dpm.setProfileOwner(admin1, userId)).isFalse();
mContext.callerPermissions.removeAll(OWNER_SETUP_PERMISSIONS);
}
@@ -8710,7 +8710,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
setUpPackageManagerForFakeAdmin(admin, adminUid, /* enabledSetting= */ null,
appTargetSdk, copyFromAdmin);
dpm.setActiveAdmin(admin, false, userId);
- assertThat(dpm.setProfileOwner(admin, null, userId)).isTrue();
+ assertThat(dpm.setProfileOwner(admin, userId)).isTrue();
mContext.callerPermissions.removeAll(OWNER_SETUP_PERMISSIONS);
}