run webview preparation in separate thread
- There is no other dependency for webview from system server.
Prepare it in separate thread and confirm completion
before allowing 3rd party apps.
bug: 33840151
Test: manual, reboot
Change-Id: I417b0451c37f663c577295ab07f33474e72fe457
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 70b0bf2..b911d2d 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -55,6 +55,7 @@
import com.android.internal.os.BinderInternal;
import com.android.internal.os.SamplingProfilerIntegration;
import com.android.internal.policy.EmergencyAffordanceManager;
+import com.android.internal.util.ConcurrentUtils;
import com.android.internal.widget.ILockSettings;
import com.android.server.accessibility.AccessibilityManagerService;
import com.android.server.am.ActivityManagerService;
@@ -117,6 +118,7 @@
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Future;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -1580,11 +1582,19 @@
}
traceEnd();
+ // No dependency on Webview preparation in system server. But this should
+ // be completed before allowring 3rd party
+ final String WEBVIEW_PREPARATION = "WebViewFactoryPreparation";
+ Future<?> webviewPrep = null;
if (!mOnlyCore) {
- Slog.i(TAG, "WebViewFactory preparation");
- traceBeginAndSlog("WebViewFactoryPreparation");
- mWebViewUpdateService.prepareWebViewInSystemServer();
- traceEnd();
+ webviewPrep = SystemServerInitThreadPool.get().submit(() -> {
+ Slog.i(TAG, WEBVIEW_PREPARATION);
+ BootTimingsTraceLog traceLog = new BootTimingsTraceLog(
+ "SystemServerTiming", Trace.TRACE_TAG_SYSTEM_SERVER);
+ traceLog.traceBegin(WEBVIEW_PREPARATION);
+ mWebViewUpdateService.prepareWebViewInSystemServer();
+ traceLog.traceEnd();
+ }, WEBVIEW_PREPARATION);
}
traceBeginAndSlog("StartSystemUI");
@@ -1641,6 +1651,10 @@
Watchdog.getInstance().start();
traceEnd();
+ if (webviewPrep != null) {
+ ConcurrentUtils.waitForFutureNoInterrupt(webviewPrep, WEBVIEW_PREPARATION);
+ }
+
// It is now okay to let the various system services start their
// third party code...
traceBeginAndSlog("PhaseThirdPartyAppsCanStart");