Add TetheredInterface{Request, Callback} interface
Define interfaces that match the signature of the existing EthernetManager.TetheredInterfaceRequest and TetheredInterfaceCallback classes and make EthernetManager.TetheredInterfaceRequest and TetheredInterfaceCallback implement/subinterface these interfaces. The new bluetooth API could also implement these interfaces to make API surface consistent. Test: TH would test the existing tests that use the subclass. Bug: 190438212 Change-Id: I093972c111cb1d921076782492716d5a046be8fc
This commit is contained in:
@@ -27,6 +27,15 @@ package android.net {
|
|||||||
method @Deprecated public int untether(@NonNull String);
|
method @Deprecated public int untether(@NonNull String);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static interface TetheringManager.TetheredInterfaceCallback {
|
||||||
|
method public void onAvailable(@NonNull String);
|
||||||
|
method public void onUnavailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static interface TetheringManager.TetheredInterfaceRequest {
|
||||||
|
method public void release();
|
||||||
|
}
|
||||||
|
|
||||||
public static interface TetheringManager.TetheringEventCallback {
|
public static interface TetheringManager.TetheringEventCallback {
|
||||||
method @Deprecated public default void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
|
method @Deprecated public default void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.annotation.IntDef;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -444,6 +445,44 @@ public class TetheringManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A request for a tethered interface.
|
||||||
|
*
|
||||||
|
* There are two reasons why this doesn't implement CLoseable:
|
||||||
|
* 1. To consistency with the existing EthernetManager.TetheredInterfaceRequest, which is
|
||||||
|
* already released.
|
||||||
|
* 2. This is not synchronous, so it's not useful to use try-with-resources.
|
||||||
|
*
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
@SystemApi(client = MODULE_LIBRARIES)
|
||||||
|
@SuppressLint("NotCloseable")
|
||||||
|
public interface TetheredInterfaceRequest {
|
||||||
|
/**
|
||||||
|
* Release the request to tear down tethered interface.
|
||||||
|
*/
|
||||||
|
void release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for requestTetheredInterface.
|
||||||
|
*
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
@SystemApi(client = MODULE_LIBRARIES)
|
||||||
|
public interface TetheredInterfaceCallback {
|
||||||
|
/**
|
||||||
|
* Called when the tethered interface is available.
|
||||||
|
* @param iface The name of the interface.
|
||||||
|
*/
|
||||||
|
void onAvailable(@NonNull String iface);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the tethered interface is now unavailable.
|
||||||
|
*/
|
||||||
|
void onUnavailable();
|
||||||
|
}
|
||||||
|
|
||||||
private static class TetheringCallbackInternal extends ITetheringEventCallback.Stub {
|
private static class TetheringCallbackInternal extends ITetheringEventCallback.Stub {
|
||||||
private volatile int mError = TETHER_ERROR_NO_ERROR;
|
private volatile int mError = TETHER_ERROR_NO_ERROR;
|
||||||
private final ConditionVariable mWaitForCallback = new ConditionVariable();
|
private final ConditionVariable mWaitForCallback = new ConditionVariable();
|
||||||
|
|||||||
Reference in New Issue
Block a user