Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91581bf1 authored by Felka Chang's avatar Felka Chang Committed by Android (Google) Code Review
Browse files

Merge "Remove PackageManager.getResourcesForApplicationAsUser API"

parents ec820fd4 3e1776c6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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
     */
@@ -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
     */
@@ -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
     */
+4 −3
Original line number Diff line number Diff line
@@ -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);
+8 −2
Original line number Diff line number Diff line
@@ -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.
@@ -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);

@@ -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) {