Merge "Non-functional code cleanup of ConnectivityService." into m-wireless-dev
This commit is contained in:
@ -821,48 +821,6 @@ public class ConnectivityManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tells each network type to set its radio power state as directed.
|
|
||||||
*
|
|
||||||
* @param turnOn a boolean, {@code true} to turn the radios on,
|
|
||||||
* {@code false} to turn them off.
|
|
||||||
* @return a boolean, {@code true} indicating success. All network types
|
|
||||||
* will be tried, even if some fail.
|
|
||||||
*
|
|
||||||
* <p>This method requires the caller to hold the permission
|
|
||||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
|
||||||
* {@hide}
|
|
||||||
*/
|
|
||||||
// TODO - check for any callers and remove
|
|
||||||
// public boolean setRadios(boolean turnOn) {
|
|
||||||
// try {
|
|
||||||
// return mService.setRadios(turnOn);
|
|
||||||
// } catch (RemoteException e) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tells a given networkType to set its radio power state as directed.
|
|
||||||
*
|
|
||||||
* @param networkType the int networkType of interest.
|
|
||||||
* @param turnOn a boolean, {@code true} to turn the radio on,
|
|
||||||
* {@code} false to turn it off.
|
|
||||||
* @return a boolean, {@code true} indicating success.
|
|
||||||
*
|
|
||||||
* <p>This method requires the caller to hold the permission
|
|
||||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
|
||||||
* {@hide}
|
|
||||||
*/
|
|
||||||
// TODO - check for any callers and remove
|
|
||||||
// public boolean setRadio(int networkType, boolean turnOn) {
|
|
||||||
// try {
|
|
||||||
// return mService.setRadio(networkType, turnOn);
|
|
||||||
// } catch (RemoteException e) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells the underlying networking system that the caller wants to
|
* Tells the underlying networking system that the caller wants to
|
||||||
* begin using the named feature. The interpretation of {@code feature}
|
* begin using the named feature. The interpretation of {@code feature}
|
||||||
|
@ -118,8 +118,6 @@ interface IConnectivityManager
|
|||||||
|
|
||||||
void captivePortalCheckCompleted(in NetworkInfo info, boolean isCaptivePortal);
|
void captivePortalCheckCompleted(in NetworkInfo info, boolean isCaptivePortal);
|
||||||
|
|
||||||
int findConnectionTypeForIface(in String iface);
|
|
||||||
|
|
||||||
int checkMobileProvisioning(int suggestedTimeOutMs);
|
int checkMobileProvisioning(int suggestedTimeOutMs);
|
||||||
|
|
||||||
String getMobileProvisioningUrl();
|
String getMobileProvisioningUrl();
|
||||||
|
@ -721,7 +721,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
info = new NetworkInfo(nai.networkInfo);
|
info = new NetworkInfo(nai.networkInfo);
|
||||||
lp = new LinkProperties(nai.linkProperties);
|
lp = new LinkProperties(nai.linkProperties);
|
||||||
nc = new NetworkCapabilities(nai.networkCapabilities);
|
nc = new NetworkCapabilities(nai.networkCapabilities);
|
||||||
network = new Network(nai.network);
|
// Network objects are outwardly immutable so there is no point to duplicating.
|
||||||
|
// Duplicating also precludes sharing socket factories and connection pools.
|
||||||
|
network = nai.network;
|
||||||
subscriberId = (nai.networkMisc != null) ? nai.networkMisc.subscriberId : null;
|
subscriberId = (nai.networkMisc != null) ? nai.networkMisc.subscriberId : null;
|
||||||
}
|
}
|
||||||
info.setType(networkType);
|
info.setType(networkType);
|
||||||
@ -789,7 +791,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
info = new NetworkInfo(nai.networkInfo);
|
info = new NetworkInfo(nai.networkInfo);
|
||||||
lp = new LinkProperties(nai.linkProperties);
|
lp = new LinkProperties(nai.linkProperties);
|
||||||
nc = new NetworkCapabilities(nai.networkCapabilities);
|
nc = new NetworkCapabilities(nai.networkCapabilities);
|
||||||
network = new Network(nai.network);
|
// Network objects are outwardly immutable so there is no point to duplicating.
|
||||||
|
// Duplicating also precludes sharing socket factories and connection pools.
|
||||||
|
network = nai.network;
|
||||||
subscriberId = (nai.networkMisc != null) ? nai.networkMisc.subscriberId : null;
|
subscriberId = (nai.networkMisc != null) ? nai.networkMisc.subscriberId : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -967,13 +971,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
@Override
|
@Override
|
||||||
public Network[] getAllNetworks() {
|
public Network[] getAllNetworks() {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
final ArrayList<Network> result = new ArrayList();
|
|
||||||
synchronized (mNetworkForNetId) {
|
synchronized (mNetworkForNetId) {
|
||||||
|
final Network[] result = new Network[mNetworkForNetId.size()];
|
||||||
for (int i = 0; i < mNetworkForNetId.size(); i++) {
|
for (int i = 0; i < mNetworkForNetId.size(); i++) {
|
||||||
result.add(new Network(mNetworkForNetId.valueAt(i).network));
|
result[i] = mNetworkForNetId.valueAt(i).network;
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return result.toArray(new Network[result.size()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetworkCapabilities getNetworkCapabilitiesAndValidation(NetworkAgentInfo nai) {
|
private NetworkCapabilities getNetworkCapabilitiesAndValidation(NetworkAgentInfo nai) {
|
||||||
@ -2860,23 +2864,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int findConnectionTypeForIface(String iface) {
|
|
||||||
enforceConnectivityInternalPermission();
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(iface)) return ConnectivityManager.TYPE_NONE;
|
|
||||||
|
|
||||||
synchronized(mNetworkForNetId) {
|
|
||||||
for (int i = 0; i < mNetworkForNetId.size(); i++) {
|
|
||||||
NetworkAgentInfo nai = mNetworkForNetId.valueAt(i);
|
|
||||||
LinkProperties lp = nai.linkProperties;
|
|
||||||
if (lp != null && iface.equals(lp.getInterfaceName()) && nai.networkInfo != null) {
|
|
||||||
return nai.networkInfo.getType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ConnectivityManager.TYPE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int checkMobileProvisioning(int suggestedTimeOutMs) {
|
public int checkMobileProvisioning(int suggestedTimeOutMs) {
|
||||||
// TODO: Remove? Any reason to trigger a provisioning check?
|
// TODO: Remove? Any reason to trigger a provisioning check?
|
||||||
@ -3130,7 +3117,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
loge("Starting user already has a VPN");
|
loge("Starting user already has a VPN");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
userVpn = new Vpn(mHandler.getLooper(), mContext, mNetd, this, userId);
|
userVpn = new Vpn(mHandler.getLooper(), mContext, mNetd, userId);
|
||||||
mVpns.put(userId, userVpn);
|
mVpns.put(userId, userVpn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ import android.os.UserHandle;
|
|||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.security.Credentials;
|
import android.security.Credentials;
|
||||||
import android.security.KeyStore;
|
import android.security.KeyStore;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
@ -114,7 +115,6 @@ public class Vpn {
|
|||||||
private LegacyVpnRunner mLegacyVpnRunner;
|
private LegacyVpnRunner mLegacyVpnRunner;
|
||||||
private PendingIntent mStatusIntent;
|
private PendingIntent mStatusIntent;
|
||||||
private volatile boolean mEnableTeardown = true;
|
private volatile boolean mEnableTeardown = true;
|
||||||
private final IConnectivityManager mConnService;
|
|
||||||
private final INetworkManagementService mNetd;
|
private final INetworkManagementService mNetd;
|
||||||
private VpnConfig mConfig;
|
private VpnConfig mConfig;
|
||||||
private NetworkAgent mNetworkAgent;
|
private NetworkAgent mNetworkAgent;
|
||||||
@ -130,10 +130,9 @@ public class Vpn {
|
|||||||
private final int mUserHandle;
|
private final int mUserHandle;
|
||||||
|
|
||||||
public Vpn(Looper looper, Context context, INetworkManagementService netService,
|
public Vpn(Looper looper, Context context, INetworkManagementService netService,
|
||||||
IConnectivityManager connService, int userHandle) {
|
int userHandle) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mNetd = netService;
|
mNetd = netService;
|
||||||
mConnService = connService;
|
|
||||||
mUserHandle = userHandle;
|
mUserHandle = userHandle;
|
||||||
mLooper = looper;
|
mLooper = looper;
|
||||||
|
|
||||||
@ -1086,11 +1085,15 @@ public class Vpn {
|
|||||||
// registering
|
// registering
|
||||||
mOuterInterface = mConfig.interfaze;
|
mOuterInterface = mConfig.interfaze;
|
||||||
|
|
||||||
try {
|
if (!TextUtils.isEmpty(mOuterInterface)) {
|
||||||
mOuterConnection.set(
|
final ConnectivityManager cm = ConnectivityManager.from(mContext);
|
||||||
mConnService.findConnectionTypeForIface(mOuterInterface));
|
for (Network network : cm.getAllNetworks()) {
|
||||||
} catch (Exception e) {
|
final LinkProperties lp = cm.getLinkProperties(network);
|
||||||
mOuterConnection.set(ConnectivityManager.TYPE_NONE);
|
if (lp != null && mOuterInterface.equals(lp.getInterfaceName())) {
|
||||||
|
final NetworkInfo networkInfo = cm.getNetworkInfo(network);
|
||||||
|
if (networkInfo != null) mOuterConnection.set(networkInfo.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
|
Reference in New Issue
Block a user