diff options
| author | 2018-07-24 08:50:50 +0000 | |
|---|---|---|
| committer | 2018-07-24 08:50:50 +0000 | |
| commit | f672c2bcb8a37e29d12f2f29e43ec3996722e9ba (patch) | |
| tree | 1649181c51a70fcae92c9ffe0ef1538234fc9308 | |
| parent | 555fc87b9961976d1f40062afb6005245a41e6fb (diff) | |
| parent | a84056a3d0c8e444f608c4f25d9525c2d9487cb5 (diff) | |
Merge "Break some dependencies on libcore internals"
| -rw-r--r-- | core/java/com/android/internal/os/RuntimeInit.java | 15 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 45 |
2 files changed, 16 insertions, 44 deletions
diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java index a9cd5c8e4adc..e37e650f6e50 100644 --- a/core/java/com/android/internal/os/RuntimeInit.java +++ b/core/java/com/android/internal/os/RuntimeInit.java @@ -30,14 +30,13 @@ import android.util.Log; import android.util.Slog; import com.android.internal.logging.AndroidConfig; import com.android.server.NetworkManagementSocketTagger; +import dalvik.system.RuntimeHooks; import dalvik.system.VMRuntime; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Objects; -import java.util.TimeZone; import java.util.logging.LogManager; -import org.apache.harmony.luni.internal.util.TimezoneGetter; /** * Main entry point for runtime initialization. Not for @@ -195,19 +194,13 @@ public class RuntimeInit { * the default handler, but not the pre handler. */ LoggingHandler loggingHandler = new LoggingHandler(); - Thread.setUncaughtExceptionPreHandler(loggingHandler); + RuntimeHooks.setUncaughtExceptionPreHandler(loggingHandler); Thread.setDefaultUncaughtExceptionHandler(new KillApplicationHandler(loggingHandler)); /* - * Install a TimezoneGetter subclass for ZoneInfo.db + * Install a time zone supplier that uses the Android persistent time zone system property. */ - TimezoneGetter.setInstance(new TimezoneGetter() { - @Override - public String getId() { - return SystemProperties.get("persist.sys.timezone"); - } - }); - TimeZone.setDefault(null); + RuntimeHooks.setTimeZoneIdSupplier(() -> SystemProperties.get("persist.sys.timezone")); /* * Sets handler for java.util.logging to use Android log facilities. diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index d1d062865b38..00ae33514ba7 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -21,9 +21,6 @@ import static android.system.OsConstants.S_IRWXO; import android.content.res.Resources; import android.content.res.TypedArray; -import android.icu.impl.CacheValue; -import android.icu.text.DecimalFormatSymbols; -import android.icu.util.ULocale; import android.opengl.EGL14; import android.os.Build; import android.os.IInstalld; @@ -122,9 +119,9 @@ public class ZygoteInit { static void preload(TimingsTraceLog bootTimingsTraceLog) { Log.d(TAG, "begin preload"); - bootTimingsTraceLog.traceBegin("BeginIcuCachePinning"); - beginIcuCachePinning(); - bootTimingsTraceLog.traceEnd(); // BeginIcuCachePinning + bootTimingsTraceLog.traceBegin("BeginPreload"); + beginPreload(); + bootTimingsTraceLog.traceEnd(); // BeginPreload bootTimingsTraceLog.traceBegin("PreloadClasses"); preloadClasses(); bootTimingsTraceLog.traceEnd(); // PreloadClasses @@ -142,7 +139,7 @@ public class ZygoteInit { // Ask the WebViewFactory to do any initialization that must run in the zygote process, // for memory sharing purposes. WebViewFactory.prepareWebViewInZygote(); - endIcuCachePinning(); + endPreload(); warmUpJcaProviders(); Log.d(TAG, "end preload"); @@ -156,27 +153,16 @@ public class ZygoteInit { preload(new TimingsTraceLog("ZygoteInitTiming_lazy", Trace.TRACE_TAG_DALVIK)); } - private static void beginIcuCachePinning() { - // Pin ICU data in memory from this point that would normally be held by soft references. - // Without this, any references created immediately below or during class preloading - // would be collected when the Zygote GC runs in gcAndFinalize(). - Log.i(TAG, "Installing ICU cache reference pinning..."); + private static void beginPreload() { + Log.i(TAG, "Calling ZygoteHooks.beginPreload()"); - CacheValue.setStrength(CacheValue.Strength.STRONG); - - Log.i(TAG, "Preloading ICU data..."); - // Explicitly exercise code to cache data apps are likely to need. - ULocale[] localesToPin = { ULocale.ROOT, ULocale.US, ULocale.getDefault() }; - for (ULocale uLocale : localesToPin) { - new DecimalFormatSymbols(uLocale); - } + ZygoteHooks.onBeginPreload(); } - private static void endIcuCachePinning() { - // All cache references created by ICU from this point will be soft. - CacheValue.setStrength(CacheValue.Strength.SOFT); + private static void endPreload() { + ZygoteHooks.onEndPreload(); - Log.i(TAG, "Uninstalled ICU cache reference pinning..."); + Log.i(TAG, "Called ZygoteHooks.endPreload()"); } private static void preloadSharedLibraries() { @@ -436,15 +422,8 @@ public class ZygoteInit { * softly- and final-reachable objects, along with any other garbage. * This is only useful just before a fork(). */ - /*package*/ static void gcAndFinalize() { - final VMRuntime runtime = VMRuntime.getRuntime(); - - /* runFinalizationSync() lets finalizers be called in Zygote, - * which doesn't have a HeapWorker thread. - */ - System.gc(); - runtime.runFinalizationSync(); - System.gc(); + private static void gcAndFinalize() { + ZygoteHooks.gcAndFinalize(); } /** |