diff options
3 files changed, 28 insertions, 29 deletions
diff --git a/service/java/com/android/safetycenter/SafetyCenterListeners.java b/service/java/com/android/safetycenter/SafetyCenterListeners.java index 5f89f46ff..091daa0a6 100644 --- a/service/java/com/android/safetycenter/SafetyCenterListeners.java +++ b/service/java/com/android/safetycenter/SafetyCenterListeners.java @@ -87,7 +87,7 @@ final class SafetyCenterListeners { */ void deliverDataForUserProfileGroup(UserProfileGroup userProfileGroup) { ArrayMap<String, SafetyCenterData> safetyCenterDataCache = new ArrayMap<>(); - int[] relevantUserIds = userProfileGroup.getProfileParentAndManagedRunningProfilesUserIds(); + int[] relevantUserIds = userProfileGroup.getAllRunningProfilesUserIds(); for (int i = 0; i < relevantUserIds.length; i++) { deliverUpdateForUser( relevantUserIds[i], @@ -105,7 +105,7 @@ final class SafetyCenterListeners { void deliverErrorForUserProfileGroup( UserProfileGroup userProfileGroup, SafetyCenterErrorDetails safetyCenterErrorDetails) { ArrayMap<String, SafetyCenterData> safetyCenterDataCache = new ArrayMap<>(); - int[] relevantUserIds = userProfileGroup.getProfileParentAndManagedRunningProfilesUserIds(); + int[] relevantUserIds = userProfileGroup.getAllRunningProfilesUserIds(); for (int i = 0; i < relevantUserIds.length; i++) { deliverUpdateForUser( relevantUserIds[i], diff --git a/service/java/com/android/safetycenter/UserProfileGroup.java b/service/java/com/android/safetycenter/UserProfileGroup.java index 86e949218..2f4ab17e4 100644 --- a/service/java/com/android/safetycenter/UserProfileGroup.java +++ b/service/java/com/android/safetycenter/UserProfileGroup.java @@ -246,11 +246,6 @@ public final class UserProfileGroup { return mProfileParentUserId; } - /** Returns the running managed profile user ids of the {@link UserProfileGroup}. */ - public int[] getManagedRunningProfilesUserIds() { - return mManagedRunningProfilesUserIds; - } - /** * A convenience method to get all the profile ids of all the users of all profile types. So, in * essence, this is equivalent to iterating through all the profile types using @@ -275,21 +270,26 @@ public final class UserProfileGroup { } /** - * Convenience method that combines the results of {@link - * UserProfileGroup#getProfileParentUserId()} and {@link - * UserProfileGroup#getManagedRunningProfilesUserIds()}. + * A convenience method to get all the profile ids of all the users (that are currently running) + * of all profile types. So, in essence, this is equivalent to iterating through all the profile + * {types using {@link ProfileType#ALL_PROFILE_TYPES} and getting all the users for each of the + * profile type using {@link #getProfilesOfType(int profileType)} only if they are running. */ - public int[] getProfileParentAndManagedRunningProfilesUserIds() { - int[] profileParentAndManagedRunningProfilesUserIds = - new int[mManagedRunningProfilesUserIds.length + 1]; - profileParentAndManagedRunningProfilesUserIds[0] = mProfileParentUserId; + public int[] getAllRunningProfilesUserIds() { + int[] allRunningProfileIds = new int[getNumRunningProfiles()]; + allRunningProfileIds[0] = mProfileParentUserId; System.arraycopy( mManagedRunningProfilesUserIds, /* srcPos= */ 0, - profileParentAndManagedRunningProfilesUserIds, + allRunningProfileIds, /* destPos= */ 1, mManagedRunningProfilesUserIds.length); - return profileParentAndManagedRunningProfilesUserIds; + + if (mPrivateProfileRunning) { + allRunningProfileIds[allRunningProfileIds.length - 1] = mPrivateProfileUserId; + } + + return allRunningProfileIds; } /** diff --git a/service/java/com/android/safetycenter/data/SafetyCenterIssueRepository.java b/service/java/com/android/safetycenter/data/SafetyCenterIssueRepository.java index 2e6f707a3..3806584a8 100644 --- a/service/java/com/android/safetycenter/data/SafetyCenterIssueRepository.java +++ b/service/java/com/android/safetycenter/data/SafetyCenterIssueRepository.java @@ -31,12 +31,12 @@ import android.safetycenter.config.SafetySourcesGroup; import android.util.SparseArray; import com.android.modules.utils.build.SdkLevel; -import com.android.permission.util.UserUtils; import com.android.safetycenter.SafetyCenterConfigReader; import com.android.safetycenter.SafetySourceIssueInfo; import com.android.safetycenter.SafetySourceKey; import com.android.safetycenter.SafetySources; import com.android.safetycenter.UserProfileGroup; +import com.android.safetycenter.UserProfileGroup.ProfileType; import com.android.safetycenter.internaldata.SafetyCenterIssueKey; import java.io.PrintWriter; @@ -88,12 +88,12 @@ final class SafetyCenterIssueRepository { * that can affect issues. */ void updateIssues(@UserIdInt int userId) { - updateIssues(userId, UserUtils.isManagedProfile(userId, mContext)); + updateIssues(userId, UserProfileGroup.getProfileTypeOfUser(userId, mContext)); } - private void updateIssues(@UserIdInt int userId, boolean isManagedProfile) { + private void updateIssues(@UserIdInt int userId, @ProfileType int profileType) { List<SafetySourceIssueInfo> issues = - getAllStoredIssuesFromRawSourceData(userId, isManagedProfile); + getAllStoredIssuesFromRawSourceData(userId, profileType); issues.sort(SAFETY_SOURCE_ISSUES_INFO_BY_SEVERITY_DESCENDING); @@ -183,14 +183,14 @@ final class SafetyCenterIssueRepository { } private List<SafetySourceIssueInfo> getAllStoredIssuesFromRawSourceData( - @UserIdInt int userId, boolean isManagedProfile) { + @UserIdInt int userId, @ProfileType int profileType) { List<SafetySourceIssueInfo> allIssuesInfo = new ArrayList<>(); List<SafetySourcesGroup> safetySourcesGroups = mSafetyCenterConfigReader.getSafetySourcesGroups(); for (int j = 0; j < safetySourcesGroups.size(); j++) { addSafetySourceIssuesInfo( - allIssuesInfo, safetySourcesGroups.get(j), userId, isManagedProfile); + allIssuesInfo, safetySourcesGroups.get(j), userId, profileType); } return allIssuesInfo; @@ -200,7 +200,7 @@ final class SafetyCenterIssueRepository { List<SafetySourceIssueInfo> issuesInfo, SafetySourcesGroup safetySourcesGroup, @UserIdInt int userId, - boolean isManagedProfile) { + @ProfileType int profileType) { List<SafetySource> safetySources = safetySourcesGroup.getSafetySources(); for (int i = 0; i < safetySources.size(); i++) { SafetySource safetySource = safetySources.get(i); @@ -208,7 +208,7 @@ final class SafetyCenterIssueRepository { if (!SafetySources.isExternal(safetySource)) { continue; } - if (isManagedProfile && !SafetySources.supportsManagedProfiles(safetySource)) { + if (!SafetySources.supportsProfileType(safetySource, profileType)) { continue; } @@ -244,12 +244,11 @@ final class SafetyCenterIssueRepository { * UserProfileGroup}. */ private List<SafetySourceIssueInfo> getIssuesFor(UserProfileGroup userProfileGroup) { - List<SafetySourceIssueInfo> issues = - new ArrayList<>(getIssuesForUser(userProfileGroup.getProfileParentUserId())); + List<SafetySourceIssueInfo> issues = new ArrayList<>(); - int[] managedRunningProfileUserIds = userProfileGroup.getManagedRunningProfilesUserIds(); - for (int i = 0; i < managedRunningProfileUserIds.length; i++) { - issues.addAll(getIssuesForUser(managedRunningProfileUserIds[i])); + int[] allRunningProfileUserIds = userProfileGroup.getAllRunningProfilesUserIds(); + for (int i = 0; i < allRunningProfileUserIds.length; i++) { + issues.addAll(getIssuesForUser(allRunningProfileUserIds[i])); } return issues; |