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

Commit 991cc142 authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] prepare for nullable dataDir

This CL prepares for nullable Application.dataDir. Currently it's a
no-op. Just adding some null checks.

BUG: 302587814
Test: builds

Change-Id: Ic2f3efb285818ddb47f3f92d5890cc4ff46b416a
parent 6fcb12be
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static android.content.pm.PackageManager.UNINSTALL_REASON_USER_TYPE;
import static android.os.Process.INVALID_UID;
import static android.os.Process.PACKAGE_INFO_GID;
import static android.os.Process.SYSTEM_UID;

import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
import static com.android.server.pm.PackageManagerService.WRITE_USER_PACKAGE_RESTRICTIONS;
import static com.android.server.pm.SharedUidMigration.BEST_EFFORT;
@@ -5211,7 +5212,7 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile

            File dataDir = PackageInfoUtils.getDataDir(ps, user.id);
            pw.print("      dataDir=");
            pw.println(dataDir.getAbsolutePath());
            pw.println(dataDir == null ? "null" : dataDir.getAbsolutePath());

            final PackageUserStateInternal pus = ps.readUserState(user.id);
            pw.print("      firstInstallTime=");
+8 −5
Original line number Diff line number Diff line
@@ -544,11 +544,6 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
     */
    public boolean compileLayouts(@NonNull PackageStateInternal ps, @NonNull AndroidPackage pkg) {
        try {
            final String packageName = pkg.getPackageName();
            final String apkPath = pkg.getSplits().get(0).getPath();
            // TODO(b/143971007): Use a cross-user directory
            File dataDir = PackageInfoUtils.getDataDir(ps, UserHandle.myUserId());
            final String outDexFile = dataDir.getAbsolutePath() + "/code_cache/compiled_view.dex";
            if (ps.isPrivileged() || pkg.isUseEmbeddedDex()
                    || pkg.isDefaultToDeviceProtectedStorage()) {
                // Privileged apps prefer to load trusted code so they don't use compiled views.
@@ -558,6 +553,14 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
                // selinux permissions required for writing to user_de.
                return false;
            }
            final String packageName = pkg.getPackageName();
            final String apkPath = pkg.getSplits().get(0).getPath();
            final File dataDir = PackageInfoUtils.getDataDir(ps, UserHandle.myUserId());
            if (dataDir == null) {
                // The app is not installed on the target user and doesn't have a data dir
                return false;
            }
            final String outDexFile = dataDir.getAbsolutePath() + "/code_cache/compiled_view.dex";
            Log.i("PackageManager", "Compiling layouts in " + packageName + " (" + apkPath +
                    ") to " + outDexFile);
            final long callingId = Binder.clearCallingIdentity();
+4 −1
Original line number Diff line number Diff line
@@ -40,8 +40,11 @@ public class ViewCompiler {
    public boolean compileLayouts(PackageStateInternal ps, String apkPath) {
        try {
            final String packageName = ps.getPackageName();
            // TODO(b/143971007): Use a cross-user directory
            File dataDir = PackageInfoUtils.getDataDir(ps, UserHandle.myUserId());
            if (dataDir == null) {
                // The app is not installed on the target user and doesn't have a data dir
                return false;
            }
            final String outDexFile = dataDir.getAbsolutePath() + "/code_cache/compiled_view.dex";
            Log.i("PackageManager", "Compiling layouts in " + packageName + " (" + apkPath +
                ") to " + outDexFile);