Loading core/java/android/app/LoadedApk.java +10 −13 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.dex.ArtManager; import android.content.pm.split.SplitDependencyLoader; import android.content.res.AssetManager; import android.content.res.CompatibilityInfo; Loading @@ -35,7 +36,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.FileUtils; import android.os.Handler; import android.os.IBinder; Loading @@ -49,13 +49,15 @@ import android.text.TextUtils; import android.util.AndroidRuntimeException; import android.util.ArrayMap; import android.util.Log; import android.util.LogPrinter; import android.util.Slog; import android.util.SparseArray; import android.view.Display; import android.view.DisplayAdjustments; import com.android.internal.util.ArrayUtils; import dalvik.system.VMRuntime; import java.io.File; import java.io.IOException; import java.io.InputStream; Loading Loading @@ -749,13 +751,6 @@ public final class LoadedApk { } } // Keep in sync with installd (frameworks/native/cmds/installd/commands.cpp). private static File getPrimaryProfileFile(String packageName) { File profileDir = Environment.getDataProfilesDePackageDirectory( UserHandle.myUserId(), packageName); return new File(profileDir, "primary.prof"); } private void setupJitProfileSupport() { if (!SystemProperties.getBoolean("dalvik.vm.usejitprofiles", false)) { return; Loading Loading @@ -783,10 +778,12 @@ public final class LoadedApk { return; } final File profileFile = getPrimaryProfileFile(mPackageName); VMRuntime.registerAppInfo(profileFile.getPath(), codePaths.toArray(new String[codePaths.size()])); for (int i = codePaths.size() - 1; i >= 0; i--) { String splitName = i == 0 ? null : mApplicationInfo.splitNames[i - 1]; String profileFile = ArtManager.getCurrentProfilePath( mPackageName, UserHandle.myUserId(), splitName); VMRuntime.registerAppInfo(profileFile, new String[] {codePaths.get(i)}); } // Register the app data directory with the reporter. It will // help deciding whether or not a dex file is the primary apk or a Loading core/java/android/content/pm/dex/ArtManager.java +28 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.content.pm.dex; import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.os.Environment; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading @@ -26,6 +27,8 @@ import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.util.Slog; import java.io.File; /** * Class for retrieving various kinds of information related to the runtime artifacts of * packages that are currently installed on the device. Loading Loading @@ -163,4 +166,29 @@ public class ArtManager { public static String getProfileName(String splitName) { return splitName == null ? "primary.prof" : splitName + ".split.prof"; } /** * Return the path to the current profile corresponding to given package and split. * * @hide */ public static String getCurrentProfilePath(String packageName, int userId, String splitName) { File profileDir = Environment.getDataProfilesDePackageDirectory(userId, packageName); return new File(profileDir, getProfileName(splitName)).getAbsolutePath(); } /** * Return the snapshot profile file for the given package and split. * * KEEP in sync with installd dexopt.cpp. * TODO(calin): inject the snapshot profile name from PM to avoid the dependency. * * @hide */ public static File getProfileSnapshotFile(String packageName, String splitName) { File profileDir = Environment.getDataRefProfilesDePackageDirectory(packageName); String snapshotFile = getProfileName(splitName) + ".snapshot"; return new File(profileDir, snapshotFile); } } core/java/android/os/Environment.java +2 −3 Original line number Diff line number Diff line Loading @@ -302,9 +302,8 @@ public class Environment { } /** {@hide} */ public static File getProfileSnapshotPath(String packageName, String codePath) { return buildPath(buildPath(getDataDirectory(), "misc", "profiles", "ref", packageName, "primary.prof.snapshot")); public static File getDataRefProfilesDePackageDirectory(String packageName) { return buildPath(getDataDirectory(), "misc", "profiles", "ref", packageName); } /** {@hide} */ Loading core/java/com/android/internal/os/ZygoteInit.java +1 −1 Original line number Diff line number Diff line Loading @@ -583,7 +583,7 @@ public class ZygoteInit { installd.dexopt(classPathElement, Process.SYSTEM_UID, packageName, instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter, uuid, classLoaderContext, seInfo, false /* downgrade */, targetSdkVersion); targetSdkVersion, /*profileName*/ null); } catch (RemoteException | ServiceSpecificException e) { // Ignore (but log), we need this on the classpath for fallback mode. Log.w(TAG, "Failed compiling classpath element for system server: " Loading services/core/java/com/android/server/pm/Installer.java +17 −16 Original line number Diff line number Diff line Loading @@ -289,43 +289,44 @@ public class Installer extends SystemService { public void dexopt(String apkPath, int uid, @Nullable String pkgName, String instructionSet, int dexoptNeeded, @Nullable String outputPath, int dexFlags, String compilerFilter, @Nullable String volumeUuid, @Nullable String sharedLibraries, @Nullable String seInfo, boolean downgrade, int targetSdkVersion) throws InstallerException { @Nullable String seInfo, boolean downgrade, int targetSdkVersion, @Nullable String profileName) throws InstallerException { assertValidInstructionSet(instructionSet); if (!checkBeforeRemote()) return; try { mInstalld.dexopt(apkPath, uid, pkgName, instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter, volumeUuid, sharedLibraries, seInfo, downgrade, targetSdkVersion); targetSdkVersion, profileName); } catch (Exception e) { throw InstallerException.from(e); } } public boolean mergeProfiles(int uid, String packageName) throws InstallerException { public boolean mergeProfiles(int uid, String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.mergeProfiles(uid, packageName); return mInstalld.mergeProfiles(uid, packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } } public boolean dumpProfiles(int uid, String packageName, String codePaths) public boolean dumpProfiles(int uid, String packageName, String profileName, String codePath) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.dumpProfiles(uid, packageName, codePaths); return mInstalld.dumpProfiles(uid, packageName, profileName, codePath); } catch (Exception e) { throw InstallerException.from(e); } } public boolean copySystemProfile(String systemProfile, int uid, String packageName) throws InstallerException { public boolean copySystemProfile(String systemProfile, int uid, String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.copySystemProfile(systemProfile, uid, packageName); return mInstalld.copySystemProfile(systemProfile, uid, packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } Loading Loading @@ -369,10 +370,10 @@ public class Installer extends SystemService { } } public void clearAppProfiles(String packageName) throws InstallerException { public void clearAppProfiles(String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return; try { mInstalld.clearAppProfiles(packageName); mInstalld.clearAppProfiles(packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } Loading Loading @@ -525,21 +526,21 @@ public class Installer extends SystemService { } } public boolean createProfileSnapshot(int appId, String packageName, String codePath) public boolean createProfileSnapshot(int appId, String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.createProfileSnapshot(appId, packageName, codePath); return mInstalld.createProfileSnapshot(appId, packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } } public void destroyProfileSnapshot(String packageName, String codePath) public void destroyProfileSnapshot(String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return; try { mInstalld.destroyProfileSnapshot(packageName, codePath); mInstalld.destroyProfileSnapshot(packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } Loading Loading
core/java/android/app/LoadedApk.java +10 −13 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.dex.ArtManager; import android.content.pm.split.SplitDependencyLoader; import android.content.res.AssetManager; import android.content.res.CompatibilityInfo; Loading @@ -35,7 +36,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.FileUtils; import android.os.Handler; import android.os.IBinder; Loading @@ -49,13 +49,15 @@ import android.text.TextUtils; import android.util.AndroidRuntimeException; import android.util.ArrayMap; import android.util.Log; import android.util.LogPrinter; import android.util.Slog; import android.util.SparseArray; import android.view.Display; import android.view.DisplayAdjustments; import com.android.internal.util.ArrayUtils; import dalvik.system.VMRuntime; import java.io.File; import java.io.IOException; import java.io.InputStream; Loading Loading @@ -749,13 +751,6 @@ public final class LoadedApk { } } // Keep in sync with installd (frameworks/native/cmds/installd/commands.cpp). private static File getPrimaryProfileFile(String packageName) { File profileDir = Environment.getDataProfilesDePackageDirectory( UserHandle.myUserId(), packageName); return new File(profileDir, "primary.prof"); } private void setupJitProfileSupport() { if (!SystemProperties.getBoolean("dalvik.vm.usejitprofiles", false)) { return; Loading Loading @@ -783,10 +778,12 @@ public final class LoadedApk { return; } final File profileFile = getPrimaryProfileFile(mPackageName); VMRuntime.registerAppInfo(profileFile.getPath(), codePaths.toArray(new String[codePaths.size()])); for (int i = codePaths.size() - 1; i >= 0; i--) { String splitName = i == 0 ? null : mApplicationInfo.splitNames[i - 1]; String profileFile = ArtManager.getCurrentProfilePath( mPackageName, UserHandle.myUserId(), splitName); VMRuntime.registerAppInfo(profileFile, new String[] {codePaths.get(i)}); } // Register the app data directory with the reporter. It will // help deciding whether or not a dex file is the primary apk or a Loading
core/java/android/content/pm/dex/ArtManager.java +28 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.content.pm.dex; import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.os.Environment; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading @@ -26,6 +27,8 @@ import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.util.Slog; import java.io.File; /** * Class for retrieving various kinds of information related to the runtime artifacts of * packages that are currently installed on the device. Loading Loading @@ -163,4 +166,29 @@ public class ArtManager { public static String getProfileName(String splitName) { return splitName == null ? "primary.prof" : splitName + ".split.prof"; } /** * Return the path to the current profile corresponding to given package and split. * * @hide */ public static String getCurrentProfilePath(String packageName, int userId, String splitName) { File profileDir = Environment.getDataProfilesDePackageDirectory(userId, packageName); return new File(profileDir, getProfileName(splitName)).getAbsolutePath(); } /** * Return the snapshot profile file for the given package and split. * * KEEP in sync with installd dexopt.cpp. * TODO(calin): inject the snapshot profile name from PM to avoid the dependency. * * @hide */ public static File getProfileSnapshotFile(String packageName, String splitName) { File profileDir = Environment.getDataRefProfilesDePackageDirectory(packageName); String snapshotFile = getProfileName(splitName) + ".snapshot"; return new File(profileDir, snapshotFile); } }
core/java/android/os/Environment.java +2 −3 Original line number Diff line number Diff line Loading @@ -302,9 +302,8 @@ public class Environment { } /** {@hide} */ public static File getProfileSnapshotPath(String packageName, String codePath) { return buildPath(buildPath(getDataDirectory(), "misc", "profiles", "ref", packageName, "primary.prof.snapshot")); public static File getDataRefProfilesDePackageDirectory(String packageName) { return buildPath(getDataDirectory(), "misc", "profiles", "ref", packageName); } /** {@hide} */ Loading
core/java/com/android/internal/os/ZygoteInit.java +1 −1 Original line number Diff line number Diff line Loading @@ -583,7 +583,7 @@ public class ZygoteInit { installd.dexopt(classPathElement, Process.SYSTEM_UID, packageName, instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter, uuid, classLoaderContext, seInfo, false /* downgrade */, targetSdkVersion); targetSdkVersion, /*profileName*/ null); } catch (RemoteException | ServiceSpecificException e) { // Ignore (but log), we need this on the classpath for fallback mode. Log.w(TAG, "Failed compiling classpath element for system server: " Loading
services/core/java/com/android/server/pm/Installer.java +17 −16 Original line number Diff line number Diff line Loading @@ -289,43 +289,44 @@ public class Installer extends SystemService { public void dexopt(String apkPath, int uid, @Nullable String pkgName, String instructionSet, int dexoptNeeded, @Nullable String outputPath, int dexFlags, String compilerFilter, @Nullable String volumeUuid, @Nullable String sharedLibraries, @Nullable String seInfo, boolean downgrade, int targetSdkVersion) throws InstallerException { @Nullable String seInfo, boolean downgrade, int targetSdkVersion, @Nullable String profileName) throws InstallerException { assertValidInstructionSet(instructionSet); if (!checkBeforeRemote()) return; try { mInstalld.dexopt(apkPath, uid, pkgName, instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter, volumeUuid, sharedLibraries, seInfo, downgrade, targetSdkVersion); targetSdkVersion, profileName); } catch (Exception e) { throw InstallerException.from(e); } } public boolean mergeProfiles(int uid, String packageName) throws InstallerException { public boolean mergeProfiles(int uid, String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.mergeProfiles(uid, packageName); return mInstalld.mergeProfiles(uid, packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } } public boolean dumpProfiles(int uid, String packageName, String codePaths) public boolean dumpProfiles(int uid, String packageName, String profileName, String codePath) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.dumpProfiles(uid, packageName, codePaths); return mInstalld.dumpProfiles(uid, packageName, profileName, codePath); } catch (Exception e) { throw InstallerException.from(e); } } public boolean copySystemProfile(String systemProfile, int uid, String packageName) throws InstallerException { public boolean copySystemProfile(String systemProfile, int uid, String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.copySystemProfile(systemProfile, uid, packageName); return mInstalld.copySystemProfile(systemProfile, uid, packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } Loading Loading @@ -369,10 +370,10 @@ public class Installer extends SystemService { } } public void clearAppProfiles(String packageName) throws InstallerException { public void clearAppProfiles(String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return; try { mInstalld.clearAppProfiles(packageName); mInstalld.clearAppProfiles(packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } Loading Loading @@ -525,21 +526,21 @@ public class Installer extends SystemService { } } public boolean createProfileSnapshot(int appId, String packageName, String codePath) public boolean createProfileSnapshot(int appId, String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.createProfileSnapshot(appId, packageName, codePath); return mInstalld.createProfileSnapshot(appId, packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } } public void destroyProfileSnapshot(String packageName, String codePath) public void destroyProfileSnapshot(String packageName, String profileName) throws InstallerException { if (!checkBeforeRemote()) return; try { mInstalld.destroyProfileSnapshot(packageName, codePath); mInstalld.destroyProfileSnapshot(packageName, profileName); } catch (Exception e) { throw InstallerException.from(e); } Loading