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

Commit fe0a5eef authored by Michael W's avatar Michael W
Browse files

SettingsLib: Fix possible NPEs

getText() can return null, resulting in a NPE when trying to call
toString(). Add a null check to prevent this.
Additionally add a null check for packageInfo, as this can also be null.

Change-Id: Ia76326522872f4de4702ef56640b2f7b357c2bb7
Reference: BugDumps 20161104-10 L#135
parent 6d2ff1d5
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -166,13 +166,16 @@ public class UidDetailProvider {
                    final ApplicationInfo appInfo = ipm.getApplicationInfo(packageName,
                    final ApplicationInfo appInfo = ipm.getApplicationInfo(packageName,
                            0 /* no flags */, userId);
                            0 /* no flags */, userId);


                    if (appInfo != null) {
                    if (appInfo != null && packageInfo != null) {
                        detail.detailLabels[i] = appInfo.loadLabel(pm).toString();
                        detail.detailLabels[i] = appInfo.loadLabel(pm).toString();
                        detail.detailContentDescriptions[i] = um.getBadgedLabelForUser(
                        detail.detailContentDescriptions[i] = um.getBadgedLabelForUser(
                                detail.detailLabels[i], userHandle);
                                detail.detailLabels[i], userHandle);
                        if (packageInfo.sharedUserLabel != 0) {
                        if (packageInfo.sharedUserLabel != 0) {
                            detail.label = pm.getText(packageName, packageInfo.sharedUserLabel,
                            CharSequence label = pm.getText(packageName,
                                    packageInfo.applicationInfo).toString();
                                    packageInfo.sharedUserLabel, packageInfo.applicationInfo);
                            if (label != null) {
                                detail.label = label.toString();
                            }
                            detail.icon = um.getBadgedIconForUser(appInfo.loadIcon(pm), userHandle);
                            detail.icon = um.getBadgedIconForUser(appInfo.loadIcon(pm), userHandle);
                        }
                        }
                    }
                    }