Remove mDeviceOwnerName - it's never read

And remove all the code whose only effect is modifying this unused
variable.

Bug: 219944571
Test: compiles
Change-Id: Ie484c4dcd3691e427365382b447e6d5a86f95cf4
Merged-In: Ie484c4dcd3691e427365382b447e6d5a86f95cf4
(cherry picked from commit 8a168e8a40)
This commit is contained in:
Pavel Grafov
2022-02-17 11:51:36 +00:00
parent ddb497d64a
commit 0707849bf3
4 changed files with 0 additions and 56 deletions

View File

@@ -510,7 +510,6 @@ interface IActivityManager {
void noteAlarmFinish(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
@UnsupportedAppUsage
int getPackageProcessState(in String packageName, in String callingPackage);
void updateDeviceOwner(in String packageName);
// Start of N transactions
// Start Binder transaction tracking for all applications.

View File

@@ -694,12 +694,6 @@ public class ActivityManagerService extends IActivityManager.Stub
return (isFg) ? mFgBroadcastQueue : mBgBroadcastQueue;
}
/**
* The package name of the DeviceOwner. This package is not permitted to have its data cleared.
* <p>Not actually used</p>
*/
private volatile String mDeviceOwnerName;
private volatile int mDeviceOwnerUid = INVALID_UID;
/**
@@ -6237,17 +6231,6 @@ public class ActivityManagerService extends IActivityManager.Stub
return ActivityClient.getInstance().getTaskForActivity(token, onlyRoot);
}
@Override
public void updateDeviceOwner(String packageName) {
final int callingUid = Binder.getCallingUid();
if (callingUid != 0 && callingUid != SYSTEM_UID) {
throw new SecurityException("updateDeviceOwner called from non-system process");
}
synchronized (this) {
mDeviceOwnerName = packageName;
}
}
@Override
public void updateLockTaskPackages(int userId, String[] packages) {
mActivityTaskManager.updateLockTaskPackages(userId, packages);

View File

@@ -1999,9 +1999,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
mOwners.load();
setDeviceOwnershipSystemPropertyLocked();
findOwnerComponentIfNecessaryLocked();
// TODO PO may not have a class name either due to b/17652534. Address that too.
updateDeviceOwnerLocked();
}
}
@@ -3142,23 +3139,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
}
private void updateDeviceOwnerLocked() {
long ident = mInjector.binderClearCallingIdentity();
try {
// TODO This is to prevent DO from getting "clear data"ed, but it should also check the
// user id and also protect all other DAs too.
final ComponentName deviceOwnerComponent = mOwners.getDeviceOwnerComponent();
if (deviceOwnerComponent != null) {
mInjector.getIActivityManager()
.updateDeviceOwner(deviceOwnerComponent.getPackageName());
}
} catch (RemoteException e) {
// Not gonna happen.
} finally {
mInjector.binderRestoreCallingIdentity(ident);
}
}
static void validateQualityConstant(int quality) {
switch (quality) {
case PASSWORD_QUALITY_UNSPECIFIED:
@@ -8590,7 +8570,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
mOwners.setDeviceOwner(admin, ownerName, userId);
mOwners.writeDeviceOwner();
updateDeviceOwnerLocked();
setDeviceOwnershipSystemPropertyLocked();
//TODO(b/180371154): when provisionFullyManagedDevice is used in tests, remove this
@@ -8951,7 +8930,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
mOwners.clearDeviceOwner();
mOwners.writeDeviceOwner();
updateDeviceOwnerLocked();
clearDeviceOwnerUserRestriction(UserHandle.of(userId));
mInjector.securityLogSetLoggingEnabledProperty(false);

View File

@@ -1137,9 +1137,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
// Verify internal calls.
verify(getServices().iactivityManager, times(1)).updateDeviceOwner(
eq(admin1.getPackageName()));
verify(getServices().userManager, times(1)).setUserRestriction(
eq(UserManager.DISALLOW_ADD_MANAGED_PROFILE),
eq(true), eq(UserHandle.SYSTEM));
@@ -1205,9 +1202,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);
// Verify internal calls.
verify(getServices().iactivityManager).updateDeviceOwner(
eq(admin1.getPackageName()));
verify(mContext.spiedContext).sendBroadcastAsUser(
MockUtils.checkIntentAction(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED),
MockUtils.checkUserHandle(UserHandle.USER_SYSTEM));
@@ -1392,11 +1386,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
dpm.setActiveAdmin(admin1, /* replace =*/ false);
assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();
// Verify internal calls.
verify(getServices().iactivityManager, times(1)).updateDeviceOwner(
eq(admin1.getPackageName()));
assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);
dpm.addUserRestriction(admin1, UserManager.DISALLOW_ADD_USER);
@@ -1501,11 +1490,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
dpm.setActiveAdmin(admin1, /* replace =*/ false);
assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();
// Verify internal calls.
verify(getServices().iactivityManager, times(1)).updateDeviceOwner(
eq(admin1.getPackageName()));
assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);
// Now call clear from the secondary user, which should throw.