summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Denver Coneybeare <denver@sleepydragon.org> 2014-06-11 17:16:03 -0400
committer Denver Coneybeare <denver@sleepydragon.org> 2014-06-18 19:50:51 +0000
commitbf8b57af351ae9272b7490b373ca57b2a96e643a (patch)
treebc0735a4d6a6a9361bd910b1f3f1c578297b70d8
parent88b37edaeab7b31cab0f5115e5c9f63a49991408 (diff)
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
-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 75b0a8293125..c10c9599b999 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;