Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c866c8a authored by Tanguy Pruvot's avatar Tanguy Pruvot Committed by Jorge Ruesga
Browse files

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
parent 5056c53f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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
+4 −0
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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;
        }
+2 −1
Original line number Diff line number Diff line
@@ -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 {