2-phase initialization of NetworkPolicyManagerService
Split systemReady() into 2 callbacks:
1) networkScoreAndNetworkManagementServiceReady - called when required
services are ready. NetworkPolicyManagerService starts its initialization
on the worker thread
2) systemReady - wait for phase (1) to finish so that the service is fully
initialized
NetworkPolicyManagerService is now prepared in parallel with
ConnectivityService and NetworkStatsService
Test: device boots without errors
Test: HostsideRestrictBackgroundNetworkTests and NetworkPolicyManagerServiceTest pass
Bug: 32315581
Change-Id: Ic9755ed096900247fa0bbb43f396d8bcb97ae6db
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 1fc4378..2ac3033 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -114,6 +114,7 @@
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
+import java.util.concurrent.CountDownLatch;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -1523,6 +1524,11 @@
} catch (Throwable e) {
reportWtf("making Network Managment Service ready", e);
}
+ CountDownLatch networkPolicyInitReadySignal = null;
+ if (networkPolicyF != null) {
+ networkPolicyInitReadySignal = networkPolicyF
+ .networkScoreAndNetworkManagementServiceReady();
+ }
traceEnd();
traceBeginAndSlog("MakeNetworkStatsServiceReady");
try {
@@ -1531,13 +1537,6 @@
reportWtf("making Network Stats Service ready", e);
}
traceEnd();
- traceBeginAndSlog("MakeNetworkPolicyServiceReady");
- try {
- if (networkPolicyF != null) networkPolicyF.systemReady();
- } catch (Throwable e) {
- reportWtf("making Network Policy Service ready", e);
- }
- traceEnd();
traceBeginAndSlog("MakeConnectivityServiceReady");
try {
if (connectivityF != null) connectivityF.systemReady();
@@ -1545,6 +1544,15 @@
reportWtf("making Connectivity Service ready", e);
}
traceEnd();
+ traceBeginAndSlog("MakeNetworkPolicyServiceReady");
+ try {
+ if (networkPolicyF != null) {
+ networkPolicyF.systemReady(networkPolicyInitReadySignal);
+ }
+ } catch (Throwable e) {
+ reportWtf("making Network Policy Service ready", e);
+ }
+ traceEnd();
traceBeginAndSlog("StartWatchdog");
Watchdog.getInstance().start();