Skip to content

Commit

Permalink
Merge "Remove internal fix for clouddpc users" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Treehugger Robot authored and Android (Google) Code Review committed Jun 14, 2024
2 parents f574665 + af1b5c6 commit ef0cc5f
Showing 1 changed file with 0 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2256,41 +2256,11 @@ DevicePolicyData getUserData(int userHandle) {
if (userHandle == UserHandle.USER_SYSTEM) {
mStateCache.setDeviceProvisioned(policy.mUserSetupComplete);
}
if (Flags.headlessSingleUserBadDeviceAdminStateFix()) {
fixBadDeviceAdminStateForInternalUsers(userHandle, policy);
}
}
return policy;
}
}

private void fixBadDeviceAdminStateForInternalUsers(int userId, DevicePolicyData policy) {
ComponentName component = mOwners.getDeviceOwnerComponent();
int doUserId = mOwners.getDeviceOwnerUserId();
ComponentName cloudDpc = new ComponentName(
"com.google.android.apps.work.clouddpc",
"com.google.android.apps.work.clouddpc.receivers.CloudDeviceAdminReceiver");
if (component == null || doUserId != userId || !component.equals(cloudDpc)) {
return;
}
Slogf.i(LOG_TAG, "Attempting to apply a temp fix for cloudpc internal users' bad state.");
final int n = policy.mAdminList.size();
for (int i = 0; i < n; i++) {
ActiveAdmin admin = policy.mAdminList.get(i);
if (component.equals(admin.info.getComponent())) {
Slogf.i(LOG_TAG, "An ActiveAdmin already exists, fix not required.");
return;
}
}
DeviceAdminInfo dai = findAdmin(component, userId, /* throwForMissingPermission= */ false);
if (dai != null) {
ActiveAdmin ap = new ActiveAdmin(dai, /* parent */ false);
policy.mAdminMap.put(ap.info.getComponent(), ap);
policy.mAdminList.add(ap);
Slogf.i(LOG_TAG, "Fix applied, an ActiveAdmin has been added.");
}
}

/**
* Creates and loads the policy data from xml for data that is shared between
* various profiles of a user. In contrast to {@link #getUserData(int)}
Expand Down

0 comments on commit ef0cc5f

Please sign in to comment.