Pass the correct user id

Pass the current user id so the secondary user won't fail to query
due to lack of INTERACT_ACROSS_USERS.

We will add a test to ensure all users see the same set of modules.

(Cherry-picked from 4421aee5e0)

Bug: 176152485
Test: N/A, will add a cts
Merged-In: I21b0fa98143f4f1699fe42a37814b3470cea7c1e
Change-Id: I21b0fa98143f4f1699fe42a37814b3470cea7c1e
This commit is contained in:
JW Wang
2021-01-14 11:44:35 +08:00
parent 3b26172c84
commit d99b14a5e3

View File

@@ -184,7 +184,7 @@ public class ModuleInfoProvider {
List<PackageInfo> allPackages;
try {
allPackages = mPackageManager.getInstalledPackages(
flags | PackageManager.MATCH_APEX, UserHandle.USER_SYSTEM).getList();
flags | PackageManager.MATCH_APEX, UserHandle.getCallingUserId()).getList();
} catch (RemoteException e) {
Slog.w(TAG, "Unable to retrieve all package names", e);
return Collections.emptyList();