Merge "Remove PackageManager.getResourcesForApplicationAsUser API"
This commit is contained in:
committed by
Android (Google) Code Review
commit
f623bfa355
@@ -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(),
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user