From fbd13585fda0edcb16c70cfa9d8b6a48af495c49 Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Thu, 1 Jun 2023 17:02:05 +0900 Subject: [PATCH] Remove the unused ITetheringStatsProvider. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is safe because : • There are no longer any existing user of this class in AOSP or downstream • Known previous uses by OEMs/vendors have been removed • This class is now superseded by the better and more generic network stats provider, so that remaining uses if any can be retrofitted into this newer, better class Test: TH Bug: 64955351 Merged-In: I88fee389a3c768baf7c29096d2245734d9dd4fe8 Change-Id: I88fee389a3c768baf7c29096d2245734d9dd4fe8 --- .../android/net/ITetheringStatsProvider.aidl | 39 ------------------- .../android/os/INetworkManagementService.aidl | 1 - .../server/NetworkManagementService.java | 38 ------------------ 3 files changed, 78 deletions(-) delete mode 100644 core/java/android/net/ITetheringStatsProvider.aidl diff --git a/core/java/android/net/ITetheringStatsProvider.aidl b/core/java/android/net/ITetheringStatsProvider.aidl deleted file mode 100644 index 199afa2ed4172..0000000000000 --- a/core/java/android/net/ITetheringStatsProvider.aidl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.net; - -import android.net.NetworkStats; - -/** - * Interface for NetworkManagementService to query tethering statistics and set data limits. - * - * TODO: this does not really need to be an interface since Tethering runs in the same process - * as NetworkManagementService. Consider refactoring Tethering to use direct access to - * NetworkManagementService instead of using INetworkManagementService, and then deleting this - * interface. - * - * @hide - */ -interface ITetheringStatsProvider { - // Sets the interface quota for the specified upstream interface. This is defined as the number - // of bytes, starting from zero and counting from now, after which data should stop being - // forwarded to/from the specified upstream. A value of QUOTA_UNLIMITED means there is no limit. - void setInterfaceQuota(String iface, long quotaBytes); - - // Indicates that no data usage limit is set. - const int QUOTA_UNLIMITED = -1; -} diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index bc11cd56161bc..ec69e2abca17e 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -19,7 +19,6 @@ package android.os; import android.net.InterfaceConfiguration; import android.net.INetworkManagementEventObserver; -import android.net.ITetheringStatsProvider; import android.net.Network; import android.net.NetworkStats; import android.net.RouteInfo; diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index acb09fd7bedb4..a027e04106011 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -44,7 +44,6 @@ import android.net.ConnectivityManager; import android.net.INetd; import android.net.INetdUnsolicitedEventListener; import android.net.INetworkManagementEventObserver; -import android.net.ITetheringStatsProvider; import android.net.InetAddresses; import android.net.InterfaceConfiguration; import android.net.InterfaceConfigurationParcel; @@ -135,10 +134,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub { private final RemoteCallbackList mObservers = new RemoteCallbackList<>(); - @GuardedBy("mTetheringStatsProviders") - private final HashMap - mTetheringStatsProviders = Maps.newHashMap(); - /** * If both locks need to be held, then they should be obtained in the order: * first {@link #mQuotaLock} and then {@link #mRulesLock}. @@ -217,10 +212,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub { mNetdUnsolicitedEventListener = new NetdUnsolicitedEventListener(); mDeps.registerLocalService(new LocalService()); - - synchronized (mTetheringStatsProviders) { - mTetheringStatsProviders.put(new NetdTetheringStatsProvider(), "netd"); - } } static NetworkManagementService create(Context context, Dependencies deps) @@ -909,17 +900,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub { } catch (RemoteException | ServiceSpecificException e) { throw new IllegalStateException(e); } - - synchronized (mTetheringStatsProviders) { - for (ITetheringStatsProvider provider : mTetheringStatsProviders.keySet()) { - try { - provider.setInterfaceQuota(iface, quotaBytes); - } catch (RemoteException e) { - Log.e(TAG, "Problem setting tethering data limit on provider " + - mTetheringStatsProviders.get(provider) + ": " + e); - } - } - } } } @@ -942,17 +922,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub { } catch (RemoteException | ServiceSpecificException e) { throw new IllegalStateException(e); } - - synchronized (mTetheringStatsProviders) { - for (ITetheringStatsProvider provider : mTetheringStatsProviders.keySet()) { - try { - provider.setInterfaceQuota(iface, ITetheringStatsProvider.QUOTA_UNLIMITED); - } catch (RemoteException e) { - Log.e(TAG, "Problem removing tethering data limit on provider " + - mTetheringStatsProviders.get(provider) + ": " + e); - } - } - } } } @@ -1148,13 +1117,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub { return true; } - private class NetdTetheringStatsProvider extends ITetheringStatsProvider.Stub { - @Override - public void setInterfaceQuota(String iface, long quotaBytes) { - // Do nothing. netd is already informed of quota changes in setInterfaceQuota. - } - } - @Override public void setFirewallEnabled(boolean enabled) { enforceSystemUid();