diff --git a/Tethering/common/TetheringLib/Android.bp b/Tethering/common/TetheringLib/Android.bp index e0adb34dad..8c4f733fb6 100644 --- a/Tethering/common/TetheringLib/Android.bp +++ b/Tethering/common/TetheringLib/Android.bp @@ -59,16 +59,33 @@ java_library { ], hostdex: true, // for hiddenapi check - visibility: [ - "//frameworks/base/packages/Tethering:__subpackages__", - //TODO(b/147200698) remove below lines when the platform is built with stubs - "//frameworks/base", - "//frameworks/base/services", - "//frameworks/base/services/core", - ], + visibility: ["//frameworks/base/packages/Tethering:__subpackages__"], apex_available: ["com.android.tethering"], } +droidstubs { + name: "framework-tethering-stubs-sources", + defaults: ["framework-module-stubs-defaults-module_libs_api"], + srcs: [ + "src/android/net/TetheredClient.java", + "src/android/net/TetheringManager.java", + "src/android/net/TetheringConstants.java", + ], + libs: [ + "tethering-aidl-interfaces-java", + "framework-all", + ], + sdk_version: "core_platform", +} + +java_library { + name: "framework-tethering-stubs", + srcs: [":framework-tethering-stubs-sources"], + libs: ["framework-all"], + static_libs: ["tethering-aidl-interfaces-java"], + sdk_version: "core_platform", +} + filegroup { name: "framework-tethering-srcs", srcs: [ diff --git a/Tethering/common/TetheringLib/src/android/net/TetheredClient.java b/Tethering/common/TetheringLib/src/android/net/TetheredClient.java index 651468846c..ca5ef09d6a 100644 --- a/Tethering/common/TetheringLib/src/android/net/TetheredClient.java +++ b/Tethering/common/TetheringLib/src/android/net/TetheredClient.java @@ -16,6 +16,8 @@ package android.net; +import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; + import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; @@ -34,6 +36,7 @@ import java.util.Objects; * @hide */ @SystemApi +@SystemApi(client = MODULE_LIBRARIES) @TestApi public final class TetheredClient implements Parcelable { @NonNull diff --git a/Tethering/common/TetheringLib/src/android/net/TetheringConstants.java b/Tethering/common/TetheringLib/src/android/net/TetheringConstants.java index 00cf98e0fc..df87ac994d 100644 --- a/Tethering/common/TetheringLib/src/android/net/TetheringConstants.java +++ b/Tethering/common/TetheringLib/src/android/net/TetheringConstants.java @@ -16,6 +16,9 @@ package android.net; +import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; + +import android.annotation.SystemApi; import android.os.ResultReceiver; /** @@ -28,39 +31,30 @@ import android.os.ResultReceiver; * symbols from framework-tethering even when they are in a non-hidden class. * @hide */ +@SystemApi(client = MODULE_LIBRARIES) public class TetheringConstants { /** * Extra used for communicating with the TetherService. Includes the type of tethering to * enable if any. - * - * {@hide} */ public static final String EXTRA_ADD_TETHER_TYPE = "extraAddTetherType"; /** * Extra used for communicating with the TetherService. Includes the type of tethering for * which to cancel provisioning. - * - * {@hide} */ public static final String EXTRA_REM_TETHER_TYPE = "extraRemTetherType"; /** * Extra used for communicating with the TetherService. True to schedule a recheck of tether * provisioning. - * - * {@hide} */ public static final String EXTRA_SET_ALARM = "extraSetAlarm"; /** * Tells the TetherService to run a provision check now. - * - * {@hide} */ public static final String EXTRA_RUN_PROVISION = "extraRunProvision"; /** * Extra used for communicating with the TetherService. Contains the {@link ResultReceiver} * which will receive provisioning results. Can be left empty. - * - * {@hide} */ public static final String EXTRA_PROVISION_CALLBACK = "extraProvisionCallback"; } diff --git a/Tethering/common/TetheringLib/src/android/net/TetheringManager.java b/Tethering/common/TetheringLib/src/android/net/TetheringManager.java index 53a358f29a..6a9f010449 100644 --- a/Tethering/common/TetheringLib/src/android/net/TetheringManager.java +++ b/Tethering/common/TetheringLib/src/android/net/TetheringManager.java @@ -15,6 +15,8 @@ */ package android.net; +import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; + import android.Manifest; import android.annotation.NonNull; import android.annotation.Nullable; @@ -50,6 +52,7 @@ import java.util.function.Supplier; * @hide */ @SystemApi +@SystemApi(client = MODULE_LIBRARIES) @TestApi public class TetheringManager { private static final String TAG = TetheringManager.class.getSimpleName(); @@ -177,6 +180,7 @@ public class TetheringManager { * service is not connected. * {@hide} */ + @SystemApi(client = MODULE_LIBRARIES) public TetheringManager(@NonNull final Context context, @NonNull Supplier connectorSupplier) { mContext = context; @@ -395,6 +399,7 @@ public class TetheringManager { * {@hide} */ @Deprecated + @SystemApi(client = MODULE_LIBRARIES) public int tether(@NonNull final String iface) { final String callerPkg = mContext.getOpPackageName(); Log.i(TAG, "tether caller:" + callerPkg); @@ -418,6 +423,7 @@ public class TetheringManager { * {@hide} */ @Deprecated + @SystemApi(client = MODULE_LIBRARIES) public int untether(@NonNull final String iface) { final String callerPkg = mContext.getOpPackageName(); Log.i(TAG, "untether caller:" + callerPkg); @@ -444,6 +450,7 @@ public class TetheringManager { * {@hide} */ @Deprecated + @SystemApi(client = MODULE_LIBRARIES) public int setUsbTethering(final boolean enable) { final String callerPkg = mContext.getOpPackageName(); Log.i(TAG, "setUsbTethering caller:" + callerPkg); @@ -702,6 +709,7 @@ public class TetheringManager { * {@hide} */ // TODO: improve the usage of ResultReceiver, b/145096122 + @SystemApi(client = MODULE_LIBRARIES) public void requestLatestTetheringEntitlementResult(final int type, @NonNull final ResultReceiver receiver, final boolean showEntitlementUi) { final String callerPkg = mContext.getOpPackageName(); @@ -982,6 +990,7 @@ public class TetheringManager { * interface * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public int getLastTetherError(@NonNull final String iface) { mCallback.waitForStarted(); if (mTetherStatesParcel == null) return TETHER_ERROR_NO_ERROR; @@ -1004,6 +1013,7 @@ public class TetheringManager { * what interfaces are considered tetherable usb interfaces. * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public @NonNull String[] getTetherableUsbRegexs() { mCallback.waitForStarted(); return mTetheringConfiguration.tetherableUsbRegexs; @@ -1018,6 +1028,7 @@ public class TetheringManager { * what interfaces are considered tetherable wifi interfaces. * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public @NonNull String[] getTetherableWifiRegexs() { mCallback.waitForStarted(); return mTetheringConfiguration.tetherableWifiRegexs; @@ -1032,6 +1043,7 @@ public class TetheringManager { * what interfaces are considered tetherable bluetooth interfaces. * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public @NonNull String[] getTetherableBluetoothRegexs() { mCallback.waitForStarted(); return mTetheringConfiguration.tetherableBluetoothRegexs; @@ -1044,6 +1056,7 @@ public class TetheringManager { * @return an array of 0 or more Strings of tetherable interface names. * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public @NonNull String[] getTetherableIfaces() { mCallback.waitForStarted(); if (mTetherStatesParcel == null) return new String[0]; @@ -1057,6 +1070,7 @@ public class TetheringManager { * @return an array of 0 or more String of currently tethered interface names. * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public @NonNull String[] getTetheredIfaces() { mCallback.waitForStarted(); if (mTetherStatesParcel == null) return new String[0]; @@ -1076,6 +1090,7 @@ public class TetheringManager { * which failed to tether. * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public @NonNull String[] getTetheringErroredIfaces() { mCallback.waitForStarted(); if (mTetherStatesParcel == null) return new String[0]; @@ -1103,6 +1118,7 @@ public class TetheringManager { * @return a boolean - {@code true} indicating Tethering is supported. * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public boolean isTetheringSupported() { final String callerPkg = mContext.getOpPackageName(); diff --git a/Tethering/tests/unit/Android.bp b/Tethering/tests/unit/Android.bp index 13174c5bb5..c6905ec8ef 100644 --- a/Tethering/tests/unit/Android.bp +++ b/Tethering/tests/unit/Android.bp @@ -34,7 +34,15 @@ android_test { "TetheringApiCurrentLib", "testables", ], + // TODO(b/147200698) change sdk_version to module-current and + // remove framework-minus-apex, ext, and framework-res + sdk_version: "core_platform", libs: [ + "framework-minus-apex", + "ext", + "framework-res", + "framework-wifi-stubs", + "framework-telephony-stubs", "android.test.runner", "android.test.base", "android.test.mock",