summaryrefslogtreecommitdiff
path: root/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-03-09 04:07:07 +0000
committerMark Chien <markchien@google.com>2020-03-09 07:59:29 +0000
commit74f27e6f635ee5c2f5a4311af4df1034472d4d2b (patch)
tree66b8662bfc2382d4d6e0520f83f74d21601d43fb /Tethering/common/TetheringLib/src/android/net/TetheringManager.java
parentcf9a67a5db0d97028720859262720b006312803a (diff)
Send offload status changed callback
The callback would be fired when offload started, stopped, or failed. If offload is not supported, "failed" callback would be fired when user enable tethering. Enabling multiple tethering would not have multiple offload status callbacks because offload should already be started or failed. Bug: 130596697 Test: -build, flash, boot -atest TetheringTests -ON/OFF hotspotf Change-Id: Ifb16dcedc8081833fa95a39596fe5cdc309ededd Merged-In: Ifb16dcedc8081833fa95a39596fe5cdc309ededd Merged-In: Ia0398601144b0e5f61dc0c5771eacf13e7cfbb59 (cherry picked from commit cd266076bed28459234c5d74ad373867944df116)
Diffstat (limited to 'Tethering/common/TetheringLib/src/android/net/TetheringManager.java')
-rw-r--r--Tethering/common/TetheringLib/src/android/net/TetheringManager.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/Tethering/common/TetheringLib/src/android/net/TetheringManager.java b/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
index fd9f7137c8..183e7ffb84 100644
--- a/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
+++ b/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
@@ -18,6 +18,7 @@ package android.net;
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
import android.Manifest;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -34,6 +35,8 @@ import android.util.Log;
import com.android.internal.annotations.GuardedBy;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -172,6 +175,23 @@ public class TetheringManager {
public static final int TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION = 14;
public static final int TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION = 15;
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = false, value = {
+ TETHER_HARDWARE_OFFLOAD_STOPPED,
+ TETHER_HARDWARE_OFFLOAD_STARTED,
+ TETHER_HARDWARE_OFFLOAD_FAILED,
+ })
+ public @interface TetherOffloadStatus {
+ }
+
+ /** Tethering offload status is stopped. */
+ public static final int TETHER_HARDWARE_OFFLOAD_STOPPED = 0;
+ /** Tethering offload status is started. */
+ public static final int TETHER_HARDWARE_OFFLOAD_STARTED = 1;
+ /** Fail to start tethering offload. */
+ public static final int TETHER_HARDWARE_OFFLOAD_FAILED = 2;
+
/**
* Create a TetheringManager object for interacting with the tethering service.
*
@@ -378,6 +398,9 @@ public class TetheringManager {
@Override
public void onTetherClientsChanged(List<TetheredClient> clients) { }
+ @Override
+ public void onOffloadStatusChanged(int status) { }
+
public void waitForStarted() {
mWaitForCallback.block(DEFAULT_TIMEOUT_MS);
throwIfPermissionFailure(mError);
@@ -802,6 +825,14 @@ public class TetheringManager {
* @param clients The new set of tethered clients; the collection is not ordered.
*/
public void onClientsChanged(@NonNull Collection<TetheredClient> clients) {}
+
+ /**
+ * Called when tethering offload status changes.
+ *
+ * <p>This will be called immediately after the callback is registered.
+ * @param status The offload status.
+ */
+ public void onOffloadStatusChanged(@TetherOffloadStatus int status) {}
}
/**
@@ -925,6 +956,7 @@ public class TetheringManager {
maybeSendTetherableIfacesChangedCallback(parcel.states);
maybeSendTetheredIfacesChangedCallback(parcel.states);
callback.onClientsChanged(parcel.tetheredClients);
+ callback.onOffloadStatusChanged(parcel.offloadStatus);
});
}
@@ -960,6 +992,11 @@ public class TetheringManager {
public void onTetherClientsChanged(final List<TetheredClient> clients) {
executor.execute(() -> callback.onClientsChanged(clients));
}
+
+ @Override
+ public void onOffloadStatusChanged(final int status) {
+ executor.execute(() -> callback.onOffloadStatusChanged(status));
+ }
};
getConnector(c -> c.registerTetheringEventCallback(remoteCallback, callerPkg));
mTetheringEventCallbacks.put(callback, remoteCallback);