Merge "Update the use of registerAppInfo" am: 95590e1a62
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1704169 Change-Id: I6e1a37576c4c49b9380c6f19b26a5f66c3fa9210
This commit is contained in:
@@ -138,23 +138,25 @@ import java.util.Set;
|
|||||||
// NOTE: Keep this in sync with installd expectations.
|
// NOTE: Keep this in sync with installd expectations.
|
||||||
File dexPathFile = new File(dexPath);
|
File dexPathFile = new File(dexPath);
|
||||||
File secondaryProfileDir = new File(dexPathFile.getParent(), "oat");
|
File secondaryProfileDir = new File(dexPathFile.getParent(), "oat");
|
||||||
File secondaryProfile = new File(secondaryProfileDir, dexPathFile.getName() + ".cur.prof");
|
File secondaryCurProfile =
|
||||||
|
new File(secondaryProfileDir, dexPathFile.getName() + ".cur.prof");
|
||||||
|
File secondaryRefProfile = new File(secondaryProfileDir, dexPathFile.getName() + ".prof");
|
||||||
|
|
||||||
// Create the profile if not already there.
|
// Create the profile if not already there.
|
||||||
// Returns true if the file was created, false if the file already exists.
|
// Returns true if the file was created, false if the file already exists.
|
||||||
// or throws exceptions in case of errors.
|
// or throws exceptions in case of errors.
|
||||||
if (!secondaryProfileDir.exists()) {
|
if (!secondaryProfileDir.exists()) {
|
||||||
if (!secondaryProfileDir.mkdir()) {
|
if (!secondaryProfileDir.mkdir()) {
|
||||||
Slog.e(TAG, "Could not create the profile directory: " + secondaryProfile);
|
Slog.e(TAG, "Could not create the profile directory: " + secondaryCurProfile);
|
||||||
// Do not continue with registration if we could not create the oat dir.
|
// Do not continue with registration if we could not create the oat dir.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean created = secondaryProfile.createNewFile();
|
boolean created = secondaryCurProfile.createNewFile();
|
||||||
if (DEBUG && created) {
|
if (DEBUG && created) {
|
||||||
Slog.i(TAG, "Created profile for secondary dex: " + secondaryProfile);
|
Slog.i(TAG, "Created profile for secondary dex: " + secondaryCurProfile);
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Slog.e(TAG, "Failed to create profile for secondary dex " + dexPath
|
Slog.e(TAG, "Failed to create profile for secondary dex " + dexPath
|
||||||
@@ -165,7 +167,12 @@ import java.util.Set;
|
|||||||
|
|
||||||
// If we got here, the dex paths is a secondary dex and we were able to create the profile.
|
// If we got here, the dex paths is a secondary dex and we were able to create the profile.
|
||||||
// Register the path to the runtime.
|
// Register the path to the runtime.
|
||||||
VMRuntime.registerAppInfo(secondaryProfile.getPath(), new String[] { dexPath });
|
VMRuntime.registerAppInfo(
|
||||||
|
ActivityThread.currentPackageName(),
|
||||||
|
secondaryCurProfile.getPath(),
|
||||||
|
secondaryRefProfile.getPath(),
|
||||||
|
new String[] { dexPath },
|
||||||
|
VMRuntime.CODE_PATH_TYPE_SECONDARY_DEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
// A dex file is a secondary dex file if it is in any of the registered app
|
// A dex file is a secondary dex file if it is in any of the registered app
|
||||||
|
|||||||
@@ -884,7 +884,7 @@ public final class LoadedApk {
|
|||||||
if (DEBUG) Slog.v(ActivityThread.TAG, "Class path: " + zip +
|
if (DEBUG) Slog.v(ActivityThread.TAG, "Class path: " + zip +
|
||||||
", JNI path: " + librarySearchPath);
|
", JNI path: " + librarySearchPath);
|
||||||
|
|
||||||
boolean needToSetupJitProfiles = false;
|
boolean registerAppInfoToArt = false;
|
||||||
if (mDefaultClassLoader == null) {
|
if (mDefaultClassLoader == null) {
|
||||||
// Temporarily disable logging of disk reads on the Looper thread
|
// Temporarily disable logging of disk reads on the Looper thread
|
||||||
// as this is early and necessary.
|
// as this is early and necessary.
|
||||||
@@ -902,7 +902,7 @@ public final class LoadedApk {
|
|||||||
|
|
||||||
setThreadPolicy(oldPolicy);
|
setThreadPolicy(oldPolicy);
|
||||||
// Setup the class loader paths for profiling.
|
// Setup the class loader paths for profiling.
|
||||||
needToSetupJitProfiles = true;
|
registerAppInfoToArt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!libPaths.isEmpty()) {
|
if (!libPaths.isEmpty()) {
|
||||||
@@ -919,7 +919,7 @@ public final class LoadedApk {
|
|||||||
final String add = TextUtils.join(File.pathSeparator, addedPaths);
|
final String add = TextUtils.join(File.pathSeparator, addedPaths);
|
||||||
ApplicationLoaders.getDefault().addPath(mDefaultClassLoader, add);
|
ApplicationLoaders.getDefault().addPath(mDefaultClassLoader, add);
|
||||||
// Setup the new code paths for profiling.
|
// Setup the new code paths for profiling.
|
||||||
needToSetupJitProfiles = true;
|
registerAppInfoToArt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup jit profile support.
|
// Setup jit profile support.
|
||||||
@@ -933,8 +933,8 @@ public final class LoadedApk {
|
|||||||
// loads code from) so we explicitly disallow it there.
|
// loads code from) so we explicitly disallow it there.
|
||||||
//
|
//
|
||||||
// It is not ok to call this in a zygote context where mActivityThread is null.
|
// It is not ok to call this in a zygote context where mActivityThread is null.
|
||||||
if (needToSetupJitProfiles && !ActivityThread.isSystem() && mActivityThread != null) {
|
if (registerAppInfoToArt && !ActivityThread.isSystem() && mActivityThread != null) {
|
||||||
setupJitProfileSupport();
|
registerAppInfoToArt();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call AppComponentFactory to select/create the main class loader of this app.
|
// Call AppComponentFactory to select/create the main class loader of this app.
|
||||||
@@ -984,12 +984,8 @@ public final class LoadedApk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupJitProfileSupport() {
|
private void registerAppInfoToArt() {
|
||||||
if (!SystemProperties.getBoolean("dalvik.vm.usejitprofiles", false)) {
|
// Setup the dex reporter to notify package manager
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we use profiles, setup the dex reporter to notify package manager
|
|
||||||
// of any relevant dex loads. The idle maintenance job will use the information
|
// of any relevant dex loads. The idle maintenance job will use the information
|
||||||
// reported to optimize the loaded dex files.
|
// reported to optimize the loaded dex files.
|
||||||
// Note that we only need one global reporter per app.
|
// Note that we only need one global reporter per app.
|
||||||
@@ -1022,9 +1018,19 @@ public final class LoadedApk {
|
|||||||
|
|
||||||
for (int i = codePaths.size() - 1; i >= 0; i--) {
|
for (int i = codePaths.size() - 1; i >= 0; i--) {
|
||||||
String splitName = i == 0 ? null : mApplicationInfo.splitNames[i - 1];
|
String splitName = i == 0 ? null : mApplicationInfo.splitNames[i - 1];
|
||||||
String profileFile = ArtManager.getCurrentProfilePath(
|
String curProfileFile = ArtManager.getCurrentProfilePath(
|
||||||
mPackageName, UserHandle.myUserId(), splitName);
|
mPackageName, UserHandle.myUserId(), splitName);
|
||||||
VMRuntime.registerAppInfo(profileFile, new String[] {codePaths.get(i)});
|
String refProfileFile = ArtManager.getReferenceProfilePath(
|
||||||
|
mPackageName, UserHandle.myUserId(), splitName);
|
||||||
|
int codePathType = codePaths.get(i).equals(mApplicationInfo.sourceDir)
|
||||||
|
? VMRuntime.CODE_PATH_TYPE_PRIMARY_APK
|
||||||
|
: VMRuntime.CODE_PATH_TYPE_SPLIT_APK;
|
||||||
|
VMRuntime.registerAppInfo(
|
||||||
|
mPackageName,
|
||||||
|
curProfileFile,
|
||||||
|
refProfileFile,
|
||||||
|
new String[] {codePaths.get(i)},
|
||||||
|
codePathType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the app data directory with the reporter. It will
|
// Register the app data directory with the reporter. It will
|
||||||
|
|||||||
@@ -200,6 +200,16 @@ public class ArtManager {
|
|||||||
return new File(profileDir, getProfileName(splitName)).getAbsolutePath();
|
return new File(profileDir, getProfileName(splitName)).getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the path to the current profile corresponding to given package and split.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static String getReferenceProfilePath(String packageName, int userId, String splitName) {
|
||||||
|
File profileDir = Environment.getDataRefProfilesDePackageDirectory(packageName);
|
||||||
|
return new File(profileDir, getProfileName(splitName)).getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the snapshot profile file for the given package and profile name.
|
* Return the snapshot profile file for the given package and profile name.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -586,10 +586,18 @@ public class ZygoteInit {
|
|||||||
codePaths[0],
|
codePaths[0],
|
||||||
/*dexMetadata*/ null);
|
/*dexMetadata*/ null);
|
||||||
|
|
||||||
File profileDir = Environment.getDataProfilesDePackageDirectory(
|
File curProfileDir = Environment.getDataProfilesDePackageDirectory(
|
||||||
UserHandle.USER_SYSTEM, systemServerPackageName);
|
UserHandle.USER_SYSTEM, systemServerPackageName);
|
||||||
String profilePath = new File(profileDir, systemServerProfileName).getAbsolutePath();
|
String curProfilePath = new File(curProfileDir, systemServerProfileName).getAbsolutePath();
|
||||||
VMRuntime.registerAppInfo(profilePath, codePaths);
|
File refProfileDir = Environment.getDataProfilesDePackageDirectory(
|
||||||
|
UserHandle.USER_SYSTEM, systemServerPackageName);
|
||||||
|
String refProfilePath = new File(refProfileDir, systemServerProfileName).getAbsolutePath();
|
||||||
|
VMRuntime.registerAppInfo(
|
||||||
|
systemServerPackageName,
|
||||||
|
curProfilePath,
|
||||||
|
refProfilePath,
|
||||||
|
codePaths,
|
||||||
|
VMRuntime.CODE_PATH_TYPE_PRIMARY_APK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user