From 9ada184a2bcbbf12d0c114246aef6d716cbfb236 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Tue, 31 May 2022 11:17:02 +0900 Subject: [PATCH] Remove logic from NetworkMonitorManager wrapper NetworkMonitorManager should just be a passthrough wrapper for INetworkMonitor. Move logic to choose the notifyNetworkConnected version to call to its only caller, ConnectivityService. This allows removing the dependency on modules-utils-build, which makes the networkstack-client library less portable; for example it would add duplicate classes if networkstack-client is included into service-wifi, as service-wifi can already use modules-utils-build from framework-wifi. Fixes: 227161380 Test: atest ConnectivityServiceTest Change-Id: Ie50f586c5d1ffe021cb0a96294f13f478fd3a2dd --- .../src/com/android/server/ConnectivityService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java index f760d3b894..986b108fc0 100644 --- a/service/src/com/android/server/ConnectivityService.java +++ b/service/src/com/android/server/ConnectivityService.java @@ -9252,7 +9252,18 @@ public class ConnectivityService extends IConnectivityManager.Stub params.networkCapabilities = networkAgent.networkCapabilities; params.linkProperties = new LinkProperties(networkAgent.linkProperties, true /* parcelSensitiveFields */); - networkAgent.networkMonitor().notifyNetworkConnected(params); + // isAtLeastT() is conservative here, as recent versions of NetworkStack support the + // newer callback even before T. However getInterfaceVersion is a synchronized binder + // call that would cause a Log.wtf to be emitted from the system_server process, and + // in the absence of a satisfactory, scalable solution which follows an easy/standard + // process to check the interface version, just use an SDK check. NetworkStack will + // always be new enough when running on T+. + if (SdkLevel.isAtLeastT()) { + networkAgent.networkMonitor().notifyNetworkConnected(params); + } else { + networkAgent.networkMonitor().notifyNetworkConnected(params.linkProperties, + params.networkCapabilities); + } scheduleUnvalidatedPrompt(networkAgent); // Whether a particular NetworkRequest listen should cause signal strength thresholds to