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

Commit e8eb2278 authored by Felka Chang's avatar Felka Chang
Browse files

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.

Test: make -j droid cts gts vts
Test: make -j docs
Test: atest SystemUITests \
    FrameworksServicesTests:com.android.server.pm
Test: atest CtsBlobStoreTestCases
Bug: 170928809
Change-Id: Ia9d376b579ef4d88637d51a5fb3947faa71c76ca
parent faf7e4a0
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.annotation.Nullable;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.UserHandle;
import android.text.format.TimeMigrationUtils;
import android.util.Slog;

@@ -34,8 +35,8 @@ class BlobStoreUtils {
    static Resources getPackageResources(@NonNull Context context,
            @NonNull String packageName, int userId) {
        try {
            return context.getPackageManager()
                    .getResourcesForApplicationAsUser(packageName, userId);
            return context.createContextAsUser(UserHandle.of(userId), /* flags */ 0)
                    .getPackageManager().getResourcesForApplication(packageName);
        } catch (PackageManager.NameNotFoundException e) {
            Slog.d(TAG, "Unknown package in user " + userId + ": "
                    + packageName, e);