Get application info in the correct user id

Fixes: 76396560

Test: Create work profile and launch hangouts in work profile.
Change-Id: Ic3727ac899153b6a96dd9b6d6921c32ba0bbd93e
This commit is contained in:
Tony Mak
2018-03-26 12:38:04 +01:00
parent c54b9cb71a
commit 2f6bcd9c06

View File

@@ -202,7 +202,9 @@ public class PermissionMonitor {
// Only using the first package name. There may be multiple names if multiple // Only using the first package name. There may be multiple names if multiple
// apps share the same UID, but in that case they also share permissions so // apps share the same UID, but in that case they also share permissions so
// querying with any of the names will return the same results. // querying with any of the names will return the same results.
final PackageInfo app = mPackageManager.getPackageInfo(names[0], GET_PERMISSIONS); int userId = UserHandle.getUserId(uid);
final PackageInfo app = mPackageManager.getPackageInfoAsUser(
names[0], GET_PERMISSIONS, userId);
return hasUseBackgroundNetworksPermission(app); return hasUseBackgroundNetworksPermission(app);
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
// App not found. // App not found.