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

Commit be1ea88e authored by Narayan Kamath's avatar Narayan Kamath Committed by android-build-merger
Browse files

Merge "PackageManager: Fix reference profile canonicalization." into nyc-dev...

Merge "PackageManager: Fix reference profile canonicalization." into nyc-dev am: 9f33e5cc am: 34d9a8c3
am: 44ff7748

* commit '44ff7748':
  PackageManager: Fix reference profile canonicalization.

Change-Id: If7166572d245d779ee60224ddf7e4e910e547acb
parents 4b99d545 44ff7748
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -328,10 +328,11 @@ class PackageDexOptimizer {

        for (String apkPath : pkg.getAllCodePathsExcludingResourceOnly()) {
            try {
                apkPath = new File(apkPath).getCanonicalPath();
                apkPath = PackageManagerServiceUtils.realpath(new File(apkPath));
            } catch (IOException e) {
                // Log an error but continue without it.
                Slog.w(TAG, "Failed to get canonical path", e);
                continue;
            }
            String useMarker = apkPath.replace('/', '@');
            final int[] currentUserIds = UserManagerService.getInstance().getUserIds();
+2 −1
Original line number Diff line number Diff line
@@ -7604,10 +7604,11 @@ public class PackageManagerService extends IPackageManager.Stub {
        for (String path : pkg.getAllCodePathsExcludingResourceOnly()) {
            try {
                path = new File(path).getCanonicalPath();
                path = PackageManagerServiceUtils.realpath(new File(path));
            } catch (IOException e) {
                // TODO: Should we return early here ?
                Slog.w(TAG, "Failed to get canonical path", e);
                continue;
            }
            final String useMarker = path.replace('/', '@');
+17 −1
Original line number Diff line number Diff line
@@ -25,9 +25,13 @@ import android.content.pm.PackageParser;
import android.content.pm.ResolveInfo;
import android.os.RemoteException;
import android.os.UserHandle;
import android.system.ErrnoException;
import android.util.ArraySet;
import android.util.Log;
import libcore.io.Libcore;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -163,4 +167,16 @@ public class PackageManagerServiceUtils {

        return result;
    }

    /**
     * Returns the canonicalized path of {@code path} as per {@code realpath(3)}
     * semantics.
     */
    public static String realpath(File path) throws IOException {
        try {
            return Libcore.os.realpath(path.getAbsolutePath());
        } catch (ErrnoException ee) {
            throw ee.rethrowAsIOException();
        }
    }
}