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
This commit is contained in:
@@ -510,7 +510,6 @@ interface IActivityManager {
|
|||||||
void noteAlarmFinish(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
|
void noteAlarmFinish(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
int getPackageProcessState(in String packageName, in String callingPackage);
|
int getPackageProcessState(in String packageName, in String callingPackage);
|
||||||
void updateDeviceOwner(in String packageName);
|
|
||||||
|
|
||||||
// Start of N transactions
|
// Start of N transactions
|
||||||
// Start Binder transaction tracking for all applications.
|
// Start Binder transaction tracking for all applications.
|
||||||
|
|||||||
@@ -690,12 +690,6 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
return (isFg) ? mFgBroadcastQueue : mBgBroadcastQueue;
|
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;
|
private volatile int mDeviceOwnerUid = INVALID_UID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6191,17 +6185,6 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
return ActivityClient.getInstance().getTaskForActivity(token, onlyRoot);
|
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
|
@Override
|
||||||
public void updateLockTaskPackages(int userId, String[] packages) {
|
public void updateLockTaskPackages(int userId, String[] packages) {
|
||||||
mActivityTaskManager.updateLockTaskPackages(userId, packages);
|
mActivityTaskManager.updateLockTaskPackages(userId, packages);
|
||||||
|
|||||||
@@ -1999,9 +1999,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
mOwners.load();
|
mOwners.load();
|
||||||
setDeviceOwnershipSystemPropertyLocked();
|
setDeviceOwnershipSystemPropertyLocked();
|
||||||
findOwnerComponentIfNecessaryLocked();
|
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) {
|
static void validateQualityConstant(int quality) {
|
||||||
switch (quality) {
|
switch (quality) {
|
||||||
case PASSWORD_QUALITY_UNSPECIFIED:
|
case PASSWORD_QUALITY_UNSPECIFIED:
|
||||||
@@ -8586,7 +8566,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
|
|
||||||
mOwners.setDeviceOwner(admin, ownerName, userId);
|
mOwners.setDeviceOwner(admin, ownerName, userId);
|
||||||
mOwners.writeDeviceOwner();
|
mOwners.writeDeviceOwner();
|
||||||
updateDeviceOwnerLocked();
|
|
||||||
setDeviceOwnershipSystemPropertyLocked();
|
setDeviceOwnershipSystemPropertyLocked();
|
||||||
|
|
||||||
//TODO(b/180371154): when provisionFullyManagedDevice is used in tests, remove this
|
//TODO(b/180371154): when provisionFullyManagedDevice is used in tests, remove this
|
||||||
@@ -8947,7 +8926,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
|
|
||||||
mOwners.clearDeviceOwner();
|
mOwners.clearDeviceOwner();
|
||||||
mOwners.writeDeviceOwner();
|
mOwners.writeDeviceOwner();
|
||||||
updateDeviceOwnerLocked();
|
|
||||||
|
|
||||||
clearDeviceOwnerUserRestriction(UserHandle.of(userId));
|
clearDeviceOwnerUserRestriction(UserHandle.of(userId));
|
||||||
mInjector.securityLogSetLoggingEnabledProperty(false);
|
mInjector.securityLogSetLoggingEnabledProperty(false);
|
||||||
|
|||||||
@@ -1134,9 +1134,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
|
|||||||
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
|
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
|
||||||
|
|
||||||
// Verify internal calls.
|
// Verify internal calls.
|
||||||
verify(getServices().iactivityManager, times(1)).updateDeviceOwner(
|
|
||||||
eq(admin1.getPackageName()));
|
|
||||||
|
|
||||||
verify(getServices().userManager, times(1)).setUserRestriction(
|
verify(getServices().userManager, times(1)).setUserRestriction(
|
||||||
eq(UserManager.DISALLOW_ADD_MANAGED_PROFILE),
|
eq(UserManager.DISALLOW_ADD_MANAGED_PROFILE),
|
||||||
eq(true), eq(UserHandle.SYSTEM));
|
eq(true), eq(UserHandle.SYSTEM));
|
||||||
@@ -1202,9 +1199,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
|
|||||||
assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);
|
assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);
|
||||||
|
|
||||||
// Verify internal calls.
|
// Verify internal calls.
|
||||||
verify(getServices().iactivityManager).updateDeviceOwner(
|
|
||||||
eq(admin1.getPackageName()));
|
|
||||||
|
|
||||||
verify(mContext.spiedContext).sendBroadcastAsUser(
|
verify(mContext.spiedContext).sendBroadcastAsUser(
|
||||||
MockUtils.checkIntentAction(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED),
|
MockUtils.checkIntentAction(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED),
|
||||||
MockUtils.checkUserHandle(UserHandle.USER_SYSTEM));
|
MockUtils.checkUserHandle(UserHandle.USER_SYSTEM));
|
||||||
@@ -1389,11 +1383,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
|
|||||||
setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
|
setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
|
||||||
dpm.setActiveAdmin(admin1, /* replace =*/ false);
|
dpm.setActiveAdmin(admin1, /* replace =*/ false);
|
||||||
assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();
|
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);
|
assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);
|
||||||
|
|
||||||
dpm.addUserRestriction(admin1, UserManager.DISALLOW_ADD_USER);
|
dpm.addUserRestriction(admin1, UserManager.DISALLOW_ADD_USER);
|
||||||
@@ -1498,11 +1487,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
|
|||||||
setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
|
setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
|
||||||
dpm.setActiveAdmin(admin1, /* replace =*/ false);
|
dpm.setActiveAdmin(admin1, /* replace =*/ false);
|
||||||
assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();
|
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);
|
assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);
|
||||||
|
|
||||||
// Now call clear from the secondary user, which should throw.
|
// Now call clear from the secondary user, which should throw.
|
||||||
|
|||||||
Reference in New Issue
Block a user