Merge "Remove moduleutils folder from NetworkStack module." am: db195e571d Original change: https://android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/2185339 Change-Id: I564d6bf5550aea0d93208448b27a8f7059924460 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/common/moduleutils/Android.bp b/common/moduleutils/Android.bp deleted file mode 100644 index 11b3d6d..0000000 --- a/common/moduleutils/Android.bp +++ /dev/null
@@ -1,44 +0,0 @@ -// -// Copyright (C) 2019 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. -// - -// Shared utility sources to be used by multiple network modules -// TODO: remove all frameworks/base dependencies on packages/modules/NetworkStack and -// frameworks/base/packages/Tethering by moving these files to frameworks/libs/net. -package { - default_applicable_licenses: ["Android-Apache-2.0"], -} - -filegroup { - name: "connectivity-module-utils-srcs", - srcs: [ - "src/android/net/shared/NetdUtils.java", - ], - visibility: [ - "//packages/modules/Connectivity/service", - ] -} - -// Shared utility sources to be used by tethering modules -filegroup { - name: "tethering-module-utils-srcs", - srcs: [ - "src/android/net/shared/NetdUtils.java", - ], - visibility: [ - "//frameworks/base/packages/Tethering", - "//packages/modules/Connectivity/Tethering" - ], -}
diff --git a/common/moduleutils/src/android/net/shared/LinkPropertiesParcelableUtil.java b/common/moduleutils/src/android/net/shared/LinkPropertiesParcelableUtil.java deleted file mode 100644 index 1729da6..0000000 --- a/common/moduleutils/src/android/net/shared/LinkPropertiesParcelableUtil.java +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright (C) 2019 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.shared; - -import android.annotation.Nullable; -import android.net.LinkProperties; -import android.net.ProxyInfo; - -/** - * Collection of utility methods to convert to and from stable AIDL parcelables for LinkProperties - * and its attributes. - * @hide - */ -public final class LinkPropertiesParcelableUtil { - // Temporary methods to facilitate migrating clients away from LinkPropertiesParcelable - // TODO: remove the following methods after migrating clients. - - /** - * @deprecated conversion to stable parcelable is no longer necessary. - */ - @Deprecated - public static LinkProperties toStableParcelable(@Nullable LinkProperties lp) { - return lp; - } - - /** - * @deprecated conversion to stable parcelable is no longer necessary. - */ - @Deprecated - public static ProxyInfo toStableParcelable(@Nullable ProxyInfo info) { - return info; - } -}
diff --git a/common/moduleutils/src/android/net/shared/NetdUtils.java b/common/moduleutils/src/android/net/shared/NetdUtils.java deleted file mode 100644 index f801e16..0000000 --- a/common/moduleutils/src/android/net/shared/NetdUtils.java +++ /dev/null
@@ -1,79 +0,0 @@ -/* - * Copyright (C) 2019 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.shared; - -import static android.system.OsConstants.EBUSY; - -import android.net.INetd; -import android.net.TetherConfigParcel; -import android.os.RemoteException; -import android.os.ServiceSpecificException; -import android.os.SystemClock; -import android.util.Log; - -/** - * Implements common operations on INetd - * @hide - */ -public class NetdUtils { - private static final String TAG = NetdUtils.class.getSimpleName(); - - /** Start tethering. */ - public static void tetherStart(final INetd netd, final boolean usingLegacyDnsProxy, - final String[] dhcpRange) throws RemoteException, ServiceSpecificException { - final TetherConfigParcel config = new TetherConfigParcel(); - config.usingLegacyDnsProxy = usingLegacyDnsProxy; - config.dhcpRanges = dhcpRange; - netd.tetherStartWithConfiguration(config); - } - - /** - * Retry Netd#networkAddInterface for EBUSY error code. - * If the same interface (e.g., wlan0) is in client mode and then switches to tethered mode. - * There can be a race where puts the interface into the local network but interface is still - * in use in netd because the ConnectivityService thread hasn't processed the disconnect yet. - * See b/158269544 for detail. - */ - private static void networkAddInterface(final INetd netd, final String iface, - int maxAttempts, int pollingIntervalMs) - throws ServiceSpecificException, RemoteException { - for (int i = 1; i <= maxAttempts; i++) { - try { - netd.networkAddInterface(INetd.LOCAL_NET_ID, iface); - return; - } catch (ServiceSpecificException e) { - if (e.errorCode == EBUSY && i < maxAttempts) { - SystemClock.sleep(pollingIntervalMs); - continue; - } - - Log.e(TAG, "Retry Netd#networkAddInterface failure: " + e); - throw e; - } - } - } - - /** Reset interface for tethering. */ - public static void untetherInterface(final INetd netd, String iface) - throws RemoteException, ServiceSpecificException { - try { - netd.tetherInterfaceRemove(iface); - } finally { - netd.networkRemoveInterface(INetd.LOCAL_NET_ID, iface); - } - } -}