Merge "Add external dependency API." into honeycomb-LTE
This commit is contained in:
committed by
Android (Google) Code Review
commit
70c3d1c23b
@@ -300,4 +300,8 @@ public class BluetoothTetheringDataTracker implements NetworkStateTracker {
|
|||||||
msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
|
msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
|
||||||
msg.sendToTarget();
|
msg.sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDependencyMet(boolean met) {
|
||||||
|
// not supported on this network
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -690,4 +690,16 @@ public class ConnectivityManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param networkType The network who's dependence has changed
|
||||||
|
* @param met Boolean - true if network use is ok, false if not
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
public void setDataDependency(int networkType, boolean met) {
|
||||||
|
try {
|
||||||
|
mService.setDataDependency(networkType, met);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,10 @@ public class DummyDataStateTracker implements NetworkStateTracker {
|
|||||||
return new LinkCapabilities(mLinkCapabilities);
|
return new LinkCapabilities(mLinkCapabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDependencyMet(boolean met) {
|
||||||
|
// not supported on this network
|
||||||
|
}
|
||||||
|
|
||||||
static private void log(String s) {
|
static private void log(String s) {
|
||||||
Slog.d(TAG, s);
|
Slog.d(TAG, s);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,4 +92,6 @@ interface IConnectivityManager
|
|||||||
void setGlobalProxy(in ProxyProperties p);
|
void setGlobalProxy(in ProxyProperties p);
|
||||||
|
|
||||||
ProxyProperties getProxy();
|
ProxyProperties getProxy();
|
||||||
|
|
||||||
|
void setDataDependency(int networkType, boolean met);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
@@ -493,6 +494,25 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* carrier dependency is met/unmet
|
||||||
|
* @param met
|
||||||
|
*/
|
||||||
|
public void setDependencyMet(boolean met) {
|
||||||
|
Bundle bundle = Bundle.forPair(DataConnectionTracker.APN_TYPE_KEY, mApnType);
|
||||||
|
try {
|
||||||
|
log("setDependencyMet: E met=" + met);
|
||||||
|
Message msg = Message.obtain();
|
||||||
|
msg.what = DataConnectionTracker.CMD_SET_DEPENDENCY_MET;
|
||||||
|
msg.arg1 = (met ? DataConnectionTracker.ENABLED : DataConnectionTracker.DISABLED);
|
||||||
|
msg.setData(bundle);
|
||||||
|
mDataConnectionTrackerAc.sendMessage(msg);
|
||||||
|
log("setDependencyMet: X met=" + met);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
log("setDependencyMet: X mAc was null" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer("Mobile data state: ");
|
StringBuffer sb = new StringBuffer("Mobile data state: ");
|
||||||
|
|||||||
76
core/java/android/net/NetworkConfig.java
Normal file
76
core/java/android/net/NetworkConfig.java
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 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.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the buildtime configuration of a network.
|
||||||
|
* Holds settings read from resources.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public class NetworkConfig {
|
||||||
|
/**
|
||||||
|
* Human readable string
|
||||||
|
*/
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type from ConnectivityManager
|
||||||
|
*/
|
||||||
|
public int type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the radio number from radio attributes config
|
||||||
|
*/
|
||||||
|
public int radio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* higher number == higher priority when turning off connections
|
||||||
|
*/
|
||||||
|
public int priority;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* indicates the boot time dependencyMet setting
|
||||||
|
*/
|
||||||
|
public boolean dependencyMet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* input string from config.xml resource. Uses the form:
|
||||||
|
* [Connection name],[ConnectivityManager connection type],
|
||||||
|
* [associated radio-type],[priority],[dependencyMet]
|
||||||
|
*/
|
||||||
|
public NetworkConfig(String init) {
|
||||||
|
String fragments[] = init.split(",");
|
||||||
|
name = fragments[0].trim().toLowerCase();
|
||||||
|
type = Integer.parseInt(fragments[1]);
|
||||||
|
radio = Integer.parseInt(fragments[2]);
|
||||||
|
priority = Integer.parseInt(fragments[3]);
|
||||||
|
if (fragments.length > 4) {
|
||||||
|
dependencyMet = Boolean.parseBoolean(fragments[4]);
|
||||||
|
} else {
|
||||||
|
dependencyMet = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if this network is supposed to be default-routable
|
||||||
|
*/
|
||||||
|
public boolean isDefault() {
|
||||||
|
return (type == radio);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -176,4 +176,9 @@ public interface NetworkStateTracker {
|
|||||||
* Indicate tear down requested from connectivity
|
* Indicate tear down requested from connectivity
|
||||||
*/
|
*/
|
||||||
public void setTeardownRequested(boolean isRequested);
|
public void setTeardownRequested(boolean isRequested);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An external dependency has been met/unmet
|
||||||
|
*/
|
||||||
|
public void setDependencyMet(boolean met);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,7 @@
|
|||||||
based on the hardware -->
|
based on the hardware -->
|
||||||
<!-- An Array of "[Connection name],[ConnectivityManager connection type],
|
<!-- An Array of "[Connection name],[ConnectivityManager connection type],
|
||||||
[associated radio-type],[priority] -->
|
[associated radio-type],[priority] -->
|
||||||
|
<!-- an optional 5th element can be added indicating boot-time dependency-met value. Defaults to true -->
|
||||||
<string-array translatable="false" name="networkAttributes">
|
<string-array translatable="false" name="networkAttributes">
|
||||||
<item>"wifi,1,1,1"</item>
|
<item>"wifi,1,1,1"</item>
|
||||||
<item>"mobile,0,0,0"</item>
|
<item>"mobile,0,0,0"</item>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.net.DummyDataStateTracker;
|
|||||||
import android.net.IConnectivityManager;
|
import android.net.IConnectivityManager;
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
import android.net.MobileDataStateTracker;
|
import android.net.MobileDataStateTracker;
|
||||||
|
import android.net.NetworkConfig;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkStateTracker;
|
import android.net.NetworkStateTracker;
|
||||||
import android.net.NetworkUtils;
|
import android.net.NetworkUtils;
|
||||||
@@ -188,6 +189,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
private static final int EVENT_APPLY_GLOBAL_HTTP_PROXY =
|
private static final int EVENT_APPLY_GLOBAL_HTTP_PROXY =
|
||||||
MAX_NETWORK_STATE_TRACKER_EVENT + 9;
|
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;
|
private Handler mHandler;
|
||||||
|
|
||||||
// list of DeathRecipients used to make sure features are turned off when
|
// list of DeathRecipients used to make sure features are turned off when
|
||||||
@@ -216,28 +225,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
private SettingsObserver mSettingsObserver;
|
private SettingsObserver mSettingsObserver;
|
||||||
|
|
||||||
private static class NetworkAttributes {
|
NetworkConfig[] mNetConfigs;
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
int mNetworksDefined;
|
int mNetworksDefined;
|
||||||
|
|
||||||
private static class RadioAttributes {
|
private static class RadioAttributes {
|
||||||
@@ -304,7 +292,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mNetworkPreference = getPersistedNetworkPreference();
|
mNetworkPreference = getPersistedNetworkPreference();
|
||||||
|
|
||||||
mRadioAttributes = new RadioAttributes[ConnectivityManager.MAX_RADIO_TYPE+1];
|
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
|
// Load device network attributes from resources
|
||||||
String[] raStrings = context.getResources().getStringArray(
|
String[] raStrings = context.getResources().getStringArray(
|
||||||
@@ -327,13 +315,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
com.android.internal.R.array.networkAttributes);
|
com.android.internal.R.array.networkAttributes);
|
||||||
for (String naString : naStrings) {
|
for (String naString : naStrings) {
|
||||||
try {
|
try {
|
||||||
NetworkAttributes n = new NetworkAttributes(naString);
|
NetworkConfig n = new NetworkConfig(naString);
|
||||||
if (n.mType > ConnectivityManager.MAX_NETWORK_TYPE) {
|
if (n.mType > ConnectivityManager.MAX_NETWORK_TYPE) {
|
||||||
loge("Error in networkAttributes - ignoring attempt to define type " +
|
loge("Error in networkAttributes - ignoring attempt to define type " +
|
||||||
n.mType);
|
n.mType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mNetAttributes[n.mType] != null) {
|
if (mNetConfigs[n.mType] != null) {
|
||||||
loge("Error in networkAttributes - ignoring attempt to redefine type " +
|
loge("Error in networkAttributes - ignoring attempt to redefine type " +
|
||||||
n.mType);
|
n.mType);
|
||||||
continue;
|
continue;
|
||||||
@@ -343,7 +331,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
"radio " + n.mRadio + " in network type " + n.mType);
|
"radio " + n.mRadio + " in network type " + n.mType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mNetAttributes[n.mType] = n;
|
mNetConfigs[n.mType] = n;
|
||||||
mNetworksDefined++;
|
mNetworksDefined++;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
// ignore it - leave the entry null
|
// ignore it - leave the entry null
|
||||||
@@ -357,7 +345,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
int currentLowest = 0;
|
int currentLowest = 0;
|
||||||
int nextLowest = 0;
|
int nextLowest = 0;
|
||||||
while (insertionPoint > -1) {
|
while (insertionPoint > -1) {
|
||||||
for (NetworkAttributes na : mNetAttributes) {
|
for (NetworkConfig na : mNetConfigs) {
|
||||||
if (na == null) continue;
|
if (na == null) continue;
|
||||||
if (na.mPriority < currentLowest) continue;
|
if (na.mPriority < currentLowest) continue;
|
||||||
if (na.mPriority > currentLowest) {
|
if (na.mPriority > currentLowest) {
|
||||||
@@ -392,7 +380,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
* to change very often.
|
* to change very often.
|
||||||
*/
|
*/
|
||||||
for (int netType : mPriorityList) {
|
for (int netType : mPriorityList) {
|
||||||
switch (mNetAttributes[netType].mRadio) {
|
switch (mNetConfigs[netType].mRadio) {
|
||||||
case ConnectivityManager.TYPE_WIFI:
|
case ConnectivityManager.TYPE_WIFI:
|
||||||
if (DBG) log("Starting Wifi Service.");
|
if (DBG) log("Starting Wifi Service.");
|
||||||
WifiStateTracker wst = new WifiStateTracker();
|
WifiStateTracker wst = new WifiStateTracker();
|
||||||
@@ -408,12 +396,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
break;
|
break;
|
||||||
case ConnectivityManager.TYPE_MOBILE:
|
case ConnectivityManager.TYPE_MOBILE:
|
||||||
mNetTrackers[netType] = new MobileDataStateTracker(netType,
|
mNetTrackers[netType] = new MobileDataStateTracker(netType,
|
||||||
mNetAttributes[netType].mName);
|
mNetConfigs[netType].mName);
|
||||||
mNetTrackers[netType].startMonitoring(context, mHandler);
|
mNetTrackers[netType].startMonitoring(context, mHandler);
|
||||||
break;
|
break;
|
||||||
case ConnectivityManager.TYPE_DUMMY:
|
case ConnectivityManager.TYPE_DUMMY:
|
||||||
mNetTrackers[netType] = new DummyDataStateTracker(netType,
|
mNetTrackers[netType] = new DummyDataStateTracker(netType,
|
||||||
mNetAttributes[netType].mName);
|
mNetConfigs[netType].mName);
|
||||||
mNetTrackers[netType].startMonitoring(context, mHandler);
|
mNetTrackers[netType].startMonitoring(context, mHandler);
|
||||||
break;
|
break;
|
||||||
case ConnectivityManager.TYPE_BLUETOOTH:
|
case ConnectivityManager.TYPE_BLUETOOTH:
|
||||||
@@ -422,7 +410,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
loge("Trying to create a DataStateTracker for an unknown radio type " +
|
loge("Trying to create a DataStateTracker for an unknown radio type " +
|
||||||
mNetAttributes[netType].mRadio);
|
mNetConfigs[netType].mRadio);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,8 +457,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
private void handleSetNetworkPreference(int preference) {
|
private void handleSetNetworkPreference(int preference) {
|
||||||
if (ConnectivityManager.isNetworkTypeValid(preference) &&
|
if (ConnectivityManager.isNetworkTypeValid(preference) &&
|
||||||
mNetAttributes[preference] != null &&
|
mNetConfigs[preference] != null &&
|
||||||
mNetAttributes[preference].isDefault()) {
|
mNetConfigs[preference].isDefault()) {
|
||||||
if (mNetworkPreference != preference) {
|
if (mNetworkPreference != preference) {
|
||||||
final ContentResolver cr = mContext.getContentResolver();
|
final ContentResolver cr = mContext.getContentResolver();
|
||||||
Settings.Secure.putInt(cr, Settings.Secure.NETWORK_PREFERENCE, preference);
|
Settings.Secure.putInt(cr, Settings.Secure.NETWORK_PREFERENCE, preference);
|
||||||
@@ -539,7 +527,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
public NetworkInfo getActiveNetworkInfo() {
|
public NetworkInfo getActiveNetworkInfo() {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
for (int type=0; type <= ConnectivityManager.MAX_NETWORK_TYPE; type++) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
NetworkStateTracker t = mNetTrackers[type];
|
NetworkStateTracker t = mNetTrackers[type];
|
||||||
@@ -585,7 +573,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
public LinkProperties getActiveLinkProperties() {
|
public LinkProperties getActiveLinkProperties() {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
for (int type=0; type <= ConnectivityManager.MAX_NETWORK_TYPE; type++) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
NetworkStateTracker t = mNetTrackers[type];
|
NetworkStateTracker t = mNetTrackers[type];
|
||||||
@@ -687,7 +675,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
enforceChangePermission();
|
enforceChangePermission();
|
||||||
if (!ConnectivityManager.isNetworkTypeValid(networkType) ||
|
if (!ConnectivityManager.isNetworkTypeValid(networkType) ||
|
||||||
mNetAttributes[networkType] == null) {
|
mNetConfigs[networkType] == null) {
|
||||||
return Phone.APN_REQUEST_FAILED;
|
return Phone.APN_REQUEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -999,6 +987,24 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
return retVal;
|
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)
|
* @see ConnectivityManager#setMobileDataEnabled(boolean)
|
||||||
*/
|
*/
|
||||||
@@ -1068,7 +1074,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
* getting the disconnect for a network that we explicitly disabled
|
* getting the disconnect for a network that we explicitly disabled
|
||||||
* in accordance with network preference policies.
|
* in accordance with network preference policies.
|
||||||
*/
|
*/
|
||||||
if (!mNetAttributes[prevNetType].isDefault()) {
|
if (!mNetConfigs[prevNetType].isDefault()) {
|
||||||
List pids = mNetRequestersPids[prevNetType];
|
List pids = mNetRequestersPids[prevNetType];
|
||||||
for (int i = 0; i<pids.size(); i++) {
|
for (int i = 0; i<pids.size(); i++) {
|
||||||
Integer pid = (Integer)pids.get(i);
|
Integer pid = (Integer)pids.get(i);
|
||||||
@@ -1093,7 +1099,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
info.getExtraInfo());
|
info.getExtraInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNetAttributes[prevNetType].isDefault()) {
|
if (mNetConfigs[prevNetType].isDefault()) {
|
||||||
tryFailover(prevNetType);
|
tryFailover(prevNetType);
|
||||||
if (mActiveDefaultNetwork != -1) {
|
if (mActiveDefaultNetwork != -1) {
|
||||||
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
||||||
@@ -1123,7 +1129,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
* Try to reconnect on all available and let them hash it out when
|
* Try to reconnect on all available and let them hash it out when
|
||||||
* more than one connects.
|
* more than one connects.
|
||||||
*/
|
*/
|
||||||
if (mNetAttributes[prevNetType].isDefault()) {
|
if (mNetConfigs[prevNetType].isDefault()) {
|
||||||
if (mActiveDefaultNetwork == prevNetType) {
|
if (mActiveDefaultNetwork == prevNetType) {
|
||||||
mActiveDefaultNetwork = -1;
|
mActiveDefaultNetwork = -1;
|
||||||
}
|
}
|
||||||
@@ -1133,12 +1139,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// TODO - don't filter by priority now - nice optimization but risky
|
// TODO - don't filter by priority now - nice optimization but risky
|
||||||
// int currentPriority = -1;
|
// int currentPriority = -1;
|
||||||
// if (mActiveDefaultNetwork != -1) {
|
// if (mActiveDefaultNetwork != -1) {
|
||||||
// currentPriority = mNetAttributes[mActiveDefaultNetwork].mPriority;
|
// currentPriority = mNetConfigs[mActiveDefaultNetwork].mPriority;
|
||||||
// }
|
// }
|
||||||
for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
|
for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
|
||||||
if (checkType == prevNetType) continue;
|
if (checkType == prevNetType) continue;
|
||||||
if (mNetAttributes[checkType] == null) continue;
|
if (mNetConfigs[checkType] == null) continue;
|
||||||
if (!mNetAttributes[checkType].isDefault()) continue;
|
if (!mNetConfigs[checkType].isDefault()) continue;
|
||||||
|
|
||||||
// Enabling the isAvailable() optimization caused mobile to not get
|
// Enabling the isAvailable() optimization caused mobile to not get
|
||||||
// selected if it was in the middle of error handling. Specifically
|
// selected if it was in the middle of error handling. Specifically
|
||||||
@@ -1150,7 +1156,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// complete before it is really complete.
|
// complete before it is really complete.
|
||||||
// if (!mNetTrackers[checkType].isAvailable()) continue;
|
// if (!mNetTrackers[checkType].isAvailable()) continue;
|
||||||
|
|
||||||
// if (currentPriority >= mNetAttributes[checkType].mPriority) continue;
|
// if (currentPriority >= mNetConfigs[checkType].mPriority) continue;
|
||||||
|
|
||||||
NetworkStateTracker checkTracker = mNetTrackers[checkType];
|
NetworkStateTracker checkTracker = mNetTrackers[checkType];
|
||||||
NetworkInfo checkInfo = checkTracker.getNetworkInfo();
|
NetworkInfo checkInfo = checkTracker.getNetworkInfo();
|
||||||
@@ -1223,7 +1229,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
info.setFailover(false);
|
info.setFailover(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNetAttributes[info.getType()].isDefault()) {
|
if (mNetConfigs[info.getType()].isDefault()) {
|
||||||
tryFailover(info.getType());
|
tryFailover(info.getType());
|
||||||
if (mActiveDefaultNetwork != -1) {
|
if (mActiveDefaultNetwork != -1) {
|
||||||
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
||||||
@@ -1276,11 +1282,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
// if this is a default net and other default is running
|
// if this is a default net and other default is running
|
||||||
// kill the one not preferred
|
// kill the one not preferred
|
||||||
if (mNetAttributes[type].isDefault()) {
|
if (mNetConfigs[type].isDefault()) {
|
||||||
if (mActiveDefaultNetwork != -1 && mActiveDefaultNetwork != type) {
|
if (mActiveDefaultNetwork != -1 && mActiveDefaultNetwork != type) {
|
||||||
if ((type != mNetworkPreference &&
|
if ((type != mNetworkPreference &&
|
||||||
mNetAttributes[mActiveDefaultNetwork].mPriority >
|
mNetConfigs[mActiveDefaultNetwork].mPriority >
|
||||||
mNetAttributes[type].mPriority) ||
|
mNetConfigs[type].mPriority) ||
|
||||||
mNetworkPreference == mActiveDefaultNetwork) {
|
mNetworkPreference == mActiveDefaultNetwork) {
|
||||||
// don't accept this one
|
// don't accept this one
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
@@ -1344,14 +1350,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
handleDnsConfigurationChange(netType);
|
handleDnsConfigurationChange(netType);
|
||||||
|
|
||||||
if (mNetTrackers[netType].getNetworkInfo().isConnected()) {
|
if (mNetTrackers[netType].getNetworkInfo().isConnected()) {
|
||||||
if (mNetAttributes[netType].isDefault()) {
|
if (mNetConfigs[netType].isDefault()) {
|
||||||
handleApplyDefaultProxy(netType);
|
handleApplyDefaultProxy(netType);
|
||||||
addDefaultRoute(mNetTrackers[netType]);
|
addDefaultRoute(mNetTrackers[netType]);
|
||||||
} else {
|
} else {
|
||||||
addPrivateDnsRoutes(mNetTrackers[netType]);
|
addPrivateDnsRoutes(mNetTrackers[netType]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mNetAttributes[netType].isDefault()) {
|
if (mNetConfigs[netType].isDefault()) {
|
||||||
removeDefaultRoute(mNetTrackers[netType]);
|
removeDefaultRoute(mNetTrackers[netType]);
|
||||||
} else {
|
} else {
|
||||||
removePrivateDnsRoutes(mNetTrackers[netType]);
|
removePrivateDnsRoutes(mNetTrackers[netType]);
|
||||||
@@ -1512,7 +1518,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
{
|
{
|
||||||
if (DBG) log("reassessPidDns for pid " + myPid);
|
if (DBG) log("reassessPidDns for pid " + myPid);
|
||||||
for(int i : mPriorityList) {
|
for(int i : mPriorityList) {
|
||||||
if (mNetAttributes[i].isDefault()) {
|
if (mNetConfigs[i].isDefault()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NetworkStateTracker nt = mNetTrackers[i];
|
NetworkStateTracker nt = mNetTrackers[i];
|
||||||
@@ -1594,7 +1600,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
Collection<InetAddress> dnses = p.getDnses();
|
Collection<InetAddress> dnses = p.getDnses();
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
if (mNetAttributes[netType].isDefault()) {
|
if (mNetConfigs[netType].isDefault()) {
|
||||||
int j = 1;
|
int j = 1;
|
||||||
if (dnses.size() == 0 && mDefaultDns != null) {
|
if (dnses.size() == 0 && mDefaultDns != null) {
|
||||||
String dnsString = mDefaultDns.getHostAddress();
|
String dnsString = mDefaultDns.getHostAddress();
|
||||||
@@ -1725,23 +1731,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
info = (NetworkInfo) msg.obj;
|
info = (NetworkInfo) msg.obj;
|
||||||
int type = info.getType();
|
int type = info.getType();
|
||||||
NetworkInfo.State state = info.getState();
|
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 " +
|
if (DBG) log("ConnectivityChange for " +
|
||||||
info.getTypeName() + ": " +
|
info.getTypeName() + ": " +
|
||||||
@@ -1780,8 +1769,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
break;
|
break;
|
||||||
case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED:
|
case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED:
|
||||||
info = (NetworkInfo) msg.obj;
|
info = (NetworkInfo) msg.obj;
|
||||||
type = info.getType();
|
handleConnectivityChange(info.getType());
|
||||||
handleConnectivityChange(type);
|
|
||||||
break;
|
break;
|
||||||
case EVENT_CLEAR_NET_TRANSITION_WAKELOCK:
|
case EVENT_CLEAR_NET_TRANSITION_WAKELOCK:
|
||||||
String causedBy = null;
|
String causedBy = null;
|
||||||
@@ -1835,6 +1823,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
case EVENT_APPLY_GLOBAL_HTTP_PROXY:
|
case EVENT_APPLY_GLOBAL_HTTP_PROXY:
|
||||||
{
|
{
|
||||||
handleDeprecatedGlobalHttpProxy();
|
handleDeprecatedGlobalHttpProxy();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EVENT_SET_DEPENDENCY_MET:
|
||||||
|
{
|
||||||
|
boolean met = (msg.arg1 == ENABLED);
|
||||||
|
handleSetDependencyMet(msg.arg2, met);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import android.app.PendingIntent;
|
|||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.android.internal.telephony.gsm.GsmDataConnection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maintain the Apn context
|
* Maintain the Apn context
|
||||||
@@ -30,9 +29,13 @@ public class ApnContext {
|
|||||||
public static final int PENDING_ACTION_NONE = 1;
|
public static final int PENDING_ACTION_NONE = 1;
|
||||||
public static final int PENDING_ACTION_RECONNECT = 2;
|
public static final int PENDING_ACTION_RECONNECT = 2;
|
||||||
public static final int PENDING_ACTION_APN_DISABLE = 3;
|
public static final int PENDING_ACTION_APN_DISABLE = 3;
|
||||||
|
|
||||||
|
public static final int DATA_ENABLED = 1;
|
||||||
|
public static final int DATA_DISABLED = 2;
|
||||||
|
|
||||||
public final String LOG_TAG;
|
public final String LOG_TAG;
|
||||||
|
|
||||||
int pendingAction;
|
int mPendingAction;
|
||||||
|
|
||||||
protected static final boolean DBG = true;
|
protected static final boolean DBG = true;
|
||||||
|
|
||||||
@@ -47,37 +50,49 @@ public class ApnContext {
|
|||||||
|
|
||||||
ApnSetting mApnSetting;
|
ApnSetting mApnSetting;
|
||||||
|
|
||||||
GsmDataConnection mDataConnection;
|
DataConnection mDataConnection;
|
||||||
|
|
||||||
String mReason;
|
String mReason;
|
||||||
|
|
||||||
PendingIntent mReconnectIntent;
|
PendingIntent mReconnectIntent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* user/app requested connection on this APN
|
||||||
|
*/
|
||||||
|
boolean mDataEnabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* carrier requirements met
|
||||||
|
*/
|
||||||
|
boolean mDependencyMet;
|
||||||
|
|
||||||
public ApnContext(String apnType, String logTag) {
|
public ApnContext(String apnType, String logTag) {
|
||||||
mApnType = apnType;
|
mApnType = apnType;
|
||||||
mState = DataConnectionTracker.State.IDLE;
|
mState = DataConnectionTracker.State.IDLE;
|
||||||
setReason(Phone.REASON_DATA_ENABLED);
|
setReason(Phone.REASON_DATA_ENABLED);
|
||||||
pendingAction = PENDING_ACTION_NONE;
|
mPendingAction = PENDING_ACTION_NONE;
|
||||||
|
mDataEnabled = false;
|
||||||
|
mDependencyMet = true;
|
||||||
LOG_TAG = logTag;
|
LOG_TAG = logTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPendingAction() {
|
public int getPendingAction() {
|
||||||
return pendingAction;
|
return mPendingAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPendingAction(int pa) {
|
public void setPendingAction(int pa) {
|
||||||
pendingAction = pa;
|
mPendingAction = pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getApnType() {
|
public String getApnType() {
|
||||||
return mApnType;
|
return mApnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GsmDataConnection getDataConnection() {
|
public DataConnection getDataConnection() {
|
||||||
return mDataConnection;
|
return mDataConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataConnection(GsmDataConnection dataConnection) {
|
public void setDataConnection(DataConnection dataConnection) {
|
||||||
mDataConnection = dataConnection;
|
mDataConnection = dataConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +175,34 @@ public class ApnContext {
|
|||||||
return mReconnectIntent;
|
return mReconnectIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isReady() {
|
||||||
|
return mDataEnabled && mDependencyMet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
if (DBG) {
|
||||||
|
log("set enabled as " + enabled + ", for type " +
|
||||||
|
mApnType + ", current state is " + mDataEnabled);
|
||||||
|
}
|
||||||
|
mDataEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return mDataEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDependencyMet(boolean met) {
|
||||||
|
if (DBG) {
|
||||||
|
log("set mDependencyMet as " + met + ", for type " + mApnType +
|
||||||
|
", current state is " + mDependencyMet);
|
||||||
|
}
|
||||||
|
mDependencyMet = met;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getDependencyMet() {
|
||||||
|
return mDependencyMet;
|
||||||
|
}
|
||||||
|
|
||||||
protected void log(String s) {
|
protected void log(String s) {
|
||||||
Log.d(LOG_TAG, "[ApnContext] " + s);
|
Log.d(LOG_TAG, "[ApnContext] " + s);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -961,4 +961,8 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
|||||||
public ApnSetting getApn() {
|
public ApnSetting getApn() {
|
||||||
return mApn;
|
return mApn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCid() {
|
||||||
|
return cid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import android.net.LinkProperties;
|
|||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.AsyncResult;
|
import android.os.AsyncResult;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
@@ -122,6 +123,7 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
protected static final int EVENT_RESET_DONE = 38;
|
protected static final int EVENT_RESET_DONE = 38;
|
||||||
public static final int CMD_SET_DATA_ENABLE = 39;
|
public static final int CMD_SET_DATA_ENABLE = 39;
|
||||||
public static final int EVENT_CLEAN_UP_ALL_CONNECTIONS = 40;
|
public static final int EVENT_CLEAN_UP_ALL_CONNECTIONS = 40;
|
||||||
|
public static final int CMD_SET_DEPENDENCY_MET = 41;
|
||||||
|
|
||||||
/***** Constants *****/
|
/***** Constants *****/
|
||||||
|
|
||||||
@@ -139,6 +141,8 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
public static final int DISABLED = 0;
|
public static final int DISABLED = 0;
|
||||||
public static final int ENABLED = 1;
|
public static final int ENABLED = 1;
|
||||||
|
|
||||||
|
public static final String APN_TYPE_KEY = "apnType";
|
||||||
|
|
||||||
// responds to the setInternalDataEnabled call - used internally to turn off data
|
// responds to the setInternalDataEnabled call - used internally to turn off data
|
||||||
// for example during emergency calls
|
// for example during emergency calls
|
||||||
protected boolean mInternalDataEnabled = true;
|
protected boolean mInternalDataEnabled = true;
|
||||||
@@ -541,6 +545,19 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case CMD_SET_DEPENDENCY_MET: {
|
||||||
|
log("CMD_SET_DEPENDENCY_MET msg=" + msg);
|
||||||
|
boolean met = (msg.arg1 == ENABLED) ? true : false;
|
||||||
|
Bundle bundle = msg.getData();
|
||||||
|
if (bundle != null) {
|
||||||
|
String apnType = (String)bundle.get(APN_TYPE_KEY);
|
||||||
|
if (apnType != null) {
|
||||||
|
onSetDependencyMet(apnType, met);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.e("DATA", "Unidentified event = " + msg.what);
|
Log.e("DATA", "Unidentified event = " + msg.what);
|
||||||
break;
|
break;
|
||||||
@@ -810,7 +827,7 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEnabled(int id, boolean enable) {
|
protected void setEnabled(int id, boolean enable) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log("setEnabled(" + id + ", " + enable + ") with old state = " + dataEnabled[id]
|
log("setEnabled(" + id + ", " + enable + ") with old state = " + dataEnabled[id]
|
||||||
+ " and enabledCount = " + enabledCount);
|
+ " and enabledCount = " + enabledCount);
|
||||||
@@ -821,7 +838,7 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
sendMessage(msg);
|
sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void onEnableApn(int apnId, int enabled) {
|
protected void onEnableApn(int apnId, int enabled) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log("EVENT_APN_ENABLE_REQUEST apnId=" + apnId + ", apnType=" + apnIdToType(apnId) +
|
log("EVENT_APN_ENABLE_REQUEST apnId=" + apnId + ", apnType=" + apnIdToType(apnId) +
|
||||||
", enabled=" + enabled + ", dataEnabled = " + dataEnabled[apnId] +
|
", enabled=" + enabled + ", dataEnabled = " + dataEnabled[apnId] +
|
||||||
@@ -829,10 +846,12 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
isApnTypeActive(apnIdToType(apnId)));
|
isApnTypeActive(apnIdToType(apnId)));
|
||||||
}
|
}
|
||||||
if (enabled == ENABLED) {
|
if (enabled == ENABLED) {
|
||||||
|
synchronized (this) {
|
||||||
if (!dataEnabled[apnId]) {
|
if (!dataEnabled[apnId]) {
|
||||||
dataEnabled[apnId] = true;
|
dataEnabled[apnId] = true;
|
||||||
enabledCount++;
|
enabledCount++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
String type = apnIdToType(apnId);
|
String type = apnIdToType(apnId);
|
||||||
if (!isApnTypeActive(type)) {
|
if (!isApnTypeActive(type)) {
|
||||||
mRequestedApnType = type;
|
mRequestedApnType = type;
|
||||||
@@ -842,12 +861,16 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// disable
|
// disable
|
||||||
|
boolean didDisable = false;
|
||||||
|
synchronized (this) {
|
||||||
if (dataEnabled[apnId]) {
|
if (dataEnabled[apnId]) {
|
||||||
dataEnabled[apnId] = false;
|
dataEnabled[apnId] = false;
|
||||||
enabledCount--;
|
enabledCount--;
|
||||||
if (enabledCount == 0) {
|
didDisable = true;
|
||||||
onCleanUpConnection(true, apnId, Phone.REASON_DATA_DISABLED);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (didDisable && enabledCount == 0) {
|
||||||
|
onCleanUpConnection(true, apnId, Phone.REASON_DATA_DISABLED);
|
||||||
|
|
||||||
// send the disconnect msg manually, since the normal route wont send
|
// send the disconnect msg manually, since the normal route wont send
|
||||||
// it (it's not enabled)
|
// it (it's not enabled)
|
||||||
@@ -961,6 +984,10 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onSetDependencyMet(String apnType, boolean met) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void resetAllRetryCounts() {
|
protected void resetAllRetryCounts() {
|
||||||
for (DataConnection dc : mDataConnections.values()) {
|
for (DataConnection dc : mDataConnections.values()) {
|
||||||
dc.resetRetryCount();
|
dc.resetRetryCount();
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ public interface Phone {
|
|||||||
static final String REASON_PS_RESTRICT_DISABLED = "psRestrictDisabled";
|
static final String REASON_PS_RESTRICT_DISABLED = "psRestrictDisabled";
|
||||||
static final String REASON_SIM_LOADED = "simLoaded";
|
static final String REASON_SIM_LOADED = "simLoaded";
|
||||||
static final String REASON_NW_TYPE_CHANGED = "nwTypeChanged";
|
static final String REASON_NW_TYPE_CHANGED = "nwTypeChanged";
|
||||||
|
static final String REASON_DATA_DEPENDENCY_MET = "dependencyMet";
|
||||||
|
static final String REASON_DATA_DEPENDENCY_UNMET = "dependencyUnmet";
|
||||||
|
|
||||||
// Used for band mode selection methods
|
// Used for band mode selection methods
|
||||||
static final int BM_UNSPECIFIED = 0; // selected by baseband automatically
|
static final int BM_UNSPECIFIED = 0; // selected by baseband automatically
|
||||||
|
|||||||
@@ -117,11 +117,6 @@ public class GsmDataConnection extends DataConnection {
|
|||||||
return mProfileId;
|
return mProfileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCid() {
|
|
||||||
// 'cid' has been defined in parent class
|
|
||||||
return cid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActiveApnType(String apnType) {
|
public void setActiveApnType(String apnType) {
|
||||||
mActiveApnType = apnType;
|
mActiveApnType = apnType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,13 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
import android.net.ProxyProperties;
|
import android.net.ProxyProperties;
|
||||||
import android.net.TrafficStats;
|
import android.net.TrafficStats;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.LinkCapabilities;
|
import android.net.LinkCapabilities;
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
|
import android.net.NetworkConfig;
|
||||||
import android.os.AsyncResult;
|
import android.os.AsyncResult;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
@@ -164,9 +166,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
p.getContext().getContentResolver().registerContentObserver(
|
p.getContext().getContentResolver().registerContentObserver(
|
||||||
Telephony.Carriers.CONTENT_URI, true, mApnObserver);
|
Telephony.Carriers.CONTENT_URI, true, mApnObserver);
|
||||||
|
|
||||||
/** Create the default connection */
|
|
||||||
mApnContexts = new ConcurrentHashMap<String, ApnContext>();
|
mApnContexts = new ConcurrentHashMap<String, ApnContext>();
|
||||||
initApncontextsAndDataConnection();
|
initApnContextsAndDataConnection();
|
||||||
broadcastMessenger();
|
broadcastMessenger();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +207,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
* because the phone is out of coverage or some like reason.</li>
|
* because the phone is out of coverage or some like reason.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @return {@code true} if data connectivity is possible, {@code false} otherwise.
|
* @return {@code true} if data connectivity is possible, {@code false} otherwise.
|
||||||
|
* TODO - do per-apn notifications of availability using dependencyMet values.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean isDataPossible() {
|
protected boolean isDataPossible() {
|
||||||
@@ -227,14 +229,57 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return INTENT_RECONNECT_ALARM;
|
return INTENT_RECONNECT_ALARM;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initApncontextsAndDataConnection() {
|
private ApnContext addApnContext(String type) {
|
||||||
|
ApnContext apnContext = new ApnContext(type, LOG_TAG);
|
||||||
|
apnContext.setDependencyMet(false);
|
||||||
|
mApnContexts.put(type, apnContext);
|
||||||
|
return apnContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initApnContextsAndDataConnection() {
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
|
||||||
boolean defaultEnabled = !sp.getBoolean(PhoneBase.DATA_DISABLED_ON_BOOT_KEY, false);
|
boolean defaultEnabled = !sp.getBoolean(PhoneBase.DATA_DISABLED_ON_BOOT_KEY, false);
|
||||||
// create default type context only if enabled
|
// Load device network attributes from resources
|
||||||
if (defaultEnabled) {
|
String[] networkConfigStrings = mPhone.getContext().getResources().getStringArray(
|
||||||
ApnContext apnContext = new ApnContext(Phone.APN_TYPE_DEFAULT, LOG_TAG);
|
com.android.internal.R.array.networkAttributes);
|
||||||
mApnContexts.put(apnContext.getApnType(), apnContext);
|
for (String networkConfigString : networkConfigStrings) {
|
||||||
createDataConnection(Phone.APN_TYPE_DEFAULT);
|
NetworkConfig networkConfig = new NetworkConfig(networkConfigString);
|
||||||
|
ApnContext apnContext = null;
|
||||||
|
|
||||||
|
switch (networkConfig.type) {
|
||||||
|
case ConnectivityManager.TYPE_MOBILE:
|
||||||
|
apnContext = addApnContext(Phone.APN_TYPE_DEFAULT);
|
||||||
|
apnContext.setEnabled(defaultEnabled);
|
||||||
|
break;
|
||||||
|
case ConnectivityManager.TYPE_MOBILE_MMS:
|
||||||
|
apnContext = addApnContext(Phone.APN_TYPE_MMS);
|
||||||
|
break;
|
||||||
|
case ConnectivityManager.TYPE_MOBILE_SUPL:
|
||||||
|
apnContext = addApnContext(Phone.APN_TYPE_SUPL);
|
||||||
|
break;
|
||||||
|
case ConnectivityManager.TYPE_MOBILE_DUN:
|
||||||
|
apnContext = addApnContext(Phone.APN_TYPE_DUN);
|
||||||
|
break;
|
||||||
|
case ConnectivityManager.TYPE_MOBILE_HIPRI:
|
||||||
|
apnContext = addApnContext(Phone.APN_TYPE_HIPRI);
|
||||||
|
break;
|
||||||
|
case ConnectivityManager.TYPE_MOBILE_FOTA:
|
||||||
|
apnContext = addApnContext(Phone.APN_TYPE_FOTA);
|
||||||
|
break;
|
||||||
|
case ConnectivityManager.TYPE_MOBILE_IMS:
|
||||||
|
apnContext = addApnContext(Phone.APN_TYPE_IMS);
|
||||||
|
break;
|
||||||
|
case ConnectivityManager.TYPE_MOBILE_CBS:
|
||||||
|
apnContext = addApnContext(Phone.APN_TYPE_CBS);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// skip unknown types
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (apnContext != null) {
|
||||||
|
// set the prop, but also apply the newly set enabled and dependency values
|
||||||
|
onSetDependencyMet(apnContext.getApnType(), networkConfig.dependencyMet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,8 +316,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
Iterator<ApnContext> it = mApnContexts.values().iterator();
|
Iterator<ApnContext> it = mApnContexts.values().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
ApnContext apnContext = it.next();
|
ApnContext apnContext = it.next();
|
||||||
|
if (apnContext.isReady()) {
|
||||||
result.add(apnContext.getApnType());
|
result.add(apnContext.getApnType());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (String[])result.toArray(new String[0]);
|
return (String[])result.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
@@ -353,24 +400,12 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
public synchronized int enableApnType(String apnType) {
|
public synchronized int enableApnType(String apnType) {
|
||||||
if (DBG) log("calling enableApnType with type:" + apnType);
|
if (DBG) log("calling enableApnType with type:" + apnType);
|
||||||
|
|
||||||
if (!isApnTypeAvailable(apnType)) {
|
ApnContext apnContext = mApnContexts.get(apnType);
|
||||||
|
if (apnContext == null || !isApnTypeAvailable(apnType)) {
|
||||||
if (DBG) log("type not available");
|
if (DBG) log("type not available");
|
||||||
return Phone.APN_TYPE_NOT_AVAILABLE;
|
return Phone.APN_TYPE_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApnContext apnContext = mApnContexts.get(apnType);
|
|
||||||
if (apnContext==null) {
|
|
||||||
// Is there a Proxy type for this?
|
|
||||||
apnContext = getProxyActiveApnType(apnType);
|
|
||||||
if (apnContext != null ) {
|
|
||||||
notifyApnIdUpToCurrent(Phone.REASON_APN_SWITCHED, apnContext, apnType);
|
|
||||||
return Phone.APN_REQUEST_STARTED;
|
|
||||||
}
|
|
||||||
apnContext = new ApnContext(apnType, LOG_TAG);
|
|
||||||
if (DBG) log("New apn type context for type "+apnType);
|
|
||||||
mApnContexts.put(apnType, apnContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If already active, return
|
// If already active, return
|
||||||
log("enableApnType(" + apnType + ")" + ", mState(" + apnContext.getState() + ")");
|
log("enableApnType(" + apnType + ")" + ", mState(" + apnContext.getState() + ")");
|
||||||
|
|
||||||
@@ -389,24 +424,11 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (DBG) log("new apn request for type " + apnType + " is to be handled");
|
if (DBG) log("new apn request for type " + apnType + " is to be handled");
|
||||||
sendMessage(obtainMessage(EVENT_ENABLE_NEW_APN, apnContext));
|
setEnabled(apnTypeToId(apnType), true);
|
||||||
if (DBG) log("return APN_REQUEST_STARTED");
|
if (DBG) log("return APN_REQUEST_STARTED");
|
||||||
return Phone.APN_REQUEST_STARTED;
|
return Phone.APN_REQUEST_STARTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns for ex: if HIGHPRI is supported by DEFAULT
|
|
||||||
public ApnContext getProxyActiveApnType(String type) {
|
|
||||||
|
|
||||||
Iterator<ApnContext> it = mApnContexts.values().iterator();
|
|
||||||
|
|
||||||
while(it.hasNext()) {
|
|
||||||
ApnContext apnContext = it.next();
|
|
||||||
if (apnContext.getApnSetting() != null && mActiveApn.canHandleType(type))
|
|
||||||
return apnContext;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A new APN has gone active and needs to send events to catch up with the
|
// A new APN has gone active and needs to send events to catch up with the
|
||||||
// current condition
|
// current condition
|
||||||
private void notifyApnIdUpToCurrent(String reason, ApnContext apnContext, String type) {
|
private void notifyApnIdUpToCurrent(String reason, ApnContext apnContext, String type) {
|
||||||
@@ -437,6 +459,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
if (apnContext.getState() != State.IDLE && apnContext.getState() != State.FAILED) {
|
if (apnContext.getState() != State.IDLE && apnContext.getState() != State.FAILED) {
|
||||||
Message msg = obtainMessage(EVENT_CLEAN_UP_CONNECTION);
|
Message msg = obtainMessage(EVENT_CLEAN_UP_CONNECTION);
|
||||||
msg.arg1 = 1; // tearDown is true;
|
msg.arg1 = 1; // tearDown is true;
|
||||||
|
// TODO - don't set things on apnContext from public functions.
|
||||||
|
// Maybe pass reason as arg2?
|
||||||
apnContext.setReason(Phone.REASON_DATA_DISABLED);
|
apnContext.setReason(Phone.REASON_DATA_DISABLED);
|
||||||
msg.obj = apnContext;
|
msg.obj = apnContext;
|
||||||
sendMessage(msg);
|
sendMessage(msg);
|
||||||
@@ -487,16 +511,11 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean getAnyDataEnabled() {
|
public synchronized boolean getAnyDataEnabled() {
|
||||||
Iterator<ApnContext> it = mApnContexts.values().iterator();
|
|
||||||
|
|
||||||
if (!(mInternalDataEnabled && mDataEnabled)) return false;
|
if (!(mInternalDataEnabled && mDataEnabled)) return false;
|
||||||
if (mApnContexts.isEmpty()) return false;
|
for (ApnContext apnContext : mApnContexts.values()) {
|
||||||
while (it.hasNext()) {
|
|
||||||
ApnContext apnContext= it.next();
|
|
||||||
// Make sure we dont have a context that going down
|
// Make sure we dont have a context that going down
|
||||||
// and is explicitly disabled.
|
// and is explicitly disabled.
|
||||||
if (!(apnContext.getState() == State.DISCONNECTING
|
if (isDataAllowed(apnContext)) {
|
||||||
&& apnContext.getPendingAction() == ApnContext.PENDING_ACTION_APN_DISABLE)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -508,7 +527,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
&& apnContext.getPendingAction() == ApnContext.PENDING_ACTION_APN_DISABLE) {
|
&& apnContext.getPendingAction() == ApnContext.PENDING_ACTION_APN_DISABLE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isDataAllowed();
|
return apnContext.isReady() && isDataAllowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
//****** Called from ServiceStateTracker
|
//****** Called from ServiceStateTracker
|
||||||
@@ -532,6 +551,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
} else {
|
} else {
|
||||||
// Only check for default APN state
|
// Only check for default APN state
|
||||||
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
||||||
|
if (defaultApnContext != null) {
|
||||||
if (defaultApnContext.getState() == State.FAILED) {
|
if (defaultApnContext.getState() == State.FAILED) {
|
||||||
cleanUpConnection(false, defaultApnContext);
|
cleanUpConnection(false, defaultApnContext);
|
||||||
defaultApnContext.getDataConnection().resetRetryCount();
|
defaultApnContext.getDataConnection().resetRetryCount();
|
||||||
@@ -539,6 +559,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
trySetupData(Phone.REASON_GPRS_ATTACHED, Phone.APN_TYPE_DEFAULT);
|
trySetupData(Phone.REASON_GPRS_ATTACHED, Phone.APN_TYPE_DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isDataAllowed() {
|
protected boolean isDataAllowed() {
|
||||||
@@ -599,10 +620,11 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
|
|
||||||
private boolean trySetupData(ApnContext apnContext) {
|
private boolean trySetupData(ApnContext apnContext) {
|
||||||
|
|
||||||
if (DBG)
|
if (DBG) {
|
||||||
log("trySetupData for type:" + apnContext.getApnType() +
|
log("trySetupData for type:" + apnContext.getApnType() +
|
||||||
" due to " + apnContext.getReason());
|
" due to " + apnContext.getReason());
|
||||||
log("[DSAC DEB] " + "trySetupData with mIsPsRestricted=" + mIsPsRestricted);
|
log("[DSAC DEB] " + "trySetupData with mIsPsRestricted=" + mIsPsRestricted);
|
||||||
|
}
|
||||||
|
|
||||||
if (mPhone.getSimulatedRadioControl() != null) {
|
if (mPhone.getSimulatedRadioControl() != null) {
|
||||||
// Assume data is connected on the simulator
|
// Assume data is connected on the simulator
|
||||||
@@ -656,12 +678,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
if (mAvailability == availability) return;
|
if (mAvailability == availability) return;
|
||||||
mAvailability = availability;
|
mAvailability = availability;
|
||||||
|
|
||||||
Iterator<ApnContext> it = mApnContexts.values().iterator();
|
for (ApnContext apnContext : mApnContexts.values()) {
|
||||||
while (it.hasNext()) {
|
if (!apnContext.isReady()) {
|
||||||
ApnContext apnContext = it.next();
|
|
||||||
// FIXME: Dont understand why this needs to be done!!
|
|
||||||
// This information is not available (DISABLED APNS)
|
|
||||||
if (false) {
|
|
||||||
if (DBG) log("notify disconnected for type:" + apnContext.getApnType());
|
if (DBG) log("notify disconnected for type:" + apnContext.getApnType());
|
||||||
mPhone.notifyDataConnection(reason != null ? reason : apnContext.getReason(),
|
mPhone.notifyDataConnection(reason != null ? reason : apnContext.getReason(),
|
||||||
apnContext.getApnType(),
|
apnContext.getApnType(),
|
||||||
@@ -738,7 +756,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GsmDataConnection conn = apnContext.getDataConnection();
|
DataConnection conn = apnContext.getDataConnection();
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
apnContext.setState(State.DISCONNECTING);
|
apnContext.setState(State.DISCONNECTING);
|
||||||
if (tearDown) {
|
if (tearDown) {
|
||||||
@@ -750,10 +768,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
|
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apnContext.getPendingAction() == ApnContext.PENDING_ACTION_APN_DISABLE) {
|
|
||||||
mApnContexts.remove(apnContext.getApnType());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -852,6 +866,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
dc = findFreeDataConnection();
|
dc = findFreeDataConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dc == null) {
|
||||||
|
dc = createDataConnection(apnContext);
|
||||||
|
}
|
||||||
|
|
||||||
if (dc == null) {
|
if (dc == null) {
|
||||||
if (DBG) log("setupData: No free GsmDataConnection found!");
|
if (DBG) log("setupData: No free GsmDataConnection found!");
|
||||||
return false;
|
return false;
|
||||||
@@ -1272,42 +1290,98 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
|
|
||||||
private void onRecordsLoaded() {
|
private void onRecordsLoaded() {
|
||||||
createAllApnList();
|
createAllApnList();
|
||||||
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
for (ApnContext apnContext : mApnContexts.values()) {
|
||||||
if (defaultApnContext!=null ) {
|
if (apnContext.isReady()) {
|
||||||
defaultApnContext.setReason(Phone.REASON_SIM_LOADED);
|
apnContext.setReason(Phone.REASON_SIM_LOADED);
|
||||||
if (defaultApnContext.getState() == State.FAILED) {
|
if (apnContext.getState() == State.FAILED) {
|
||||||
if (DBG) log("onRecordsLoaded clean connection");
|
if (DBG) {
|
||||||
cleanUpConnection(false, defaultApnContext);
|
log("onRecordsLoaded clean connection for " + apnContext.getApnType());
|
||||||
}
|
}
|
||||||
sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA,defaultApnContext ));
|
cleanUpConnection(false, apnContext);
|
||||||
}
|
}
|
||||||
}
|
sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA, apnContext));
|
||||||
|
}
|
||||||
protected void onEnableNewApn(ApnContext apnContext ) {
|
}
|
||||||
// change our retry manager to use the appropriate numbers for the new APN
|
}
|
||||||
log("onEnableNewApn with ApnContext E");
|
|
||||||
if (apnContext.getApnType().equals(Phone.APN_TYPE_DEFAULT)) {
|
@Override
|
||||||
log("onEnableNewApn default type");
|
protected void onSetDependencyMet(String apnType, boolean met) {
|
||||||
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
ApnContext apnContext = mApnContexts.get(apnType);
|
||||||
defaultApnContext.getDataConnection().resetRetryCount();
|
if (apnContext == null) {
|
||||||
} else if (mApnToDataConnectionId.get(apnContext.getApnType()) == null) {
|
log("ApnContext not found in onSetDependencyMet(" + apnType + ", " + met + ")");
|
||||||
log("onEnableNewApn ApnType=" + apnContext.getApnType() +
|
return;
|
||||||
" missing, make a new connection");
|
}
|
||||||
int id = createDataConnection(apnContext.getApnType());
|
applyNewState(apnContext, apnContext.isEnabled(), met);
|
||||||
mDataConnections.get(id).resetRetryCount();
|
}
|
||||||
} else {
|
|
||||||
log("oneEnableNewApn connection already exists, nothing to setup");
|
private void applyNewState(ApnContext apnContext, boolean enabled, boolean met) {
|
||||||
}
|
boolean cleanup = false;
|
||||||
|
boolean trySetup = false;
|
||||||
// TODO: To support simultaneous PDP contexts, this should really only call
|
if (DBG) {
|
||||||
// cleanUpConnection if it needs to free up a GsmDataConnection.
|
log("applyNewState(" + apnContext.getApnType() + ", " + enabled +
|
||||||
if (DBG) log("onEnableNewApn setup data");
|
"(" + apnContext.isEnabled() + "), " + met + "(" +
|
||||||
|
apnContext.getDependencyMet() +"))");
|
||||||
|
}
|
||||||
|
if (apnContext.isReady()) {
|
||||||
|
if (enabled && met) return;
|
||||||
|
if (!enabled) {
|
||||||
|
apnContext.setReason(Phone.REASON_DATA_DISABLED);
|
||||||
|
} else {
|
||||||
|
apnContext.setReason(Phone.REASON_DATA_DEPENDENCY_UNMET);
|
||||||
|
}
|
||||||
|
cleanup = true;
|
||||||
|
} else {
|
||||||
|
if (enabled && met) {
|
||||||
|
if (apnContext.isEnabled()) {
|
||||||
|
apnContext.setReason(Phone.REASON_DATA_DEPENDENCY_MET);
|
||||||
|
} else {
|
||||||
|
apnContext.setReason(Phone.REASON_DATA_ENABLED);
|
||||||
|
}
|
||||||
|
DataConnection conn = checkForConnectionForApnContext(apnContext);
|
||||||
|
if (conn == null) {
|
||||||
if (apnContext.getState() == State.FAILED) {
|
if (apnContext.getState() == State.FAILED) {
|
||||||
if (DBG) log("previous state is FAILED, reset to IDLE");
|
|
||||||
apnContext.setState(State.IDLE);
|
apnContext.setState(State.IDLE);
|
||||||
}
|
}
|
||||||
trySetupData(apnContext);
|
trySetup = true;
|
||||||
log("onEnableNewApn with ApnContext X");
|
} else {
|
||||||
|
// TODO send notifications
|
||||||
|
if (DBG) {
|
||||||
|
log("Found existing connection for " + apnContext.getApnType() +
|
||||||
|
": " + conn);
|
||||||
|
}
|
||||||
|
apnContext.setDataConnection(conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apnContext.setEnabled(enabled);
|
||||||
|
apnContext.setDependencyMet(met);
|
||||||
|
if (cleanup) cleanUpConnection(true, apnContext);
|
||||||
|
if (trySetup) trySetupData(apnContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataConnection checkForConnectionForApnContext(ApnContext apnContext) {
|
||||||
|
// Loop through all apnContexts looking for one with a conn that satisfies this apnType
|
||||||
|
String apnType = apnContext.getApnType();
|
||||||
|
for (ApnContext c : mApnContexts.values()) {
|
||||||
|
DataConnection conn = c.getDataConnection();
|
||||||
|
if (conn != null) {
|
||||||
|
ApnSetting apnSetting = c.getApnSetting();
|
||||||
|
if (apnSetting != null && apnSetting.canHandleType(apnType)) return conn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEnableApn(int apnId, int enabled) {
|
||||||
|
ApnContext apnContext = mApnContexts.get(apnIdToType(apnId));
|
||||||
|
if (apnContext == null) {
|
||||||
|
log("ApnContext not found in onEnableApn(" + apnId + ", " + enabled + ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO change our retry manager to use the appropriate numbers for the new APN
|
||||||
|
log("onEnableApn with ApnContext E");
|
||||||
|
applyNewState(apnContext, enabled == ENABLED, apnContext.getDependencyMet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1392,7 +1466,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
mLinkProperties = getLinkProperties(apnContext.getDataConnection());
|
mLinkProperties = getLinkProperties(apnContext.getDataConnection());
|
||||||
mLinkCapabilities = getLinkCapabilities(apnContext.getDataConnection());
|
mLinkCapabilities = getLinkCapabilities(apnContext.getDataConnection());
|
||||||
|
|
||||||
ApnSetting apn = apnContext.getDataConnection().getApn();
|
ApnSetting apn = apnContext.getApnSetting();
|
||||||
if (apn.proxy != null && apn.proxy.length() != 0) {
|
if (apn.proxy != null && apn.proxy.length() != 0) {
|
||||||
try {
|
try {
|
||||||
ProxyProperties proxy = new ProxyProperties(apn.proxy,
|
ProxyProperties proxy = new ProxyProperties(apn.proxy,
|
||||||
@@ -1508,8 +1582,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
|
|
||||||
// Check if APN disabled.
|
// Check if APN disabled.
|
||||||
if (apnContext.getPendingAction() == ApnContext.PENDING_ACTION_APN_DISABLE) {
|
if (apnContext.getPendingAction() == ApnContext.PENDING_ACTION_APN_DISABLE) {
|
||||||
mApnContexts.remove(apnContext.getApnType());
|
apnContext.setEnabled(false);
|
||||||
return;
|
apnContext.setPendingAction(ApnContext.PENDING_ACTION_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TextUtils.equals(apnContext.getApnType(), Phone.APN_TYPE_DEFAULT)
|
if (TextUtils.equals(apnContext.getApnType(), Phone.APN_TYPE_DEFAULT)
|
||||||
@@ -1553,12 +1627,14 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
} else {
|
} else {
|
||||||
// reset reconnect timer
|
// reset reconnect timer
|
||||||
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
||||||
|
if (defaultApnContext != null) {
|
||||||
defaultApnContext.getDataConnection().resetRetryCount();
|
defaultApnContext.getDataConnection().resetRetryCount();
|
||||||
mReregisterOnReconnectFailure = false;
|
mReregisterOnReconnectFailure = false;
|
||||||
// in case data setup was attempted when we were on a voice call
|
// in case data setup was attempted when we were on a voice call
|
||||||
trySetupData(Phone.REASON_VOICE_CALL_ENDED, Phone.APN_TYPE_DEFAULT);
|
trySetupData(Phone.REASON_VOICE_CALL_ENDED, Phone.APN_TYPE_DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCleanUpConnection(boolean tearDown, int apnId, String reason) {
|
protected void onCleanUpConnection(boolean tearDown, int apnId, String reason) {
|
||||||
@@ -1584,10 +1660,12 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
Iterator<ApnContext> it = mApnContexts.values().iterator();
|
Iterator<ApnContext> it = mApnContexts.values().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
ApnContext apnContext = it.next();
|
ApnContext apnContext = it.next();
|
||||||
|
if (apnContext.isReady()) {
|
||||||
if (DBG) log("notify for type:"+apnContext.getApnType());
|
if (DBG) log("notify for type:"+apnContext.getApnType());
|
||||||
mPhone.notifyDataConnection(reason != null ? reason : apnContext.getReason(),
|
mPhone.notifyDataConnection(reason != null ? reason : apnContext.getReason(),
|
||||||
apnContext.getApnType());
|
apnContext.getApnType());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
notifyDataAvailability(reason);
|
notifyDataAvailability(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1598,7 +1676,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
private void createAllApnList() {
|
private void createAllApnList() {
|
||||||
mAllApns = new ArrayList<ApnSetting>();
|
mAllApns = new ArrayList<ApnSetting>();
|
||||||
String operator = mPhone.mSIMRecords.getSIMOperatorNumeric();
|
String operator = mPhone.mSIMRecords.getSIMOperatorNumeric();
|
||||||
|
|
||||||
if (operator != null) {
|
if (operator != null) {
|
||||||
String selection = "numeric = '" + operator + "'";
|
String selection = "numeric = '" + operator + "'";
|
||||||
if (DBG) log("createAllApnList: selection=" + selection);
|
if (DBG) log("createAllApnList: selection=" + selection);
|
||||||
@@ -1631,7 +1708,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Return the id for a new data connection */
|
/** Return the id for a new data connection */
|
||||||
private int createDataConnection(String apnType) {
|
private GsmDataConnection createDataConnection(ApnContext apnContext) {
|
||||||
|
String apnType = apnContext.getApnType();
|
||||||
log("createDataConnection(" + apnType + ") E");
|
log("createDataConnection(" + apnType + ") E");
|
||||||
RetryManager rm = new RetryManager();
|
RetryManager rm = new RetryManager();
|
||||||
|
|
||||||
@@ -1656,12 +1734,13 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int id = mUniqueIdGenerator.getAndIncrement();
|
int id = mUniqueIdGenerator.getAndIncrement();
|
||||||
DataConnection conn = GsmDataConnection.makeDataConnection(mPhone, id, rm);
|
GsmDataConnection conn = GsmDataConnection.makeDataConnection(mPhone, id, rm);
|
||||||
|
conn.resetRetryCount();
|
||||||
mDataConnections.put(id, conn);
|
mDataConnections.put(id, conn);
|
||||||
mApnToDataConnectionId.put(apnType, id);
|
apnContext.setDataConnection(conn);
|
||||||
|
|
||||||
log("createDataConnection(" + apnType + ") X id=" + id);
|
log("createDataConnection(" + apnType + ") X id=" + id);
|
||||||
return id;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyDataConnections() {
|
private void destroyDataConnections() {
|
||||||
@@ -1691,7 +1770,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String operator = mPhone.mSIMRecords.getSIMOperatorNumeric();
|
String operator = mPhone.mSIMRecords.getSIMOperatorNumeric();
|
||||||
|
|
||||||
if (requestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
|
if (requestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
|
||||||
if (canSetPreferApn && mPreferredApn != null) {
|
if (canSetPreferApn && mPreferredApn != null) {
|
||||||
log("Preferred APN:" + operator + ":"
|
log("Preferred APN:" + operator + ":"
|
||||||
@@ -1707,13 +1785,14 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAllApns != null) {
|
if (mAllApns != null) {
|
||||||
for (ApnSetting apn : mAllApns) {
|
for (ApnSetting apn : mAllApns) {
|
||||||
if (apn.canHandleType(requestedApnType)) {
|
if (apn.canHandleType(requestedApnType)) {
|
||||||
apnList.add(apn);
|
apnList.add(apn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
loge("mAllApns is empty!");
|
||||||
}
|
}
|
||||||
if (DBG) log("buildWaitingApns: X apnList=" + apnList);
|
if (DBG) log("buildWaitingApns: X apnList=" + apnList);
|
||||||
return apnList;
|
return apnList;
|
||||||
@@ -1797,14 +1876,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
onRecordsLoaded();
|
onRecordsLoaded();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_ENABLE_NEW_APN:
|
|
||||||
ApnContext apnContext = null;
|
|
||||||
if (msg.obj instanceof ApnContext) {
|
|
||||||
apnContext = (ApnContext)msg.obj;
|
|
||||||
}
|
|
||||||
onEnableNewApn(apnContext);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVENT_DATA_CONNECTION_DETACHED:
|
case EVENT_DATA_CONNECTION_DETACHED:
|
||||||
onDataConnectionDetached();
|
onDataConnectionDetached();
|
||||||
break;
|
break;
|
||||||
@@ -1883,8 +1954,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
if (msg.obj instanceof ApnContext) {
|
if (msg.obj instanceof ApnContext) {
|
||||||
cleanUpConnection(tearDown, (ApnContext)msg.obj);
|
cleanUpConnection(tearDown, (ApnContext)msg.obj);
|
||||||
} else {
|
} else {
|
||||||
Log.e(LOG_TAG,
|
loge("[GsmDataConnectionTracker] connectpion cleanup request w/o apn context");
|
||||||
"[GsmDataConnectionTracker] connectpion cleanup request w/o apn context");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class WifiStateTracker implements NetworkStateTracker {
|
|||||||
private LinkProperties mLinkProperties;
|
private LinkProperties mLinkProperties;
|
||||||
private LinkCapabilities mLinkCapabilities;
|
private LinkCapabilities mLinkCapabilities;
|
||||||
private NetworkInfo mNetworkInfo;
|
private NetworkInfo mNetworkInfo;
|
||||||
|
private NetworkInfo.State mLastState = NetworkInfo.State.UNKNOWN;
|
||||||
|
|
||||||
/* For sending events to connectivity service handler */
|
/* For sending events to connectivity service handler */
|
||||||
private Handler mCsHandler;
|
private Handler mCsHandler;
|
||||||
@@ -217,6 +218,14 @@ public class WifiStateTracker implements NetworkStateTracker {
|
|||||||
if (mLinkCapabilities == null) {
|
if (mLinkCapabilities == null) {
|
||||||
mLinkCapabilities = new LinkCapabilities();
|
mLinkCapabilities = new LinkCapabilities();
|
||||||
}
|
}
|
||||||
|
// don't want to send redundent state messages
|
||||||
|
// TODO can this be fixed in WifiStateMachine?
|
||||||
|
NetworkInfo.State state = mNetworkInfo.getState();
|
||||||
|
if (mLastState == state) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
mLastState = state;
|
||||||
|
}
|
||||||
Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
|
Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
|
||||||
msg.sendToTarget();
|
msg.sendToTarget();
|
||||||
} else if (intent.getAction().equals(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION)) {
|
} else if (intent.getAction().equals(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION)) {
|
||||||
@@ -228,4 +237,7 @@ public class WifiStateTracker implements NetworkStateTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDependencyMet(boolean met) {
|
||||||
|
// not supported on this network
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user