Don't crash when procstats has data for a now-disused uid
That is, PackageManager.getPackagesForUid(uid) can return null, so deal with it. Bug 10374656 Change-Id: I4eacd48c809b778e131d37dba0e86c583553e41f
This commit is contained in:
@@ -335,26 +335,31 @@ public class ProcessStatsUi extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
if (targetApp == null) {
|
if (targetApp == null) {
|
||||||
String[] packages = pm.getPackagesForUid(proc.mUid);
|
String[] packages = pm.getPackagesForUid(proc.mUid);
|
||||||
for (String curPkg : packages) {
|
if (packages != null) {
|
||||||
try {
|
for (String curPkg : packages) {
|
||||||
final PackageInfo pi = pm.getPackageInfo(curPkg,
|
try {
|
||||||
PackageManager.GET_DISABLED_COMPONENTS |
|
final PackageInfo pi = pm.getPackageInfo(curPkg,
|
||||||
PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS |
|
PackageManager.GET_DISABLED_COMPONENTS |
|
||||||
PackageManager.GET_UNINSTALLED_PACKAGES);
|
PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS |
|
||||||
if (pi.sharedUserLabel != 0) {
|
PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||||
targetApp = pi.applicationInfo;
|
if (pi.sharedUserLabel != 0) {
|
||||||
final CharSequence nm = pm.getText(curPkg,
|
targetApp = pi.applicationInfo;
|
||||||
pi.sharedUserLabel, pi.applicationInfo);
|
final CharSequence nm = pm.getText(curPkg,
|
||||||
if (nm != null) {
|
pi.sharedUserLabel, pi.applicationInfo);
|
||||||
label = nm.toString() + " (" + proc.mName + ")";
|
if (nm != null) {
|
||||||
} else {
|
label = nm.toString() + " (" + proc.mName + ")";
|
||||||
label = targetApp.loadLabel(pm).toString() + " ("
|
} else {
|
||||||
+ proc.mName + ")";
|
label = targetApp.loadLabel(pm).toString() + " ("
|
||||||
|
+ proc.mName + ")";
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// no current packages for this uid, typically because of uninstall
|
||||||
|
Log.i(TAG, "No package for uid " + proc.mUid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pref.setTitle(label);
|
pref.setTitle(label);
|
||||||
|
Reference in New Issue
Block a user