Fix ethernet enable / disable API
The ethernet APIs connectNetwork() / disconnectNetwork() are inaccurately named. Physical link state cannot be changed by calling an API. This change renames these functions to enableInterface and disableInterface, respectively, to better reflect their intention and behavior. Test: atest EthernetManagerPermissionTest Merged-In: I3361ad0e01e761ffd77faf6c55924fa4612ede90 Change-Id: I3361ad0e01e761ffd77faf6c55924fa4612ede90
This commit is contained in:
@@ -535,14 +535,13 @@ public class EthernetManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an ethernet network's link state up.
|
* Enable a network interface.
|
||||||
*
|
*
|
||||||
* When the link is successfully turned up, the callback will be called with the network
|
* Enables a previously disabled network interface.
|
||||||
* interface was torn down, if any. If any error or unexpected condition happens while the
|
* This function accepts an {@link OutcomeReceiver} that is called once the operation has
|
||||||
* system tries to turn the interface down, the callback will be called with an appropriate
|
* finished execution.
|
||||||
* exception. The callback is guaranteed to be called exactly once for each call to this method.
|
|
||||||
*
|
*
|
||||||
* @param iface the name of the interface to act upon.
|
* @param iface the name of the interface to enable.
|
||||||
* @param executor an {@link Executor} to execute the callback on. Optional if callback is null.
|
* @param executor an {@link Executor} to execute the callback on. Optional if callback is null.
|
||||||
* @param callback an optional {@link OutcomeReceiver} to listen for completion of the
|
* @param callback an optional {@link OutcomeReceiver} to listen for completion of the
|
||||||
* operation. On success, {@link OutcomeReceiver#onResult} is called with the
|
* operation. On success, {@link OutcomeReceiver#onResult} is called with the
|
||||||
@@ -550,7 +549,6 @@ public class EthernetManager {
|
|||||||
* information about the error.
|
* information about the error.
|
||||||
* @throws SecurityException if the process doesn't hold
|
* @throws SecurityException if the process doesn't hold
|
||||||
* {@link android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}.
|
* {@link android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}.
|
||||||
* @throws UnsupportedOperationException if called on a non-automotive device.
|
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@@ -559,7 +557,7 @@ public class EthernetManager {
|
|||||||
android.Manifest.permission.NETWORK_STACK,
|
android.Manifest.permission.NETWORK_STACK,
|
||||||
android.Manifest.permission.MANAGE_ETHERNET_NETWORKS})
|
android.Manifest.permission.MANAGE_ETHERNET_NETWORKS})
|
||||||
@RequiresFeature(PackageManager.FEATURE_AUTOMOTIVE)
|
@RequiresFeature(PackageManager.FEATURE_AUTOMOTIVE)
|
||||||
public void connectNetwork(
|
public void enableInterface(
|
||||||
@NonNull String iface,
|
@NonNull String iface,
|
||||||
@Nullable @CallbackExecutor Executor executor,
|
@Nullable @CallbackExecutor Executor executor,
|
||||||
@Nullable OutcomeReceiver<String, EthernetNetworkManagementException> callback) {
|
@Nullable OutcomeReceiver<String, EthernetNetworkManagementException> callback) {
|
||||||
@@ -574,14 +572,14 @@ public class EthernetManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an ethernet network's link state down.
|
* Disable a network interface.
|
||||||
*
|
*
|
||||||
* When the link is successfully turned down, the callback will be called with the network
|
* Disables the use of a network interface to fulfill network requests. If the interface
|
||||||
* interface was torn down, if any. If any error or unexpected condition happens while the
|
* currently serves a request, the network will be torn down.
|
||||||
* system tries to turn the interface down, the callback will be called with an appropriate
|
* This function accepts an {@link OutcomeReceiver} that is called once the operation has
|
||||||
* exception. The callback is guaranteed to be called exactly once for each call to this method.
|
* finished execution.
|
||||||
*
|
*
|
||||||
* @param iface the name of the interface to act upon.
|
* @param iface the name of the interface to disable.
|
||||||
* @param executor an {@link Executor} to execute the callback on. Optional if callback is null.
|
* @param executor an {@link Executor} to execute the callback on. Optional if callback is null.
|
||||||
* @param callback an optional {@link OutcomeReceiver} to listen for completion of the
|
* @param callback an optional {@link OutcomeReceiver} to listen for completion of the
|
||||||
* operation. On success, {@link OutcomeReceiver#onResult} is called with the
|
* operation. On success, {@link OutcomeReceiver#onResult} is called with the
|
||||||
@@ -589,7 +587,6 @@ public class EthernetManager {
|
|||||||
* information about the error.
|
* information about the error.
|
||||||
* @throws SecurityException if the process doesn't hold
|
* @throws SecurityException if the process doesn't hold
|
||||||
* {@link android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}.
|
* {@link android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}.
|
||||||
* @throws UnsupportedOperationException if called on a non-automotive device.
|
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@@ -598,7 +595,7 @@ public class EthernetManager {
|
|||||||
android.Manifest.permission.NETWORK_STACK,
|
android.Manifest.permission.NETWORK_STACK,
|
||||||
android.Manifest.permission.MANAGE_ETHERNET_NETWORKS})
|
android.Manifest.permission.MANAGE_ETHERNET_NETWORKS})
|
||||||
@RequiresFeature(PackageManager.FEATURE_AUTOMOTIVE)
|
@RequiresFeature(PackageManager.FEATURE_AUTOMOTIVE)
|
||||||
public void disconnectNetwork(
|
public void disableInterface(
|
||||||
@NonNull String iface,
|
@NonNull String iface,
|
||||||
@Nullable @CallbackExecutor Executor executor,
|
@Nullable @CallbackExecutor Executor executor,
|
||||||
@Nullable OutcomeReceiver<String, EthernetNetworkManagementException> callback) {
|
@Nullable OutcomeReceiver<String, EthernetNetworkManagementException> callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user