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

Commit 41767934 authored by tmfang's avatar tmfang
Browse files

Guard NPE in getIcon of Tile

Test: Run Settings app, robotest
Fixes: 128777208
Change-Id: I847c0297189d849288a781d34316ea2728342bae
parent d20bf0ef
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -276,6 +276,12 @@ public class Tile implements Parcelable {
            return null;
        }
        ensureMetadataNotStale(context);
        final ActivityInfo activityInfo = getActivityInfo(context);
        if (activityInfo == null) {
            Log.w(TAG, "Cannot find ActivityInfo for " + getDescription());
            return null;
        }

        int iconResId = mMetaData.getInt(META_DATA_PREFERENCE_ICON);
        // Set the icon
        if (iconResId == 0) {
@@ -283,11 +289,11 @@ public class Tile implements Parcelable {
            // ICON_URI should be loaded in app UI when need the icon object. Handling IPC at this
            // level is too complex because we don't have a strong threading contract for this class
            if (!mMetaData.containsKey(META_DATA_PREFERENCE_ICON_URI)) {
                iconResId = getActivityInfo(context).icon;
                iconResId = activityInfo.icon;
            }
        }
        if (iconResId != 0) {
            return Icon.createWithResource(getActivityInfo(context).packageName, iconResId);
            return Icon.createWithResource(activityInfo.packageName, iconResId);
        } else {
            return null;
        }