Use internal version of getUserInfos
This change ensures we use the internal version of getUserInfos so to avoid unnecessary permission checks when updating the apps filter cache. Test: atest AppSecurityTests.testCrossPackageDiffCertSetInstaller Bug: 150405193 Change-Id: I67969ee2dec7a70442d2bea43c99fba977ee33f4
This commit is contained in:
@@ -149,7 +149,7 @@ public class AppsFilter {
|
||||
void runWithState(CurrentStateCallback callback);
|
||||
|
||||
interface CurrentStateCallback {
|
||||
void currentState(ArrayMap<String, PackageSetting> settings, List<UserInfo> users);
|
||||
void currentState(ArrayMap<String, PackageSetting> settings, UserInfo[] users);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ public class AppsFilter {
|
||||
final StateProvider stateProvider = command -> {
|
||||
synchronized (injector.getLock()) {
|
||||
command.currentState(injector.getSettings().mPackages,
|
||||
injector.getUserManagerService().getUsers(false, false, false));
|
||||
injector.getUserManagerInternal().getUserInfos());
|
||||
}
|
||||
};
|
||||
AppsFilter appsFilter = new AppsFilter(stateProvider, featureConfig,
|
||||
@@ -474,8 +474,8 @@ public class AppsFilter {
|
||||
mStateProvider.runWithState(new StateProvider.CurrentStateCallback() {
|
||||
@Override
|
||||
public void currentState(ArrayMap<String, PackageSetting> settings,
|
||||
List<UserInfo> users) {
|
||||
mShouldFilterCache = new SparseArray<>(users.size() * settings.size());
|
||||
UserInfo[] users) {
|
||||
mShouldFilterCache = new SparseArray<>(users.length * settings.size());
|
||||
}
|
||||
});
|
||||
mFeatureConfig.onSystemReady();
|
||||
@@ -632,7 +632,7 @@ public class AppsFilter {
|
||||
|
||||
private void updateShouldFilterCacheForPackage(@Nullable String skipPackageName,
|
||||
PackageSetting subjectSetting, ArrayMap<String, PackageSetting> allSettings,
|
||||
List<UserInfo> allUsers, int maxIndex) {
|
||||
UserInfo[] allUsers, int maxIndex) {
|
||||
for (int i = Math.min(maxIndex, allSettings.size() - 1); i >= 0; i--) {
|
||||
PackageSetting otherSetting = allSettings.valueAt(i);
|
||||
if (subjectSetting.appId == otherSetting.appId) {
|
||||
@@ -642,12 +642,12 @@ public class AppsFilter {
|
||||
if (subjectSetting.name == skipPackageName || otherSetting.name == skipPackageName) {
|
||||
continue;
|
||||
}
|
||||
final int userCount = allUsers.size();
|
||||
final int userCount = allUsers.length;
|
||||
final int appxUidCount = userCount * allSettings.size();
|
||||
for (int su = 0; su < userCount; su++) {
|
||||
int subjectUser = allUsers.get(su).id;
|
||||
int subjectUser = allUsers[su].id;
|
||||
for (int ou = su; ou < userCount; ou++) {
|
||||
int otherUser = allUsers.get(ou).id;
|
||||
int otherUser = allUsers[ou].id;
|
||||
int subjectUid = UserHandle.getUid(subjectUser, subjectSetting.appId);
|
||||
if (!mShouldFilterCache.contains(subjectUid)) {
|
||||
mShouldFilterCache.put(subjectUid, new SparseBooleanArray(appxUidCount));
|
||||
@@ -777,9 +777,9 @@ public class AppsFilter {
|
||||
public void removePackage(PackageSetting setting) {
|
||||
removeAppIdFromVisibilityCache(setting.appId);
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
final int userCount = users.size();
|
||||
final int userCount = users.length;
|
||||
for (int u = 0; u < userCount; u++) {
|
||||
final int userId = users.get(u).id;
|
||||
final int userId = users[u].id;
|
||||
final int removingUid = UserHandle.getUid(userId, setting.appId);
|
||||
mImplicitlyQueryable.remove(removingUid);
|
||||
for (int i = mImplicitlyQueryable.size() - 1; i >= 0; i--) {
|
||||
|
||||
@@ -84,8 +84,8 @@ public class AppsFilterTest {
|
||||
private static final int SYSTEM_USER = 0;
|
||||
private static final int SECONDARY_USER = 10;
|
||||
private static final int[] USER_ARRAY = {SYSTEM_USER, SECONDARY_USER};
|
||||
private static final List<UserInfo> USER_INFO_LIST = Arrays.stream(USER_ARRAY).mapToObj(
|
||||
id -> new UserInfo(id, Integer.toString(id), 0)).collect(Collectors.toList());
|
||||
private static final UserInfo[] USER_INFO_LIST = Arrays.stream(USER_ARRAY).mapToObj(
|
||||
id -> new UserInfo(id, Integer.toString(id), 0)).toArray(UserInfo[]::new);
|
||||
|
||||
@Mock
|
||||
AppsFilter.FeatureConfig mFeatureConfigMock;
|
||||
|
||||
Reference in New Issue
Block a user