From 78713031a997d362a04e8056f8d923665ddb09ee Mon Sep 17 00:00:00 2001 From: Felka Chang Date: Tue, 8 Sep 2020 20:58:50 +0800 Subject: [PATCH] Remove PackageManager.getResourcesForApplicationAsUser API To switch another user to do something should create the context of the specified user by using Context.createContextAsUser rather than call *AsUser API directly. This patch replaces the usage of PackageManager.getResourcesForApplicationAsUser in SystemUI. Test: make -j droid cts gts vts Test: make -j docs Test: atest SystemUITests \ FrameworksServicesTests:com.android.server.pm Bug: 170928809 Change-Id: Ie31d772a5002f349d8dd0e0ec8fe6134b1895517 --- .../SystemUI/src/com/android/systemui/bubbles/Bubble.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java index 529af2297ef1a..75442b637e306 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java @@ -646,14 +646,14 @@ class Bubble implements BubbleViewProvider { } private int getDimenForPackageUser(Context context, int resId, String pkg, int userId) { - PackageManager pm = context.getPackageManager(); Resources r; if (pkg != null) { try { if (userId == UserHandle.USER_ALL) { userId = UserHandle.USER_SYSTEM; } - r = pm.getResourcesForApplicationAsUser(pkg, userId); + r = context.createContextAsUser(UserHandle.of(userId), /* flags */ 0) + .getPackageManager().getResourcesForApplication(pkg); return r.getDimensionPixelSize(resId); } catch (PackageManager.NameNotFoundException ex) { // Uninstalled, don't care