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

Commit d9635968 authored by Winson Chung's avatar Winson Chung
Browse files

Workaround fetching user's package resources

Bug: 77747389
Test: Manual, create work profile user, create an apk with an icon resource
      in its task description, and ensure that launcher can load the icon.

Change-Id: I33c7eaca9481fe44440b4b584b64531835e2fe9e
parent d74a971f
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -15,10 +15,13 @@
 */
package com.android.systemui.shared.recents.model;

import static android.content.pm.PackageManager.MATCH_ANY_USER;

import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -108,10 +111,12 @@ public abstract class IconLoader {
        }
        if (desc.getIconResource() != 0) {
            try {
                Context packageContext = mContext.createPackageContextAsUser(
                        taskKey.getPackageName(), 0, UserHandle.of(userId));
                return createBadgedDrawable(packageContext.getDrawable(desc.getIconResource()),
                        userId, desc);
                PackageManager pm = mContext.getPackageManager();
                ApplicationInfo appInfo = pm.getApplicationInfo(taskKey.getPackageName(),
                        MATCH_ANY_USER);
                Resources res = pm.getResourcesForApplication(appInfo);
                return createBadgedDrawable(res.getDrawable(desc.getIconResource(), null), userId,
                        desc);
            } catch (Resources.NotFoundException|PackageManager.NameNotFoundException e) {
                Log.e(TAG, "Could not find icon drawable from resource", e);
            }