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

Commit ac063d64 authored by David Sehr's avatar David Sehr
Browse files

Simplify code paths computation, allow adb root to dump

Bug: 28748264
Change-Id: I1aefa5d98e80b58d6ed500c5d2d610569cf25c3a
parent a85c1e8e
Loading
Loading
Loading
Loading
+5 −12
Original line number Original line Diff line number Diff line
@@ -7520,9 +7520,11 @@ public class PackageManagerService extends IPackageManager.Stub {
                throw new IllegalArgumentException("Unknown package: " + packageName);
                throw new IllegalArgumentException("Unknown package: " + packageName);
            }
            }
        }
        }
        /* Only the shell or the app user should be able to dump profiles. */
        /* Only the shell, root, or the app user should be able to dump profiles. */
        int callingUid = Binder.getCallingUid();
        int callingUid = Binder.getCallingUid();
        if (callingUid != Process.SHELL_UID && callingUid != pkg.applicationInfo.uid) {
        if (callingUid != Process.SHELL_UID &&
            callingUid != Process.ROOT_UID &&
            callingUid != pkg.applicationInfo.uid) {
            throw new SecurityException("dumpProfiles");
            throw new SecurityException("dumpProfiles");
        }
        }
@@ -7530,16 +7532,7 @@ public class PackageManagerService extends IPackageManager.Stub {
            Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dump profiles");
            Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dump profiles");
            final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid);
            final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid);
            try {
            try {
                final File codeFile = new File(pkg.applicationInfo.getCodePath());
                List<String> allCodePaths = pkg.getAllCodePathsExcludingResourceOnly();
                List<String> allCodePaths = Collections.EMPTY_LIST;
                if (codeFile != null && codeFile.exists()) {
                    try {
                        final PackageLite codePkg = PackageParser.parsePackageLite(codeFile, 0);
                        allCodePaths = codePkg.getAllCodePaths();
                    } catch (PackageParserException e) {
                        // Well, we tried.
                    }
                }
                String gid = Integer.toString(sharedGid);
                String gid = Integer.toString(sharedGid);
                String codePaths = TextUtils.join(";", allCodePaths);
                String codePaths = TextUtils.join(";", allCodePaths);
                mInstaller.dumpProfiles(gid, packageName, codePaths);
                mInstaller.dumpProfiles(gid, packageName, codePaths);