diff options
author | Michael W <baddaemon87@gmail.com> | 2016-11-14 11:30:24 +0100 |
---|---|---|
committer | Michael W <baddaemon87@gmail.com> | 2016-11-14 11:30:24 +0100 |
commit | fe0a5eeffe3209677c50e82d3137cce293253977 (patch) | |
tree | bf87199854b36ad57975feceb6bf6a738a1c4049 /packages/SettingsLib | |
parent | 6d2ff1d511921b0be3cbcdc6c29d9ac9add41ad9 (diff) | |
download | frameworks_base-fe0a5eeffe3209677c50e82d3137cce293253977.zip frameworks_base-fe0a5eeffe3209677c50e82d3137cce293253977.tar.gz frameworks_base-fe0a5eeffe3209677c50e82d3137cce293253977.tar.bz2 |
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
Diffstat (limited to 'packages/SettingsLib')
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java b/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java index 224b967..517075d 100644 --- a/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java +++ b/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java @@ -166,13 +166,16 @@ public class UidDetailProvider { final ApplicationInfo appInfo = ipm.getApplicationInfo(packageName, 0 /* no flags */, userId); - if (appInfo != null) { + if (appInfo != null && packageInfo != null) { detail.detailLabels[i] = appInfo.loadLabel(pm).toString(); detail.detailContentDescriptions[i] = um.getBadgedLabelForUser( detail.detailLabels[i], userHandle); if (packageInfo.sharedUserLabel != 0) { - detail.label = pm.getText(packageName, packageInfo.sharedUserLabel, - packageInfo.applicationInfo).toString(); + CharSequence label = pm.getText(packageName, + packageInfo.sharedUserLabel, packageInfo.applicationInfo); + if (label != null) { + detail.label = label.toString(); + } detail.icon = um.getBadgedIconForUser(appInfo.loadIcon(pm), userHandle); } } |