From 46cb167e0864eafc5cc2dea34800207fadd8ab3d Mon Sep 17 00:00:00 2001 From: Cody Kesting Date: Wed, 4 Mar 2020 13:35:20 -0800 Subject: [PATCH] Decrement networkRequestPerUid when callbacks are unregistered. ConnectivityDiagnosticsCallbacks are tied to NetworkRequestInfo objects when registered with the platform. Each NetworkRequestInfo is tied to a specific uid, and ConnectivityService enforces a limit on the number of network requests that can be associated with each uid. When ConnectivityDiagnosticsCallbacks are unregistered from the platform, their NetworkRequestInfo is freed and the number of network requests per the user's uid should be decremented. Bug: 150802582 Test: atest android.net.cts.ConnectivityDiagnosticsManagerTest Change-Id: Ia5ed39c1d8e6221cd402be4f8baf69fa643a6113 --- .../core/java/com/android/server/ConnectivityService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 11a5f1b70e..c48ee276c8 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -7863,6 +7863,11 @@ public class ConnectivityService extends IConnectivityManager.Stub return; } + // Decrement the reference count for this NetworkRequestInfo. The reference count is + // incremented when the NetworkRequestInfo is created as part of + // enforceRequestCountLimit(). + decrementNetworkRequestPerUidCount(nri); + cb.asBinder().unlinkToDeath(mConnectivityDiagnosticsCallbacks.remove(cb), 0); }