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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user