Revert "Unify registration and NM assignment in NAI"
Revert submission 3535182
Reason for revert: <Droidmonitor created revert due to b/404070202.Will be verified through ABTD for standard investigation.>
Reverted changes: /q/submissionid:3535182
Change-Id: I65fdaaacb56c8ef227eaf1a0193efe8d332d6473
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index 1ac22bd..6453d76 100644
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -9409,6 +9409,8 @@
nai.getDeclaredCapabilitiesSanitized(mCarrierPrivilegeAuthenticator)));
processLinkPropertiesFromAgent(nai, nai.linkProperties);
+ nai.onNetworkMonitorCreated(networkMonitor);
+
mNetworkAgentInfos.add(nai);
synchronized (mNetworkForNetId) {
mNetworkForNetId.put(nai.network.getNetId(), nai);
@@ -9423,7 +9425,7 @@
if (nai.isLocalNetwork()) {
handleUpdateLocalNetworkConfig(nai, null /* oldConfig */, nai.localNetworkConfig);
}
- nai.notifyRegistered(networkMonitor);
+ nai.notifyRegistered();
NetworkInfo networkInfo = nai.networkInfo;
updateNetworkInfo(nai, networkInfo);
updateVpnUids(nai, null, nai.networkCapabilities);
diff --git a/service/src/com/android/server/connectivity/NetworkAgentInfo.java b/service/src/com/android/server/connectivity/NetworkAgentInfo.java
index 6d25d63..d6bd659 100644
--- a/service/src/com/android/server/connectivity/NetworkAgentInfo.java
+++ b/service/src/com/android/server/connectivity/NetworkAgentInfo.java
@@ -700,9 +700,7 @@
* Must be called from the ConnectivityService handler thread. A NetworkAgent can only be
* registered once.
*/
- public void notifyRegistered(final INetworkMonitor nm) {
- HandlerUtils.ensureRunningOnHandlerThread(mHandler);
- mNetworkMonitor = new NetworkMonitorManager(nm);
+ public void notifyRegistered() {
try {
networkAgent.asBinder().linkToDeath(mDeathMonitor, 0);
networkAgent.onRegistered();
@@ -1040,6 +1038,13 @@
}
/**
+ * Inform NetworkAgentInfo that a new NetworkMonitor was created.
+ */
+ public void onNetworkMonitorCreated(INetworkMonitor networkMonitor) {
+ mNetworkMonitor = new NetworkMonitorManager(networkMonitor);
+ }
+
+ /**
* Set the NetworkCapabilities on this NetworkAgentInfo. Also attempts to notify NetworkMonitor
* of the new capabilities, if NetworkMonitor has been created.
*