Remove dead code, mostly DataStateTracker.

Change-Id: I1433937bffdb29bd42fb1adbfcf0a50ceffac7dd
This commit is contained in:
Paul Jensen
2014-11-21 09:14:45 -05:00
parent 0992f96246
commit 9edb1fc511
4 changed files with 0 additions and 331 deletions

View File

@@ -1792,25 +1792,6 @@ public class ConnectivityManager {
} }
} }
/**
* Sets a secondary requirement bit for the given networkType.
* This requirement bit is generally under the control of the carrier
* or its agents and is not directly controlled by the user.
*
* @param networkType The network who's dependence has changed
* @param met Boolean - true if network use is OK, false if not
*
* <p>This method requires the call to hold the permission
* {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
* {@hide}
*/
public void setDataDependency(int networkType, boolean met) {
try {
mService.setDataDependency(networkType, met);
} catch (RemoteException e) {
}
}
/** /**
* Returns true if the hardware supports the given network type * Returns true if the hardware supports the given network type
* else it returns false. This doesn't indicate we have coverage * else it returns false. This doesn't indicate we have coverage
@@ -1891,20 +1872,6 @@ public class ConnectivityManager {
} }
} }
/**
* Supply the backend messenger for a network tracker
*
* @param networkType NetworkType to set
* @param messenger {@link Messenger}
* {@hide}
*/
public void supplyMessenger(int networkType, Messenger messenger) {
try {
mService.supplyMessenger(networkType, messenger);
} catch (RemoteException e) {
}
}
/** /**
* Check mobile provisioning. * Check mobile provisioning.
* *

View File

@@ -102,8 +102,6 @@ interface IConnectivityManager
ProxyInfo getDefaultProxy(); ProxyInfo getDefaultProxy();
void setDataDependency(int networkType, boolean met);
boolean prepareVpn(String oldPackage, String newPackage); boolean prepareVpn(String oldPackage, String newPackage);
void setVpnPackageAuthorization(boolean authorized); void setVpnPackageAuthorization(boolean authorized);
@@ -120,8 +118,6 @@ interface IConnectivityManager
void captivePortalCheckCompleted(in NetworkInfo info, boolean isCaptivePortal); void captivePortalCheckCompleted(in NetworkInfo info, boolean isCaptivePortal);
void supplyMessenger(int networkType, in Messenger messenger);
int findConnectionTypeForIface(in String iface); int findConnectionTypeForIface(in String iface);
int checkMobileProvisioning(int suggestedTimeOutMs); int checkMobileProvisioning(int suggestedTimeOutMs);

View File

@@ -48,7 +48,6 @@ import android.net.INetworkPolicyManager;
import android.net.INetworkStatsService; import android.net.INetworkStatsService;
import android.net.LinkProperties; import android.net.LinkProperties;
import android.net.LinkProperties.CompareResult; import android.net.LinkProperties.CompareResult;
import android.net.MobileDataStateTracker;
import android.net.Network; import android.net.Network;
import android.net.NetworkAgent; import android.net.NetworkAgent;
import android.net.NetworkCapabilities; import android.net.NetworkCapabilities;
@@ -59,7 +58,6 @@ import android.net.NetworkMisc;
import android.net.NetworkQuotaInfo; import android.net.NetworkQuotaInfo;
import android.net.NetworkRequest; import android.net.NetworkRequest;
import android.net.NetworkState; import android.net.NetworkState;
import android.net.NetworkStateTracker;
import android.net.NetworkUtils; import android.net.NetworkUtils;
import android.net.Proxy; import android.net.Proxy;
import android.net.ProxyInfo; import android.net.ProxyInfo;
@@ -153,9 +151,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
private static final boolean DBG = true; private static final boolean DBG = true;
private static final boolean VDBG = false; private static final boolean VDBG = false;
// network sampling debugging
private static final boolean SAMPLE_DBG = false;
private static final boolean LOGD_RULES = false; private static final boolean LOGD_RULES = false;
// TODO: create better separation between radio types and network types // TODO: create better separation between radio types and network types
@@ -166,33 +161,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
private static final String NETWORK_RESTORE_DELAY_PROP_NAME = private static final String NETWORK_RESTORE_DELAY_PROP_NAME =
"android.telephony.apn-restore"; "android.telephony.apn-restore";
// Default value if FAIL_FAST_TIME_MS is not set
private static final int DEFAULT_FAIL_FAST_TIME_MS = 1 * 60 * 1000;
// system property that can override DEFAULT_FAIL_FAST_TIME_MS
private static final String FAIL_FAST_TIME_MS =
"persist.radio.fail_fast_time_ms";
private static final String ACTION_PKT_CNT_SAMPLE_INTERVAL_ELAPSED =
"android.net.ConnectivityService.action.PKT_CNT_SAMPLE_INTERVAL_ELAPSED";
private static final int SAMPLE_INTERVAL_ELAPSED_REQUEST_CODE = 0;
// How long to delay to removal of a pending intent based request. // How long to delay to removal of a pending intent based request.
// See Settings.Secure.CONNECTIVITY_RELEASE_PENDING_INTENT_DELAY_MS // See Settings.Secure.CONNECTIVITY_RELEASE_PENDING_INTENT_DELAY_MS
private final int mReleasePendingIntentDelayMs; private final int mReleasePendingIntentDelayMs;
private PendingIntent mSampleIntervalElapsedIntent;
// Set network sampling interval at 12 minutes, this way, even if the timers get
// aggregated, it will fire at around 15 minutes, which should allow us to
// aggregate this timer with other timers (specially the socket keep alive timers)
private static final int DEFAULT_SAMPLING_INTERVAL_IN_SECONDS = (SAMPLE_DBG ? 30 : 12 * 60);
// start network sampling a minute after booting ...
private static final int DEFAULT_START_SAMPLING_INTERVAL_IN_SECONDS = (SAMPLE_DBG ? 30 : 60);
AlarmManager mAlarmManager;
private Tethering mTethering; private Tethering mTethering;
private final PermissionMonitor mPermissionMonitor; private final PermissionMonitor mPermissionMonitor;
@@ -212,13 +184,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
/** Set of ifaces that are costly. */ /** Set of ifaces that are costly. */
private HashSet<String> mMeteredIfaces = Sets.newHashSet(); private HashSet<String> mMeteredIfaces = Sets.newHashSet();
/**
* Sometimes we want to refer to the individual network state
* trackers separately, and sometimes we just want to treat them
* abstractly.
*/
private NetworkStateTracker mNetTrackers[];
private Context mContext; private Context mContext;
private int mNetworkPreference; private int mNetworkPreference;
// 0 is full bad, 100 is full good // 0 is full bad, 100 is full good
@@ -277,28 +242,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
*/ */
private static final int EVENT_APPLY_GLOBAL_HTTP_PROXY = 9; private static final int EVENT_APPLY_GLOBAL_HTTP_PROXY = 9;
/**
* used internally to set external dependency met/unmet
* arg1 = ENABLED (met) or DISABLED (unmet)
* arg2 = NetworkType
*/
private static final int EVENT_SET_DEPENDENCY_MET = 10;
/** /**
* used internally to send a sticky broadcast delayed. * used internally to send a sticky broadcast delayed.
*/ */
private static final int EVENT_SEND_STICKY_BROADCAST_INTENT = 11; private static final int EVENT_SEND_STICKY_BROADCAST_INTENT = 11;
/**
* Used internally to disable fail fast of mobile data
*/
private static final int EVENT_ENABLE_FAIL_FAST_MOBILE_DATA = 14;
/**
* used internally to indicate that data sampling interval is up
*/
private static final int EVENT_SAMPLE_INTERVAL_ELAPSED = 15;
/** /**
* PAC manager has received new port. * PAC manager has received new port.
*/ */
@@ -419,8 +367,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
private DataConnectionStats mDataConnectionStats; private DataConnectionStats mDataConnectionStats;
private AtomicInteger mEnableFailFastMobileDataTag = new AtomicInteger(0);
TelephonyManager mTelephonyManager; TelephonyManager mTelephonyManager;
// sequence number for Networks; keep in sync with system/netd/NetworkController.cpp // sequence number for Networks; keep in sync with system/netd/NetworkController.cpp
@@ -650,9 +596,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
com.android.internal.R.integer.config_networkTransitionTimeout); com.android.internal.R.integer.config_networkTransitionTimeout);
mPendingIntentWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); mPendingIntentWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
mNetTrackers = new NetworkStateTracker[
ConnectivityManager.MAX_NETWORK_TYPE+1];
mNetConfigs = new NetworkConfig[ConnectivityManager.MAX_NETWORK_TYPE+1]; mNetConfigs = new NetworkConfig[ConnectivityManager.MAX_NETWORK_TYPE+1];
// TODO: What is the "correct" way to do determine if this is a wifi only device? // TODO: What is the "correct" way to do determine if this is a wifi only device?
@@ -740,23 +683,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
mDataConnectionStats = new DataConnectionStats(mContext); mDataConnectionStats = new DataConnectionStats(mContext);
mDataConnectionStats.startMonitoring(); mDataConnectionStats.startMonitoring();
mAlarmManager = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_PKT_CNT_SAMPLE_INTERVAL_ELAPSED);
mContext.registerReceiver(
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(ACTION_PKT_CNT_SAMPLE_INTERVAL_ELAPSED)) {
mHandler.sendMessage(mHandler.obtainMessage
(EVENT_SAMPLE_INTERVAL_ELAPSED));
}
}
},
new IntentFilter(filter));
mPacManager = new PacManager(mContext, mHandler, EVENT_PROXY_HAS_CHANGED); mPacManager = new PacManager(mContext, mHandler, EVENT_PROXY_HAS_CHANGED);
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE); mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
@@ -782,15 +708,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
throw new IllegalStateException("No free netIds"); throw new IllegalStateException("No free netIds");
} }
private boolean teardown(NetworkStateTracker netTracker) {
if (netTracker.teardown()) {
netTracker.setTeardownRequested(true);
return true;
} else {
return false;
}
}
private NetworkState getFilteredNetworkState(int networkType, int uid) { private NetworkState getFilteredNetworkState(int networkType, int uid) {
NetworkInfo info = null; NetworkInfo info = null;
LinkProperties lp = null; LinkProperties lp = null;
@@ -1350,22 +1267,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
return true; return true;
} }
public void setDataDependency(int networkType, boolean met) {
enforceConnectivityInternalPermission();
mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_DEPENDENCY_MET,
(met ? ENABLED : DISABLED), networkType));
}
private void handleSetDependencyMet(int networkType, boolean met) {
if (mNetTrackers[networkType] != null) {
if (DBG) {
log("handleSetDependencyMet(" + networkType + ", " + met + ")");
}
mNetTrackers[networkType].setDependencyMet(met);
}
}
private INetworkPolicyListener mPolicyListener = new INetworkPolicyListener.Stub() { private INetworkPolicyListener mPolicyListener = new INetworkPolicyListener.Stub() {
@Override @Override
public void onUidRulesChanged(int uid, int uidRules) { public void onUidRulesChanged(int uid, int uidRules) {
@@ -1406,21 +1307,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (LOGD_RULES) { if (LOGD_RULES) {
log("onRestrictBackgroundChanged(restrictBackground=" + restrictBackground + ")"); log("onRestrictBackgroundChanged(restrictBackground=" + restrictBackground + ")");
} }
// kick off connectivity change broadcast for active network, since
// global background policy change is radical.
// TODO: Dead code; remove.
//
// final int networkType = mActiveDefaultNetwork;
// if (isNetworkTypeValid(networkType)) {
// final NetworkStateTracker tracker = mNetTrackers[networkType];
// if (tracker != null) {
// final NetworkInfo info = tracker.getNetworkInfo();
// if (info != null && info.isConnected()) {
// sendConnectedBroadcast(info);
// }
// }
// }
} }
}; };
@@ -1536,14 +1422,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
void systemReady() { void systemReady() {
// start network sampling ..
Intent intent = new Intent(ACTION_PKT_CNT_SAMPLE_INTERVAL_ELAPSED);
intent.setPackage(mContext.getPackageName());
mSampleIntervalElapsedIntent = PendingIntent.getBroadcast(mContext,
SAMPLE_INTERVAL_ELAPSED_REQUEST_CODE, intent, 0);
setAlarm(DEFAULT_START_SAMPLING_INTERVAL_IN_SECONDS * 1000, mSampleIntervalElapsedIntent);
loadGlobalProxy(); loadGlobalProxy();
synchronized(this) { synchronized(this) {
@@ -2015,66 +1893,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
break; break;
} }
case NetworkStateTracker.EVENT_STATE_CHANGED: {
info = (NetworkInfo) msg.obj;
NetworkInfo.State state = info.getState();
if (VDBG || (state == NetworkInfo.State.CONNECTED) ||
(state == NetworkInfo.State.DISCONNECTED) ||
(state == NetworkInfo.State.SUSPENDED)) {
log("ConnectivityChange for " +
info.getTypeName() + ": " +
state + "/" + info.getDetailedState());
}
EventLogTags.writeConnectivityStateChanged(
info.getType(), info.getSubtype(), info.getDetailedState().ordinal());
if (info.isConnectedToProvisioningNetwork()) {
/**
* TODO: Create ConnectivityManager.TYPE_MOBILE_PROVISIONING
* for now its an in between network, its a network that
* is actually a default network but we don't want it to be
* announced as such to keep background applications from
* trying to use it. It turns out that some still try so we
* take the additional step of clearing any default routes
* to the link that may have incorrectly setup by the lower
* levels.
*/
LinkProperties lp = getLinkPropertiesForType(info.getType());
if (DBG) {
log("EVENT_STATE_CHANGED: connected to provisioning network, lp=" + lp);
}
// Clear any default routes setup by the radio so
// any activity by applications trying to use this
// connection will fail until the provisioning network
// is enabled.
/*
for (RouteInfo r : lp.getRoutes()) {
removeRoute(lp, r, TO_DEFAULT_TABLE,
mNetTrackers[info.getType()].getNetwork().netId);
}
*/
} else if (state == NetworkInfo.State.DISCONNECTED) {
} else if (state == NetworkInfo.State.SUSPENDED) {
} else if (state == NetworkInfo.State.CONNECTED) {
// handleConnect(info);
}
notifyLockdownVpn(null);
break;
}
case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED: {
info = (NetworkInfo) msg.obj;
// TODO: Temporary allowing network configuration
// change not resetting sockets.
// @see bug/4455071
/*
handleConnectivityChange(info.getType(), mCurrentLinkProperties[info.getType()],
false);
*/
break;
}
} }
} }
} }
@@ -2439,34 +2257,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
handleDeprecatedGlobalHttpProxy(); handleDeprecatedGlobalHttpProxy();
break; break;
} }
case EVENT_SET_DEPENDENCY_MET: {
boolean met = (msg.arg1 == ENABLED);
handleSetDependencyMet(msg.arg2, met);
break;
}
case EVENT_SEND_STICKY_BROADCAST_INTENT: { case EVENT_SEND_STICKY_BROADCAST_INTENT: {
Intent intent = (Intent)msg.obj; Intent intent = (Intent)msg.obj;
sendStickyBroadcast(intent); sendStickyBroadcast(intent);
break; break;
} }
case EVENT_ENABLE_FAIL_FAST_MOBILE_DATA: {
int tag = mEnableFailFastMobileDataTag.get();
if (msg.arg1 == tag) {
MobileDataStateTracker mobileDst =
(MobileDataStateTracker) mNetTrackers[ConnectivityManager.TYPE_MOBILE];
if (mobileDst != null) {
mobileDst.setEnableFailFastMobileData(msg.arg2);
}
} else {
log("EVENT_ENABLE_FAIL_FAST_MOBILE_DATA: stale arg1:" + msg.arg1
+ " != tag:" + tag);
}
break;
}
case EVENT_SAMPLE_INTERVAL_ELAPSED: {
handleNetworkSamplingTimeout();
break;
}
case EVENT_PROXY_HAS_CHANGED: { case EVENT_PROXY_HAS_CHANGED: {
handleApplyDefaultProxy((ProxyInfo)msg.obj); handleApplyDefaultProxy((ProxyInfo)msg.obj);
break; break;
@@ -3066,14 +2861,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
} }
public void supplyMessenger(int networkType, Messenger messenger) {
enforceConnectivityInternalPermission();
if (isNetworkTypeValid(networkType) && mNetTrackers[networkType] != null) {
mNetTrackers[networkType].supplyMessenger(messenger);
}
}
public int findConnectionTypeForIface(String iface) { public int findConnectionTypeForIface(String iface) {
enforceConnectivityInternalPermission(); enforceConnectivityInternalPermission();
@@ -3091,23 +2878,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
return ConnectivityManager.TYPE_NONE; return ConnectivityManager.TYPE_NONE;
} }
/**
* Have mobile data fail fast if enabled.
*
* @param enabled DctConstants.ENABLED/DISABLED
*/
private void setEnableFailFastMobileData(int enabled) {
int tag;
if (enabled == DctConstants.ENABLED) {
tag = mEnableFailFastMobileDataTag.incrementAndGet();
} else {
tag = mEnableFailFastMobileDataTag.get();
}
mHandler.sendMessage(mHandler.obtainMessage(EVENT_ENABLE_FAIL_FAST_MOBILE_DATA, tag,
enabled));
}
@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?
@@ -3392,69 +3162,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
}; };
/* Infrastructure for network sampling */
private void handleNetworkSamplingTimeout() {
if (SAMPLE_DBG) log("Sampling interval elapsed, updating statistics ..");
// initialize list of interfaces ..
Map<String, SamplingDataTracker.SamplingSnapshot> mapIfaceToSample =
new HashMap<String, SamplingDataTracker.SamplingSnapshot>();
for (NetworkStateTracker tracker : mNetTrackers) {
if (tracker != null) {
String ifaceName = tracker.getNetworkInterfaceName();
if (ifaceName != null) {
mapIfaceToSample.put(ifaceName, null);
}
}
}
// Read samples for all interfaces
SamplingDataTracker.getSamplingSnapshots(mapIfaceToSample);
// process samples for all networks
for (NetworkStateTracker tracker : mNetTrackers) {
if (tracker != null) {
String ifaceName = tracker.getNetworkInterfaceName();
SamplingDataTracker.SamplingSnapshot ss = mapIfaceToSample.get(ifaceName);
if (ss != null) {
// end the previous sampling cycle
tracker.stopSampling(ss);
// start a new sampling cycle ..
tracker.startSampling(ss);
}
}
}
if (SAMPLE_DBG) log("Done.");
int samplingIntervalInSeconds = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.CONNECTIVITY_SAMPLING_INTERVAL_IN_SECONDS,
DEFAULT_SAMPLING_INTERVAL_IN_SECONDS);
if (SAMPLE_DBG) {
log("Setting timer for " + String.valueOf(samplingIntervalInSeconds) + "seconds");
}
setAlarm(samplingIntervalInSeconds * 1000, mSampleIntervalElapsedIntent);
}
/**
* Sets a network sampling alarm.
*/
void setAlarm(int timeoutInMilliseconds, PendingIntent intent) {
long wakeupTime = SystemClock.elapsedRealtime() + timeoutInMilliseconds;
int alarmType;
if (Resources.getSystem().getBoolean(
R.bool.config_networkSamplingWakesDevice)) {
alarmType = AlarmManager.ELAPSED_REALTIME_WAKEUP;
} else {
alarmType = AlarmManager.ELAPSED_REALTIME;
}
mAlarmManager.set(alarmType, wakeupTime, intent);
}
private final HashMap<Messenger, NetworkFactoryInfo> mNetworkFactoryInfos = private final HashMap<Messenger, NetworkFactoryInfo> mNetworkFactoryInfos =
new HashMap<Messenger, NetworkFactoryInfo>(); new HashMap<Messenger, NetworkFactoryInfo>();
private final HashMap<NetworkRequest, NetworkRequestInfo> mNetworkRequests = private final HashMap<NetworkRequest, NetworkRequestInfo> mNetworkRequests =

View File

@@ -20,7 +20,6 @@ import static android.net.ConnectivityManager.CONNECTIVITY_ACTION_IMMEDIATE;
import static android.net.ConnectivityManager.TYPE_MOBILE; import static android.net.ConnectivityManager.TYPE_MOBILE;
import static android.net.ConnectivityManager.TYPE_WIFI; import static android.net.ConnectivityManager.TYPE_WIFI;
import static android.net.ConnectivityManager.getNetworkTypeName; import static android.net.ConnectivityManager.getNetworkTypeName;
import static android.net.NetworkStateTracker.EVENT_STATE_CHANGED;
import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isA; import static org.mockito.Matchers.isA;