Handle variable class loader context for system server

Do not dexopt system server dex files which have a
variable class-loader context. We could extract them
but that will interfer with ZygoteInit code which will
try to verify them again.

As part of this change, also improve PackageDexOptimizer
error handling, logging wtf message when we cannot retrieve
the dexoptStatus.

Test: manual
Bug: 154789494
Change-Id: I8a8181ce637b13e5cab10267c50c0dccb187b15b
This commit is contained in:
Calin Juravle
2020-04-23 11:57:36 -07:00
parent 4a2288bf0e
commit 1ef2b2b6eb
2 changed files with 13 additions and 0 deletions

View File

@@ -725,6 +725,9 @@ public class PackageDexOptimizer {
} catch (IOException ioe) {
Slog.w(TAG, "IOException reading apk: " + path, ioe);
return DEX_OPT_FAILED;
} catch (Exception e) {
Slog.wtf(TAG, "Unexpected exception when calling dexoptNeeded on " + path, e);
return DEX_OPT_FAILED;
}
return adjustDexoptNeeded(dexoptNeeded);
}

View File

@@ -548,6 +548,16 @@ public class DexManager {
continue;
}
if (dexUseInfo.isUnsupportedClassLoaderContext()
|| dexUseInfo.isVariableClassLoaderContext()) {
String debugMsg = dexUseInfo.isUnsupportedClassLoaderContext()
? "unsupported"
: "variable";
Slog.w(TAG, "Skipping dexopt for system server path loaded with " + debugMsg
+ " class loader context: " + dexPath);
continue;
}
int newResult = pdo.dexoptSystemServerPath(dexPath, dexUseInfo, overriddenOptions);
// The end result is: