From 31d38bffdf1ee9023340e645f6461a07e2b06cb9 Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Mon, 4 Jul 2022 17:28:39 +0800 Subject: [PATCH] Remove ConnectivityService#PerUidCounter hack Follow up from aosp/1781202 and aosp/1821293, creating nris before removing old nris had been proven not necessary for per-app API flow. Hence, the per-uid counter hack for system uid that allows counter temporary go over limit does not actually be used in the production code. In other words, this CL is a no-op refactoring. Test: testRequestCountLimits Bug: 235771502 Change-Id: I8f71c6e4506fbec60cb503731aee64ab022b4634 --- .../src/com/android/server/ConnectivityService.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java index 0ca0d835af..7342efa886 100644 --- a/service/src/com/android/server/ConnectivityService.java +++ b/service/src/com/android/server/ConnectivityService.java @@ -1220,16 +1220,7 @@ public class ConnectivityService extends IConnectivityManager.Stub public void incrementCountOrThrow(final int uid) { synchronized (mUidToNetworkRequestCount) { final int newRequestCount = mUidToNetworkRequestCount.get(uid, 0) + 1; - if (newRequestCount >= mMaxCountPerUid - // HACK : the system server is allowed to go over the request count limit - // when it is creating requests on behalf of another app (but not itself, - // so it can still detect its own request leaks). This only happens in the - // per-app API flows in which case the old requests for that particular - // UID will be removed soon. - // TODO : with the removal of the legacy transact() method, exempting the - // system server UID should no longer be necessary. Make sure this is the - // case and remove this test. - && (Process.myUid() == uid || Process.myUid() != Binder.getCallingUid())) { + if (newRequestCount >= mMaxCountPerUid) { throw new ServiceSpecificException( ConnectivityManager.Errors.TOO_MANY_REQUESTS, "Uid " + uid + " exceeded its allotted requests limit"); @@ -10856,6 +10847,7 @@ public class ConnectivityService extends IConnectivityManager.Stub removeDefaultNetworkRequestsForPreference(PREFERENCE_ORDER_PROFILE); addPerAppDefaultNetworkRequests( createNrisFromProfileNetworkPreferences(mProfileNetworkPreferences)); + // Finally, rematch. rematchAllNetworksAndRequests();