Loading core/java/android/content/pm/ShortcutInfo.java +3 −3 Original line number Diff line number Diff line Loading @@ -630,7 +630,7 @@ public final class ShortcutInfo implements Parcelable { * This will set {@link #FLAG_STRINGS_RESOLVED}. * * @param res {@link Resources} for the publisher. Must have been loaded with * {@link PackageManager#getResourcesForApplicationAsUser}. * {@link PackageManager#getResourcesForApplication(String)}. * * @hide */ Loading Loading @@ -752,7 +752,7 @@ public final class ShortcutInfo implements Parcelable { * aforementioned method would do internally, but not documented, so doing here explicitly.) * * @param res {@link Resources} for the publisher. Must have been loaded with * {@link PackageManager#getResourcesForApplicationAsUser}. * {@link PackageManager#getResourcesForApplication(String)}. * * @hide */ Loading Loading @@ -782,7 +782,7 @@ public final class ShortcutInfo implements Parcelable { * in the resource name fields. * * @param res {@link Resources} for the publisher. Must have been loaded with * {@link PackageManager#getResourcesForApplicationAsUser}. * {@link PackageManager#getResourcesForApplication(String)}. * * @hide */ Loading services/core/java/com/android/server/pm/ShortcutService.java +4 −3 Original line number Diff line number Diff line Loading @@ -3907,10 +3907,11 @@ public class ShortcutService extends IShortcutService.Stub { final long start = getStatStartTime(); final long token = injectClearCallingIdentity(); try { return mContext.getPackageManager().getResourcesForApplicationAsUser( packageName, userId); return mContext.createContextAsUser(UserHandle.of(userId), /* flags */ 0) .getPackageManager().getResourcesForApplication(packageName); } catch (NameNotFoundException e) { Slog.e(TAG, "Resources for package " + packageName + " not found"); Slog.e(TAG, "Resources of package " + packageName + " for user " + userId + " not found"); return null; } finally { injectRestoreCallingIdentity(token); Loading services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -176,6 +176,12 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { return null; } @Override public Context createContextAsUser(UserHandle user, int flags) { when(mMockPackageManager.getUserId()).thenReturn(user.getIdentifier()); return this; } @Override public void unregisterReceiver(BroadcastReceiver receiver) { // ignore. Loading Loading @@ -939,7 +945,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { assertEquals(Process.SYSTEM_UID, mInjectedCallingUid); final String packageName = (String) pmInvocation.getArguments()[0]; final int userId = (Integer) pmInvocation.getArguments()[1]; final int userId = mMockPackageManager.getUserId(); final Resources res = mock(Resources.class); Loading Loading @@ -971,7 +977,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { return Integer.parseInt(entryName.substring(1)) + ressIdOffset; }).when(res).getIdentifier(anyStringOrNull(), anyStringOrNull(), anyStringOrNull()); return res; }).when(mMockPackageManager).getResourcesForApplicationAsUser(anyString(), anyInt()); }).when(mMockPackageManager).getResourcesForApplication(anyString()); } protected static UserInfo withProfileGroupId(UserInfo in, int groupId) { Loading Loading
core/java/android/content/pm/ShortcutInfo.java +3 −3 Original line number Diff line number Diff line Loading @@ -630,7 +630,7 @@ public final class ShortcutInfo implements Parcelable { * This will set {@link #FLAG_STRINGS_RESOLVED}. * * @param res {@link Resources} for the publisher. Must have been loaded with * {@link PackageManager#getResourcesForApplicationAsUser}. * {@link PackageManager#getResourcesForApplication(String)}. * * @hide */ Loading Loading @@ -752,7 +752,7 @@ public final class ShortcutInfo implements Parcelable { * aforementioned method would do internally, but not documented, so doing here explicitly.) * * @param res {@link Resources} for the publisher. Must have been loaded with * {@link PackageManager#getResourcesForApplicationAsUser}. * {@link PackageManager#getResourcesForApplication(String)}. * * @hide */ Loading Loading @@ -782,7 +782,7 @@ public final class ShortcutInfo implements Parcelable { * in the resource name fields. * * @param res {@link Resources} for the publisher. Must have been loaded with * {@link PackageManager#getResourcesForApplicationAsUser}. * {@link PackageManager#getResourcesForApplication(String)}. * * @hide */ Loading
services/core/java/com/android/server/pm/ShortcutService.java +4 −3 Original line number Diff line number Diff line Loading @@ -3907,10 +3907,11 @@ public class ShortcutService extends IShortcutService.Stub { final long start = getStatStartTime(); final long token = injectClearCallingIdentity(); try { return mContext.getPackageManager().getResourcesForApplicationAsUser( packageName, userId); return mContext.createContextAsUser(UserHandle.of(userId), /* flags */ 0) .getPackageManager().getResourcesForApplication(packageName); } catch (NameNotFoundException e) { Slog.e(TAG, "Resources for package " + packageName + " not found"); Slog.e(TAG, "Resources of package " + packageName + " for user " + userId + " not found"); return null; } finally { injectRestoreCallingIdentity(token); Loading
services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -176,6 +176,12 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { return null; } @Override public Context createContextAsUser(UserHandle user, int flags) { when(mMockPackageManager.getUserId()).thenReturn(user.getIdentifier()); return this; } @Override public void unregisterReceiver(BroadcastReceiver receiver) { // ignore. Loading Loading @@ -939,7 +945,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { assertEquals(Process.SYSTEM_UID, mInjectedCallingUid); final String packageName = (String) pmInvocation.getArguments()[0]; final int userId = (Integer) pmInvocation.getArguments()[1]; final int userId = mMockPackageManager.getUserId(); final Resources res = mock(Resources.class); Loading Loading @@ -971,7 +977,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { return Integer.parseInt(entryName.substring(1)) + ressIdOffset; }).when(res).getIdentifier(anyStringOrNull(), anyStringOrNull(), anyStringOrNull()); return res; }).when(mMockPackageManager).getResourcesForApplicationAsUser(anyString(), anyInt()); }).when(mMockPackageManager).getResourcesForApplication(anyString()); } protected static UserInfo withProfileGroupId(UserInfo in, int groupId) { Loading