Snap for 8681172 from f8d403cb4a04a2bb55573bb45af8f3315f5ce649 to tm-release Change-Id: Ia7cfccd763192b4c96afb5822106b9a143916927
diff --git a/apishim/29/com/android/networkstack/apishim/api29/EthernetManagerShimImpl.java b/apishim/29/com/android/networkstack/apishim/api29/EthernetManagerShimImpl.java deleted file mode 100644 index 2f5fb7d..0000000 --- a/apishim/29/com/android/networkstack/apishim/api29/EthernetManagerShimImpl.java +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright (C) 2022 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 com.android.networkstack.apishim.api29; - -import android.content.Context; -import android.os.Build; - -import androidx.annotation.RequiresApi; - -import com.android.networkstack.apishim.common.EthernetManagerShim; - -/** - * Implementation of {@link EthernetManagerShim} for API 29. - * - * Cannot actually import EthernetManager because that only became @SystemApi in API 30. - */ -@RequiresApi(Build.VERSION_CODES.Q) -public class EthernetManagerShimImpl implements EthernetManagerShim { - /** - * Get a new instance of {@link EthernetManagerShim}. - */ - public static EthernetManagerShim newInstance(Context context) { - return new EthernetManagerShimImpl(); - } -}
diff --git a/apishim/31/com/android/networkstack/apishim/api31/EthernetManagerShimImpl.java b/apishim/31/com/android/networkstack/apishim/api31/EthernetManagerShimImpl.java deleted file mode 100644 index 2c93d7c..0000000 --- a/apishim/31/com/android/networkstack/apishim/api31/EthernetManagerShimImpl.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright (C) 2022 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 com.android.networkstack.apishim.api31; - -import static com.android.modules.utils.build.SdkLevel.isAtLeastS; - -import android.content.Context; -import android.os.Build; - -import androidx.annotation.RequiresApi; - -import com.android.networkstack.apishim.common.EthernetManagerShim; - -/** - * Implementation of {@link EthernetManagerShim} for API 31. - * - * Doesn't have any methods, but must exist because the stable shim API level is currently 31. - * TODO: delete when the stable shim API level becomes 33. - */ -@RequiresApi(Build.VERSION_CODES.S) -public class EthernetManagerShimImpl - extends com.android.networkstack.apishim.api29.EthernetManagerShimImpl { - /** - * Get a new instance of {@link EthernetManagerShim}. - */ - @RequiresApi(Build.VERSION_CODES.Q) - public static EthernetManagerShim newInstance(Context context) { - if (!isAtLeastS()) { - return com.android.networkstack.apishim.api29.EthernetManagerShimImpl - .newInstance(context); - } - return new EthernetManagerShimImpl(); - } -}
diff --git a/apishim/33/com/android/networkstack/apishim/api33/EthernetManagerShimImpl.java b/apishim/33/com/android/networkstack/apishim/api33/EthernetManagerShimImpl.java deleted file mode 100644 index 5bd6487..0000000 --- a/apishim/33/com/android/networkstack/apishim/api33/EthernetManagerShimImpl.java +++ /dev/null
@@ -1,105 +0,0 @@ -/* - * Copyright (C) 2022 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 com.android.networkstack.apishim.api33; - -import static com.android.modules.utils.build.SdkLevel.isAtLeastT; - -import android.content.Context; -import android.net.EthernetManager; -import android.os.Build; - -import androidx.annotation.NonNull; -import androidx.annotation.RequiresApi; - -import com.android.networkstack.apishim.common.EthernetManagerShim; - -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executor; - -/** - * Implementation of {@link EthernetManagerShim} for API 33. - */ -@RequiresApi(Build.VERSION_CODES.TIRAMISU) -public class EthernetManagerShimImpl - extends com.android.networkstack.apishim.api31.EthernetManagerShimImpl { - - protected final EthernetManager mEm; - - // This is needed because callers of the shim cannot use EthernetManager.InterfaceStateListener, - // they need to use EthernetManagerShim.InterfaceStateListener instead. But when actually - // registering a callback, the callback type passed to EthernetManager must be a real - // listener, not a shim. This map keeps track of the mapping between the two objects so that - // when a caller calls removeInterfaceStateListener with a shim listener, this class knows what - // real listener to pass to EthernetManager. - private final ConcurrentHashMap<InterfaceStateListener, EthernetManager.InterfaceStateListener> - mListeners = new ConcurrentHashMap<>(); - - protected EthernetManagerShimImpl(Context context) { - mEm = context.getSystemService(EthernetManager.class); - } - - /** - * Get a new instance of {@link EthernetManagerShim}. - */ - @RequiresApi(Build.VERSION_CODES.Q) - public static EthernetManagerShim newInstance(Context context) { - if (!isAtLeastT()) { - return com.android.networkstack.apishim.api31.EthernetManagerShimImpl - .newInstance(context); - } - return new EthernetManagerShimImpl(context); - } - - @Override - public void addInterfaceStateListener(@NonNull Executor executor, - @NonNull InterfaceStateListener listener) { - final EthernetManager.InterfaceStateListener wrapper = (a, b, c, d) -> { - listener.onInterfaceStateChanged(a, b, c, d); - }; - // EthernetManager#addInterfaceStateListener will allow registering the same listener twice, - // but this does not seem very useful and is difficult to support with the wrapper scheme - // used by this shim. Don't allow it. - final EthernetManager.InterfaceStateListener existing = - mListeners.putIfAbsent(listener, wrapper); - if (existing != null) { - throw new IllegalStateException("Attempt to register duplicate listener"); - } - mEm.addInterfaceStateListener(executor, wrapper); - } - - @Override - public void removeInterfaceStateListener(@NonNull InterfaceStateListener listener) { - final EthernetManager.InterfaceStateListener wrapper = mListeners.remove(listener); - if (wrapper != null) { - mEm.removeInterfaceStateListener(wrapper); - } - } - - @Override - // This method existed in R and S, but as @TestApi, so should not appear in the shims before T - // because otherwise it could be used by production code on R and S. - public void setIncludeTestInterfaces(boolean include) { - mEm.setIncludeTestInterfaces(include); - } - - @Override - @NonNull - public List<String> getInterfaceList() { - return mEm.getInterfaceList(); - } -}
diff --git a/apishim/34/com/android/networkstack/apishim/EthernetManagerShimImpl.java b/apishim/34/com/android/networkstack/apishim/EthernetManagerShimImpl.java deleted file mode 100644 index e9a33a1..0000000 --- a/apishim/34/com/android/networkstack/apishim/EthernetManagerShimImpl.java +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (C) 2022 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 com.android.networkstack.apishim; - -import android.content.Context; -import android.os.Build; - -import androidx.annotation.RequiresApi; - -import com.android.networkstack.apishim.common.EthernetManagerShim; - -/** - * Implementation of {@link EthernetManagerShim} for API 34. - */ -// TODO: when available in all active branches: @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) -@RequiresApi(Build.VERSION_CODES.CUR_DEVELOPMENT) -public class EthernetManagerShimImpl - extends com.android.networkstack.apishim.api33.EthernetManagerShimImpl { - protected EthernetManagerShimImpl(Context context) { - super(context); - } -}
diff --git a/apishim/common/com/android/networkstack/apishim/common/EthernetManagerShim.java b/apishim/common/com/android/networkstack/apishim/common/EthernetManagerShim.java deleted file mode 100644 index 02a08de..0000000 --- a/apishim/common/com/android/networkstack/apishim/common/EthernetManagerShim.java +++ /dev/null
@@ -1,63 +0,0 @@ -/* - * Copyright (C) 2022 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 com.android.networkstack.apishim.common; - -import android.net.IpConfiguration; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import java.util.List; -import java.util.concurrent.Executor; - -/** API shim for EthernetManager */ -public interface EthernetManagerShim { - int STATE_ABSENT = 0; - int STATE_LINK_DOWN = 1; - int STATE_LINK_UP = 2; - int ROLE_NONE = 0; - int ROLE_CLIENT = 1; - int ROLE_SERVER = 2; - - /** Shim for EthernetManager#InterfaceStateListener. */ - interface InterfaceStateListener { - void onInterfaceStateChanged(@NonNull String iface, int state, int role, - @Nullable IpConfiguration configuration); - } - - /** Shim for EthernetManager#addInterfaceStateListener */ - default void addInterfaceStateListener(@NonNull Executor executor, - @NonNull InterfaceStateListener listener) throws UnsupportedApiLevelException { - throw new UnsupportedApiLevelException(); - } - - /** Shim for EthernetManager#removeInterfaceStateListener */ - default void removeInterfaceStateListener(@NonNull InterfaceStateListener listener) - throws UnsupportedApiLevelException { - throw new UnsupportedApiLevelException("Not supported until API 33"); - } - - /** Shim for EthernetManager#setIncludeTestInterfaces */ - default void setIncludeTestInterfaces(boolean include) throws UnsupportedApiLevelException { - throw new UnsupportedApiLevelException("Not supported until API 30"); - } - - /** Shim for EthernetManager#getInterfaceList */ - default List<String> getInterfaceList() throws UnsupportedApiLevelException { - throw new UnsupportedApiLevelException("Not supported until API 33"); - } -}