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

Commit f83612b2 authored by Brian Carlstrom's avatar Brian Carlstrom
Browse files

Add support for --user to "pm path" for work profile use

Change-Id: Ic8bb923e15a40f32cc7daa6a344250abfc81e423
parent cafacef6
Loading
Loading
Loading
Loading
+21 −8
Original line number Original line Diff line number Diff line
@@ -247,7 +247,7 @@ public final class Pm {
            } else if (args.length == 2) {
            } else if (args.length == 2) {
                if (args[0].equalsIgnoreCase("-p")) {
                if (args[0].equalsIgnoreCase("-p")) {
                    validCommand = true;
                    validCommand = true;
                    return displayPackageFilePath(args[1]);
                    return displayPackageFilePath(args[1], UserHandle.USER_OWNER);
                }
                }
            }
            }
            return 1;
            return 1;
@@ -731,12 +731,25 @@ public final class Pm {
    }
    }


    private int runPath() {
    private int runPath() {
        int userId = UserHandle.USER_OWNER;
        String option = nextOption();
        if (option != null && option.equals("--user")) {
            String optionData = nextOptionData();
            if (optionData == null || !isNumber(optionData)) {
                System.err.println("Error: no USER_ID specified");
                showUsage();
                return 1;
            } else {
                userId = Integer.parseInt(optionData);
            }
        }

        String pkg = nextArg();
        String pkg = nextArg();
        if (pkg == null) {
        if (pkg == null) {
            System.err.println("Error: no package specified");
            System.err.println("Error: no package specified");
            return 1;
            return 1;
        }
        }
        return displayPackageFilePath(pkg);
        return displayPackageFilePath(pkg, userId);
    }
    }


    private int runDump() {
    private int runDump() {
@@ -1365,7 +1378,7 @@ public final class Pm {
    }
    }


    private int runClear() {
    private int runClear() {
        int userId = 0;
        int userId = UserHandle.USER_OWNER;
        String option = nextOption();
        String option = nextOption();
        if (option != null && option.equals("--user")) {
        if (option != null && option.equals("--user")) {
            String optionData = nextOptionData();
            String optionData = nextOptionData();
@@ -1437,7 +1450,7 @@ public final class Pm {
    }
    }


    private int runSetEnabledSetting(int state) {
    private int runSetEnabledSetting(int state) {
        int userId = 0;
        int userId = UserHandle.USER_OWNER;
        String option = nextOption();
        String option = nextOption();
        if (option != null && option.equals("--user")) {
        if (option != null && option.equals("--user")) {
            String optionData = nextOptionData();
            String optionData = nextOptionData();
@@ -1486,7 +1499,7 @@ public final class Pm {
    }
    }


    private int runSetHiddenSetting(boolean state) {
    private int runSetHiddenSetting(boolean state) {
        int userId = 0;
        int userId = UserHandle.USER_OWNER;
        String option = nextOption();
        String option = nextOption();
        if (option != null && option.equals("--user")) {
        if (option != null && option.equals("--user")) {
            String optionData = nextOptionData();
            String optionData = nextOptionData();
@@ -1659,9 +1672,9 @@ public final class Pm {
     * Displays the package file for a package.
     * Displays the package file for a package.
     * @param pckg
     * @param pckg
     */
     */
    private int displayPackageFilePath(String pckg) {
    private int displayPackageFilePath(String pckg, int userId) {
        try {
        try {
            PackageInfo info = mPm.getPackageInfo(pckg, 0, 0);
            PackageInfo info = mPm.getPackageInfo(pckg, 0, userId);
            if (info != null && info.applicationInfo != null) {
            if (info != null && info.applicationInfo != null) {
                System.out.print("package:");
                System.out.print("package:");
                System.out.println(info.applicationInfo.sourceDir);
                System.out.println(info.applicationInfo.sourceDir);
@@ -1800,7 +1813,7 @@ public final class Pm {
        System.err.println("       pm list features");
        System.err.println("       pm list features");
        System.err.println("       pm list libraries");
        System.err.println("       pm list libraries");
        System.err.println("       pm list users");
        System.err.println("       pm list users");
        System.err.println("       pm path PACKAGE");
        System.err.println("       pm path [--user USER_ID] PACKAGE");
        System.err.println("       pm dump PACKAGE");
        System.err.println("       pm dump PACKAGE");
        System.err.println("       pm install [-lrtsfd] [-i PACKAGE] [PATH]");
        System.err.println("       pm install [-lrtsfd] [-i PACKAGE] [PATH]");
        System.err.println("       pm install-create [-lrtsfdp] [-i PACKAGE] [-S BYTES]");
        System.err.println("       pm install-create [-lrtsfdp] [-i PACKAGE] [-S BYTES]");