Merge "Use package context for loading task description icon resource" into pi-dev
This commit is contained in:
@@ -19,6 +19,7 @@ import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
@@ -106,11 +107,12 @@ public abstract class IconLoader {
|
||||
return createDrawableFromBitmap(tdIcon, userId, desc);
|
||||
}
|
||||
if (desc.getIconResource() != 0) {
|
||||
// TODO: Use task context here
|
||||
try {
|
||||
return createBadgedDrawable(
|
||||
mContext.getDrawable(desc.getIconResource()), userId, desc);
|
||||
} catch (Resources.NotFoundException e) {
|
||||
Context packageContext = mContext.createPackageContextAsUser(
|
||||
taskKey.getPackageName(), 0, UserHandle.of(userId));
|
||||
return createBadgedDrawable(packageContext.getDrawable(desc.getIconResource()),
|
||||
userId, desc);
|
||||
} catch (Resources.NotFoundException|PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Could not find icon drawable from resource", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,13 @@ public class Task {
|
||||
return this.baseIntent.getComponent();
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
if (this.baseIntent.getComponent() != null) {
|
||||
return this.baseIntent.getComponent().getPackageName();
|
||||
}
|
||||
return this.baseIntent.getPackage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof TaskKey)) {
|
||||
|
||||
Reference in New Issue
Block a user