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)
This commit is contained in:
committed by
Mark Chien
parent
cf9a67a5db
commit
74f27e6f63
@@ -35,4 +35,5 @@ oneway interface ITetheringEventCallback
|
||||
void onConfigurationChanged(in TetheringConfigurationParcel config);
|
||||
void onTetherStatesChanged(in TetherStatesParcel states);
|
||||
void onTetherClientsChanged(in List<TetheredClient> clients);
|
||||
void onOffloadStatusChanged(int status);
|
||||
}
|
||||
|
||||
@@ -31,4 +31,5 @@ parcelable TetheringCallbackStartedParcel {
|
||||
TetheringConfigurationParcel config;
|
||||
TetherStatesParcel states;
|
||||
List<TetheredClient> tetheredClients;
|
||||
}
|
||||
int offloadStatus;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user