On some "non-standard" devices, load label can cause a security exception
due to modified platform code Bug: 28243147 Change-Id: Iab899d0cb233e19ebf994f8a3eacba26f840148f
This commit is contained in:
@@ -26,6 +26,7 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class LauncherActivityInfoCompatV16 extends LauncherActivityInfoCompat {
|
||||
@@ -51,7 +52,12 @@ public class LauncherActivityInfoCompatV16 extends LauncherActivityInfoCompat {
|
||||
}
|
||||
|
||||
public CharSequence getLabel() {
|
||||
return mResolveInfo.loadLabel(mPm);
|
||||
try {
|
||||
return mResolveInfo.loadLabel(mPm);
|
||||
} catch (SecurityException e) {
|
||||
Log.e("LAInfoCompat", "Failed to extract app display name from resolve info", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public Drawable getIcon(int density) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.compat.AppWidgetManagerCompat;
|
||||
@@ -91,7 +93,13 @@ public class WidgetsAndShortcutNameComparator implements Comparator<Object> {
|
||||
return Utilities.trim(mManager.loadLabel(widgetInfo));
|
||||
} else {
|
||||
ResolveInfo shortcutInfo = (ResolveInfo) o;
|
||||
return Utilities.trim(shortcutInfo.loadLabel(mPackageManager));
|
||||
try {
|
||||
return Utilities.trim(shortcutInfo.loadLabel(mPackageManager));
|
||||
} catch (Exception e) {
|
||||
Log.e("ShortcutNameComparator",
|
||||
"Failed to extract app display name from resolve info", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user