Allow DataConnectionTrackers to manage multiple data connections.
This is the first step to allow simultaneous data connections. Bug: 2441767 Change-Id: Ia625cfe94b771a6958401adca84b80543fbdb35c
This commit is contained in:
@@ -261,8 +261,10 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
protected static final int EVENT_LOG_BAD_DNS_ADDRESS = 50100;
|
||||
|
||||
//***** Member Variables
|
||||
protected int mId;
|
||||
protected int mTag;
|
||||
protected PhoneBase phone;
|
||||
protected RetryManager mRetryMgr;
|
||||
protected int cid;
|
||||
protected LinkProperties mLinkProperties = new LinkProperties();
|
||||
protected LinkCapabilities mCapabilities = new LinkCapabilities();
|
||||
@@ -285,10 +287,11 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
|
||||
|
||||
//***** Constructor
|
||||
protected DataConnection(PhoneBase phone, String name) {
|
||||
protected DataConnection(PhoneBase phone, String name, RetryManager rm) {
|
||||
super(name);
|
||||
if (DBG) log("DataConnection constructor E");
|
||||
this.phone = phone;
|
||||
mRetryMgr = rm;
|
||||
this.cid = -1;
|
||||
clearSettings();
|
||||
|
||||
@@ -358,8 +361,8 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
|
||||
if (dp.onCompletedMsg != null) {
|
||||
Message msg = dp.onCompletedMsg;
|
||||
log(String.format("msg.what=%d msg.obj=%s",
|
||||
msg.what, ((msg.obj instanceof String) ? (String) msg.obj : "<no-reason>")));
|
||||
log(String.format("msg=%s msg.obj=%s", msg.toString(),
|
||||
((msg.obj instanceof String) ? (String) msg.obj : "<no-reason>")));
|
||||
AsyncResult.forMessage(msg);
|
||||
msg.sendToTarget();
|
||||
}
|
||||
@@ -372,6 +375,10 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
clearSettings();
|
||||
}
|
||||
|
||||
public RetryManager getRetryMgr() {
|
||||
return mRetryMgr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all settings called when entering mInactiveState.
|
||||
*/
|
||||
@@ -857,13 +864,13 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
|
||||
/**
|
||||
* Connect to the apn and return an AsyncResult in onCompletedMsg.
|
||||
* Used for cellular networks that use Acess Point Names (APN) such
|
||||
* Used for cellular networks that use Acesss Point Names (APN) such
|
||||
* as GSM networks.
|
||||
*
|
||||
* @param onCompletedMsg is sent with its msg.obj as an AsyncResult object.
|
||||
* With AsyncResult.userObj set to the original msg.obj,
|
||||
* AsyncResult.result = FailCause and AsyncResult.exception = Exception().
|
||||
* @param apn is the Acces Point Name to connect to
|
||||
* @param apn is the Access Point Name to connect to
|
||||
*/
|
||||
public void connect(Message onCompletedMsg, ApnSetting apn) {
|
||||
sendMessage(obtainMessage(EVENT_CONNECT, new ConnectionParams(apn, onCompletedMsg)));
|
||||
@@ -914,6 +921,13 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DataConnection ID
|
||||
*/
|
||||
public int getDataConnectionId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the LinkProperties for the connection.
|
||||
*
|
||||
|
||||
@@ -16,27 +16,38 @@
|
||||
|
||||
package com.android.internal.telephony;
|
||||
|
||||
import com.android.internal.telephony.cdma.CDMAPhone;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.IConnectivityManager;
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.AsyncResult;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.ServiceManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.SettingNotFoundException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
*
|
||||
*/
|
||||
public abstract class DataConnectionTracker extends Handler {
|
||||
protected static final boolean DBG = false;
|
||||
protected final String LOG_TAG = "DataConnectionTracker";
|
||||
protected static final boolean DBG = true;
|
||||
|
||||
/**
|
||||
* IDLE: ready to start data connection setup, default state
|
||||
@@ -121,9 +132,10 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
protected boolean mMasterDataEnabled = true;
|
||||
|
||||
protected boolean[] dataEnabled = new boolean[APN_NUM_TYPES];
|
||||
|
||||
protected int enabledCount = 0;
|
||||
|
||||
/* Currently requested APN type */
|
||||
/* Currently requested APN type (TODO: This should probably be a parameter not a member) */
|
||||
protected String mRequestedApnType = Phone.APN_TYPE_DEFAULT;
|
||||
|
||||
/** Retry configuration: A doubling of retry times from 5secs to 30minutes */
|
||||
@@ -165,20 +177,27 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
// represents an invalid IP address
|
||||
protected static final String NULL_IP = "0.0.0.0";
|
||||
|
||||
// TODO: See if we can remove INTENT_RECONNECT_ALARM
|
||||
// having to have different values for GSM and
|
||||
// CDMA. If so we can then remove the need for
|
||||
// getActionIntentReconnectAlarm.
|
||||
protected static final String INTENT_RECONNECT_ALARM_EXTRA_REASON = "reason";
|
||||
|
||||
// member variables
|
||||
protected PhoneBase phone;
|
||||
protected Activity activity = Activity.NONE;
|
||||
protected State state = State.IDLE;
|
||||
protected PhoneBase mPhone;
|
||||
protected Activity mActivity = Activity.NONE;
|
||||
protected State mState = State.IDLE;
|
||||
protected Handler mDataConnectionTracker = null;
|
||||
|
||||
|
||||
protected long txPkts, rxPkts, sentSinceLastRecv;
|
||||
protected int netStatPollPeriod;
|
||||
protected long mTxPkts;
|
||||
protected long mRxPkts;
|
||||
protected long mSentSinceLastRecv;
|
||||
protected int mNetStatPollPeriod;
|
||||
protected int mNoRecvPollCount = 0;
|
||||
protected boolean netStatPollEnabled = false;
|
||||
protected boolean mNetStatPollEnabled = false;
|
||||
|
||||
/** Manage the behavior of data retry after failure */
|
||||
/** Manage the behavior of data retry after failure (TODO: One per connection in the future?) */
|
||||
protected RetryManager mRetryMgr = new RetryManager();
|
||||
|
||||
// wifi connection status will be updated by sticky intent
|
||||
@@ -188,37 +207,125 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
protected PendingIntent mReconnectIntent = null;
|
||||
|
||||
/** CID of active data connection */
|
||||
protected int cidActive;
|
||||
protected int mCidActive;
|
||||
|
||||
/** indication of our availability (preconditions to trysetupData are met) **/
|
||||
protected boolean mAvailability = false;
|
||||
|
||||
// When false we will not auto attach and manully attaching is required.
|
||||
protected boolean mAutoAttachOnCreation = false;
|
||||
|
||||
// State of screen
|
||||
// (TODO: Reconsider tying directly to screen, maybe this is
|
||||
// really a lower power mode")
|
||||
protected boolean mIsScreenOn = true;
|
||||
|
||||
/** The link properties (dns, gateway, ip, etc) */
|
||||
protected LinkProperties mLinkProperties = new LinkProperties();
|
||||
|
||||
/** The link capabilities */
|
||||
protected LinkCapabilities mLinkCapabilities = new LinkCapabilities();
|
||||
|
||||
/** Allows the generation of unique Id's for DataConnection objects */
|
||||
protected AtomicInteger mUniqueIdGenerator = new AtomicInteger(0);
|
||||
|
||||
/** The data connections. */
|
||||
protected HashMap<Integer, DataConnection> mDataConnections =
|
||||
new HashMap<Integer, DataConnection>();
|
||||
|
||||
protected BroadcastReceiver mIntentReceiver = new BroadcastReceiver ()
|
||||
{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
String action = intent.getAction();
|
||||
if (action.equals(Intent.ACTION_SCREEN_ON)) {
|
||||
mIsScreenOn = true;
|
||||
stopNetStatPoll();
|
||||
startNetStatPoll();
|
||||
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||
mIsScreenOn = false;
|
||||
stopNetStatPoll();
|
||||
startNetStatPoll();
|
||||
} else if (action.equals(getActionIntentReconnectAlarm())) {
|
||||
log("Reconnect alarm. Previous state was " + mState);
|
||||
|
||||
String reason = intent.getStringExtra(INTENT_RECONNECT_ALARM_EXTRA_REASON);
|
||||
if (mState == State.FAILED) {
|
||||
Message msg = obtainMessage(EVENT_CLEAN_UP_CONNECTION);
|
||||
msg.arg1 = 0; // tearDown is false
|
||||
msg.obj = reason;
|
||||
sendMessage(msg);
|
||||
}
|
||||
sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA));
|
||||
} else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
|
||||
final android.net.NetworkInfo networkInfo = (NetworkInfo)
|
||||
intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||
mIsWifiConnected = (networkInfo != null && networkInfo.isConnected());
|
||||
} else if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
|
||||
final boolean enabled = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
|
||||
WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_ENABLED;
|
||||
|
||||
if (!enabled) {
|
||||
// when WiFi got disabled, the NETWORK_STATE_CHANGED_ACTION
|
||||
// quit and won't report disconnected until next enabling.
|
||||
mIsWifiConnected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
protected DataConnectionTracker(PhoneBase phone) {
|
||||
super();
|
||||
this.phone = phone;
|
||||
mPhone = phone;
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(getActionIntentReconnectAlarm());
|
||||
filter.addAction(Intent.ACTION_SCREEN_ON);
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||
|
||||
// TODO: Why is this registering the phone as the receiver of the intent
|
||||
// and not its own handler?
|
||||
mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone);
|
||||
|
||||
// This preference tells us 1) initial condition for "dataEnabled",
|
||||
// and 2) whether the RIL will setup the baseband to auto-PS attach.
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
|
||||
boolean dataEnabledSetting = true;
|
||||
try {
|
||||
dataEnabledSetting = IConnectivityManager.Stub.asInterface(ServiceManager.
|
||||
getService(Context.CONNECTIVITY_SERVICE)).getMobileDataEnabled();
|
||||
} catch (Exception e) {
|
||||
// nothing to do - use the old behavior and leave data on
|
||||
}
|
||||
dataEnabled[APN_DEFAULT_ID] =
|
||||
!sp.getBoolean(PhoneBase.DATA_DISABLED_ON_BOOT_KEY, false) &&
|
||||
dataEnabledSetting;
|
||||
if (dataEnabled[APN_DEFAULT_ID]) {
|
||||
enabledCount++;
|
||||
}
|
||||
mAutoAttachOnCreation = dataEnabled[APN_DEFAULT_ID];
|
||||
}
|
||||
|
||||
public abstract void dispose();
|
||||
public void dispose() {
|
||||
mPhone.getContext().unregisterReceiver(this.mIntentReceiver);
|
||||
}
|
||||
|
||||
public Activity getActivity() {
|
||||
return activity;
|
||||
return mActivity;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
return mState;
|
||||
}
|
||||
|
||||
public String getStateInString() {
|
||||
switch (state) {
|
||||
switch (mState) {
|
||||
case IDLE: return "IDLE";
|
||||
case INITING: return "INIT";
|
||||
case CONNECTING: return "CING";
|
||||
@@ -230,6 +337,14 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data connections
|
||||
*/
|
||||
public ArrayList<DataConnection> getAllDataConnections() {
|
||||
/** TODO: change return type to Collection? */
|
||||
return new ArrayList<DataConnection>(mDataConnections.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* The data connection is expected to be setup while device
|
||||
* 1. has Icc card
|
||||
@@ -246,9 +361,9 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
// the shared values. If it is not, then update it.
|
||||
public void setDataOnRoamingEnabled(boolean enabled) {
|
||||
if (getDataOnRoamingEnabled() != enabled) {
|
||||
Settings.Secure.putInt(phone.getContext().getContentResolver(),
|
||||
Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
|
||||
Settings.Secure.DATA_ROAMING, enabled ? 1 : 0);
|
||||
if (phone.getServiceState().getRoaming()) {
|
||||
if (mPhone.getServiceState().getRoaming()) {
|
||||
if (enabled) {
|
||||
mRetryMgr.resetRetryCount();
|
||||
}
|
||||
@@ -257,16 +372,19 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
//Retrieve the data roaming setting from the shared preferences.
|
||||
// Retrieve the data roaming setting from the shared preferences.
|
||||
public boolean getDataOnRoamingEnabled() {
|
||||
try {
|
||||
return Settings.Secure.getInt(phone.getContext().getContentResolver(),
|
||||
Settings.Secure.DATA_ROAMING) > 0;
|
||||
return Settings.Secure.getInt(
|
||||
mPhone.getContext().getContentResolver(), Settings.Secure.DATA_ROAMING) > 0;
|
||||
} catch (SettingNotFoundException snfe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected abstract String getActionIntentReconnectAlarm();
|
||||
|
||||
// abstract handler methods
|
||||
protected abstract boolean onTrySetupData(String reason);
|
||||
protected abstract void onRoamingOff();
|
||||
@@ -274,14 +392,14 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
protected abstract void onRadioAvailable();
|
||||
protected abstract void onRadioOffOrNotAvailable();
|
||||
protected abstract void onDataSetupComplete(AsyncResult ar);
|
||||
protected abstract void onDisconnectDone(AsyncResult ar);
|
||||
protected abstract void onDisconnectDone(int connId, AsyncResult ar);
|
||||
protected abstract void onResetDone(AsyncResult ar);
|
||||
protected abstract void onVoiceCallStarted();
|
||||
protected abstract void onVoiceCallEnded();
|
||||
protected abstract void onCleanUpConnection(boolean tearDown, String reason);
|
||||
|
||||
@Override
|
||||
public void handleMessage (Message msg) {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
|
||||
case EVENT_ENABLE_NEW_APN:
|
||||
@@ -291,7 +409,7 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
case EVENT_TRY_SETUP_DATA:
|
||||
String reason = null;
|
||||
if (msg.obj instanceof String) {
|
||||
reason = (String)msg.obj;
|
||||
reason = (String) msg.obj;
|
||||
}
|
||||
onTrySetupData(reason);
|
||||
break;
|
||||
@@ -316,12 +434,13 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
break;
|
||||
|
||||
case EVENT_DATA_SETUP_COMPLETE:
|
||||
cidActive = msg.arg1;
|
||||
mCidActive = msg.arg1;
|
||||
onDataSetupComplete((AsyncResult) msg.obj);
|
||||
break;
|
||||
|
||||
case EVENT_DISCONNECT_DONE:
|
||||
onDisconnectDone((AsyncResult) msg.obj);
|
||||
log("DataConnectoinTracker.handleMessage: EVENT_DISCONNECT_DONE msg=" + msg);
|
||||
onDisconnectDone(msg.arg1, (AsyncResult) msg.obj);
|
||||
break;
|
||||
|
||||
case EVENT_VOICE_CALL_STARTED:
|
||||
@@ -334,7 +453,7 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
case EVENT_CLEAN_UP_CONNECTION:
|
||||
boolean tearDown = (msg.arg1 == 0) ? false : true;
|
||||
onCleanUpConnection(tearDown, (String)msg.obj);
|
||||
onCleanUpConnection(tearDown, (String) msg.obj);
|
||||
break;
|
||||
|
||||
case EVENT_SET_MASTER_DATA_ENABLE:
|
||||
@@ -354,8 +473,9 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
/**
|
||||
* Report the current state of data connectivity (enabled or disabled)
|
||||
*
|
||||
* @return {@code false} if data connectivity has been explicitly disabled,
|
||||
* {@code true} otherwise.
|
||||
* {@code true} otherwise.
|
||||
*/
|
||||
public synchronized boolean getDataEnabled() {
|
||||
return dataEnabled[APN_DEFAULT_ID];
|
||||
@@ -363,8 +483,9 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
/**
|
||||
* Report on whether data connectivity is enabled
|
||||
*
|
||||
* @return {@code false} if data connectivity has been explicitly disabled,
|
||||
* {@code true} otherwise.
|
||||
* {@code true} otherwise.
|
||||
*/
|
||||
public boolean getAnyDataEnabled() {
|
||||
return (enabledCount != 0);
|
||||
@@ -378,6 +499,8 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
protected abstract void log(String s);
|
||||
|
||||
protected abstract void loge(String s);
|
||||
|
||||
protected int apnTypeToId(String type) {
|
||||
if (TextUtils.equals(type, Phone.APN_TYPE_DEFAULT)) {
|
||||
return APN_DEFAULT_ID;
|
||||
@@ -407,7 +530,7 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
case APN_HIPRI_ID:
|
||||
return Phone.APN_TYPE_HIPRI;
|
||||
default:
|
||||
Log.e(LOG_TAG, "Unknown id (" + id + ") in apnIdToType");
|
||||
log("Unknown id (" + id + ") in apnIdToType");
|
||||
return Phone.APN_TYPE_DEFAULT;
|
||||
}
|
||||
}
|
||||
@@ -420,8 +543,6 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
protected abstract String getActiveApnString();
|
||||
|
||||
public abstract ArrayList<DataConnection> getAllDataConnections();
|
||||
|
||||
protected abstract void setState(State s);
|
||||
|
||||
protected LinkProperties getLinkProperties(String apnType) {
|
||||
@@ -467,33 +588,34 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
protected void notifyDataConnection(String reason) {
|
||||
for (int id = 0; id < APN_NUM_TYPES; id++) {
|
||||
if (dataEnabled[id]) {
|
||||
phone.notifyDataConnection(reason, apnIdToType(id));
|
||||
mPhone.notifyDataConnection(reason, apnIdToType(id));
|
||||
}
|
||||
}
|
||||
notifyDataAvailability(reason);
|
||||
}
|
||||
|
||||
// a new APN has gone active and needs to send events to catch up with the current condition
|
||||
// a new APN has gone active and needs to send events to catch up with the
|
||||
// current condition
|
||||
private void notifyApnIdUpToCurrent(String reason, int apnId) {
|
||||
switch (state) {
|
||||
switch (mState) {
|
||||
case IDLE:
|
||||
case INITING:
|
||||
break;
|
||||
case CONNECTING:
|
||||
case SCANNING:
|
||||
phone.notifyDataConnection(reason, apnIdToType(apnId), Phone.DataState.CONNECTING);
|
||||
mPhone.notifyDataConnection(reason, apnIdToType(apnId), Phone.DataState.CONNECTING);
|
||||
break;
|
||||
case CONNECTED:
|
||||
case DISCONNECTING:
|
||||
phone.notifyDataConnection(reason, apnIdToType(apnId), Phone.DataState.CONNECTING);
|
||||
phone.notifyDataConnection(reason, apnIdToType(apnId), Phone.DataState.CONNECTED);
|
||||
mPhone.notifyDataConnection(reason, apnIdToType(apnId), Phone.DataState.CONNECTING);
|
||||
mPhone.notifyDataConnection(reason, apnIdToType(apnId), Phone.DataState.CONNECTED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// since we normally don't send info to a disconnected APN, we need to do this specially
|
||||
private void notifyApnIdDisconnected(String reason, int apnId) {
|
||||
phone.notifyDataConnection(reason, apnIdToType(apnId), Phone.DataState.DISCONNECTED);
|
||||
mPhone.notifyDataConnection(reason, apnIdToType(apnId), Phone.DataState.DISCONNECTED);
|
||||
}
|
||||
|
||||
// disabled apn's still need avail/unavail notificiations - send them out
|
||||
@@ -526,10 +648,10 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
* @return {@code true} if data connectivity is possible, {@code false} otherwise.
|
||||
*/
|
||||
protected boolean isDataPossible() {
|
||||
boolean possible = (isDataAllowed() &&
|
||||
!(getDataEnabled() && (state == State.FAILED || state == State.IDLE)));
|
||||
boolean possible = (isDataAllowed()
|
||||
&& !(getDataEnabled() && (mState == State.FAILED || mState == State.IDLE)));
|
||||
if (!possible && DBG && isDataAllowed()) {
|
||||
log("Data not possible. No coverage: dataState = " + state);
|
||||
log("Data not possible. No coverage: dataState = " + mState);
|
||||
}
|
||||
return possible;
|
||||
}
|
||||
@@ -549,13 +671,13 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
/**
|
||||
* Ensure that we are connected to an APN of the specified type.
|
||||
* @param type the APN type (currently the only valid values
|
||||
* are {@link Phone#APN_TYPE_MMS} and {@link Phone#APN_TYPE_SUPL})
|
||||
* @return the result of the operation. Success is indicated by
|
||||
* a return value of either {@code Phone.APN_ALREADY_ACTIVE} or
|
||||
* {@code Phone.APN_REQUEST_STARTED}. In the latter case, a broadcast
|
||||
* will be sent by the ConnectivityManager when a connection to
|
||||
* the APN has been established.
|
||||
*
|
||||
* @param type the APN type (currently the only valid values are
|
||||
* {@link Phone#APN_TYPE_MMS} and {@link Phone#APN_TYPE_SUPL})
|
||||
* @return Success is indicated by {@code Phone.APN_ALREADY_ACTIVE} or
|
||||
* {@code Phone.APN_REQUEST_STARTED}. In the latter case, a
|
||||
* broadcast will be sent by the ConnectivityManager when a
|
||||
* connection to the APN has been established.
|
||||
*/
|
||||
public synchronized int enableApnType(String type) {
|
||||
int id = apnTypeToId(type);
|
||||
@@ -564,13 +686,12 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
}
|
||||
|
||||
if (DBG) {
|
||||
Log.d(LOG_TAG, "enableApnType(" + type + "), isApnTypeActive = "
|
||||
+ isApnTypeActive(type) + ", isApnIdEnabled =" + isApnIdEnabled(id) +
|
||||
" and state = " + state);
|
||||
log("enableApnType(" + type + "), isApnTypeActive = " + isApnTypeActive(type)
|
||||
+ ", isApnIdEnabled =" + isApnIdEnabled(id) + " and state = " + mState);
|
||||
}
|
||||
|
||||
if (!isApnTypeAvailable(type)) {
|
||||
if (DBG) Log.d(LOG_TAG, "type not available");
|
||||
if (DBG) log("type not available");
|
||||
return Phone.APN_TYPE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
@@ -583,15 +704,21 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* The APN of the specified type is no longer needed. Ensure that if
|
||||
* use of the default APN has not been explicitly disabled, we are connected
|
||||
* to the default APN.
|
||||
* The APN of the specified type is no longer needed. Ensure that if use of
|
||||
* the default APN has not been explicitly disabled, we are connected to the
|
||||
* default APN.
|
||||
*
|
||||
* @param type the APN type. The only valid values are currently
|
||||
* {@link Phone#APN_TYPE_MMS} and {@link Phone#APN_TYPE_SUPL}.
|
||||
* @return
|
||||
* {@link Phone#APN_TYPE_MMS} and {@link Phone#APN_TYPE_SUPL}.
|
||||
* @return Success is indicated by {@code Phone.APN_ALREADY_ACTIVE} or
|
||||
* {@code Phone.APN_REQUEST_STARTED}. In the latter case, a
|
||||
* broadcast will be sent by the ConnectivityManager when a
|
||||
* connection to the APN has been disconnected. A {@code
|
||||
* Phone.APN_REQUEST_FAILED} is returned if the type parameter is
|
||||
* invalid or if the apn wasn't enabled.
|
||||
*/
|
||||
public synchronized int disableApnType(String type) {
|
||||
if (DBG) Log.d(LOG_TAG, "disableApnType("+type+")");
|
||||
if (DBG) log("disableApnType(" + type + ")");
|
||||
int id = apnTypeToId(type);
|
||||
if (id == APN_INVALID_ID) {
|
||||
return Phone.APN_REQUEST_FAILED;
|
||||
@@ -614,8 +741,8 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
private void setEnabled(int id, boolean enable) {
|
||||
if (DBG) {
|
||||
Log.d(LOG_TAG, "setEnabled(" + id + ", " + enable + ") with old state = "
|
||||
+ dataEnabled[id] + " and enabledCount = " + enabledCount);
|
||||
log("setEnabled(" + id + ", " + enable + ") with old state = " + dataEnabled[id]
|
||||
+ " and enabledCount = " + enabledCount);
|
||||
}
|
||||
Message msg = obtainMessage(EVENT_ENABLE_NEW_APN);
|
||||
msg.arg1 = id;
|
||||
@@ -625,9 +752,10 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
protected synchronized void onEnableApn(int apnId, int enabled) {
|
||||
if (DBG) {
|
||||
Log.d(LOG_TAG, "EVENT_APN_ENABLE_REQUEST " + apnId + ", " + enabled);
|
||||
Log.d(LOG_TAG, " dataEnabled = " + dataEnabled[apnId] + ", enabledCount = "
|
||||
+ enabledCount + ", isApnTypeActive = " + isApnTypeActive(apnIdToType(apnId)));
|
||||
log("EVENT_APN_ENABLE_REQUEST apnId=" + apnId + ", apnType=" + apnIdToType(apnId) +
|
||||
", enabled=" + enabled + ", dataEnabled = " + dataEnabled[apnId] +
|
||||
", enabledCount = " + enabledCount + ", isApnTypeActive = " +
|
||||
isApnTypeActive(apnIdToType(apnId)));
|
||||
}
|
||||
if (enabled == ENABLED) {
|
||||
if (!dataEnabled[apnId]) {
|
||||
@@ -676,18 +804,22 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent mobile data connections from being established,
|
||||
* or once again allow mobile data connections. If the state
|
||||
* toggles, then either tear down or set up data, as
|
||||
* appropriate to match the new state.
|
||||
* <p>This operation only affects the default APN, and if the same APN is
|
||||
* currently being used for MMS traffic, the teardown will not happen
|
||||
* even when {@code enable} is {@code false}.</p>
|
||||
* @param enable indicates whether to enable ({@code true}) or disable ({@code false}) data
|
||||
* Prevent mobile data connections from being established, or once again
|
||||
* allow mobile data connections. If the state toggles, then either tear
|
||||
* down or set up data, as appropriate to match the new state.
|
||||
* <p>
|
||||
* This operation only affects the default APN, and if the same APN is
|
||||
* currently being used for MMS traffic, the teardown will not happen even
|
||||
* when {@code enable} is {@code false}.
|
||||
* </p>
|
||||
*
|
||||
* @param enable indicates whether to enable ({@code true}) or disable (
|
||||
* {@code false}) data
|
||||
* @return {@code true} if the operation succeeded
|
||||
*/
|
||||
public boolean setDataEnabled(boolean enable) {
|
||||
if (DBG) Log.d(LOG_TAG, "setDataEnabled(" + enable + ")");
|
||||
if (DBG)
|
||||
log("setDataEnabled(" + enable + ")");
|
||||
|
||||
Message msg = obtainMessage(EVENT_SET_MASTER_DATA_ENABLE);
|
||||
msg.arg1 = (enable ? ENABLED : DISABLED);
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.android.internal.telephony.DataConnection;
|
||||
import com.android.internal.telephony.gsm.ApnSetting;
|
||||
import com.android.internal.telephony.Phone;
|
||||
import com.android.internal.telephony.RILConstants;
|
||||
import com.android.internal.telephony.RetryManager;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
@@ -39,23 +40,27 @@ public class CdmaDataConnection extends DataConnection {
|
||||
|
||||
|
||||
// ***** Constructor
|
||||
private CdmaDataConnection(CDMAPhone phone, String name) {
|
||||
super(phone, name);
|
||||
private CdmaDataConnection(CDMAPhone phone, String name, RetryManager rm) {
|
||||
super(phone, name, rm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the connection object
|
||||
*
|
||||
* @param phone
|
||||
* @param phone the Phone
|
||||
* @param id the connection id
|
||||
* @param rm the RetryManager
|
||||
* @return CdmaDataConnection that was created.
|
||||
*/
|
||||
static CdmaDataConnection makeDataConnection(CDMAPhone phone) {
|
||||
static CdmaDataConnection makeDataConnection(CDMAPhone phone, int id, RetryManager rm) {
|
||||
synchronized (mCountLock) {
|
||||
mCount += 1;
|
||||
}
|
||||
CdmaDataConnection cdmaDc = new CdmaDataConnection(phone, "CdmaDataConnection-" + mCount);
|
||||
CdmaDataConnection cdmaDc = new CdmaDataConnection(phone,
|
||||
"CdmaDataConnection-" + mCount, rm);
|
||||
cdmaDc.start();
|
||||
if (DBG) cdmaDc.log("Made " + cdmaDc.getName());
|
||||
cdmaDc.mId = id;
|
||||
return cdmaDc;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,21 +18,13 @@ package com.android.internal.telephony.cdma;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.IConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.TrafficStats;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.AsyncResult;
|
||||
import android.os.Message;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.cdma.CdmaCellLocation;
|
||||
@@ -46,6 +38,7 @@ import com.android.internal.telephony.DataConnection.FailCause;
|
||||
import com.android.internal.telephony.DataConnection;
|
||||
import com.android.internal.telephony.DataConnectionTracker;
|
||||
import com.android.internal.telephony.EventLogTags;
|
||||
import com.android.internal.telephony.RetryManager;
|
||||
import com.android.internal.telephony.gsm.ApnSetting;
|
||||
import com.android.internal.telephony.Phone;
|
||||
|
||||
@@ -59,20 +52,11 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
|
||||
private CDMAPhone mCdmaPhone;
|
||||
|
||||
// Indicates baseband will not auto-attach
|
||||
private boolean noAutoAttach = false;
|
||||
private boolean mIsScreenOn = true;
|
||||
|
||||
//useful for debugging
|
||||
boolean failNextConnect = false;
|
||||
boolean mFailNextConnect = false;
|
||||
|
||||
/**
|
||||
* dataConnectionList holds all the Data connection
|
||||
*/
|
||||
private ArrayList<DataConnection> dataConnectionList;
|
||||
|
||||
/** Currently active CdmaDataConnection */
|
||||
private CdmaDataConnection mActiveDataConnection;
|
||||
/** The DataConnection being setup */
|
||||
private CdmaDataConnection mPendingDataConnection;
|
||||
|
||||
private boolean mPendingRestartRadio = false;
|
||||
private static final int TIME_DELAYED_TO_RESTART_RADIO =
|
||||
@@ -83,10 +67,8 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
*/
|
||||
private static final int DATA_CONNECTION_POOL_SIZE = 1;
|
||||
|
||||
private static final int POLL_CONNECTION_MILLIS = 5 * 1000;
|
||||
private static final String INTENT_RECONNECT_ALARM =
|
||||
"com.android.internal.telephony.cdma-reconnect";
|
||||
private static final String INTENT_RECONNECT_ALARM_EXTRA_REASON = "reason";
|
||||
"com.android.internal.telephony.cdma-reconnect";
|
||||
|
||||
/**
|
||||
* Constants for the data connection activity:
|
||||
@@ -110,49 +92,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
// if we have no active Apn this is null
|
||||
protected ApnSetting mActiveApn;
|
||||
|
||||
// Possibly promote to base class, the only difference is
|
||||
// the INTENT_RECONNECT_ALARM action is a different string.
|
||||
// Do consider technology changes if it is promoted.
|
||||
BroadcastReceiver mIntentReceiver = new BroadcastReceiver ()
|
||||
{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
String action = intent.getAction();
|
||||
if (action.equals(Intent.ACTION_SCREEN_ON)) {
|
||||
mIsScreenOn = true;
|
||||
stopNetStatPoll();
|
||||
startNetStatPoll();
|
||||
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||
mIsScreenOn = false;
|
||||
stopNetStatPoll();
|
||||
startNetStatPoll();
|
||||
} else if (action.equals((INTENT_RECONNECT_ALARM))) {
|
||||
Log.d(LOG_TAG, "Data reconnect alarm. Previous state was " + state);
|
||||
|
||||
String reason = intent.getStringExtra(INTENT_RECONNECT_ALARM_EXTRA_REASON);
|
||||
if (state == State.FAILED) {
|
||||
cleanUpConnection(false, reason);
|
||||
}
|
||||
trySetupData(reason);
|
||||
} else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
|
||||
final android.net.NetworkInfo networkInfo = (NetworkInfo)
|
||||
intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||
mIsWifiConnected = (networkInfo != null && networkInfo.isConnected());
|
||||
} else if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
|
||||
final boolean enabled = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
|
||||
WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_ENABLED;
|
||||
|
||||
if (!enabled) {
|
||||
// when wifi got disabeled, the NETWORK_STATE_CHANGED_ACTION
|
||||
// quit and wont report disconnected til next enalbing.
|
||||
mIsWifiConnected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Constructor */
|
||||
|
||||
CdmaDataConnectionTracker(CDMAPhone p) {
|
||||
@@ -172,79 +111,49 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
p.mSST.registerForRoamingOff(this, EVENT_ROAMING_OFF, null);
|
||||
p.mCM.registerForCdmaOtaProvision(this, EVENT_CDMA_OTA_PROVISION, null);
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(INTENT_RECONNECT_ALARM);
|
||||
filter.addAction(Intent.ACTION_SCREEN_ON);
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||
|
||||
// TODO: Why is this registering the phone as the receiver of the intent
|
||||
// and not its own handler?
|
||||
p.getContext().registerReceiver(mIntentReceiver, filter, null, p);
|
||||
|
||||
mDataConnectionTracker = this;
|
||||
|
||||
createAllDataConnectionList();
|
||||
|
||||
// This preference tells us 1) initial condition for "dataEnabled",
|
||||
// and 2) whether the RIL will setup the baseband to auto-PS attach.
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
|
||||
|
||||
boolean dataEnabledSetting = true;
|
||||
try {
|
||||
dataEnabledSetting = IConnectivityManager.Stub.asInterface(ServiceManager.
|
||||
getService(Context.CONNECTIVITY_SERVICE)).getMobileDataEnabled();
|
||||
} catch (Exception e) {
|
||||
// nothing to do - use the old behavior and leave data on
|
||||
}
|
||||
dataEnabled[APN_DEFAULT_ID] =
|
||||
!sp.getBoolean(CDMAPhone.DATA_DISABLED_ON_BOOT_KEY, false) &&
|
||||
dataEnabledSetting;
|
||||
if (dataEnabled[APN_DEFAULT_ID]) {
|
||||
enabledCount++;
|
||||
}
|
||||
noAutoAttach = !dataEnabled[APN_DEFAULT_ID];
|
||||
|
||||
if (!mRetryMgr.configure(SystemProperties.get("ro.cdma.data_retry_config"))) {
|
||||
if (!mRetryMgr.configure(DEFAULT_DATA_RETRY_CONFIG)) {
|
||||
// Should never happen, log an error and default to a simple linear sequence.
|
||||
Log.e(LOG_TAG, "Could not configure using DEFAULT_DATA_RETRY_CONFIG="
|
||||
+ DEFAULT_DATA_RETRY_CONFIG);
|
||||
mRetryMgr.configure(20, 2000, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
|
||||
// Unregister from all events
|
||||
phone.mCM.unregisterForAvailable(this);
|
||||
phone.mCM.unregisterForOffOrNotAvailable(this);
|
||||
mPhone.mCM.unregisterForAvailable(this);
|
||||
mPhone.mCM.unregisterForOffOrNotAvailable(this);
|
||||
mCdmaPhone.mRuimRecords.unregisterForRecordsLoaded(this);
|
||||
phone.mCM.unregisterForNVReady(this);
|
||||
phone.mCM.unregisterForDataStateChanged(this);
|
||||
mPhone.mCM.unregisterForNVReady(this);
|
||||
mPhone.mCM.unregisterForDataStateChanged(this);
|
||||
mCdmaPhone.mCT.unregisterForVoiceCallEnded(this);
|
||||
mCdmaPhone.mCT.unregisterForVoiceCallStarted(this);
|
||||
mCdmaPhone.mSST.unregisterForCdmaDataConnectionAttached(this);
|
||||
mCdmaPhone.mSST.unregisterForCdmaDataConnectionDetached(this);
|
||||
mCdmaPhone.mSST.unregisterForRoamingOn(this);
|
||||
mCdmaPhone.mSST.unregisterForRoamingOff(this);
|
||||
phone.mCM.unregisterForCdmaOtaProvision(this);
|
||||
mPhone.mCM.unregisterForCdmaOtaProvision(this);
|
||||
|
||||
phone.getContext().unregisterReceiver(this.mIntentReceiver);
|
||||
destroyAllDataConnectionList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
if(DBG) Log.d(LOG_TAG, "CdmaDataConnectionTracker finalized");
|
||||
if(DBG) log("CdmaDataConnectionTracker finalized");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getActionIntentReconnectAlarm() {
|
||||
return INTENT_RECONNECT_ALARM;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setState(State s) {
|
||||
if (DBG) log ("setState: " + s);
|
||||
if (state != s) {
|
||||
if (mState != s) {
|
||||
EventLog.writeEvent(EventLogTags.CDMA_DATA_STATE_CHANGE,
|
||||
state.toString(), s.toString());
|
||||
state = s;
|
||||
mState.toString(), s.toString());
|
||||
mState = s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +172,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getActiveApnTypes() {
|
||||
String[] result;
|
||||
if (mActiveApn != null) {
|
||||
@@ -274,6 +184,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getActiveApnString() {
|
||||
return null;
|
||||
}
|
||||
@@ -287,45 +198,51 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
*
|
||||
* @return false while no data connection if all above requirements are met.
|
||||
*/
|
||||
@Override
|
||||
public boolean isDataConnectionAsDesired() {
|
||||
boolean roaming = phone.getServiceState().getRoaming();
|
||||
boolean roaming = mPhone.getServiceState().getRoaming();
|
||||
|
||||
if (((phone.mCM.getRadioState() == CommandsInterface.RadioState.NV_READY) ||
|
||||
if (((mPhone.mCM.getRadioState() == CommandsInterface.RadioState.NV_READY) ||
|
||||
mCdmaPhone.mRuimRecords.getRecordsLoaded()) &&
|
||||
(mCdmaPhone.mSST.getCurrentCdmaDataConnectionState() ==
|
||||
ServiceState.STATE_IN_SERVICE) &&
|
||||
(!roaming || getDataOnRoamingEnabled()) &&
|
||||
!mIsWifiConnected ) {
|
||||
return (state == State.CONNECTED);
|
||||
return (mState == State.CONNECTED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDataAllowed() {
|
||||
int psState = mCdmaPhone.mSST.getCurrentCdmaDataConnectionState();
|
||||
boolean roaming = (phone.getServiceState().getRoaming() && !getDataOnRoamingEnabled());
|
||||
boolean roaming = (mPhone.getServiceState().getRoaming() && !getDataOnRoamingEnabled());
|
||||
boolean desiredPowerState = mCdmaPhone.mSST.getDesiredPowerState();
|
||||
|
||||
boolean allowed = (psState == ServiceState.STATE_IN_SERVICE &&
|
||||
(phone.mCM.getRadioState() == CommandsInterface.RadioState.NV_READY ||
|
||||
mCdmaPhone.mRuimRecords.getRecordsLoaded()) &&
|
||||
(mCdmaPhone.mSST.isConcurrentVoiceAndData() ||
|
||||
phone.getState() == Phone.State.IDLE) &&
|
||||
!roaming &&
|
||||
mMasterDataEnabled &&
|
||||
desiredPowerState &&
|
||||
!mPendingRestartRadio &&
|
||||
!mCdmaPhone.needsOtaServiceProvisioning());
|
||||
boolean allowed =
|
||||
(psState == ServiceState.STATE_IN_SERVICE ||
|
||||
mAutoAttachOnCreation) &&
|
||||
(mPhone.mCM.getRadioState() == CommandsInterface.RadioState.NV_READY ||
|
||||
mCdmaPhone.mRuimRecords.getRecordsLoaded()) &&
|
||||
(mCdmaPhone.mSST.isConcurrentVoiceAndData() ||
|
||||
mPhone.getState() == Phone.State.IDLE) &&
|
||||
!roaming &&
|
||||
mMasterDataEnabled &&
|
||||
desiredPowerState &&
|
||||
!mPendingRestartRadio &&
|
||||
!mCdmaPhone.needsOtaServiceProvisioning();
|
||||
if (!allowed && DBG) {
|
||||
String reason = "";
|
||||
if (psState != ServiceState.STATE_IN_SERVICE) reason += " - psState= " + psState;
|
||||
if (phone.mCM.getRadioState() != CommandsInterface.RadioState.NV_READY &&
|
||||
!mCdmaPhone.mRuimRecords.getRecordsLoaded()) {
|
||||
reason += " - radioState= " + phone.mCM.getRadioState() + " - RUIM not loaded";
|
||||
if (!((psState == ServiceState.STATE_IN_SERVICE) || mAutoAttachOnCreation)) {
|
||||
reason += " - psState= " + psState;
|
||||
}
|
||||
if (phone.getState() != Phone.State.IDLE &&
|
||||
if (!(mPhone.mCM.getRadioState() == CommandsInterface.RadioState.NV_READY ||
|
||||
mCdmaPhone.mRuimRecords.getRecordsLoaded())) {
|
||||
reason += " - radioState= " + mPhone.mCM.getRadioState() + " - RUIM not loaded";
|
||||
}
|
||||
if (mPhone.getState() != Phone.State.IDLE &&
|
||||
mCdmaPhone.mSST.isConcurrentVoiceAndData()) {
|
||||
reason += " - concurrentVoiceAndData not allowed and state= " + phone.getState();
|
||||
reason += " - concurrentVoiceAndData not allowed and state= " + mPhone.getState();
|
||||
}
|
||||
if (roaming) reason += " - Roaming";
|
||||
if (!mMasterDataEnabled) reason += " - mMasterDataEnabled= false";
|
||||
@@ -340,22 +257,22 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
private boolean trySetupData(String reason) {
|
||||
if (DBG) log("***trySetupData due to " + (reason == null ? "(unspecified)" : reason));
|
||||
|
||||
if (phone.getSimulatedRadioControl() != null) {
|
||||
if (mPhone.getSimulatedRadioControl() != null) {
|
||||
// Assume data is connected on the simulator
|
||||
// FIXME this can be improved
|
||||
setState(State.CONNECTED);
|
||||
notifyDataConnection(reason);
|
||||
notifyOffApnsOfAvailability(reason, true);
|
||||
|
||||
Log.i(LOG_TAG, "(fix?) We're on the simulator; assuming data is connected");
|
||||
log("(fix?) We're on the simulator; assuming data is connected");
|
||||
return true;
|
||||
}
|
||||
|
||||
int psState = mCdmaPhone.mSST.getCurrentCdmaDataConnectionState();
|
||||
boolean roaming = phone.getServiceState().getRoaming();
|
||||
boolean roaming = mPhone.getServiceState().getRoaming();
|
||||
boolean desiredPowerState = mCdmaPhone.mSST.getDesiredPowerState();
|
||||
|
||||
if ((state == State.IDLE || state == State.SCANNING) &&
|
||||
if ((mState == State.IDLE || mState == State.SCANNING) &&
|
||||
isDataAllowed() && getAnyDataEnabled()) {
|
||||
boolean retValue = setupData(reason);
|
||||
notifyOffApnsOfAvailability(reason, retValue);
|
||||
@@ -367,13 +284,12 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
/**
|
||||
* If tearDown is true, this only tears down a CONNECTED session. Presently,
|
||||
* there is no mechanism for abandoning an INITING/CONNECTING session,
|
||||
* but would likely involve cancelling pending async requests or
|
||||
* setting a flag or new state to ignore them when they came in
|
||||
* @param tearDown true if the underlying DataConnection should be
|
||||
* disconnected.
|
||||
* @param reason reason for the clean up.
|
||||
* Cleanup all connections.
|
||||
*
|
||||
* TODO: Cleanup only a specified connection passed as a parameter.
|
||||
*
|
||||
* @param tearDown true if the underlying DataConnection should be disconnected.
|
||||
* @param reason for the clean up.
|
||||
*/
|
||||
private void cleanUpConnection(boolean tearDown, String reason) {
|
||||
if (DBG) log("cleanUpConnection: reason: " + reason);
|
||||
@@ -381,7 +297,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
// Clear the reconnect alarm, if set.
|
||||
if (mReconnectIntent != null) {
|
||||
AlarmManager am =
|
||||
(AlarmManager) phone.getContext().getSystemService(Context.ALARM_SERVICE);
|
||||
(AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
|
||||
am.cancel(mReconnectIntent);
|
||||
mReconnectIntent = null;
|
||||
}
|
||||
@@ -390,11 +306,12 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
notifyDataAvailability(reason);
|
||||
|
||||
boolean notificationDeferred = false;
|
||||
for (DataConnection conn : dataConnectionList) {
|
||||
for (DataConnection conn : mDataConnections.values()) {
|
||||
if(conn != null) {
|
||||
if (tearDown) {
|
||||
if (DBG) log("cleanUpConnection: teardown, call conn.disconnect");
|
||||
conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE, reason));
|
||||
conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE,
|
||||
conn.getDataConnectionId(), 0, reason));
|
||||
notificationDeferred = true;
|
||||
} else {
|
||||
if (DBG) log("cleanUpConnection: !tearDown, call conn.resetSynchronously");
|
||||
@@ -413,10 +330,9 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
private CdmaDataConnection findFreeDataConnection() {
|
||||
for (DataConnection connBase : dataConnectionList) {
|
||||
CdmaDataConnection conn = (CdmaDataConnection) connBase;
|
||||
if (conn.isInactive()) {
|
||||
return conn;
|
||||
for (DataConnection dc : mDataConnections.values()) {
|
||||
if (dc.isInactive()) {
|
||||
return (CdmaDataConnection) dc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -430,7 +346,8 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
return false;
|
||||
}
|
||||
|
||||
mActiveDataConnection = conn;
|
||||
/** TODO: We probably want the connection being setup to a parameter passed around */
|
||||
mPendingDataConnection = conn;
|
||||
String[] types;
|
||||
if (mRequestedApnType.equals(Phone.APN_TYPE_DUN)) {
|
||||
types = new String[1];
|
||||
@@ -458,28 +375,31 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
private void resetPollStats() {
|
||||
txPkts = -1;
|
||||
rxPkts = -1;
|
||||
sentSinceLastRecv = 0;
|
||||
netStatPollPeriod = POLL_NETSTAT_MILLIS;
|
||||
mTxPkts = -1;
|
||||
mRxPkts = -1;
|
||||
mSentSinceLastRecv = 0;
|
||||
mNetStatPollPeriod = POLL_NETSTAT_MILLIS;
|
||||
mNoRecvPollCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startNetStatPoll() {
|
||||
if (state == State.CONNECTED && netStatPollEnabled == false) {
|
||||
Log.d(LOG_TAG, "[DataConnection] Start poll NetStat");
|
||||
if (mState == State.CONNECTED && mNetStatPollEnabled == false) {
|
||||
log("[DataConnection] Start poll NetStat");
|
||||
resetPollStats();
|
||||
netStatPollEnabled = true;
|
||||
mNetStatPollEnabled = true;
|
||||
mPollNetStat.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stopNetStatPoll() {
|
||||
netStatPollEnabled = false;
|
||||
mNetStatPollEnabled = false;
|
||||
removeCallbacks(mPollNetStat);
|
||||
Log.d(LOG_TAG, "[DataConnection] Stop poll NetStat");
|
||||
log("[DataConnection] Stop poll NetStat");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void restartRadio() {
|
||||
if (DBG) log("Cleanup connection and wait " +
|
||||
(TIME_DELAYED_TO_RESTART_RADIO / 1000) + "s to restart radio");
|
||||
@@ -496,73 +416,73 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
|
||||
Activity newActivity;
|
||||
|
||||
preTxPkts = txPkts;
|
||||
preRxPkts = rxPkts;
|
||||
preTxPkts = mTxPkts;
|
||||
preRxPkts = mRxPkts;
|
||||
|
||||
txPkts = TrafficStats.getMobileTxPackets();
|
||||
rxPkts = TrafficStats.getMobileRxPackets();
|
||||
mTxPkts = TrafficStats.getMobileTxPackets();
|
||||
mRxPkts = TrafficStats.getMobileRxPackets();
|
||||
|
||||
//Log.d(LOG_TAG, "rx " + String.valueOf(rxPkts) + " tx " + String.valueOf(txPkts));
|
||||
//log("rx " + String.valueOf(rxPkts) + " tx " + String.valueOf(txPkts));
|
||||
|
||||
if (netStatPollEnabled && (preTxPkts > 0 || preRxPkts > 0)) {
|
||||
sent = txPkts - preTxPkts;
|
||||
received = rxPkts - preRxPkts;
|
||||
if (mNetStatPollEnabled && (preTxPkts > 0 || preRxPkts > 0)) {
|
||||
sent = mTxPkts - preTxPkts;
|
||||
received = mRxPkts - preRxPkts;
|
||||
|
||||
if ( sent > 0 && received > 0 ) {
|
||||
sentSinceLastRecv = 0;
|
||||
mSentSinceLastRecv = 0;
|
||||
newActivity = Activity.DATAINANDOUT;
|
||||
} else if (sent > 0 && received == 0) {
|
||||
if (phone.getState() == Phone.State.IDLE) {
|
||||
sentSinceLastRecv += sent;
|
||||
if (mPhone.getState() == Phone.State.IDLE) {
|
||||
mSentSinceLastRecv += sent;
|
||||
} else {
|
||||
sentSinceLastRecv = 0;
|
||||
mSentSinceLastRecv = 0;
|
||||
}
|
||||
newActivity = Activity.DATAOUT;
|
||||
} else if (sent == 0 && received > 0) {
|
||||
sentSinceLastRecv = 0;
|
||||
mSentSinceLastRecv = 0;
|
||||
newActivity = Activity.DATAIN;
|
||||
} else if (sent == 0 && received == 0) {
|
||||
newActivity = (activity == Activity.DORMANT) ? activity : Activity.NONE;
|
||||
newActivity = (mActivity == Activity.DORMANT) ? mActivity : Activity.NONE;
|
||||
} else {
|
||||
sentSinceLastRecv = 0;
|
||||
newActivity = (activity == Activity.DORMANT) ? activity : Activity.NONE;
|
||||
mSentSinceLastRecv = 0;
|
||||
newActivity = (mActivity == Activity.DORMANT) ? mActivity : Activity.NONE;
|
||||
}
|
||||
|
||||
if (activity != newActivity) {
|
||||
activity = newActivity;
|
||||
phone.notifyDataActivity();
|
||||
if (mActivity != newActivity && mIsScreenOn) {
|
||||
mActivity = newActivity;
|
||||
mPhone.notifyDataActivity();
|
||||
}
|
||||
}
|
||||
|
||||
if (sentSinceLastRecv >= NUMBER_SENT_PACKETS_OF_HANG) {
|
||||
if (mSentSinceLastRecv >= NUMBER_SENT_PACKETS_OF_HANG) {
|
||||
// Packets sent without ack exceeded threshold.
|
||||
|
||||
if (mNoRecvPollCount == 0) {
|
||||
EventLog.writeEvent(
|
||||
EventLogTags.PDP_RADIO_RESET_COUNTDOWN_TRIGGERED,
|
||||
sentSinceLastRecv);
|
||||
mSentSinceLastRecv);
|
||||
}
|
||||
|
||||
if (mNoRecvPollCount < NO_RECV_POLL_LIMIT) {
|
||||
mNoRecvPollCount++;
|
||||
// Slow down the poll interval to let things happen
|
||||
netStatPollPeriod = POLL_NETSTAT_SLOW_MILLIS;
|
||||
mNetStatPollPeriod = POLL_NETSTAT_SLOW_MILLIS;
|
||||
} else {
|
||||
if (DBG) log("Sent " + String.valueOf(sentSinceLastRecv) +
|
||||
if (DBG) log("Sent " + String.valueOf(mSentSinceLastRecv) +
|
||||
" pkts since last received");
|
||||
// We've exceeded the threshold. Restart the radio.
|
||||
netStatPollEnabled = false;
|
||||
mNetStatPollEnabled = false;
|
||||
stopNetStatPoll();
|
||||
restartRadio();
|
||||
EventLog.writeEvent(EventLogTags.PDP_RADIO_RESET, NO_RECV_POLL_LIMIT);
|
||||
}
|
||||
} else {
|
||||
mNoRecvPollCount = 0;
|
||||
netStatPollPeriod = POLL_NETSTAT_MILLIS;
|
||||
mNetStatPollPeriod = POLL_NETSTAT_MILLIS;
|
||||
}
|
||||
|
||||
if (netStatPollEnabled) {
|
||||
mDataConnectionTracker.postDelayed(this, netStatPollPeriod);
|
||||
if (mNetStatPollEnabled) {
|
||||
mDataConnectionTracker.postDelayed(this, mNetStatPollPeriod);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -594,7 +514,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
private void reconnectAfterFail(FailCause lastFailCauseCode, String reason) {
|
||||
if (state == State.FAILED) {
|
||||
if (mState == State.FAILED) {
|
||||
/**
|
||||
* For now With CDMA we never try to reconnect on
|
||||
* error and instead just continue to retry
|
||||
@@ -602,15 +522,15 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
* TODO: Make this configurable?
|
||||
*/
|
||||
int nextReconnectDelay = mRetryMgr.getRetryTimer();
|
||||
Log.d(LOG_TAG, "Data Connection activate failed. Scheduling next attempt for "
|
||||
log("Data Connection activate failed. Scheduling next attempt for "
|
||||
+ (nextReconnectDelay / 1000) + "s");
|
||||
|
||||
AlarmManager am =
|
||||
(AlarmManager) phone.getContext().getSystemService(Context.ALARM_SERVICE);
|
||||
(AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
|
||||
Intent intent = new Intent(INTENT_RECONNECT_ALARM);
|
||||
intent.putExtra(INTENT_RECONNECT_ALARM_EXTRA_REASON, reason);
|
||||
mReconnectIntent = PendingIntent.getBroadcast(
|
||||
phone.getContext(), 0, intent, 0);
|
||||
mPhone.getContext(), 0, intent, 0);
|
||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||
SystemClock.elapsedRealtime() + nextReconnectDelay,
|
||||
mReconnectIntent);
|
||||
@@ -618,7 +538,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
mRetryMgr.increaseRetryCount();
|
||||
|
||||
if (!shouldPostNotification(lastFailCauseCode)) {
|
||||
Log.d(LOG_TAG,"NOT Posting Data Connection Unavailable notification "
|
||||
log("NOT Posting Data Connection Unavailable notification "
|
||||
+ "-- likely transient error");
|
||||
} else {
|
||||
notifyNoData(lastFailCauseCode);
|
||||
@@ -639,14 +559,14 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
protected void onRecordsLoaded() {
|
||||
if (state == State.FAILED) {
|
||||
if (mState == State.FAILED) {
|
||||
cleanUpConnection(false, null);
|
||||
}
|
||||
sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA, Phone.REASON_SIM_LOADED));
|
||||
}
|
||||
|
||||
protected void onNVReady() {
|
||||
if (state == State.FAILED) {
|
||||
if (mState == State.FAILED) {
|
||||
cleanUpConnection(false, null);
|
||||
}
|
||||
sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA));
|
||||
@@ -657,12 +577,13 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
*/
|
||||
@Override
|
||||
protected void onEnableNewApn() {
|
||||
cleanUpConnection(true, Phone.REASON_APN_SWITCHED);
|
||||
cleanUpConnection(true, Phone.REASON_APN_SWITCHED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
@Override
|
||||
protected boolean onTrySetupData(String reason) {
|
||||
return trySetupData(reason);
|
||||
}
|
||||
@@ -670,6 +591,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
@Override
|
||||
protected void onRoamingOff() {
|
||||
trySetupData(Phone.REASON_ROAMING_OFF);
|
||||
}
|
||||
@@ -677,6 +599,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
@Override
|
||||
protected void onRoamingOn() {
|
||||
if (getDataOnRoamingEnabled()) {
|
||||
trySetupData(Phone.REASON_ROAMING_ON);
|
||||
@@ -689,19 +612,20 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
@Override
|
||||
protected void onRadioAvailable() {
|
||||
if (phone.getSimulatedRadioControl() != null) {
|
||||
if (mPhone.getSimulatedRadioControl() != null) {
|
||||
// Assume data is connected on the simulator
|
||||
// FIXME this can be improved
|
||||
setState(State.CONNECTED);
|
||||
notifyDataConnection(null);
|
||||
|
||||
Log.i(LOG_TAG, "We're on the simulator; assuming data is connected");
|
||||
log("We're on the simulator; assuming data is connected");
|
||||
}
|
||||
|
||||
notifyDataAvailability(null);
|
||||
|
||||
if (state != State.IDLE) {
|
||||
if (mState != State.IDLE) {
|
||||
cleanUpConnection(true, null);
|
||||
}
|
||||
}
|
||||
@@ -709,13 +633,14 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
@Override
|
||||
protected void onRadioOffOrNotAvailable() {
|
||||
mRetryMgr.resetRetryCount();
|
||||
|
||||
if (phone.getSimulatedRadioControl() != null) {
|
||||
if (mPhone.getSimulatedRadioControl() != null) {
|
||||
// Assume data is connected on the simulator
|
||||
// FIXME this can be improved
|
||||
Log.i(LOG_TAG, "We're on the simulator; assuming radio off is meaningless");
|
||||
log("We're on the simulator; assuming radio off is meaningless");
|
||||
} else {
|
||||
if (DBG) log("Radio is off and clean up all connection");
|
||||
cleanUpConnection(false, Phone.REASON_RADIO_TURNED_OFF);
|
||||
@@ -725,6 +650,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
@Override
|
||||
protected void onDataSetupComplete(AsyncResult ar) {
|
||||
String reason = null;
|
||||
if (ar.userObj instanceof String) {
|
||||
@@ -733,8 +659,8 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
|
||||
if (ar.exception == null) {
|
||||
// TODO: We should clear LinkProperties/Capabilities when torn down or disconnected
|
||||
mLinkProperties = getLinkProperties(mActiveDataConnection);
|
||||
mLinkCapabilities = getLinkCapabilities(mActiveDataConnection);
|
||||
mLinkProperties = getLinkProperties(mPendingDataConnection);
|
||||
mLinkCapabilities = getLinkCapabilities(mPendingDataConnection);
|
||||
|
||||
// everything is setup
|
||||
notifyDefaultData(reason);
|
||||
@@ -754,8 +680,9 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
/**
|
||||
* Called when EVENT_DISCONNECT_DONE is received.
|
||||
*/
|
||||
protected void onDisconnectDone(AsyncResult ar) {
|
||||
if(DBG) log("EVENT_DISCONNECT_DONE");
|
||||
@Override
|
||||
protected void onDisconnectDone(int connId, AsyncResult ar) {
|
||||
if(DBG) log("EVENT_DISCONNECT_DONE connId=" + connId);
|
||||
String reason = null;
|
||||
if (ar.userObj instanceof String) {
|
||||
reason = (String) ar.userObj;
|
||||
@@ -799,8 +726,9 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
@Override
|
||||
protected void onVoiceCallStarted() {
|
||||
if (state == State.CONNECTED && !mCdmaPhone.mSST.isConcurrentVoiceAndData()) {
|
||||
if (mState == State.CONNECTED && !mCdmaPhone.mSST.isConcurrentVoiceAndData()) {
|
||||
stopNetStatPoll();
|
||||
notifyDataConnection(Phone.REASON_VOICE_CALL_STARTED);
|
||||
notifyDataAvailability(Phone.REASON_VOICE_CALL_STARTED);
|
||||
@@ -810,8 +738,9 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
@Override
|
||||
protected void onVoiceCallEnded() {
|
||||
if (state == State.CONNECTED) {
|
||||
if (mState == State.CONNECTED) {
|
||||
if (!mCdmaPhone.mSST.isConcurrentVoiceAndData()) {
|
||||
startNetStatPoll();
|
||||
notifyDataConnection(Phone.REASON_VOICE_CALL_ENDED);
|
||||
@@ -827,39 +756,49 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
@Override
|
||||
protected void onCleanUpConnection(boolean tearDown, String reason) {
|
||||
cleanUpConnection(tearDown, reason);
|
||||
}
|
||||
|
||||
private void createAllDataConnectionList() {
|
||||
dataConnectionList = new ArrayList<DataConnection>();
|
||||
CdmaDataConnection dataConn;
|
||||
|
||||
for (int i = 0; i < DATA_CONNECTION_POOL_SIZE; i++) {
|
||||
dataConn = CdmaDataConnection.makeDataConnection(mCdmaPhone);
|
||||
dataConnectionList.add(dataConn);
|
||||
}
|
||||
/** TODO: Use one retry manager for all connections for now */
|
||||
RetryManager rm = mRetryMgr;
|
||||
if (!rm.configure(SystemProperties.get("ro.cdma.data_retry_config"))) {
|
||||
if (!rm.configure(DEFAULT_DATA_RETRY_CONFIG)) {
|
||||
// Should never happen, log an error and default to a simple linear sequence.
|
||||
log("Could not configure using DEFAULT_DATA_RETRY_CONFIG="
|
||||
+ DEFAULT_DATA_RETRY_CONFIG);
|
||||
rm.configure(20, 2000, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < DATA_CONNECTION_POOL_SIZE; i++) {
|
||||
int id = mUniqueIdGenerator.getAndIncrement();
|
||||
|
||||
dataConn = CdmaDataConnection.makeDataConnection(mCdmaPhone, id, rm);
|
||||
mDataConnections.put(id, dataConn);
|
||||
}
|
||||
}
|
||||
|
||||
private void destroyAllDataConnectionList() {
|
||||
if(dataConnectionList != null) {
|
||||
dataConnectionList.removeAll(dataConnectionList);
|
||||
if(mDataConnections != null) {
|
||||
mDataConnections.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void onCdmaDataDetached() {
|
||||
if (state == State.CONNECTED) {
|
||||
if (mState == State.CONNECTED) {
|
||||
startNetStatPoll();
|
||||
notifyDataConnection(Phone.REASON_CDMA_DATA_DETACHED);
|
||||
} else {
|
||||
if (state == State.FAILED) {
|
||||
if (mState == State.FAILED) {
|
||||
cleanUpConnection(false, Phone.REASON_CDMA_DATA_DETACHED);
|
||||
mRetryMgr.resetRetryCount();
|
||||
|
||||
CdmaCellLocation loc = (CdmaCellLocation)(phone.getCellLocation());
|
||||
CdmaCellLocation loc = (CdmaCellLocation)(mPhone.getCellLocation());
|
||||
EventLog.writeEvent(EventLogTags.CDMA_DATA_SETUP_FAILED,
|
||||
loc != null ? loc.getBaseStationId() : -1,
|
||||
TelephonyManager.getDefault().getNetworkType());
|
||||
@@ -886,8 +825,8 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
|
||||
private void onRestartRadio() {
|
||||
if (mPendingRestartRadio) {
|
||||
Log.d(LOG_TAG, "************TURN OFF RADIO**************");
|
||||
phone.mCM.setRadioPower(false, null);
|
||||
log("************TURN OFF RADIO**************");
|
||||
mPhone.mCM.setRadioPower(false, null);
|
||||
/* Note: no need to call setRadioPower(true). Assuming the desired
|
||||
* radio power state is still ON (as tracked by ServiceStateTracker),
|
||||
* ServiceStateTracker will call setRadioPower when it receives the
|
||||
@@ -900,7 +839,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
private void writeEventLogCdmaDataDrop() {
|
||||
CdmaCellLocation loc = (CdmaCellLocation)(phone.getCellLocation());
|
||||
CdmaCellLocation loc = (CdmaCellLocation)(mPhone.getCellLocation());
|
||||
EventLog.writeEvent(EventLogTags.CDMA_DATA_DROP,
|
||||
loc != null ? loc.getBaseStationId() : -1,
|
||||
TelephonyManager.getDefault().getNetworkType());
|
||||
@@ -916,7 +855,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state == State.CONNECTED) {
|
||||
if (mState == State.CONNECTED) {
|
||||
boolean isActiveOrDormantConnectionPresent = false;
|
||||
int connectionState = DATA_CONNECTION_ACTIVE_PH_LINK_INACTIVE;
|
||||
|
||||
@@ -932,7 +871,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
|
||||
if (!isActiveOrDormantConnectionPresent) {
|
||||
// No active or dormant connection
|
||||
Log.i(LOG_TAG, "onDataStateChanged: No active connection"
|
||||
log("onDataStateChanged: No active connection"
|
||||
+ "state is CONNECTED, disconnecting/cleanup");
|
||||
writeEventLogCdmaDataDrop();
|
||||
cleanUpConnection(true, null);
|
||||
@@ -941,42 +880,39 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
|
||||
switch (connectionState) {
|
||||
case DATA_CONNECTION_ACTIVE_PH_LINK_UP:
|
||||
Log.v(LOG_TAG, "onDataStateChanged: active=LINK_ACTIVE && CONNECTED, ignore");
|
||||
activity = Activity.NONE;
|
||||
phone.notifyDataActivity();
|
||||
log("onDataStateChanged: active=LINK_ACTIVE && CONNECTED, ignore");
|
||||
mActivity = Activity.NONE;
|
||||
mPhone.notifyDataActivity();
|
||||
startNetStatPoll();
|
||||
break;
|
||||
|
||||
case DATA_CONNECTION_ACTIVE_PH_LINK_DOWN:
|
||||
Log.v(LOG_TAG, "onDataStateChanged active=LINK_DOWN && CONNECTED, dormant");
|
||||
activity = Activity.DORMANT;
|
||||
phone.notifyDataActivity();
|
||||
log("onDataStateChanged active=LINK_DOWN && CONNECTED, dormant");
|
||||
mActivity = Activity.DORMANT;
|
||||
mPhone.notifyDataActivity();
|
||||
stopNetStatPoll();
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.v(LOG_TAG, "onDataStateChanged: IGNORE unexpected DataCallState.active="
|
||||
log("onDataStateChanged: IGNORE unexpected DataCallState.active="
|
||||
+ connectionState);
|
||||
}
|
||||
} else {
|
||||
// TODO: Do we need to do anything?
|
||||
Log.i(LOG_TAG, "onDataStateChanged: not connected, state=" + state + " ignoring");
|
||||
log("onDataStateChanged: not connected, state=" + mState + " ignoring");
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<DataConnection> getAllDataConnections() {
|
||||
return dataConnectionList;
|
||||
}
|
||||
|
||||
private void startDelayedRetry(FailCause cause, String reason) {
|
||||
notifyNoData(cause);
|
||||
reconnectAfterFail(cause, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage (Message msg) {
|
||||
|
||||
if (!phone.mIsTheCurrentActivePhone) {
|
||||
Log.d(LOG_TAG, "Ignore CDMA msgs since CDMA phone is inactive");
|
||||
if (!mPhone.mIsTheCurrentActivePhone) {
|
||||
log("Ignore CDMA msgs since CDMA phone is inactive");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1013,7 +949,13 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void log(String s) {
|
||||
Log.d(LOG_TAG, "[CdmaDataConnectionTracker] " + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loge(String s) {
|
||||
Log.e(LOG_TAG, "[CdmaDataConnectionTracker] " + s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.util.Patterns;
|
||||
import com.android.internal.telephony.DataConnection;
|
||||
import com.android.internal.telephony.Phone;
|
||||
import com.android.internal.telephony.RILConstants;
|
||||
import com.android.internal.telephony.RetryManager;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
@@ -53,23 +54,27 @@ public class GsmDataConnection extends DataConnection {
|
||||
private ApnSetting apn;
|
||||
|
||||
//***** Constructor
|
||||
private GsmDataConnection(GSMPhone phone, String name) {
|
||||
super(phone, name);
|
||||
private GsmDataConnection(GSMPhone phone, String name, RetryManager rm) {
|
||||
super(phone, name, rm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the connection object
|
||||
*
|
||||
* @param phone
|
||||
* @param phone the Phone
|
||||
* @param id the connection id
|
||||
* @param rm the RetryManager
|
||||
* @return GsmDataConnection that was created.
|
||||
*/
|
||||
static GsmDataConnection makeDataConnection(GSMPhone phone) {
|
||||
static GsmDataConnection makeDataConnection(GSMPhone phone, int id, RetryManager rm) {
|
||||
synchronized (mCountLock) {
|
||||
mCount += 1;
|
||||
}
|
||||
GsmDataConnection gsmDc = new GsmDataConnection(phone, "GsmDataConnection-" + mCount);
|
||||
GsmDataConnection gsmDc = new GsmDataConnection(phone, "GsmDataConnection-" + mCount, rm);
|
||||
gsmDc.start();
|
||||
if (DBG) gsmDc.log("Made " + gsmDc.getName());
|
||||
gsmDc.mId = id;
|
||||
gsmDc.mRetryMgr = rm;
|
||||
return gsmDc;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user