diff options
Diffstat (limited to 'services')
3 files changed, 191 insertions, 148 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index b1552a8..9bc7a9f 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -28,11 +28,13 @@ import android.net.EthernetDataTracker; import android.net.IConnectivityManager; import android.net.LinkProperties; import android.net.MobileDataStateTracker; +import android.net.NetworkConfig; import android.net.NetworkInfo; import android.net.NetworkStateTracker; import android.net.NetworkUtils; import android.net.Proxy; import android.net.ProxyProperties; +import android.net.RouteInfo; import android.net.vpn.VpnManager; import android.net.wifi.WifiStateTracker; import android.os.Binder; @@ -79,6 +81,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { private static final String NETWORK_RESTORE_DELAY_PROP_NAME = "android.telephony.apn-restore"; + // used in recursive route setting to add gateways for the host for which + // a host route was requested. + private static final int MAX_HOSTROUTE_CYCLE_COUNT = 10; + private Tethering mTethering; private boolean mTetheringConfigValid = false; @@ -189,6 +195,14 @@ public class ConnectivityService extends IConnectivityManager.Stub { private static final int EVENT_APPLY_GLOBAL_HTTP_PROXY = MAX_NETWORK_STATE_TRACKER_EVENT + 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 = + MAX_NETWORK_STATE_TRACKER_EVENT + 10; + private Handler mHandler; // list of DeathRecipients used to make sure features are turned off when @@ -217,28 +231,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { private SettingsObserver mSettingsObserver; - private static class NetworkAttributes { - /** - * Class for holding settings read from resources. - */ - public String mName; - public int mType; - public int mRadio; - public int mPriority; - public NetworkInfo.State mLastState; - public NetworkAttributes(String init) { - String fragments[] = init.split(","); - mName = fragments[0].toLowerCase(); - mType = Integer.parseInt(fragments[1]); - mRadio = Integer.parseInt(fragments[2]); - mPriority = Integer.parseInt(fragments[3]); - mLastState = NetworkInfo.State.UNKNOWN; - } - public boolean isDefault() { - return (mType == mRadio); - } - } - NetworkAttributes[] mNetAttributes; + NetworkConfig[] mNetConfigs; int mNetworksDefined; private static class RadioAttributes { @@ -305,7 +298,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { mNetworkPreference = getPersistedNetworkPreference(); mRadioAttributes = new RadioAttributes[ConnectivityManager.MAX_RADIO_TYPE+1]; - mNetAttributes = new NetworkAttributes[ConnectivityManager.MAX_NETWORK_TYPE+1]; + mNetConfigs = new NetworkConfig[ConnectivityManager.MAX_NETWORK_TYPE+1]; // Load device network attributes from resources String[] raStrings = context.getResources().getStringArray( @@ -328,23 +321,23 @@ public class ConnectivityService extends IConnectivityManager.Stub { com.android.internal.R.array.networkAttributes); for (String naString : naStrings) { try { - NetworkAttributes n = new NetworkAttributes(naString); - if (n.mType > ConnectivityManager.MAX_NETWORK_TYPE) { + NetworkConfig n = new NetworkConfig(naString); + if (n.type > ConnectivityManager.MAX_NETWORK_TYPE) { loge("Error in networkAttributes - ignoring attempt to define type " + - n.mType); + n.type); continue; } - if (mNetAttributes[n.mType] != null) { + if (mNetConfigs[n.type] != null) { loge("Error in networkAttributes - ignoring attempt to redefine type " + - n.mType); + n.type); continue; } - if (mRadioAttributes[n.mRadio] == null) { + if (mRadioAttributes[n.radio] == null) { loge("Error in networkAttributes - ignoring attempt to use undefined " + - "radio " + n.mRadio + " in network type " + n.mType); + "radio " + n.radio + " in network type " + n.type); continue; } - mNetAttributes[n.mType] = n; + mNetConfigs[n.type] = n; mNetworksDefined++; } catch(Exception e) { // ignore it - leave the entry null @@ -358,16 +351,16 @@ public class ConnectivityService extends IConnectivityManager.Stub { int currentLowest = 0; int nextLowest = 0; while (insertionPoint > -1) { - for (NetworkAttributes na : mNetAttributes) { + for (NetworkConfig na : mNetConfigs) { if (na == null) continue; - if (na.mPriority < currentLowest) continue; - if (na.mPriority > currentLowest) { - if (na.mPriority < nextLowest || nextLowest == 0) { - nextLowest = na.mPriority; + if (na.priority < currentLowest) continue; + if (na.priority > currentLowest) { + if (na.priority < nextLowest || nextLowest == 0) { + nextLowest = na.priority; } continue; } - mPriorityList[insertionPoint--] = na.mType; + mPriorityList[insertionPoint--] = na.type; } currentLowest = nextLowest; nextLowest = 0; @@ -393,7 +386,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { * to change very often. */ for (int netType : mPriorityList) { - switch (mNetAttributes[netType].mRadio) { + switch (mNetConfigs[netType].radio) { case ConnectivityManager.TYPE_WIFI: if (DBG) log("Starting Wifi Service."); WifiStateTracker wst = new WifiStateTracker(); @@ -409,12 +402,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { break; case ConnectivityManager.TYPE_MOBILE: mNetTrackers[netType] = new MobileDataStateTracker(netType, - mNetAttributes[netType].mName); + mNetConfigs[netType].name); mNetTrackers[netType].startMonitoring(context, mHandler); break; case ConnectivityManager.TYPE_DUMMY: mNetTrackers[netType] = new DummyDataStateTracker(netType, - mNetAttributes[netType].mName); + mNetConfigs[netType].name); mNetTrackers[netType].startMonitoring(context, mHandler); break; case ConnectivityManager.TYPE_BLUETOOTH: @@ -427,7 +420,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { break; default: loge("Trying to create a DataStateTracker for an unknown radio type " + - mNetAttributes[netType].mRadio); + mNetConfigs[netType].radio); continue; } } @@ -474,8 +467,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void handleSetNetworkPreference(int preference) { if (ConnectivityManager.isNetworkTypeValid(preference) && - mNetAttributes[preference] != null && - mNetAttributes[preference].isDefault()) { + mNetConfigs[preference] != null && + mNetConfigs[preference].isDefault()) { if (mNetworkPreference != preference) { final ContentResolver cr = mContext.getContentResolver(); Settings.Secure.putInt(cr, Settings.Secure.NETWORK_PREFERENCE, preference); @@ -544,7 +537,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { public NetworkInfo getActiveNetworkInfo() { enforceAccessPermission(); for (int type=0; type <= ConnectivityManager.MAX_NETWORK_TYPE; type++) { - if (mNetAttributes[type] == null || !mNetAttributes[type].isDefault()) { + if (mNetConfigs[type] == null || !mNetConfigs[type].isDefault()) { continue; } NetworkStateTracker t = mNetTrackers[type]; @@ -590,7 +583,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { public LinkProperties getActiveLinkProperties() { enforceAccessPermission(); for (int type=0; type <= ConnectivityManager.MAX_NETWORK_TYPE; type++) { - if (mNetAttributes[type] == null || !mNetAttributes[type].isDefault()) { + if (mNetConfigs[type] == null || !mNetConfigs[type].isDefault()) { continue; } NetworkStateTracker t = mNetTrackers[type]; @@ -692,7 +685,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } enforceChangePermission(); if (!ConnectivityManager.isNetworkTypeValid(networkType) || - mNetAttributes[networkType] == null) { + mNetConfigs[networkType] == null) { return Phone.APN_REQUEST_FAILED; } @@ -701,15 +694,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { // TODO - move this into the MobileDataStateTracker int usedNetworkType = networkType; if(networkType == ConnectivityManager.TYPE_MOBILE) { - if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_MMS)) { - usedNetworkType = ConnectivityManager.TYPE_MOBILE_MMS; - } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_SUPL)) { - usedNetworkType = ConnectivityManager.TYPE_MOBILE_SUPL; - } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN) || - TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN_ALWAYS)) { - usedNetworkType = ConnectivityManager.TYPE_MOBILE_DUN; - } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_HIPRI)) { - usedNetworkType = ConnectivityManager.TYPE_MOBILE_HIPRI; + usedNetworkType = convertFeatureToNetworkType(feature); + if (usedNetworkType < 0) { + Slog.e(TAG, "Can't match any netTracker!"); + usedNetworkType = networkType; } } NetworkStateTracker network = mNetTrackers[usedNetworkType]; @@ -735,9 +723,13 @@ public class ConnectivityService extends IConnectivityManager.Stub { mNetRequestersPids[usedNetworkType].add(currentPid); } } - mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_RESTORE_DEFAULT_NETWORK, - f), getRestoreDefaultNetworkDelay()); + int restoreTimer = getRestoreDefaultNetworkDelay(usedNetworkType); + + if (restoreTimer >= 0) { + mHandler.sendMessageDelayed( + mHandler.obtainMessage(EVENT_RESTORE_DEFAULT_NETWORK, f), restoreTimer); + } if ((ni.isConnectedOrConnecting() == true) && !network.isTeardownRequested()) { @@ -853,15 +845,9 @@ public class ConnectivityService extends IConnectivityManager.Stub { // TODO - move to MobileDataStateTracker int usedNetworkType = networkType; if (networkType == ConnectivityManager.TYPE_MOBILE) { - if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_MMS)) { - usedNetworkType = ConnectivityManager.TYPE_MOBILE_MMS; - } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_SUPL)) { - usedNetworkType = ConnectivityManager.TYPE_MOBILE_SUPL; - } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN) || - TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN_ALWAYS)) { - usedNetworkType = ConnectivityManager.TYPE_MOBILE_DUN; - } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_HIPRI)) { - usedNetworkType = ConnectivityManager.TYPE_MOBILE_HIPRI; + usedNetworkType = convertFeatureToNetworkType(feature); + if (usedNetworkType < 0) { + usedNetworkType = networkType; } } tracker = mNetTrackers[usedNetworkType]; @@ -939,7 +925,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } try { InetAddress addr = InetAddress.getByAddress(hostAddress); - return addHostRoute(tracker, addr); + return addHostRoute(tracker, addr, 0); } catch (UnknownHostException e) {} return false; } @@ -952,24 +938,45 @@ public class ConnectivityService extends IConnectivityManager.Stub { * TODO - deprecate * @return {@code true} on success, {@code false} on failure */ - private boolean addHostRoute(NetworkStateTracker nt, InetAddress hostAddress) { + private boolean addHostRoute(NetworkStateTracker nt, InetAddress hostAddress, int cycleCount) { if (nt.getNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI) { return false; } - LinkProperties p = nt.getLinkProperties(); - if (p == null) return false; - String interfaceName = p.getInterfaceName(); + LinkProperties lp = nt.getLinkProperties(); + if ((lp == null) || (hostAddress == null)) return false; + String interfaceName = lp.getInterfaceName(); if (DBG) { - log("Requested host route to " + hostAddress + "(" + interfaceName + ")"); + log("Requested host route to " + hostAddress + "(" + interfaceName + "), cycleCount=" + + cycleCount); } - if (interfaceName != null) { - return NetworkUtils.addHostRoute(interfaceName, hostAddress, null); - } else { + if (interfaceName == null) { if (DBG) loge("addHostRoute failed due to null interface name"); return false; } + + RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getRoutes(), hostAddress); + InetAddress gateway = null; + if (bestRoute != null) { + gateway = bestRoute.getGateway(); + // if the best route is ourself, don't relf-reference, just add the host route + if (hostAddress.equals(gateway)) gateway = null; + } + if (gateway != null) { + if (cycleCount > MAX_HOSTROUTE_CYCLE_COUNT) { + loge("Error adding hostroute - too much recursion"); + return false; + } + if (!addHostRoute(nt, gateway, cycleCount+1)) return false; + } + return NetworkUtils.addHostRoute(interfaceName, hostAddress, gateway); + } + + // TODO support the removal of single host routes. Keep a ref count of them so we + // aren't over-zealous + private boolean removeHostRoute(NetworkStateTracker nt, InetAddress hostAddress) { + return false; } /** @@ -1015,6 +1022,24 @@ public class ConnectivityService extends IConnectivityManager.Stub { return retVal; } + public void setDataDependency(int networkType, boolean met) { + enforceChangePermission(); + if (DBG) { + log("setDataDependency(" + networkType + ", " + met + ")"); + } + 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); + } + } + /** * @see ConnectivityManager#setMobileDataEnabled(boolean) */ @@ -1023,7 +1048,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (DBG) log("setMobileDataEnabled(" + enabled + ")"); mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_MOBILE_DATA, - (enabled ? ENABLED : DISABLED), 0)); + (enabled ? ENABLED : DISABLED), 0)); } private void handleSetMobileData(boolean enabled) { @@ -1084,7 +1109,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { * getting the disconnect for a network that we explicitly disabled * in accordance with network preference policies. */ - if (!mNetAttributes[prevNetType].isDefault()) { + if (!mNetConfigs[prevNetType].isDefault()) { List pids = mNetRequestersPids[prevNetType]; for (int i = 0; i<pids.size(); i++) { Integer pid = (Integer)pids.get(i); @@ -1109,7 +1134,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { info.getExtraInfo()); } - if (mNetAttributes[prevNetType].isDefault()) { + if (mNetConfigs[prevNetType].isDefault()) { tryFailover(prevNetType); if (mActiveDefaultNetwork != -1) { NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo(); @@ -1139,7 +1164,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { * Try to reconnect on all available and let them hash it out when * more than one connects. */ - if (mNetAttributes[prevNetType].isDefault()) { + if (mNetConfigs[prevNetType].isDefault()) { if (mActiveDefaultNetwork == prevNetType) { mActiveDefaultNetwork = -1; } @@ -1149,12 +1174,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { // TODO - don't filter by priority now - nice optimization but risky // int currentPriority = -1; // if (mActiveDefaultNetwork != -1) { -// currentPriority = mNetAttributes[mActiveDefaultNetwork].mPriority; +// currentPriority = mNetConfigs[mActiveDefaultNetwork].mPriority; // } for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) { if (checkType == prevNetType) continue; - if (mNetAttributes[checkType] == null) continue; - if (!mNetAttributes[checkType].isDefault()) continue; + if (mNetConfigs[checkType] == null) continue; + if (!mNetConfigs[checkType].isDefault()) continue; // Enabling the isAvailable() optimization caused mobile to not get // selected if it was in the middle of error handling. Specifically @@ -1166,7 +1191,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { // complete before it is really complete. // if (!mNetTrackers[checkType].isAvailable()) continue; -// if (currentPriority >= mNetAttributes[checkType].mPriority) continue; +// if (currentPriority >= mNetConfigs[checkType].mPriority) continue; NetworkStateTracker checkTracker = mNetTrackers[checkType]; NetworkInfo checkInfo = checkTracker.getNetworkInfo(); @@ -1239,7 +1264,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { info.setFailover(false); } - if (mNetAttributes[info.getType()].isDefault()) { + if (mNetConfigs[info.getType()].isDefault()) { tryFailover(info.getType()); if (mActiveDefaultNetwork != -1) { NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo(); @@ -1292,11 +1317,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { // if this is a default net and other default is running // kill the one not preferred - if (mNetAttributes[type].isDefault()) { + if (mNetConfigs[type].isDefault()) { if (mActiveDefaultNetwork != -1 && mActiveDefaultNetwork != type) { if ((type != mNetworkPreference && - mNetAttributes[mActiveDefaultNetwork].mPriority > - mNetAttributes[type].mPriority) || + mNetConfigs[mActiveDefaultNetwork].priority > + mNetConfigs[type].priority) || mNetworkPreference == mActiveDefaultNetwork) { // don't accept this one if (DBG) { @@ -1360,14 +1385,14 @@ public class ConnectivityService extends IConnectivityManager.Stub { handleDnsConfigurationChange(netType); if (mNetTrackers[netType].getNetworkInfo().isConnected()) { - if (mNetAttributes[netType].isDefault()) { + if (mNetConfigs[netType].isDefault()) { handleApplyDefaultProxy(netType); addDefaultRoute(mNetTrackers[netType]); } else { addPrivateDnsRoutes(mNetTrackers[netType]); } } else { - if (mNetAttributes[netType].isDefault()) { + if (mNetConfigs[netType].isDefault()) { removeDefaultRoute(mNetTrackers[netType]); } else { removePrivateDnsRoutes(mNetTrackers[netType]); @@ -1389,7 +1414,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { Collection<InetAddress> dnsList = p.getDnses(); for (InetAddress dns : dnsList) { if (DBG) log(" adding " + dns); - NetworkUtils.addHostRoute(interfaceName, dns, null); + addHostRoute(nt, dns, 0); } nt.privateDnsRouteSet(true); } @@ -1418,14 +1443,19 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (p == null) return; String interfaceName = p.getInterfaceName(); if (TextUtils.isEmpty(interfaceName)) return; - for (InetAddress gateway : p.getGateways()) { + for (RouteInfo route : p.getRoutes()) { - if (NetworkUtils.addHostRoute(interfaceName, gateway, null) && - NetworkUtils.addDefaultRoute(interfaceName, gateway)) { - if (DBG) { - NetworkInfo networkInfo = nt.getNetworkInfo(); - log("addDefaultRoute for " + networkInfo.getTypeName() + - " (" + interfaceName + "), GatewayAddr=" + gateway.getHostAddress()); + //TODO - handle non-default routes + if (route.isDefaultRoute()) { + InetAddress gateway = route.getGateway(); + if (addHostRoute(nt, gateway, 0) && + NetworkUtils.addDefaultRoute(interfaceName, gateway)) { + if (DBG) { + NetworkInfo networkInfo = nt.getNetworkInfo(); + log("addDefaultRoute for " + networkInfo.getTypeName() + + " (" + interfaceName + "), GatewayAddr=" + + gateway.getHostAddress()); + } } } } @@ -1528,7 +1558,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { { if (DBG) log("reassessPidDns for pid " + myPid); for(int i : mPriorityList) { - if (mNetAttributes[i].isDefault()) { + if (mNetConfigs[i].isDefault()) { continue; } NetworkStateTracker nt = mNetTrackers[i]; @@ -1610,7 +1640,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (p == null) return; Collection<InetAddress> dnses = p.getDnses(); boolean changed = false; - if (mNetAttributes[netType].isDefault()) { + if (mNetConfigs[netType].isDefault()) { int j = 1; if (dnses.size() == 0 && mDefaultDns != null) { String dnsString = mDefaultDns.getHostAddress(); @@ -1657,7 +1687,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } - private int getRestoreDefaultNetworkDelay() { + private int getRestoreDefaultNetworkDelay(int networkType) { String restoreDefaultNetworkDelayStr = SystemProperties.get( NETWORK_RESTORE_DELAY_PROP_NAME); if(restoreDefaultNetworkDelayStr != null && @@ -1667,7 +1697,14 @@ public class ConnectivityService extends IConnectivityManager.Stub { } catch (NumberFormatException e) { } } - return RESTORE_DEFAULT_NETWORK_DELAY; + // if the system property isn't set, use the value for the apn type + int ret = RESTORE_DEFAULT_NETWORK_DELAY; + + if ((networkType <= ConnectivityManager.MAX_NETWORK_TYPE) && + (mNetConfigs[networkType] != null)) { + ret = mNetConfigs[networkType].restoreTime; + } + return ret; } @Override @@ -1741,23 +1778,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { info = (NetworkInfo) msg.obj; int type = info.getType(); NetworkInfo.State state = info.getState(); - // only do this optimization for wifi. It going into scan mode for location - // services generates alot of noise. Meanwhile the mms apn won't send out - // subsequent notifications when on default cellular because it never - // disconnects.. so only do this to wifi notifications. Fixed better when the - // APN notifications are standardized. - if (mNetAttributes[type].mLastState == state && - mNetAttributes[type].mRadio == ConnectivityManager.TYPE_WIFI) { - if (DBG) { - // TODO - remove this after we validate the dropping doesn't break - // anything - log("Dropping ConnectivityChange for " + - info.getTypeName() + ": " + - state + "/" + info.getDetailedState()); - } - return; - } - mNetAttributes[type].mLastState = state; if (DBG) log("ConnectivityChange for " + info.getTypeName() + ": " + @@ -1796,8 +1816,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { break; case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED: info = (NetworkInfo) msg.obj; - type = info.getType(); - handleConnectivityChange(type); + handleConnectivityChange(info.getType()); break; case EVENT_CLEAR_NET_TRANSITION_WAKELOCK: String causedBy = null; @@ -1851,6 +1870,13 @@ public class ConnectivityService extends IConnectivityManager.Stub { case EVENT_APPLY_GLOBAL_HTTP_PROXY: { handleDeprecatedGlobalHttpProxy(); + break; + } + case EVENT_SET_DEPENDENCY_MET: + { + boolean met = (msg.arg1 == ENABLED); + handleSetDependencyMet(msg.arg2, met); + break; } } } @@ -2184,4 +2210,24 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void loge(String s) { Slog.e(TAG, s); } + int convertFeatureToNetworkType(String feature){ + int networkType = -1; + if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_MMS)) { + networkType = ConnectivityManager.TYPE_MOBILE_MMS; + } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_SUPL)) { + networkType = ConnectivityManager.TYPE_MOBILE_SUPL; + } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN) || + TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN_ALWAYS)) { + networkType = ConnectivityManager.TYPE_MOBILE_DUN; + } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_HIPRI)) { + networkType = ConnectivityManager.TYPE_MOBILE_HIPRI; + } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_FOTA)) { + networkType = ConnectivityManager.TYPE_MOBILE_FOTA; + } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_IMS)) { + networkType = ConnectivityManager.TYPE_MOBILE_IMS; + } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_CBS)) { + networkType = ConnectivityManager.TYPE_MOBILE_CBS; + } + return networkType; + } } diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java index eb14180..a8d40b7 100644 --- a/services/java/com/android/server/TelephonyRegistry.java +++ b/services/java/com/android/server/TelephonyRegistry.java @@ -546,7 +546,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); - intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); Bundle data = new Bundle(); state.fillInNotifierBundle(data); intent.putExtras(data); @@ -586,7 +585,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); - intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertCallState(state).toString()); if (!TextUtils.isEmpty(incomingNumber)) { intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber); @@ -602,7 +600,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { // status bar takes care of that after taking into account all of the // required info. Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); - intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertDataState(state).toString()); if (!isDataConnectivityPossible) { intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY, true); @@ -627,7 +624,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private void broadcastDataConnectionFailed(String reason, String apnType) { Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED); - intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.putExtra(Phone.FAILURE_REASON_KEY, reason); intent.putExtra(Phone.DATA_APN_TYPE_KEY, apnType); mContext.sendStickyBroadcast(intent); diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java index 5853696..9ff5233 100644 --- a/services/java/com/android/server/connectivity/Tethering.java +++ b/services/java/com/android/server/connectivity/Tethering.java @@ -49,8 +49,9 @@ import android.provider.Settings; import android.util.Log; import com.android.internal.telephony.Phone; -import com.android.internal.util.HierarchicalState; -import com.android.internal.util.HierarchicalStateMachine; +import com.android.internal.util.IState; +import com.android.internal.util.State; +import com.android.internal.util.StateMachine; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -122,7 +123,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { // resampled each time we turn on tethering - used as cache for settings/config-val private boolean mDunRequired; // configuration info - must use DUN apn on 3g - private HierarchicalStateMachine mTetherMasterSM; + private StateMachine mTetherMasterSM; private Notification mTetheredNotification; @@ -668,7 +669,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } - class TetherInterfaceSM extends HierarchicalStateMachine { + class TetherInterfaceSM extends StateMachine { // notification from the master SM that it's not in tether mode static final int CMD_TETHER_MODE_DEAD = 1; // request from the user that it wants to tether @@ -694,13 +695,13 @@ public class Tethering extends INetworkManagementEventObserver.Stub { // the upstream connection has changed static final int CMD_TETHER_CONNECTION_CHANGED = 12; - private HierarchicalState mDefaultState; + private State mDefaultState; - private HierarchicalState mInitialState; - private HierarchicalState mStartingState; - private HierarchicalState mTetheredState; + private State mInitialState; + private State mStartingState; + private State mTetheredState; - private HierarchicalState mUnavailableState; + private State mUnavailableState; private boolean mAvailable; private boolean mTethered; @@ -732,7 +733,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { public String toString() { String res = new String(); res += mIfaceName + " - "; - HierarchicalState current = getCurrentState(); + IState current = getCurrentState(); if (current == mInitialState) res += "InitialState"; if (current == mStartingState) res += "StartingState"; if (current == mTetheredState) res += "TetheredState"; @@ -782,7 +783,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { return (mLastError != ConnectivityManager.TETHER_ERROR_NO_ERROR); } - class InitialState extends HierarchicalState { + class InitialState extends State { @Override public void enter() { setAvailable(true); @@ -812,7 +813,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } } - class StartingState extends HierarchicalState { + class StartingState extends State { @Override public void enter() { setAvailable(false); @@ -870,7 +871,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } } - class TetheredState extends HierarchicalState { + class TetheredState extends State { @Override public void enter() { IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); @@ -1034,7 +1035,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } } - class UnavailableState extends HierarchicalState { + class UnavailableState extends State { @Override public void enter() { setAvailable(false); @@ -1064,7 +1065,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } - class TetherMasterSM extends HierarchicalStateMachine { + class TetherMasterSM extends StateMachine { // an interface SM has requested Tethering static final int CMD_TETHER_MODE_REQUESTED = 1; // an interface SM has unrequested Tethering @@ -1082,14 +1083,14 @@ public class Tethering extends INetworkManagementEventObserver.Stub { // We do not flush the old ones. private int mSequenceNumber; - private HierarchicalState mInitialState; - private HierarchicalState mTetherModeAliveState; + private State mInitialState; + private State mTetherModeAliveState; - private HierarchicalState mSetIpForwardingEnabledErrorState; - private HierarchicalState mSetIpForwardingDisabledErrorState; - private HierarchicalState mStartTetheringErrorState; - private HierarchicalState mStopTetheringErrorState; - private HierarchicalState mSetDnsForwardersErrorState; + private State mSetIpForwardingEnabledErrorState; + private State mSetIpForwardingDisabledErrorState; + private State mStartTetheringErrorState; + private State mStopTetheringErrorState; + private State mSetDnsForwardersErrorState; private ArrayList mNotifyList; @@ -1125,7 +1126,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { setInitialState(mInitialState); } - class TetherMasterUtilState extends HierarchicalState { + class TetherMasterUtilState extends State { protected final static boolean TRY_TO_SETUP_MOBILE_CONNECTION = true; protected final static boolean WAIT_FOR_NETWORK_TO_SETTLE = false; @@ -1440,7 +1441,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } } - class ErrorState extends HierarchicalState { + class ErrorState extends State { int mErrorNotification; @Override public boolean processMessage(Message message) { |