Merge changes from topic "bgdex2oatd_cherry_pick"
* changes: Use dex2oatd when available on debug builds Add package use info to dexopt dump
This commit is contained in:
@@ -336,7 +336,8 @@ public class BackgroundDexOptService extends JobService {
|
|||||||
int dexoptFlags =
|
int dexoptFlags =
|
||||||
DexoptOptions.DEXOPT_CHECK_FOR_PROFILES_UPDATES |
|
DexoptOptions.DEXOPT_CHECK_FOR_PROFILES_UPDATES |
|
||||||
DexoptOptions.DEXOPT_BOOT_COMPLETE |
|
DexoptOptions.DEXOPT_BOOT_COMPLETE |
|
||||||
(downgrade ? DexoptOptions.DEXOPT_DOWNGRADE : 0);
|
(downgrade ? DexoptOptions.DEXOPT_DOWNGRADE : 0) |
|
||||||
|
DexoptOptions.DEXOPT_IDLE_BACKGROUND_JOB;
|
||||||
if (is_for_primary_dex) {
|
if (is_for_primary_dex) {
|
||||||
int result = pm.performDexOptWithStatus(new DexoptOptions(pkg,
|
int result = pm.performDexOptWithStatus(new DexoptOptions(pkg,
|
||||||
PackageManagerService.REASON_BACKGROUND_DEXOPT,
|
PackageManagerService.REASON_BACKGROUND_DEXOPT,
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ public class Installer extends SystemService {
|
|||||||
public static final int DEXOPT_STORAGE_CE = 1 << 7;
|
public static final int DEXOPT_STORAGE_CE = 1 << 7;
|
||||||
/** Indicates that the dex file passed to dexopt in on DE storage. */
|
/** Indicates that the dex file passed to dexopt in on DE storage. */
|
||||||
public static final int DEXOPT_STORAGE_DE = 1 << 8;
|
public static final int DEXOPT_STORAGE_DE = 1 << 8;
|
||||||
|
/** Indicates that dexopt is invoked from the background service. */
|
||||||
|
public static final int DEXOPT_IDLE_BACKGROUND_JOB = 1 << 9;
|
||||||
|
|
||||||
// NOTE: keep in sync with installd
|
// NOTE: keep in sync with installd
|
||||||
public static final int FLAG_CLEAR_CACHE_ONLY = 1 << 8;
|
public static final int FLAG_CLEAR_CACHE_ONLY = 1 << 8;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import dalvik.system.DexFile;
|
import dalvik.system.DexFile;
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ import static com.android.server.pm.Installer.DEXOPT_SECONDARY_DEX;
|
|||||||
import static com.android.server.pm.Installer.DEXOPT_FORCE;
|
import static com.android.server.pm.Installer.DEXOPT_FORCE;
|
||||||
import static com.android.server.pm.Installer.DEXOPT_STORAGE_CE;
|
import static com.android.server.pm.Installer.DEXOPT_STORAGE_CE;
|
||||||
import static com.android.server.pm.Installer.DEXOPT_STORAGE_DE;
|
import static com.android.server.pm.Installer.DEXOPT_STORAGE_DE;
|
||||||
|
import static com.android.server.pm.Installer.DEXOPT_IDLE_BACKGROUND_JOB;
|
||||||
import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
|
import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
|
||||||
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
|
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
|
||||||
|
|
||||||
@@ -392,26 +394,60 @@ public class PackageDexOptimizer {
|
|||||||
/**
|
/**
|
||||||
* Dumps the dexopt state of the given package {@code pkg} to the given {@code PrintWriter}.
|
* Dumps the dexopt state of the given package {@code pkg} to the given {@code PrintWriter}.
|
||||||
*/
|
*/
|
||||||
void dumpDexoptState(IndentingPrintWriter pw, PackageParser.Package pkg) {
|
void dumpDexoptState(IndentingPrintWriter pw, PackageParser.Package pkg,
|
||||||
|
PackageDexUsage.PackageUseInfo useInfo) {
|
||||||
final String[] instructionSets = getAppDexInstructionSets(pkg.applicationInfo);
|
final String[] instructionSets = getAppDexInstructionSets(pkg.applicationInfo);
|
||||||
final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets);
|
final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets);
|
||||||
|
|
||||||
final List<String> paths = pkg.getAllCodePathsExcludingResourceOnly();
|
final List<String> paths = pkg.getAllCodePathsExcludingResourceOnly();
|
||||||
|
|
||||||
for (String instructionSet : dexCodeInstructionSets) {
|
for (String path : paths) {
|
||||||
pw.println("Instruction Set: " + instructionSet);
|
pw.println("path: " + path);
|
||||||
pw.increaseIndent();
|
pw.increaseIndent();
|
||||||
for (String path : paths) {
|
|
||||||
String status = null;
|
for (String isa : dexCodeInstructionSets) {
|
||||||
try {
|
String status = null;
|
||||||
status = DexFile.getDexFileStatus(path, instructionSet);
|
try {
|
||||||
} catch (IOException ioe) {
|
status = DexFile.getDexFileStatus(path, isa);
|
||||||
status = "[Exception]: " + ioe.getMessage();
|
} catch (IOException ioe) {
|
||||||
}
|
status = "[Exception]: " + ioe.getMessage();
|
||||||
pw.println("path: " + path);
|
}
|
||||||
pw.println("status: " + status);
|
pw.println(isa + ": " + status);
|
||||||
}
|
}
|
||||||
pw.decreaseIndent();
|
|
||||||
|
if (useInfo.isUsedByOtherApps(path)) {
|
||||||
|
pw.println("used be other apps: " + useInfo.getLoadingPackages(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, PackageDexUsage.DexUseInfo> dexUseInfoMap = useInfo.getDexUseInfoMap();
|
||||||
|
|
||||||
|
if (!dexUseInfoMap.isEmpty()) {
|
||||||
|
pw.println("known secondary dex files:");
|
||||||
|
pw.increaseIndent();
|
||||||
|
for (Map.Entry<String, PackageDexUsage.DexUseInfo> e : dexUseInfoMap.entrySet()) {
|
||||||
|
String dex = e.getKey();
|
||||||
|
PackageDexUsage.DexUseInfo dexUseInfo = e.getValue();
|
||||||
|
pw.println(dex);
|
||||||
|
pw.increaseIndent();
|
||||||
|
for (String isa : dexUseInfo.getLoaderIsas()) {
|
||||||
|
String status = null;
|
||||||
|
try {
|
||||||
|
status = DexFile.getDexFileStatus(path, isa);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
status = "[Exception]: " + ioe.getMessage();
|
||||||
|
}
|
||||||
|
pw.println(isa + ": " + status);
|
||||||
|
}
|
||||||
|
|
||||||
|
pw.println("class loader context: " + dexUseInfo.getClassLoaderContext());
|
||||||
|
if (dexUseInfo.isUsedByOtherApps()) {
|
||||||
|
pw.println("used be other apps: " + dexUseInfo.getLoadingPackages());
|
||||||
|
}
|
||||||
|
pw.decreaseIndent();
|
||||||
|
}
|
||||||
|
pw.decreaseIndent();
|
||||||
|
}
|
||||||
|
pw.decreaseIndent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,6 +604,9 @@ public class PackageDexOptimizer {
|
|||||||
if ((flags & DEXOPT_STORAGE_DE) == DEXOPT_STORAGE_DE) {
|
if ((flags & DEXOPT_STORAGE_DE) == DEXOPT_STORAGE_DE) {
|
||||||
flagsList.add("storage_de");
|
flagsList.add("storage_de");
|
||||||
}
|
}
|
||||||
|
if ((flags & DEXOPT_IDLE_BACKGROUND_JOB) == DEXOPT_IDLE_BACKGROUND_JOB) {
|
||||||
|
flagsList.add("idle_background_job");
|
||||||
|
}
|
||||||
|
|
||||||
return String.join(",", flagsList);
|
return String.join(",", flagsList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22555,7 +22555,8 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
|
|||||||
for (PackageParser.Package pkg : packages) {
|
for (PackageParser.Package pkg : packages) {
|
||||||
ipw.println("[" + pkg.packageName + "]");
|
ipw.println("[" + pkg.packageName + "]");
|
||||||
ipw.increaseIndent();
|
ipw.increaseIndent();
|
||||||
mPackageDexOptimizer.dumpDexoptState(ipw, pkg);
|
mPackageDexOptimizer.dumpDexoptState(ipw, pkg,
|
||||||
|
mDexManager.getPackageUseInfoOrDefault(pkg.packageName));
|
||||||
ipw.decreaseIndent();
|
ipw.decreaseIndent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ public final class DexoptOptions {
|
|||||||
// actually shared at runtime.
|
// actually shared at runtime.
|
||||||
public static final int DEXOPT_AS_SHARED_LIBRARY = 1 << 6;
|
public static final int DEXOPT_AS_SHARED_LIBRARY = 1 << 6;
|
||||||
|
|
||||||
|
// When set, indicates that dexopt is invoked from the background service.
|
||||||
|
public static final int DEXOPT_IDLE_BACKGROUND_JOB = 1 << 9;
|
||||||
|
|
||||||
// The name of package to optimize.
|
// The name of package to optimize.
|
||||||
private final String mPackageName;
|
private final String mPackageName;
|
||||||
|
|
||||||
@@ -86,7 +89,8 @@ public final class DexoptOptions {
|
|||||||
DEXOPT_ONLY_SECONDARY_DEX |
|
DEXOPT_ONLY_SECONDARY_DEX |
|
||||||
DEXOPT_ONLY_SHARED_DEX |
|
DEXOPT_ONLY_SHARED_DEX |
|
||||||
DEXOPT_DOWNGRADE |
|
DEXOPT_DOWNGRADE |
|
||||||
DEXOPT_AS_SHARED_LIBRARY;
|
DEXOPT_AS_SHARED_LIBRARY |
|
||||||
|
DEXOPT_IDLE_BACKGROUND_JOB;
|
||||||
if ((flags & (~validityMask)) != 0) {
|
if ((flags & (~validityMask)) != 0) {
|
||||||
throw new IllegalArgumentException("Invalid flags : " + Integer.toHexString(flags));
|
throw new IllegalArgumentException("Invalid flags : " + Integer.toHexString(flags));
|
||||||
}
|
}
|
||||||
@@ -133,6 +137,10 @@ public final class DexoptOptions {
|
|||||||
return (mFlags & DEXOPT_AS_SHARED_LIBRARY) != 0;
|
return (mFlags & DEXOPT_AS_SHARED_LIBRARY) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDexoptIdleBackgroundJob() {
|
||||||
|
return (mFlags & DEXOPT_IDLE_BACKGROUND_JOB) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSplitName() {
|
public String getSplitName() {
|
||||||
return mSplitName;
|
return mSplitName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class DexoptOptionsTests {
|
|||||||
assertFalse(opt.isDexoptOnlySharedDex());
|
assertFalse(opt.isDexoptOnlySharedDex());
|
||||||
assertFalse(opt.isDowngrade());
|
assertFalse(opt.isDowngrade());
|
||||||
assertFalse(opt.isForce());
|
assertFalse(opt.isForce());
|
||||||
|
assertFalse(opt.isDexoptIdleBackgroundJob());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -63,7 +64,8 @@ public class DexoptOptionsTests {
|
|||||||
DexoptOptions.DEXOPT_ONLY_SECONDARY_DEX |
|
DexoptOptions.DEXOPT_ONLY_SECONDARY_DEX |
|
||||||
DexoptOptions.DEXOPT_ONLY_SHARED_DEX |
|
DexoptOptions.DEXOPT_ONLY_SHARED_DEX |
|
||||||
DexoptOptions.DEXOPT_DOWNGRADE |
|
DexoptOptions.DEXOPT_DOWNGRADE |
|
||||||
DexoptOptions.DEXOPT_AS_SHARED_LIBRARY;
|
DexoptOptions.DEXOPT_AS_SHARED_LIBRARY |
|
||||||
|
DexoptOptions.DEXOPT_IDLE_BACKGROUND_JOB;
|
||||||
|
|
||||||
DexoptOptions opt = new DexoptOptions(mPackageName, mCompilerFilter, flags);
|
DexoptOptions opt = new DexoptOptions(mPackageName, mCompilerFilter, flags);
|
||||||
assertEquals(mPackageName, opt.getPackageName());
|
assertEquals(mPackageName, opt.getPackageName());
|
||||||
@@ -76,6 +78,7 @@ public class DexoptOptionsTests {
|
|||||||
assertTrue(opt.isDowngrade());
|
assertTrue(opt.isDowngrade());
|
||||||
assertTrue(opt.isForce());
|
assertTrue(opt.isForce());
|
||||||
assertTrue(opt.isDexoptAsSharedLibrary());
|
assertTrue(opt.isDexoptAsSharedLibrary());
|
||||||
|
assertTrue(opt.isDexoptIdleBackgroundJob());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -137,4 +140,4 @@ public class DexoptOptionsTests {
|
|||||||
|
|
||||||
assertTrue(gotException);
|
assertTrue(gotException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user