summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:21:49 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:21:49 +0000
commit4ba94bab70bc1f4526b7718491ebe3c1bf17eea1 (patch)
tree48dbb10f5bcf70273982c07fd8b5d12d97a1dd0c
parent086db676e21b019e64bba2e8b87262f6c5354235 (diff)
parent683512d947d6a6dde21c295b692afb76ec69199f (diff)
downloadethernet-android10-mainline-tzdata-release.tar.gz
Change-Id: I79a94becfc7978905a7b565c9d93f9d1c953b39b
-rw-r--r--java/com/android/server/ethernet/EthernetNetworkFactory.java32
-rw-r--r--java/com/android/server/ethernet/EthernetServiceImpl.java9
2 files changed, 14 insertions, 27 deletions
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java
index 3cda13f..b8ed845 100644
--- a/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -21,7 +21,6 @@ import static android.net.shared.LinkPropertiesParcelableUtil.toStableParcelable
import static com.android.internal.util.Preconditions.checkNotNull;
import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.IpConfiguration;
@@ -54,7 +53,6 @@ import com.android.internal.util.IndentingPrintWriter;
import java.io.FileDescriptor;
import java.lang.Math;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.Objects;
/**
* {@link NetworkFactory} that represents Ethernet networks.
@@ -157,7 +155,7 @@ public class EthernetNetworkFactory extends NetworkFactory {
}
NetworkInterfaceState iface = new NetworkInterfaceState(
- ifaceName, hwAddress, mHandler, mContext, capabilities, this);
+ ifaceName, hwAddress, mHandler, mContext, capabilities);
iface.setIpConfig(ipConfiguration);
mTrackingInterfaces.put(ifaceName, iface);
@@ -248,17 +246,16 @@ public class EthernetNetworkFactory extends NetworkFactory {
private final Handler mHandler;
private final Context mContext;
private final NetworkInfo mNetworkInfo;
- private final NetworkFactory mNetworkFactory;
private static String sTcpBufferSizes = null; // Lazy initialized.
private boolean mLinkUp;
private LinkProperties mLinkProperties = new LinkProperties();
- private volatile @Nullable IIpClient mIpClient;
- private @Nullable IpClientCallbacksImpl mIpClientCallback;
- private @Nullable NetworkAgent mNetworkAgent;
- private @Nullable IpConfiguration mIpConfig;
+ private volatile IIpClient mIpClient;
+ private IpClientCallbacksImpl mIpClientCallback;
+ private NetworkAgent mNetworkAgent;
+ private IpConfiguration mIpConfig;
/**
* An object to contain all transport type information, including base network score and
@@ -357,15 +354,13 @@ public class EthernetNetworkFactory extends NetworkFactory {
}
NetworkInterfaceState(String ifaceName, String hwAddress, Handler handler, Context context,
- @NonNull NetworkCapabilities capabilities, NetworkFactory networkFactory) {
+ @NonNull NetworkCapabilities capabilities) {
name = ifaceName;
mCapabilities = checkNotNull(capabilities);
mHandler = handler;
mContext = context;
- mNetworkFactory = networkFactory;
int legacyType = ConnectivityManager.TYPE_NONE;
int[] transportTypes = mCapabilities.getTransportTypes();
-
if (transportTypes.length > 0) {
legacyType = getLegacyType(transportTypes[0]);
} else {
@@ -381,14 +376,7 @@ public class EthernetNetworkFactory extends NetworkFactory {
}
void setIpConfig(IpConfiguration ipConfig) {
- if (Objects.equals(this.mIpConfig, ipConfig)) {
- if (DBG) Log.d(TAG, "ipConfig have not changed,so ignore setIpConfig");
- return;
- }
this.mIpConfig = ipConfig;
- if (mNetworkInfo.getDetailedState() != DetailedState.DISCONNECTED) {
- restart();
- }
}
boolean statisified(NetworkCapabilities requestedCapabilities) {
@@ -474,7 +462,7 @@ public class EthernetNetworkFactory extends NetworkFactory {
// Create our NetworkAgent.
mNetworkAgent = new NetworkAgent(mHandler.getLooper(), mContext,
NETWORK_TYPE, mNetworkInfo, mCapabilities, mLinkProperties,
- getNetworkScore(), mNetworkFactory.getSerialNumber()) {
+ getNetworkScore()) {
public void unwanted() {
if (this == mNetworkAgent) {
stop();
@@ -599,12 +587,6 @@ public class EthernetNetworkFactory extends NetworkFactory {
}
}
- void restart(){
- if (DBG) Log.d(TAG, "reconnecting Etherent");
- stop();
- start();
- }
-
@Override
public String toString() {
return getClass().getSimpleName() + "{ "
diff --git a/java/com/android/server/ethernet/EthernetServiceImpl.java b/java/com/android/server/ethernet/EthernetServiceImpl.java
index fda3c3c..d5beec1 100644
--- a/java/com/android/server/ethernet/EthernetServiceImpl.java
+++ b/java/com/android/server/ethernet/EthernetServiceImpl.java
@@ -21,7 +21,6 @@ import android.content.pm.PackageManager;
import android.net.IEthernetManager;
import android.net.IEthernetServiceListener;
import android.net.IpConfiguration;
-import android.net.NetworkStack;
import android.os.Binder;
import android.os.Handler;
import android.os.HandlerThread;
@@ -58,6 +57,12 @@ public class EthernetServiceImpl extends IEthernetManager.Stub {
"EthernetService");
}
+ private void enforceConnectivityInternalPermission() {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.CONNECTIVITY_INTERNAL,
+ "ConnectivityService");
+ }
+
private void enforceUseRestrictedNetworksPermission() {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS,
@@ -112,7 +117,7 @@ public class EthernetServiceImpl extends IEthernetManager.Stub {
Log.w(TAG, "System isn't ready enough to change ethernet configuration");
}
- NetworkStack.checkNetworkStackPermission(mContext);
+ enforceConnectivityInternalPermission();
if (mTracker.isRestrictedInterface(iface)) {
enforceUseRestrictedNetworksPermission();