diff options
| author | Tanguy Pruvot <tanguy.pruvot@gmail.com> | 2012-11-17 01:47:24 +0100 |
|---|---|---|
| committer | Jorge Ruesga <jorge@ruesga.com> | 2012-11-17 16:28:36 +0100 |
| commit | 9c866c8abc9b3dcfd7d31a469a49968f1e6e968a (patch) | |
| tree | f0ce6da5addabd37da862238613913563150df17 | |
| parent | 5056c53f5893ea8a103459cccdb490bde6a61e70 (diff) | |
| download | android_packages_apps_CMFileManager-9c866c8abc9b3dcfd7d31a469a49968f1e6e968a.tar.gz android_packages_apps_CMFileManager-9c866c8abc9b3dcfd7d31a469a49968f1e6e968a.tar.bz2 android_packages_apps_CMFileManager-9c866c8abc9b3dcfd7d31a469a49968f1e6e968a.zip | |
Fix possible NPE, and log path of "not found" commands
Patchset 2: Added more log from https://github.com/tpruvot/android_packages_apps_CMFileManager/commit/6634611ba820f2a2c90f6ed9a7658f1d076bb32c
Change-Id: I1612e16b7e144f688909501434230f7e55d5d459
4 files changed, 10 insertions, 4 deletions
diff --git a/src/com/cyanogenmod/filemanager/commands/shell/IdentityCommand.java b/src/com/cyanogenmod/filemanager/commands/shell/IdentityCommand.java index 339637a6..e87a90ec 100644 --- a/src/com/cyanogenmod/filemanager/commands/shell/IdentityCommand.java +++ b/src/com/cyanogenmod/filemanager/commands/shell/IdentityCommand.java @@ -89,7 +89,8 @@ public class IdentityCommand extends SyncResultProgram implements IdentityExecut //At least uid and gid must be present if (!p.containsKey(UID) && !p.containsKey(GID)) { throw new ParseException( - String.format("no %s or %s present", UID, GID), 0); //$NON-NLS-1$ + String.format( + "no %s or %s present in %s", UID, GID, szLine), 0); //$NON-NLS-1$ } //1.- Extract user diff --git a/src/com/cyanogenmod/filemanager/commands/shell/Shell.java b/src/com/cyanogenmod/filemanager/commands/shell/Shell.java index 648dcfd1..779796d7 100644 --- a/src/com/cyanogenmod/filemanager/commands/shell/Shell.java +++ b/src/com/cyanogenmod/filemanager/commands/shell/Shell.java @@ -24,6 +24,7 @@ import com.cyanogenmod.filemanager.console.InsufficientPermissionsException; import com.cyanogenmod.filemanager.console.NoSuchFileOrDirectory; import com.cyanogenmod.filemanager.console.ReadOnlyFilesystemException; +import android.util.Log; /** * An abstract class that represents a command to wrap others commands, @@ -33,6 +34,8 @@ public abstract class Shell extends Command { private int mPid; + private final String TAG = "Shell"; + /** * @Constructor of <code>Shell</code> * @@ -72,6 +75,7 @@ public abstract class Shell extends Command { throws InsufficientPermissionsException, CommandNotFoundException, ExecutionException { //Command not found if (exitCode == 127) { + Log.w(TAG, getCommand() + " " + getArguments() + ": error"); throw new CommandNotFoundException(getId()); } //No exit code diff --git a/src/com/cyanogenmod/filemanager/console/ConsoleBuilder.java b/src/com/cyanogenmod/filemanager/console/ConsoleBuilder.java index 331e8245..1552abd9 100644 --- a/src/com/cyanogenmod/filemanager/console/ConsoleBuilder.java +++ b/src/com/cyanogenmod/filemanager/console/ConsoleBuilder.java @@ -115,7 +115,7 @@ public final class ConsoleBuilder { public static boolean changeToNonPrivilegedConsole(Context context) { //Check the current console - if (sHolder.getConsole() instanceof NonPriviledgeConsole) { + if (sHolder != null && sHolder.getConsole() instanceof NonPriviledgeConsole) { //The current console is non-privileged. Not needed return true; } @@ -147,7 +147,7 @@ public final class ConsoleBuilder { public static boolean changeToPrivilegedConsole(Context context) { //Destroy and create the new console - if (sHolder.getConsole() instanceof PrivilegedConsole) { + if (sHolder != null && sHolder.getConsole() instanceof PrivilegedConsole) { //The current console is privileged. Not needed return true; } diff --git a/src/com/cyanogenmod/filemanager/util/ParseHelper.java b/src/com/cyanogenmod/filemanager/util/ParseHelper.java index f59b9800..43c4b6e7 100644 --- a/src/com/cyanogenmod/filemanager/util/ParseHelper.java +++ b/src/com/cyanogenmod/filemanager/util/ParseHelper.java @@ -152,7 +152,8 @@ public final class ParseHelper { Pattern pattern = Pattern.compile(DATE_PATTERN); Matcher matcher = pattern.matcher(raw); if (!matcher.find()) { - throw new ParseException("last modification date not found", 0); //$NON-NLS-1$ + throw new ParseException( + "last modification date not found in " + raw, 0); //$NON-NLS-1$ } Date dLastModified = null; try { |
