Correctly identify the COPE user for screenshot policy.
Test: btest "android.devicepolicy.cts.ScreenCaptureDisabledTest#setScreenCaptureDisabled_true_works[IncludeRunOnParentOfOrganizationOwnedProfileOwnerUsingParentInstance]" -sy Bug: 258561494 Change-Id: I9e940e5ba7faadbcfdb71461400886fa8a11ca69
This commit is contained in:
@@ -2588,7 +2588,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
ensureLocked();
|
||||
// Try to find an admin which can use reqPolicy
|
||||
final ComponentName poAdminComponent = mOwners.getProfileOwnerComponent(userId);
|
||||
final ComponentName doAdminComponent = mOwners.getDeviceOwnerComponent();
|
||||
|
||||
if (poAdminComponent != null) {
|
||||
return getProfileOwnerLocked(userId);
|
||||
@@ -7762,9 +7761,15 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
// be disabled device-wide.
|
||||
private void pushScreenCapturePolicy(int adminUserId) {
|
||||
// Update screen capture device-wide if disabled by the DO or COPE PO on the parent profile.
|
||||
ActiveAdmin admin =
|
||||
getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked(
|
||||
UserHandle.USER_SYSTEM);
|
||||
// TODO(b/261999445): remove
|
||||
ActiveAdmin admin;
|
||||
if (isHeadlessFlagEnabled()) {
|
||||
admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked(
|
||||
mUserManagerInternal.getProfileParentId(adminUserId));
|
||||
} else {
|
||||
admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked(
|
||||
UserHandle.USER_SYSTEM);
|
||||
}
|
||||
if (admin != null && admin.disableScreenCapture) {
|
||||
setScreenCaptureDisabled(UserHandle.USER_ALL);
|
||||
} else {
|
||||
@@ -8817,10 +8822,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
return admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use the version which does not take a user id.
|
||||
*/
|
||||
@Deprecated
|
||||
ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked(int userId) {
|
||||
ensureLocked();
|
||||
ActiveAdmin admin = getDeviceOwnerAdminLocked();
|
||||
@@ -8831,16 +8832,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
return admin != null ? admin.getParentActiveAdmin() : null;
|
||||
}
|
||||
|
||||
ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked() {
|
||||
ensureLocked();
|
||||
ActiveAdmin admin = getDeviceOwnerAdminLocked();
|
||||
if (admin != null) {
|
||||
return admin;
|
||||
}
|
||||
admin = getProfileOwnerOfOrganizationOwnedDeviceLocked();
|
||||
return admin != null ? admin.getParentActiveAdmin() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearDeviceOwner(String packageName) {
|
||||
Objects.requireNonNull(packageName, "packageName is null");
|
||||
@@ -9374,10 +9365,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
return admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use the version which does not take a user id.
|
||||
*/
|
||||
@Deprecated
|
||||
@GuardedBy("getLockObject()")
|
||||
ActiveAdmin getProfileOwnerOfOrganizationOwnedDeviceLocked(int userHandle) {
|
||||
return mInjector.binderWithCleanCallingIdentity(() -> {
|
||||
|
||||
Reference in New Issue
Block a user