Skip to content

Commit 1c3274c

Browse files
Ali Utku SelenKenneth Andersson
authored andcommitted
Fix crash by "adb shell pm list permissions -f|-s"
pm command makes the assumption that every permission should contain android:description and android:label attributes while they are not mandatory. If a permission does not contain these two attributes, we get "android.content.res. Resources$NotFoundException: String resource ID #0x0" followed by a NPE when using -f or -s options. With the following change, users will get "null" in output for respective fields. Change-Id: I4e7f407592fa071abdab1d979775f46ec27dc9d2
1 parent f0f6c54 commit 1c3274c

File tree

1 file changed

+5
-3
lines changed
  • cmds/pm/src/com/android/commands/pm

1 file changed

+5
-3
lines changed

cmds/pm/src/com/android/commands/pm/Pm.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,11 @@ private String loadText(PackageItemInfo pii, int res, CharSequence nonLocalized)
341341
if (nonLocalized != null) {
342342
return nonLocalized.toString();
343343
}
344-
Resources r = getResources(pii);
345-
if (r != null) {
346-
return r.getString(res);
344+
if (res != 0) {
345+
Resources r = getResources(pii);
346+
if (r != null) {
347+
return r.getString(res);
348+
}
347349
}
348350
return null;
349351
}

0 commit comments

Comments
 (0)