Merge "Remove PackageManager.getResourcesForApplicationAsUser API"

This commit is contained in:
TreeHugger Robot
2020-10-23 05:31:13 +00:00
committed by Android (Google) Code Review
2 changed files with 4 additions and 4 deletions

View File

@@ -39,6 +39,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Log;
@@ -441,10 +442,11 @@ public final class Icon implements Parcelable {
resPackage = context.getPackageName();
}
if (getResources() == null && !(getResPackage().equals("android"))) {
final PackageManager pm = context.getPackageManager();
final PackageManager pm = context.createContextAsUser(
UserHandle.of(userId), /* flags */ 0).getPackageManager();
try {
// assign getResources() as the correct user
mObj1 = pm.getResourcesForApplicationAsUser(resPackage, userId);
mObj1 = pm.getResourcesForApplication(resPackage);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, String.format("Unable to find pkg=%s user=%d",
getResPackage(),

View File

@@ -73,8 +73,6 @@ public class StatusBarIconViewTest extends SysuiTestCase {
// Set up context such that asking for "mockPackage" resources returns mMockResources.
mMockResources = mock(Resources.class);
mPackageManagerSpy = spy(getContext().getPackageManager());
doReturn(mMockResources).when(mPackageManagerSpy)
.getResourcesForApplicationAsUser(eq("mockPackage"), anyInt());
doReturn(mMockResources).when(mPackageManagerSpy)
.getResourcesForApplication(eq("mockPackage"));
doReturn(mMockResources).when(mPackageManagerSpy).getResourcesForApplication(argThat(