Merge change 21581 into eclair
* changes: Fix CDMA to startup/shutdown based on apn en/disab
This commit is contained in:
@@ -49,7 +49,6 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
|
|
||||||
private String mApnType;
|
private String mApnType;
|
||||||
private boolean mEnabled;
|
private boolean mEnabled;
|
||||||
private boolean mTeardownRequested;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new MobileDataStateTracker
|
* Create a new MobileDataStateTracker
|
||||||
@@ -66,7 +65,6 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
TelephonyManager.getDefault().getNetworkTypeName());
|
TelephonyManager.getDefault().getNetworkTypeName());
|
||||||
mApnType = apnType;
|
mApnType = apnType;
|
||||||
mPhoneService = null;
|
mPhoneService = null;
|
||||||
mTeardownRequested = false;
|
|
||||||
if(netType == ConnectivityManager.TYPE_MOBILE) {
|
if(netType == ConnectivityManager.TYPE_MOBILE) {
|
||||||
mEnabled = true;
|
mEnabled = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -81,7 +79,9 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
"net.eth0.dns3",
|
"net.eth0.dns3",
|
||||||
"net.eth0.dns4",
|
"net.eth0.dns4",
|
||||||
"net.gprs.dns1",
|
"net.gprs.dns1",
|
||||||
"net.gprs.dns2"};
|
"net.gprs.dns2",
|
||||||
|
"net.ppp0.dns1",
|
||||||
|
"net.ppp0.dns2"};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,9 +160,9 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case DISCONNECTED:
|
case DISCONNECTED:
|
||||||
if(mTeardownRequested) {
|
if(isTeardownRequested()) {
|
||||||
mEnabled = false;
|
mEnabled = false;
|
||||||
mTeardownRequested = false;
|
setTeardownRequested(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setDetailedState(DetailedState.DISCONNECTED, reason, apnName);
|
setDetailedState(DetailedState.DISCONNECTED, reason, apnName);
|
||||||
@@ -277,7 +277,7 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean teardown() {
|
public boolean teardown() {
|
||||||
mTeardownRequested = true;
|
setTeardownRequested(true);
|
||||||
return (setEnableApn(mApnType, false) != Phone.APN_REQUEST_FAILED);
|
return (setEnableApn(mApnType, false) != Phone.APN_REQUEST_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
*/
|
*/
|
||||||
public boolean reconnect() {
|
public boolean reconnect() {
|
||||||
mEnabled = true;
|
mEnabled = true;
|
||||||
mTeardownRequested = false;
|
setTeardownRequested(false);
|
||||||
mEnabled = (setEnableApn(mApnType, true) !=
|
mEnabled = (setEnableApn(mApnType, true) !=
|
||||||
Phone.APN_REQUEST_FAILED);
|
Phone.APN_REQUEST_FAILED);
|
||||||
return mEnabled;
|
return mEnabled;
|
||||||
|
|||||||
@@ -1428,7 +1428,8 @@ public class ListView extends AbsListView {
|
|||||||
throw new IllegalStateException("The content of the adapter has changed but "
|
throw new IllegalStateException("The content of the adapter has changed but "
|
||||||
+ "ListView did not receive a notification. Make sure the content of "
|
+ "ListView did not receive a notification. Make sure the content of "
|
||||||
+ "your adapter is not modified from a background thread, but only "
|
+ "your adapter is not modified from a background thread, but only "
|
||||||
+ "from the UI thread.");
|
+ "from the UI thread. [in ListView(" + getId() + ", " + getClass()
|
||||||
|
+ ") with Adapter(" + mAdapter.getClass() + ")]");
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelectedPositionInt(mNextSelectedPosition);
|
setSelectedPositionInt(mNextSelectedPosition);
|
||||||
|
|||||||
@@ -24,14 +24,18 @@ import android.os.Message;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.SettingNotFoundException;
|
import android.provider.Settings.SettingNotFoundException;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class DataConnectionTracker extends Handler {
|
public abstract class DataConnectionTracker extends Handler {
|
||||||
private static final boolean DBG = true;
|
protected static final boolean DBG = true;
|
||||||
|
protected final String LOG_TAG = "DataConnectionTracker";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IDLE: ready to start data connection setup, default state
|
* IDLE: ready to start data connection setup, default state
|
||||||
@@ -98,6 +102,20 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
|
|
||||||
//***** Constants
|
//***** Constants
|
||||||
|
|
||||||
|
protected static final int APN_INVALID_ID = -1;
|
||||||
|
protected static final int APN_DEFAULT_ID = 0;
|
||||||
|
protected static final int APN_MMS_ID = 1;
|
||||||
|
protected static final int APN_SUPL_ID = 2;
|
||||||
|
protected static final int APN_DUN_ID = 3;
|
||||||
|
protected static final int APN_HIPRI_ID = 4;
|
||||||
|
protected static final int APN_NUM_TYPES = 5;
|
||||||
|
|
||||||
|
protected boolean[] dataEnabled = new boolean[APN_NUM_TYPES];
|
||||||
|
protected int enabledCount = 0;
|
||||||
|
|
||||||
|
/* Currently requested APN type */
|
||||||
|
protected String mRequestedApnType = Phone.APN_TYPE_DEFAULT;
|
||||||
|
|
||||||
/** Retry configuration: A doubling of retry times from 5secs to 30minutes */
|
/** Retry configuration: A doubling of retry times from 5secs to 30minutes */
|
||||||
protected static final String DEFAULT_DATA_RETRY_CONFIG = "default_randomization=2000,"
|
protected static final String DEFAULT_DATA_RETRY_CONFIG = "default_randomization=2000,"
|
||||||
+ "5000,10000,20000,40000,80000:5000,160000:5000,"
|
+ "5000,10000,20000,40000,80000:5000,160000:5000,"
|
||||||
@@ -167,6 +185,8 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
this.phone = phone;
|
this.phone = phone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void dispose();
|
||||||
|
|
||||||
public Activity getActivity() {
|
public Activity getActivity() {
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
@@ -301,24 +321,18 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
* @return {@code false} if data connectivity has been explicitly disabled,
|
* @return {@code false} if data connectivity has been explicitly disabled,
|
||||||
* {@code true} otherwise.
|
* {@code true} otherwise.
|
||||||
*/
|
*/
|
||||||
public abstract boolean getDataEnabled();
|
public boolean getDataEnabled() {
|
||||||
|
return dataEnabled[APN_DEFAULT_ID];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report on whether data connectivity is enabled
|
* Report on whether data connectivity is enabled
|
||||||
* @return {@code false} if data connectivity has been explicitly disabled,
|
* @return {@code false} if data connectivity has been explicitly disabled,
|
||||||
* {@code true} otherwise.
|
* {@code true} otherwise.
|
||||||
*/
|
*/
|
||||||
public abstract boolean getAnyDataEnabled();
|
public boolean getAnyDataEnabled() {
|
||||||
|
return (enabledCount != 0);
|
||||||
/**
|
}
|
||||||
* 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.
|
|
||||||
* @param enable indicates whether to enable ({@code true}) or disable ({@code false}) data
|
|
||||||
* @return {@code true} if the operation succeeded
|
|
||||||
*/
|
|
||||||
public abstract boolean setDataEnabled(boolean enable);
|
|
||||||
|
|
||||||
protected abstract void startNetStatPoll();
|
protected abstract void startNetStatPoll();
|
||||||
|
|
||||||
@@ -327,4 +341,162 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
protected abstract void restartRadio();
|
protected abstract void restartRadio();
|
||||||
|
|
||||||
protected abstract void log(String s);
|
protected abstract void log(String s);
|
||||||
|
|
||||||
|
protected int apnTypeToId(String type) {
|
||||||
|
if (TextUtils.equals(type, Phone.APN_TYPE_DEFAULT)) {
|
||||||
|
return APN_DEFAULT_ID;
|
||||||
|
} else if (TextUtils.equals(type, Phone.APN_TYPE_MMS)) {
|
||||||
|
return APN_MMS_ID;
|
||||||
|
} else if (TextUtils.equals(type, Phone.APN_TYPE_SUPL)) {
|
||||||
|
return APN_SUPL_ID;
|
||||||
|
} else if (TextUtils.equals(type, Phone.APN_TYPE_DUN)) {
|
||||||
|
return APN_DUN_ID;
|
||||||
|
} else if (TextUtils.equals(type, Phone.APN_TYPE_HIPRI)) {
|
||||||
|
return APN_HIPRI_ID;
|
||||||
|
} else {
|
||||||
|
return APN_INVALID_ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract boolean isApnTypeActive(String type);
|
||||||
|
|
||||||
|
protected abstract boolean isApnTypeAvailable(String type);
|
||||||
|
|
||||||
|
protected abstract String[] getActiveApnTypes();
|
||||||
|
|
||||||
|
protected abstract String getActiveApnString();
|
||||||
|
|
||||||
|
public abstract ArrayList<DataConnection> getAllDataConnections();
|
||||||
|
|
||||||
|
protected abstract String getInterfaceName(String apnType);
|
||||||
|
|
||||||
|
protected abstract String getIpAddress(String apnType);
|
||||||
|
|
||||||
|
protected abstract String getGateway(String apnType);
|
||||||
|
|
||||||
|
protected abstract String[] getDnsServers(String apnType);
|
||||||
|
|
||||||
|
protected abstract void setState(State s);
|
||||||
|
|
||||||
|
protected boolean isEnabled(int id) {
|
||||||
|
if (id != APN_INVALID_ID) {
|
||||||
|
return dataEnabled[id];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
public int enableApnType(String type) {
|
||||||
|
int id = apnTypeToId(type);
|
||||||
|
if (id == APN_INVALID_ID) {
|
||||||
|
return Phone.APN_REQUEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If already active, return
|
||||||
|
if(DBG) Log.d(LOG_TAG, "enableApnType("+type+"), isApnTypeActive = "
|
||||||
|
+ isApnTypeActive(type) + " and state = " + state);
|
||||||
|
|
||||||
|
if (isApnTypeActive(type)) {
|
||||||
|
if (state == State.INITING) return Phone.APN_REQUEST_STARTED;
|
||||||
|
else if (state == State.CONNECTED) return Phone.APN_ALREADY_ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isApnTypeAvailable(type)) {
|
||||||
|
return Phone.APN_TYPE_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
setEnabled(id, true);
|
||||||
|
mRequestedApnType = type;
|
||||||
|
sendMessage(obtainMessage(EVENT_ENABLE_NEW_APN));
|
||||||
|
return Phone.APN_REQUEST_STARTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
public int disableApnType(String type) {
|
||||||
|
if (DBG) Log.d(LOG_TAG, "disableApnType("+type+")");
|
||||||
|
int id = apnTypeToId(type);
|
||||||
|
if (id == APN_INVALID_ID) {
|
||||||
|
return Phone.APN_REQUEST_FAILED;
|
||||||
|
}
|
||||||
|
if (isEnabled(id)) {
|
||||||
|
setEnabled(id, false);
|
||||||
|
if (isApnTypeActive(Phone.APN_TYPE_DEFAULT)) {
|
||||||
|
mRequestedApnType = Phone.APN_TYPE_DEFAULT;
|
||||||
|
if (dataEnabled[APN_DEFAULT_ID]) {
|
||||||
|
return Phone.APN_ALREADY_ACTIVE;
|
||||||
|
} else {
|
||||||
|
return Phone.APN_REQUEST_STARTED;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Phone.APN_REQUEST_STARTED;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Phone.APN_REQUEST_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected synchronized void setEnabled(int id, boolean enable) {
|
||||||
|
if (DBG) Log.d(LOG_TAG, "setEnabled(" + id + ", " + enable + ')');
|
||||||
|
if (dataEnabled[id] != enable) {
|
||||||
|
dataEnabled[id] = enable;
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
enabledCount++;
|
||||||
|
} else {
|
||||||
|
enabledCount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enabledCount == 0) {
|
||||||
|
setPrivateDataEnabled(false);
|
||||||
|
} else if (enabledCount == 1) {
|
||||||
|
setPrivateDataEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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+")");
|
||||||
|
setEnabled(APN_DEFAULT_ID, enable);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPrivateDataEnabled(boolean enable) {
|
||||||
|
if (DBG) Log.d(LOG_TAG, "setPrivateDataEnabled("+enable+")");
|
||||||
|
if (enable) {
|
||||||
|
sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA));
|
||||||
|
} else {
|
||||||
|
Message msg = obtainMessage(EVENT_CLEAN_UP_CONNECTION);
|
||||||
|
msg.arg1 = 1; // tearDown is true
|
||||||
|
msg.obj = Phone.REASON_DATA_DISABLED;
|
||||||
|
sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ public abstract class PhoneBase implements Phone {
|
|||||||
public CommandsInterface mCM;
|
public CommandsInterface mCM;
|
||||||
protected IccFileHandler mIccFileHandler;
|
protected IccFileHandler mIccFileHandler;
|
||||||
boolean mDnsCheckDisabled = false;
|
boolean mDnsCheckDisabled = false;
|
||||||
|
public DataConnectionTracker mDataConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a system property, unless we're in unit test mode
|
* Set a system property, unless we're in unit test mode
|
||||||
@@ -824,4 +825,71 @@ public abstract class PhoneBase implements Phone {
|
|||||||
// This function should be overridden by the class CDMAPhone. Not implemented in GSMPhone.
|
// This function should be overridden by the class CDMAPhone. Not implemented in GSMPhone.
|
||||||
Log.e(LOG_TAG, "Error! This function should never be executed, inactive CDMAPhone.");
|
Log.e(LOG_TAG, "Error! This function should never be executed, inactive CDMAPhone.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getInterfaceName(String apnType) {
|
||||||
|
return mDataConnection.getInterfaceName(apnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIpAddress(String apnType) {
|
||||||
|
return mDataConnection.getIpAddress(apnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDataConnectivityEnabled() {
|
||||||
|
return mDataConnection.getDataEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGateway(String apnType) {
|
||||||
|
return mDataConnection.getGateway(apnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getDnsServers(String apnType) {
|
||||||
|
return mDataConnection.getDnsServers(apnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getActiveApnTypes() {
|
||||||
|
return mDataConnection.getActiveApnTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActiveApn() {
|
||||||
|
return mDataConnection.getActiveApnString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int enableApnType(String type) {
|
||||||
|
return mDataConnection.enableApnType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int disableApnType(String type) {
|
||||||
|
return mDataConnection.disableApnType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* simulateDataConnection
|
||||||
|
*
|
||||||
|
* simulates various data connection states. This messes with
|
||||||
|
* DataConnectionTracker's internal states, but doesn't actually change
|
||||||
|
* the underlying radio connection states.
|
||||||
|
*
|
||||||
|
* @param state Phone.DataState enum.
|
||||||
|
*/
|
||||||
|
public void simulateDataConnection(Phone.DataState state) {
|
||||||
|
DataConnectionTracker.State dcState;
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case CONNECTED:
|
||||||
|
dcState = DataConnectionTracker.State.CONNECTED;
|
||||||
|
break;
|
||||||
|
case SUSPENDED:
|
||||||
|
dcState = DataConnectionTracker.State.CONNECTED;
|
||||||
|
break;
|
||||||
|
case DISCONNECTED:
|
||||||
|
dcState = DataConnectionTracker.State.FAILED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dcState = DataConnectionTracker.State.CONNECTING;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDataConnection.setState(dcState);
|
||||||
|
notifyDataConnection(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
CdmaCallTracker mCT;
|
CdmaCallTracker mCT;
|
||||||
CdmaSMSDispatcher mSMS;
|
CdmaSMSDispatcher mSMS;
|
||||||
CdmaServiceStateTracker mSST;
|
CdmaServiceStateTracker mSST;
|
||||||
CdmaDataConnectionTracker mDataConnection;
|
|
||||||
RuimFileHandler mRuimFileHandler;
|
RuimFileHandler mRuimFileHandler;
|
||||||
RuimRecords mRuimRecords;
|
RuimRecords mRuimRecords;
|
||||||
RuimCard mRuimCard;
|
RuimCard mRuimCard;
|
||||||
@@ -369,42 +368,11 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
return mCT.backgroundCall;
|
return mCT.backgroundCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGateway(String apnType) {
|
|
||||||
return mDataConnection.getGateway();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean handleInCallMmiCommands(String dialString) {
|
public boolean handleInCallMmiCommands(String dialString) {
|
||||||
Log.e(LOG_TAG, "method handleInCallMmiCommands is NOT supported in CDMA!");
|
Log.e(LOG_TAG, "method handleInCallMmiCommands is NOT supported in CDMA!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int enableApnType(String type) {
|
|
||||||
// This request is mainly used to enable MMS APN
|
|
||||||
// In CDMA there is no need to enable/disable a different APN for MMS
|
|
||||||
Log.d(LOG_TAG, "Request to enableApnType("+type+")");
|
|
||||||
if (TextUtils.equals(type, Phone.APN_TYPE_MMS)) {
|
|
||||||
return Phone.APN_ALREADY_ACTIVE;
|
|
||||||
} else {
|
|
||||||
return Phone.APN_REQUEST_FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int disableApnType(String type) {
|
|
||||||
// This request is mainly used to disable MMS APN
|
|
||||||
// In CDMA there is no need to enable/disable a different APN for MMS
|
|
||||||
Log.d(LOG_TAG, "Request to disableApnType("+type+")");
|
|
||||||
if (TextUtils.equals(type, Phone.APN_TYPE_MMS)) {
|
|
||||||
return Phone.APN_REQUEST_STARTED;
|
|
||||||
} else {
|
|
||||||
return Phone.APN_REQUEST_FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getActiveApn() {
|
|
||||||
Log.d(LOG_TAG, "Request to getActiveApn()");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void
|
public void
|
||||||
setNetworkSelectionModeAutomatic(Message response) {
|
setNetworkSelectionModeAutomatic(Message response) {
|
||||||
Log.e(LOG_TAG, "method setNetworkSelectionModeAutomatic is NOT supported in CDMA!");
|
Log.e(LOG_TAG, "method setNetworkSelectionModeAutomatic is NOT supported in CDMA!");
|
||||||
@@ -481,10 +449,6 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInterfaceName(String apnType) {
|
|
||||||
return mDataConnection.getInterfaceName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CellLocation getCellLocation() {
|
public CellLocation getCellLocation() {
|
||||||
return mSST.cellLoc;
|
return mSST.cellLoc;
|
||||||
}
|
}
|
||||||
@@ -512,10 +476,6 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDataConnectivityEnabled() {
|
|
||||||
return mDataConnection.getDataEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDataConnectivityPossible() {
|
public boolean isDataConnectivityPossible() {
|
||||||
boolean noData = mDataConnection.getDataEnabled() &&
|
boolean noData = mDataConnection.getDataEnabled() &&
|
||||||
getDataConnectionState() == DataState.DISCONNECTED;
|
getDataConnectionState() == DataState.DISCONNECTED;
|
||||||
@@ -528,10 +488,6 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
Log.e(LOG_TAG, "setLine1Number: not possible in CDMA");
|
Log.e(LOG_TAG, "setLine1Number: not possible in CDMA");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getDnsServers(String apnType) {
|
|
||||||
return mDataConnection.getDnsServers();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IccCard getIccCard() {
|
public IccCard getIccCard() {
|
||||||
return mRuimCard;
|
return mRuimCard;
|
||||||
}
|
}
|
||||||
@@ -584,10 +540,6 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
mCT.unregisterForCallWaiting(h);
|
mCT.unregisterForCallWaiting(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIpAddress(String apnType) {
|
|
||||||
return mDataConnection.getIpAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void
|
public void
|
||||||
getNeighboringCids(Message response) {
|
getNeighboringCids(Message response) {
|
||||||
/*
|
/*
|
||||||
@@ -701,14 +653,6 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
Log.e(LOG_TAG, "getAvailableNetworks: not possible in CDMA");
|
Log.e(LOG_TAG, "getAvailableNetworks: not possible in CDMA");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getActiveApnTypes() {
|
|
||||||
String[] result;
|
|
||||||
Log.d(LOG_TAG, "Request to getActiveApn()");
|
|
||||||
result = new String[1];
|
|
||||||
result[0] = Phone.APN_TYPE_DEFAULT;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode, Message onComplete) {
|
public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode, Message onComplete) {
|
||||||
Log.e(LOG_TAG, "setOutgoingCallerIdDisplay: not possible in CDMA");
|
Log.e(LOG_TAG, "setOutgoingCallerIdDisplay: not possible in CDMA");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ import java.util.ArrayList;
|
|||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||||
private static final String LOG_TAG = "CDMA";
|
protected final String LOG_TAG = "CDMA";
|
||||||
private static final boolean DBG = true;
|
|
||||||
|
|
||||||
private CDMAPhone mCdmaPhone;
|
private CDMAPhone mCdmaPhone;
|
||||||
|
|
||||||
@@ -77,12 +76,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
/** Currently active CdmaDataConnection */
|
/** Currently active CdmaDataConnection */
|
||||||
private CdmaDataConnection mActiveDataConnection;
|
private CdmaDataConnection mActiveDataConnection;
|
||||||
|
|
||||||
/** Defined cdma connection profiles */
|
|
||||||
private static final int EXTERNAL_NETWORK_DEFAULT_ID = 0;
|
|
||||||
private static final int EXTERNAL_NETWORK_NUM_TYPES = 1;
|
|
||||||
|
|
||||||
private boolean[] dataEnabled = new boolean[EXTERNAL_NETWORK_NUM_TYPES];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pool size of CdmaDataConnection objects.
|
* Pool size of CdmaDataConnection objects.
|
||||||
*/
|
*/
|
||||||
@@ -101,6 +94,11 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
private static final int DATA_CONNECTION_ACTIVE_PH_LINK_DOWN = 1;
|
private static final int DATA_CONNECTION_ACTIVE_PH_LINK_DOWN = 1;
|
||||||
private static final int DATA_CONNECTION_ACTIVE_PH_LINK_UP = 2;
|
private static final int DATA_CONNECTION_ACTIVE_PH_LINK_UP = 2;
|
||||||
|
|
||||||
|
private static final String[] mSupportedApnTypes = {
|
||||||
|
Phone.APN_TYPE_DEFAULT,
|
||||||
|
Phone.APN_TYPE_MMS,
|
||||||
|
Phone.APN_TYPE_HIPRI };
|
||||||
|
|
||||||
// Possibly promoate to base class, the only difference is
|
// Possibly promoate to base class, the only difference is
|
||||||
// the INTENT_RECONNECT_ALARM action is a different string.
|
// the INTENT_RECONNECT_ALARM action is a different string.
|
||||||
// Do consider technology changes if it is promoted.
|
// Do consider technology changes if it is promoted.
|
||||||
@@ -182,9 +180,12 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
// and 2) whether the RIL will setup the baseband to auto-PS attach.
|
// and 2) whether the RIL will setup the baseband to auto-PS attach.
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
|
||||||
|
|
||||||
dataEnabled[EXTERNAL_NETWORK_DEFAULT_ID] =
|
dataEnabled[APN_DEFAULT_ID] =
|
||||||
!sp.getBoolean(CDMAPhone.DATA_DISABLED_ON_BOOT_KEY, false);
|
!sp.getBoolean(CDMAPhone.DATA_DISABLED_ON_BOOT_KEY, false);
|
||||||
noAutoAttach = !dataEnabled[EXTERNAL_NETWORK_DEFAULT_ID];
|
if (dataEnabled[APN_DEFAULT_ID]) {
|
||||||
|
enabledCount++;
|
||||||
|
}
|
||||||
|
noAutoAttach = !dataEnabled[APN_DEFAULT_ID];
|
||||||
|
|
||||||
if (!mRetryMgr.configure(SystemProperties.get("ro.cdma.data_retry_config"))) {
|
if (!mRetryMgr.configure(SystemProperties.get("ro.cdma.data_retry_config"))) {
|
||||||
if (!mRetryMgr.configure(DEFAULT_DATA_RETRY_CONFIG)) {
|
if (!mRetryMgr.configure(DEFAULT_DATA_RETRY_CONFIG)) {
|
||||||
@@ -219,7 +220,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
if(DBG) Log.d(LOG_TAG, "CdmaDataConnectionTracker finalized");
|
if(DBG) Log.d(LOG_TAG, "CdmaDataConnectionTracker finalized");
|
||||||
}
|
}
|
||||||
|
|
||||||
void setState(State s) {
|
protected void setState(State s) {
|
||||||
if (DBG) log ("setState: " + s);
|
if (DBG) log ("setState: " + s);
|
||||||
if (state != s) {
|
if (state != s) {
|
||||||
if (s == State.INITING) { // request Data connection context
|
if (s == State.INITING) { // request Data connection context
|
||||||
@@ -236,39 +237,33 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
state = s;
|
state = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int enableApnType(String type) {
|
@Override
|
||||||
// This request is mainly used to enable MMS APN
|
protected boolean isApnTypeActive(String type) {
|
||||||
// In CDMA there is no need to enable/disable a different APN for MMS
|
return (isApnTypeAvailable(type) &&
|
||||||
Log.d(LOG_TAG, "Request to enableApnType("+type+")");
|
mCdmaPhone.mSST.getCurrentCdmaDataConnectionState() ==
|
||||||
if (TextUtils.equals(type, Phone.APN_TYPE_MMS)) {
|
ServiceState.STATE_IN_SERVICE);
|
||||||
return Phone.APN_ALREADY_ACTIVE;
|
|
||||||
} else if (TextUtils.equals(type, Phone.APN_TYPE_SUPL)) {
|
|
||||||
Log.w(LOG_TAG, "Phone.APN_TYPE_SUPL not enabled for CDMA");
|
|
||||||
return Phone.APN_REQUEST_FAILED;
|
|
||||||
} else {
|
|
||||||
return Phone.APN_REQUEST_FAILED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int disableApnType(String type) {
|
@Override
|
||||||
// This request is mainly used to disable MMS APN
|
protected boolean isApnTypeAvailable(String type) {
|
||||||
// In CDMA there is no need to enable/disable a different APN for MMS
|
for (String s : mSupportedApnTypes) {
|
||||||
Log.d(LOG_TAG, "Request to disableApnType("+type+")");
|
if (TextUtils.equals(type, s)) {
|
||||||
if (TextUtils.equals(type, Phone.APN_TYPE_MMS)) {
|
return true;
|
||||||
return Phone.APN_REQUEST_STARTED;
|
|
||||||
} else {
|
|
||||||
return Phone.APN_REQUEST_FAILED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isEnabled(int cdmaDataProfile) {
|
protected String[] getActiveApnTypes() {
|
||||||
return dataEnabled[cdmaDataProfile];
|
if (mCdmaPhone.mSST.getCurrentCdmaDataConnectionState() ==
|
||||||
|
ServiceState.STATE_IN_SERVICE) {
|
||||||
|
return mSupportedApnTypes.clone();
|
||||||
|
}
|
||||||
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEnabled(int cdmaDataProfile, boolean enable) {
|
protected String getActiveApnString() {
|
||||||
Log.d(LOG_TAG, "setEnabled(" + cdmaDataProfile + ", " + enable + ')');
|
return null;
|
||||||
dataEnabled[cdmaDataProfile] = enable;
|
|
||||||
Log.d(LOG_TAG, "dataEnabled[DEFAULT_PROFILE]=" + dataEnabled[EXTERNAL_NETWORK_DEFAULT_ID]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -294,54 +289,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 connection
|
|
||||||
* @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) {
|
|
||||||
|
|
||||||
boolean isEnabled = isEnabled(EXTERNAL_NETWORK_DEFAULT_ID);
|
|
||||||
|
|
||||||
Log.d(LOG_TAG, "setDataEnabled("+enable+") isEnabled=" + isEnabled);
|
|
||||||
if (!isEnabled && enable) {
|
|
||||||
setEnabled(EXTERNAL_NETWORK_DEFAULT_ID, true);
|
|
||||||
sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA));
|
|
||||||
} else if (!enable) {
|
|
||||||
setEnabled(EXTERNAL_NETWORK_DEFAULT_ID, false);
|
|
||||||
Message msg = obtainMessage(EVENT_CLEAN_UP_CONNECTION);
|
|
||||||
msg.arg1 = 1; // tearDown is true
|
|
||||||
msg.obj = Phone.REASON_DATA_DISABLED;
|
|
||||||
sendMessage(msg);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Report the current state of data connectivity (enabled or disabled)
|
|
||||||
* @return {@code false} if data connectivity has been explicitly disabled,
|
|
||||||
* {@code true} otherwise.
|
|
||||||
*/
|
|
||||||
public boolean getDataEnabled() {
|
|
||||||
return dataEnabled[EXTERNAL_NETWORK_DEFAULT_ID];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Report on whether data connectivity is enabled
|
|
||||||
* @return {@code false} if data connectivity has been explicitly disabled,
|
|
||||||
* {@code true} otherwise.
|
|
||||||
*/
|
|
||||||
public boolean getAnyDataEnabled() {
|
|
||||||
for (int i=0; i < EXTERNAL_NETWORK_NUM_TYPES; i++) {
|
|
||||||
if (isEnabled(i)) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isDataAllowed() {
|
private boolean isDataAllowed() {
|
||||||
boolean roaming = phone.getServiceState().getRoaming();
|
boolean roaming = phone.getServiceState().getRoaming();
|
||||||
return getAnyDataEnabled() && (!roaming || getDataOnRoamingEnabled());
|
return getAnyDataEnabled() && (!roaming || getDataOnRoamingEnabled());
|
||||||
@@ -921,28 +868,28 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getInterfaceName() {
|
protected String getInterfaceName(String apnType) {
|
||||||
if (mActiveDataConnection != null) {
|
if (mActiveDataConnection != null) {
|
||||||
return mActiveDataConnection.getInterface();
|
return mActiveDataConnection.getInterface();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getIpAddress() {
|
protected String getIpAddress(String apnType) {
|
||||||
if (mActiveDataConnection != null) {
|
if (mActiveDataConnection != null) {
|
||||||
return mActiveDataConnection.getIpAddress();
|
return mActiveDataConnection.getIpAddress();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getGateway() {
|
protected String getGateway(String apnType) {
|
||||||
if (mActiveDataConnection != null) {
|
if (mActiveDataConnection != null) {
|
||||||
return mActiveDataConnection.getGatewayAddress();
|
return mActiveDataConnection.getGatewayAddress();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getDnsServers() {
|
protected String[] getDnsServers(String apnType) {
|
||||||
if (mActiveDataConnection != null) {
|
if (mActiveDataConnection != null) {
|
||||||
return mActiveDataConnection.getDnsServers();
|
return mActiveDataConnection.getDnsServers();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ public class GSMPhone extends PhoneBase {
|
|||||||
GsmCallTracker mCT;
|
GsmCallTracker mCT;
|
||||||
GsmServiceStateTracker mSST;
|
GsmServiceStateTracker mSST;
|
||||||
GsmSMSDispatcher mSMS;
|
GsmSMSDispatcher mSMS;
|
||||||
GsmDataConnectionTracker mDataConnection;
|
|
||||||
SIMRecords mSIMRecords;
|
SIMRecords mSIMRecords;
|
||||||
SimCard mSimCard;
|
SimCard mSimCard;
|
||||||
StkService mStkService;
|
StkService mStkService;
|
||||||
@@ -280,14 +279,6 @@ public class GSMPhone extends PhoneBase {
|
|||||||
return "GSM";
|
return "GSM";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getActiveApnTypes() {
|
|
||||||
return mDataConnection.getActiveApnTypes();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getActiveApn() {
|
|
||||||
return mDataConnection.getActiveApnString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SignalStrength getSignalStrength() {
|
public SignalStrength getSignalStrength() {
|
||||||
return mSST.mSignalStrength;
|
return mSST.mSignalStrength;
|
||||||
}
|
}
|
||||||
@@ -1145,38 +1136,10 @@ public class GSMPhone extends PhoneBase {
|
|||||||
return mDataConnection.setDataEnabled(true);
|
return mDataConnection.setDataEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int enableApnType(String type) {
|
|
||||||
return mDataConnection.enableApnType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int disableApnType(String type) {
|
|
||||||
return mDataConnection.disableApnType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean disableDataConnectivity() {
|
public boolean disableDataConnectivity() {
|
||||||
return mDataConnection.setDataEnabled(false);
|
return mDataConnection.setDataEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInterfaceName(String apnType) {
|
|
||||||
return mDataConnection.getInterfaceName(apnType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIpAddress(String apnType) {
|
|
||||||
return mDataConnection.getIpAddress(apnType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGateway(String apnType) {
|
|
||||||
return mDataConnection.getGateway(apnType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getDnsServers(String apnType) {
|
|
||||||
return mDataConnection.getDnsServers(apnType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDataConnectivityEnabled() {
|
|
||||||
return mDataConnection.getDataEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The only circumstances under which we report that data connectivity is not
|
* The only circumstances under which we report that data connectivity is not
|
||||||
* possible are
|
* possible are
|
||||||
@@ -1543,36 +1506,6 @@ public class GSMPhone extends PhoneBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* simulateDataConnection
|
|
||||||
*
|
|
||||||
* simulates various data connection states. This messes with
|
|
||||||
* DataConnectionTracker's internal states, but doesn't actually change
|
|
||||||
* the underlying radio connection states.
|
|
||||||
*
|
|
||||||
* @param state Phone.DataState enum.
|
|
||||||
*/
|
|
||||||
public void simulateDataConnection(Phone.DataState state) {
|
|
||||||
DataConnectionTracker.State dcState;
|
|
||||||
|
|
||||||
switch (state) {
|
|
||||||
case CONNECTED:
|
|
||||||
dcState = DataConnectionTracker.State.CONNECTED;
|
|
||||||
break;
|
|
||||||
case SUSPENDED:
|
|
||||||
dcState = DataConnectionTracker.State.CONNECTED;
|
|
||||||
break;
|
|
||||||
case DISCONNECTED:
|
|
||||||
dcState = DataConnectionTracker.State.FAILED;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dcState = DataConnectionTracker.State.CONNECTING;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mDataConnection.setState(dcState);
|
|
||||||
notifyDataConnection(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the PhoneSubInfo of the GSMPhone
|
* Retrieves the PhoneSubInfo of the GSMPhone
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ import java.util.ArrayList;
|
|||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||||
private static final String LOG_TAG = "GSM";
|
protected final String LOG_TAG = "GSM";
|
||||||
private static final boolean DBG = true;
|
|
||||||
|
|
||||||
private GSMPhone mGsmPhone;
|
private GSMPhone mGsmPhone;
|
||||||
/**
|
/**
|
||||||
@@ -119,31 +118,17 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
|
|
||||||
private ApnSetting preferredApn = null;
|
private ApnSetting preferredApn = null;
|
||||||
|
|
||||||
|
/* Currently active APN */
|
||||||
|
protected ApnSetting mActiveApn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pdpList holds all the PDP connection, i.e. IP Link in GPRS
|
* pdpList holds all the PDP connection, i.e. IP Link in GPRS
|
||||||
*/
|
*/
|
||||||
private ArrayList<DataConnection> pdpList;
|
private ArrayList<DataConnection> pdpList;
|
||||||
|
|
||||||
/** Currently requested APN type */
|
|
||||||
private String mRequestedApnType = Phone.APN_TYPE_DEFAULT;
|
|
||||||
|
|
||||||
/** Currently active APN */
|
|
||||||
private ApnSetting mActiveApn;
|
|
||||||
|
|
||||||
/** Currently active PdpConnection */
|
/** Currently active PdpConnection */
|
||||||
private PdpConnection mActivePdp;
|
private PdpConnection mActivePdp;
|
||||||
|
|
||||||
private static int APN_INVALID_ID = -1;
|
|
||||||
private static int APN_DEFAULT_ID = 0;
|
|
||||||
private static int APN_MMS_ID = 1;
|
|
||||||
private static int APN_SUPL_ID = 2;
|
|
||||||
private static int APN_DUN_ID = 3;
|
|
||||||
private static int APN_HIPRI_ID = 4;
|
|
||||||
private static int APN_NUM_TYPES = 5;
|
|
||||||
|
|
||||||
private boolean[] dataEnabled = new boolean[APN_NUM_TYPES];
|
|
||||||
private int enabledCount = 0;
|
|
||||||
|
|
||||||
/** Is packet service restricted by network */
|
/** Is packet service restricted by network */
|
||||||
private boolean mIsPsRestricted = false;
|
private boolean mIsPsRestricted = false;
|
||||||
|
|
||||||
@@ -293,7 +278,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
if(DBG) Log.d(LOG_TAG, "GsmDataConnectionTracker finalized");
|
if(DBG) Log.d(LOG_TAG, "GsmDataConnectionTracker finalized");
|
||||||
}
|
}
|
||||||
|
|
||||||
void setState(State s) {
|
protected void setState(State s) {
|
||||||
if (DBG) log ("setState: " + s);
|
if (DBG) log ("setState: " + s);
|
||||||
if (state != s) {
|
if (state != s) {
|
||||||
if (s == State.INITING) { // request PDP context
|
if (s == State.INITING) { // request PDP context
|
||||||
@@ -317,7 +302,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] getActiveApnTypes() {
|
public String[] getActiveApnTypes() {
|
||||||
String[] result;
|
String[] result;
|
||||||
if (mActiveApn != null) {
|
if (mActiveApn != null) {
|
||||||
result = mActiveApn.types;
|
result = mActiveApn.types;
|
||||||
@@ -336,87 +321,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int apnTypeToId(String type) {
|
|
||||||
if (TextUtils.equals(type, Phone.APN_TYPE_DEFAULT)) {
|
|
||||||
return APN_DEFAULT_ID;
|
|
||||||
} else if (TextUtils.equals(type, Phone.APN_TYPE_MMS)) {
|
|
||||||
return APN_MMS_ID;
|
|
||||||
} else if (TextUtils.equals(type, Phone.APN_TYPE_SUPL)) {
|
|
||||||
return APN_SUPL_ID;
|
|
||||||
} else if (TextUtils.equals(type, Phone.APN_TYPE_DUN)) {
|
|
||||||
return APN_DUN_ID;
|
|
||||||
} else if (TextUtils.equals(type, Phone.APN_TYPE_HIPRI)) {
|
|
||||||
return APN_HIPRI_ID;
|
|
||||||
} else {
|
|
||||||
return APN_INVALID_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
protected int enableApnType(String type) {
|
|
||||||
int id = apnTypeToId(type);
|
|
||||||
if (id == APN_INVALID_ID) {
|
|
||||||
return Phone.APN_REQUEST_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If already active, return
|
|
||||||
if(DBG) Log.d(LOG_TAG, "enableApnType("+type+"), isApnTypeActive = "
|
|
||||||
+ isApnTypeActive(type) + " and state = " + state);
|
|
||||||
if (isApnTypeActive(type)) {
|
|
||||||
if (state == State.INITING) return Phone.APN_REQUEST_STARTED;
|
|
||||||
else if (state == State.CONNECTED) return Phone.APN_ALREADY_ACTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isApnTypeAvailable(type)) {
|
|
||||||
return Phone.APN_TYPE_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
setEnabled(id, true);
|
|
||||||
mRequestedApnType = type;
|
|
||||||
sendMessage(obtainMessage(EVENT_ENABLE_NEW_APN));
|
|
||||||
return Phone.APN_REQUEST_STARTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
protected int disableApnType(String type) {
|
|
||||||
if (DBG) Log.d(LOG_TAG, "disableApnType("+type+")");
|
|
||||||
int id = apnTypeToId(type);
|
|
||||||
if (id == APN_INVALID_ID) {
|
|
||||||
return Phone.APN_REQUEST_FAILED;
|
|
||||||
}
|
|
||||||
if (isEnabled(id)) {
|
|
||||||
setEnabled(id, false);
|
|
||||||
if (isApnTypeActive(Phone.APN_TYPE_DEFAULT)) {
|
|
||||||
mRequestedApnType = Phone.APN_TYPE_DEFAULT;
|
|
||||||
if (dataEnabled[APN_DEFAULT_ID]) {
|
|
||||||
return Phone.APN_ALREADY_ACTIVE;
|
|
||||||
} else {
|
|
||||||
return Phone.APN_REQUEST_STARTED;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return Phone.APN_REQUEST_STARTED;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return Phone.APN_REQUEST_FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The data connection is expected to be setup while device
|
* The data connection is expected to be setup while device
|
||||||
* 1. has sim card
|
* 1. has sim card
|
||||||
@@ -439,12 +343,14 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isApnTypeActive(String type) {
|
@Override
|
||||||
// TODO: to support simultaneous, mActiveApn can be a List instead.
|
protected boolean isApnTypeActive(String type) {
|
||||||
|
// TODO: support simultaneous with List instead
|
||||||
return mActiveApn != null && mActiveApn.canHandleType(type);
|
return mActiveApn != null && mActiveApn.canHandleType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isApnTypeAvailable(String type) {
|
@Override
|
||||||
|
protected boolean isApnTypeAvailable(String type) {
|
||||||
if (allApns != null) {
|
if (allApns != null) {
|
||||||
for (ApnSetting apn : allApns) {
|
for (ApnSetting apn : allApns) {
|
||||||
if (apn.canHandleType(type)) {
|
if (apn.canHandleType(type)) {
|
||||||
@@ -455,80 +361,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEnabled(int id) {
|
|
||||||
if (id != APN_INVALID_ID) {
|
|
||||||
return dataEnabled[id];
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setEnabled(int id, boolean enable) {
|
|
||||||
if (DBG) Log.d(LOG_TAG, "setEnabled(" + id + ", " + enable + ')');
|
|
||||||
if (dataEnabled[id] != enable) {
|
|
||||||
dataEnabled[id] = enable;
|
|
||||||
|
|
||||||
if (enable) {
|
|
||||||
enabledCount++;
|
|
||||||
} else {
|
|
||||||
enabledCount--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enabledCount == 0) {
|
|
||||||
setPrivateDataEnabled(false);
|
|
||||||
} else if (enabledCount == 1) {
|
|
||||||
setPrivateDataEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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+")");
|
|
||||||
setEnabled(APN_DEFAULT_ID, enable);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPrivateDataEnabled(boolean enable) {
|
|
||||||
if (DBG) Log.d(LOG_TAG, "setPrivateDataEnabled("+enable+")");
|
|
||||||
if (enable) {
|
|
||||||
sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA));
|
|
||||||
} else {
|
|
||||||
Message msg = obtainMessage(EVENT_CLEAN_UP_CONNECTION);
|
|
||||||
msg.arg1 = 1; // tearDown is true
|
|
||||||
msg.obj = Phone.REASON_DATA_DISABLED;
|
|
||||||
sendMessage(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Report the current state of data connectivity (enabled or disabled) for
|
|
||||||
* the default APN.
|
|
||||||
* @return {@code false} if data connectivity has been explicitly disabled,
|
|
||||||
* {@code true} otherwise.
|
|
||||||
*/
|
|
||||||
public boolean getDataEnabled() {
|
|
||||||
return dataEnabled[APN_DEFAULT_ID];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Report on whether data connectivity is enabled for any APN.
|
|
||||||
* @return {@code false} if data connectivity has been explicitly disabled,
|
|
||||||
* {@code true} otherwise.
|
|
||||||
*/
|
|
||||||
public boolean getAnyDataEnabled() {
|
|
||||||
return (enabledCount != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formerly this method was ArrayList<PdpConnection> getAllPdps()
|
* Formerly this method was ArrayList<PdpConnection> getAllPdps()
|
||||||
*/
|
*/
|
||||||
@@ -744,7 +576,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getInterfaceName(String apnType) {
|
protected String getInterfaceName(String apnType) {
|
||||||
if (mActivePdp != null
|
if (mActivePdp != null
|
||||||
&& (apnType == null || mActiveApn.canHandleType(apnType))) {
|
&& (apnType == null || mActiveApn.canHandleType(apnType))) {
|
||||||
return mActivePdp.getInterface();
|
return mActivePdp.getInterface();
|
||||||
@@ -760,7 +592,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getGateway(String apnType) {
|
public String getGateway(String apnType) {
|
||||||
if (mActivePdp != null
|
if (mActivePdp != null
|
||||||
&& (apnType == null || mActiveApn.canHandleType(apnType))) {
|
&& (apnType == null || mActiveApn.canHandleType(apnType))) {
|
||||||
return mActivePdp.getGatewayAddress();
|
return mActivePdp.getGatewayAddress();
|
||||||
|
|||||||
64
tests/backup/backup_stress_test.sh
Executable file
64
tests/backup/backup_stress_test.sh
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright (C) 2009 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.
|
||||||
|
|
||||||
|
iterations=150
|
||||||
|
failures=0
|
||||||
|
i=0
|
||||||
|
LOGDIR="$HOME/backup_tests"
|
||||||
|
LOGFILE="$LOGDIR/backup_stress.`date +%s`.log"
|
||||||
|
export BUGREPORT_DIR="$LOGDIR/bugreports"
|
||||||
|
|
||||||
|
# make sure that we have a place to put logs and bugreports
|
||||||
|
mkdir -p $LOGDIR $BUGREPORT_DIR
|
||||||
|
|
||||||
|
echo "logfile is $LOGFILE"
|
||||||
|
|
||||||
|
(while (sleep 10); do
|
||||||
|
failed=0
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Iteration $i at `date`"
|
||||||
|
echo
|
||||||
|
|
||||||
|
./test_backup.sh "$@" 2>&1
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
echo "Restore at `date`"
|
||||||
|
echo
|
||||||
|
|
||||||
|
./test_restore.sh "$@" 2>&1 || failed=1
|
||||||
|
|
||||||
|
if [ "$failed" -ne 0 ]; then
|
||||||
|
failures=$(($failures+1))
|
||||||
|
# Long and verbose so it sticks out
|
||||||
|
echo "FAILED iteration $i of $iterations; $failures failures so far"
|
||||||
|
echo "FAILED iteration $i of $iterations; $failures failures so far" > /dev/stderr
|
||||||
|
else
|
||||||
|
printf "Iteration %d:\tPASS; remaining: %d\n" $i $(($iterations - $i - 1))
|
||||||
|
printf "Iteration %d:\tPASS; remaining: %d\n" $i $(($iterations - $i - 1)) > /dev/stderr
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "End $i at `date`"
|
||||||
|
|
||||||
|
i=$(($i+1))
|
||||||
|
if [ $i -eq $iterations ]; then
|
||||||
|
echo "DONE: $iterations iterations with $failures failures."
|
||||||
|
echo "DONE: $iterations iterations with $failures failures." > /dev/stderr
|
||||||
|
[ "$failures" -eq 0 ] && exit 0
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done) > "$LOGFILE"
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
#export DRY_RUN="echo"
|
#export DRY_RUN="echo"
|
||||||
source test_backup_common.sh
|
source test_backup_common.sh
|
||||||
|
|
||||||
BUGREPORT_DIR="$HOME/backup/bugreports"
|
[ -z "$BUGREPORT_DIR" ] && BUGREPORT_DIR="$HOME/backup/bugreports"
|
||||||
|
|
||||||
function check_file
|
function check_file
|
||||||
{
|
{
|
||||||
@@ -107,3 +107,5 @@ echo
|
|||||||
echo "Last 3 timestamps in 3.txt:"
|
echo "Last 3 timestamps in 3.txt:"
|
||||||
a shell cat /data/data/com.android.backuptest/files/3.txt | tail -n 3
|
a shell cat /data/data/com.android.backuptest/files/3.txt | tail -n 3
|
||||||
|
|
||||||
|
exit $need_bug
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user