Merge changes from topic "railway_stub" am: 9ff27e5802
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1923578 Change-Id: I67b78f551bc24d3fda6f8c55dca618ee62808906
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.net;
|
||||||
|
|
||||||
|
parcelable InternalNetworkManagementException;
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.net;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public final class InternalNetworkManagementException
|
||||||
|
extends RuntimeException implements Parcelable {
|
||||||
|
|
||||||
|
/* @hide */
|
||||||
|
public InternalNetworkManagementException(@NonNull final Throwable t) {
|
||||||
|
super(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
private InternalNetworkManagementException(@NonNull final Parcel source) {
|
||||||
|
super(source.readString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||||
|
dest.writeString(getCause().getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static final Parcelable.Creator<InternalNetworkManagementException> CREATOR =
|
||||||
|
new Parcelable.Creator<InternalNetworkManagementException>() {
|
||||||
|
@Override
|
||||||
|
public InternalNetworkManagementException[] newArray(int size) {
|
||||||
|
return new InternalNetworkManagementException[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InternalNetworkManagementException createFromParcel(@NonNull Parcel source) {
|
||||||
|
return new InternalNetworkManagementException(source);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
19
core/java/android/net/InternalNetworkUpdateRequest.aidl
Normal file
19
core/java/android/net/InternalNetworkUpdateRequest.aidl
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.net;
|
||||||
|
|
||||||
|
parcelable InternalNetworkUpdateRequest;
|
||||||
108
core/java/android/net/InternalNetworkUpdateRequest.java
Normal file
108
core/java/android/net/InternalNetworkUpdateRequest.java
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.net;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public final class InternalNetworkUpdateRequest implements Parcelable {
|
||||||
|
@NonNull
|
||||||
|
private final StaticIpConfiguration mIpConfig;
|
||||||
|
@Nullable
|
||||||
|
private final NetworkCapabilities mNetworkCapabilities;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public StaticIpConfiguration getIpConfig() {
|
||||||
|
return new StaticIpConfiguration(mIpConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public NetworkCapabilities getNetworkCapabilities() {
|
||||||
|
return mNetworkCapabilities == null
|
||||||
|
? null : new NetworkCapabilities(mNetworkCapabilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public InternalNetworkUpdateRequest(@NonNull final StaticIpConfiguration ipConfig,
|
||||||
|
@Nullable final NetworkCapabilities networkCapabilities) {
|
||||||
|
Objects.requireNonNull(ipConfig);
|
||||||
|
mIpConfig = new StaticIpConfiguration(ipConfig);
|
||||||
|
if (null == networkCapabilities) {
|
||||||
|
mNetworkCapabilities = null;
|
||||||
|
} else {
|
||||||
|
mNetworkCapabilities = new NetworkCapabilities(networkCapabilities);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private InternalNetworkUpdateRequest(@NonNull final Parcel source) {
|
||||||
|
Objects.requireNonNull(source);
|
||||||
|
mIpConfig = StaticIpConfiguration.CREATOR.createFromParcel(source);
|
||||||
|
mNetworkCapabilities = NetworkCapabilities.CREATOR.createFromParcel(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InternalNetworkUpdateRequest{"
|
||||||
|
+ "mIpConfig=" + mIpConfig
|
||||||
|
+ ", mNetworkCapabilities=" + mNetworkCapabilities + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
InternalNetworkUpdateRequest that = (InternalNetworkUpdateRequest) o;
|
||||||
|
|
||||||
|
return Objects.equals(that.getIpConfig(), mIpConfig)
|
||||||
|
&& Objects.equals(that.getNetworkCapabilities(), mNetworkCapabilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(mIpConfig, mNetworkCapabilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||||
|
mIpConfig.writeToParcel(dest, flags);
|
||||||
|
mNetworkCapabilities.writeToParcel(dest, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static final Parcelable.Creator<InternalNetworkUpdateRequest> CREATOR =
|
||||||
|
new Parcelable.Creator<InternalNetworkUpdateRequest>() {
|
||||||
|
@Override
|
||||||
|
public InternalNetworkUpdateRequest[] newArray(int size) {
|
||||||
|
return new InternalNetworkUpdateRequest[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InternalNetworkUpdateRequest createFromParcel(@NonNull Parcel source) {
|
||||||
|
return new InternalNetworkUpdateRequest(source);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
|
import android.annotation.CallbackExecutor;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.SystemService;
|
import android.annotation.SystemService;
|
||||||
@@ -32,6 +34,7 @@ import com.android.internal.os.BackgroundThread;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing the IP configuration of the Ethernet network.
|
* A class representing the IP configuration of the Ethernet network.
|
||||||
@@ -315,4 +318,83 @@ public class EthernetManager {
|
|||||||
}
|
}
|
||||||
return new TetheredInterfaceRequest(mService, cbInternal);
|
return new TetheredInterfaceRequest(mService, cbInternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class InternalNetworkManagementListener
|
||||||
|
extends IInternalNetworkManagementListener.Stub {
|
||||||
|
@NonNull
|
||||||
|
private final Executor mExecutor;
|
||||||
|
@NonNull
|
||||||
|
private final BiConsumer<Network, InternalNetworkManagementException> mListener;
|
||||||
|
|
||||||
|
InternalNetworkManagementListener(
|
||||||
|
@NonNull final Executor executor,
|
||||||
|
@NonNull final BiConsumer<Network, InternalNetworkManagementException> listener) {
|
||||||
|
Objects.requireNonNull(executor, "Pass a non-null executor");
|
||||||
|
Objects.requireNonNull(listener, "Pass a non-null listener");
|
||||||
|
mExecutor = executor;
|
||||||
|
mListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete(
|
||||||
|
@Nullable final Network network,
|
||||||
|
@Nullable final InternalNetworkManagementException e) {
|
||||||
|
mExecutor.execute(() -> mListener.accept(network, e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private InternalNetworkManagementListener getInternalNetworkManagementListener(
|
||||||
|
@Nullable final Executor executor,
|
||||||
|
@Nullable final BiConsumer<Network, InternalNetworkManagementException> listener) {
|
||||||
|
if (null != listener) {
|
||||||
|
Objects.requireNonNull(executor, "Pass a non-null executor, or a null listener");
|
||||||
|
}
|
||||||
|
final InternalNetworkManagementListener proxy;
|
||||||
|
if (null == listener) {
|
||||||
|
proxy = null;
|
||||||
|
} else {
|
||||||
|
proxy = new InternalNetworkManagementListener(executor, listener);
|
||||||
|
}
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateConfiguration(
|
||||||
|
@NonNull String iface,
|
||||||
|
@NonNull InternalNetworkUpdateRequest request,
|
||||||
|
@Nullable @CallbackExecutor Executor executor,
|
||||||
|
@Nullable BiConsumer<Network, InternalNetworkManagementException> listener) {
|
||||||
|
final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
|
||||||
|
executor, listener);
|
||||||
|
try {
|
||||||
|
mService.updateConfiguration(iface, request, proxy);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connectNetwork(
|
||||||
|
@NonNull String iface,
|
||||||
|
@Nullable @CallbackExecutor Executor executor,
|
||||||
|
@Nullable BiConsumer<Network, InternalNetworkManagementException> listener) {
|
||||||
|
final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
|
||||||
|
executor, listener);
|
||||||
|
try {
|
||||||
|
mService.connectNetwork(iface, proxy);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disconnectNetwork(
|
||||||
|
@NonNull String iface,
|
||||||
|
@Nullable @CallbackExecutor Executor executor,
|
||||||
|
@Nullable BiConsumer<Network, InternalNetworkManagementException> listener) {
|
||||||
|
final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
|
||||||
|
executor, listener);
|
||||||
|
try {
|
||||||
|
mService.disconnectNetwork(iface, proxy);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package android.net;
|
|||||||
|
|
||||||
import android.net.IpConfiguration;
|
import android.net.IpConfiguration;
|
||||||
import android.net.IEthernetServiceListener;
|
import android.net.IEthernetServiceListener;
|
||||||
|
import android.net.IInternalNetworkManagementListener;
|
||||||
|
import android.net.InternalNetworkUpdateRequest;
|
||||||
import android.net.ITetheredInterfaceCallback;
|
import android.net.ITetheredInterfaceCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,4 +38,8 @@ interface IEthernetManager
|
|||||||
void setIncludeTestInterfaces(boolean include);
|
void setIncludeTestInterfaces(boolean include);
|
||||||
void requestTetheredInterface(in ITetheredInterfaceCallback callback);
|
void requestTetheredInterface(in ITetheredInterfaceCallback callback);
|
||||||
void releaseTetheredInterface(in ITetheredInterfaceCallback callback);
|
void releaseTetheredInterface(in ITetheredInterfaceCallback callback);
|
||||||
|
void updateConfiguration(String iface, in InternalNetworkUpdateRequest request,
|
||||||
|
in IInternalNetworkManagementListener listener);
|
||||||
|
void connectNetwork(String iface, in IInternalNetworkManagementListener listener);
|
||||||
|
void disconnectNetwork(String iface, in IInternalNetworkManagementListener listener);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user