summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
authorDenver Coneybeare <denver@sleepydragon.org>2014-06-11 17:16:03 -0400
committerDenver Coneybeare <denver@sleepydragon.org>2014-06-18 19:50:51 +0000
commitbf8b57af351ae9272b7490b373ca57b2a96e643a (patch)
treebc0735a4d6a6a9361bd910b1f3f1c578297b70d8 /cmds/pm
parent88b37edaeab7b31cab0f5115e5c9f63a49991408 (diff)
downloadframeworks_base-bf8b57af351ae9272b7490b373ca57b2a96e643a.zip
frameworks_base-bf8b57af351ae9272b7490b373ca57b2a96e643a.tar.gz
frameworks_base-bf8b57af351ae9272b7490b373ca57b2a96e643a.tar.bz2
Fix "pm list permissions" crash if resource string missing
The "pm list permissions" command lists detailed information about each permission on the system, including its label and description, both of which can be stored as translatable resource strings in APK files. However, it is possible that the resource identifiers for these strings point to non-existent resources. When this happens, the loadText() method throws Resources.NotFoundException, causing the "pm" command to abort prematurely, simply printing "Killed" to stdout and a stack trace to logcat. This commit fixes the crash by explicitly catching the Resources.NotFoundException exception in loadText() and returning null if it is thrown. The loadText() method already has the potential to return null so none of its callers need be modified. This fixes the crash and simply shows "label:null" and/or "description:null" in the output if the string resource is missing. Change-Id: I92273399e1dac6029163750d004940ee1da67428
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 75b0a82..c10c959 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -504,7 +504,10 @@ public final class Pm {
if (res != 0) {
Resources r = getResources(pii);
if (r != null) {
- return r.getString(res);
+ try {
+ return r.getString(res);
+ } catch (Resources.NotFoundException e) {
+ }
}
}
return null;