Merge "Add PhoneStateListener.onOtaspChanged."

This commit is contained in:
Wink Saville
2010-11-01 14:47:38 -07:00
committed by Android (Google) Code Review
13 changed files with 162 additions and 22 deletions

View File

@@ -103,6 +103,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
private int mDataConnectionNetworkType;
private int mOtaspMode;
static final int PHONE_STATE_PERMISSION_MASK =
PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
PhoneStateListener.LISTEN_CALL_STATE |
@@ -225,6 +227,13 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
remove(r.binder);
}
}
if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
try {
r.callback.onOtaspChanged(mOtaspMode);
} catch (RemoteException ex) {
remove(r.binder);
}
}
}
}
} else {
@@ -467,6 +476,25 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
}
public void notifyOtaspChanged(int otaspMode) {
if (!checkNotifyPermission("notifyOtaspChanged()" )) {
return;
}
synchronized (mRecords) {
mOtaspMode = otaspMode;
for (Record r : mRecords) {
if ((r.events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
try {
r.callback.onOtaspChanged(otaspMode);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
}
handleRemoveListLocked();
}
}
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)

View File

@@ -148,6 +148,14 @@ public class PhoneStateListener {
*/
public static final int LISTEN_SIGNAL_STRENGTHS = 0x00000100;
/**
* Listen for changes to OTASP mode.
*
* @see #onOtaspChanged
* @hide
*/
public static final int LISTEN_OTASP_CHANGED = 0x00000200;
public PhoneStateListener() {
}
@@ -252,6 +260,21 @@ public class PhoneStateListener {
// default implementation empty
}
/**
* The Over The Air Service Provisioning (OTASP) has changed. Requires
* the READ_PHONE_STATE permission.
* @param otaspMode is integer <code>OTASP_UNKNOWN=1<code>
* means the value is currently unknown and the system should wait until
* <code>OTASP_NEEDED=2<code> or <code>OTASP_NOT_NEEDED=3<code> is received before
* making the decisision to perform OTASP or not.
*
* @hide
*/
public void onOtaspChanged(int otaspMode) {
// default implementation empty
}
/**
* The callback methods need to be called on the handler thread where
* this object was created. If the binder did that for us it'd be nice.
@@ -292,9 +315,14 @@ public class PhoneStateListener {
public void onDataActivity(int direction) {
Message.obtain(mHandler, LISTEN_DATA_ACTIVITY, direction, 0, null).sendToTarget();
}
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
Message.obtain(mHandler, LISTEN_SIGNAL_STRENGTHS, 0, 0, signalStrength).sendToTarget();
}
public void onOtaspChanged(int otaspMode) {
Message.obtain(mHandler, LISTEN_OTASP_CHANGED, otaspMode, 0).sendToTarget();
}
};
Handler mHandler = new Handler() {
@@ -329,6 +357,9 @@ public class PhoneStateListener {
case LISTEN_SIGNAL_STRENGTHS:
PhoneStateListener.this.onSignalStrengthsChanged((SignalStrength)msg.obj);
break;
case LISTEN_OTASP_CHANGED:
PhoneStateListener.this.onOtaspChanged(msg.arg1);
break;
}
}
};

View File

@@ -148,6 +148,14 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
}
}
public void notifyOtaspChanged(Phone sender, int otaspMode) {
try {
mRegistry.notifyOtaspChanged(otaspMode);
} catch (RemoteException ex) {
// system process is dead
}
}
private void log(String s) {
Log.d(LOG_TAG, "[PhoneNotifier] " + s);
}

View File

@@ -32,5 +32,6 @@ oneway interface IPhoneStateListener {
void onDataConnectionStateChanged(int state, int networkType);
void onDataActivity(int direction);
void onSignalStrengthsChanged(in SignalStrength signalStrength);
void onOtaspChanged(in int otaspMode);
}

View File

@@ -38,4 +38,5 @@ interface ITelephonyRegistry {
in LinkCapabilities linkCapabilities, int networkType);
void notifyDataConnectionFailed(String reason, String apnType);
void notifyCellLocation(in Bundle cellLocation);
void notifyOtaspChanged(in int otaspMode);
}

View File

@@ -750,6 +750,10 @@ public abstract class PhoneBase extends Handler implements Phone {
mNotifier.notifyDataConnection(this, reason, apnType);
}
public void notifyOtaspChanged(int otaspMode) {
mNotifier.notifyOtaspChanged(this, otaspMode);
}
public abstract String getPhoneName();
public abstract int getPhoneType();

View File

@@ -42,4 +42,5 @@ public interface PhoneNotifier {
public void notifyDataActivity(Phone sender);
public void notifyOtaspChanged(Phone sender, int otaspMode);
}

View File

@@ -53,6 +53,12 @@ public abstract class ServiceStateTracker extends Handler {
public SignalStrength mSignalStrength;
/* The otaspMode passed to PhoneStateListener#onOtaspChanged */
static public final int OTASP_UNINITIALIZED = 0;
static public final int OTASP_UNKNOWN = 1;
static public final int OTASP_NEEDED = 2;
static public final int OTASP_NOT_NEEDED = 3;
/**
* A unique identifier to track requests associated with a poll
* and ignore stale responses. The value is a count-down of
@@ -268,9 +274,11 @@ public abstract class ServiceStateTracker extends Handler {
public abstract void handleMessage(Message msg);
protected abstract Phone getPhone();
protected abstract void handlePollStateResult(int what, AsyncResult ar);
protected abstract void updateSpnDisplay();
protected abstract void setPowerStateToDesired();
protected abstract void log(String s);
/**
* Clean up existing voice and data connection then turn off radio power.

View File

@@ -61,6 +61,7 @@ import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.PhoneNotifier;
import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.PhoneSubInfo;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.UUSInfo;
@@ -83,10 +84,6 @@ public class CDMAPhone extends PhoneBase {
static final String LOG_TAG = "CDMA";
private static final boolean DBG = true;
// Min values used to by needsActivation
private static final String UNACTIVATED_MIN2_VALUE = "000000";
private static final String UNACTIVATED_MIN_VALUE = "1111110111";
// Default Emergency Callback Mode exit timer
private static final int DEFAULT_ECM_EXIT_TIMER_VALUE = 300000;
@@ -1170,19 +1167,7 @@ public class CDMAPhone extends PhoneBase {
*/
@Override
public boolean needsOtaServiceProvisioning() {
String cdmaMin = getCdmaMin();
boolean needsProvisioning;
if (cdmaMin == null || (cdmaMin.length() < 6)) {
if (DBG) Log.d(LOG_TAG, "needsOtaServiceProvisioning: illegal cdmaMin='"
+ cdmaMin + "' assume provisioning needed.");
needsProvisioning = true;
} else {
needsProvisioning = (cdmaMin.equals(UNACTIVATED_MIN_VALUE)
|| cdmaMin.substring(0,6).equals(UNACTIVATED_MIN2_VALUE))
|| SystemProperties.getBoolean("test_cdma_setup", false);
}
if (DBG) Log.d(LOG_TAG, "needsOtaServiceProvisioning: ret=" + needsProvisioning);
return needsProvisioning;
return mSST.getOtasp() != ServiceStateTracker.OTASP_NOT_NEEDED;
}
private static final String IS683A_FEATURE_CODE = "*228";

View File

@@ -354,6 +354,24 @@ public final class CdmaCallTracker extends CallTracker {
|| (foregroundCall.getState() == CdmaCall.State.ACTIVE)
|| !backgroundCall.getState().isAlive());
if (!ret) {
log(String.format("canDial is false\n" +
"((serviceState=%d) != ServiceState.STATE_POWER_OFF)::=%s\n" +
"&& pendingMO == null::=%s\n" +
"&& !ringingCall.isRinging()::=%s\n" +
"&& !disableCall.equals(\"true\")::=%s\n" +
"&& (!foregroundCall.getState().isAlive()::=%s\n" +
" || foregroundCall.getState() == CdmaCall.State.ACTIVE::=%s\n" +
" ||!backgroundCall.getState().isAlive())::=%s)",
serviceState,
serviceState != ServiceState.STATE_POWER_OFF,
pendingMO == null,
!ringingCall.isRinging(),
!disableCall.equals("true"),
!foregroundCall.getState().isAlive(),
foregroundCall.getState() == CdmaCall.State.ACTIVE,
!backgroundCall.getState().isAlive()));
}
return ret;
}

View File

@@ -22,6 +22,7 @@ import com.android.internal.telephony.DataConnectionTracker;
import com.android.internal.telephony.EventLogTags;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;
@@ -65,6 +66,13 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
CdmaCellLocation cellLoc;
CdmaCellLocation newCellLoc;
// Min values used to by getOtasp()
private static final String UNACTIVATED_MIN2_VALUE = "000000";
private static final String UNACTIVATED_MIN_VALUE = "1111110111";
// Current Otasp value
int mCurrentOtaspMode = OTASP_UNINITIALIZED;
/** if time between NITZ updates is less than mNitzUpdateSpacing the update may be ignored. */
private static final int NITZ_UPDATE_SPACING_DEFAULT = 1000 * 60 * 10;
private int mNitzUpdateSpacing = SystemProperties.getInt("ro.nitz_update_spacing",
@@ -446,6 +454,13 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
if (!mIsMinInfoReady) {
mIsMinInfoReady = true;
}
int otaspMode = getOtasp();
if (mCurrentOtaspMode != otaspMode) {
Log.d(LOG_TAG, "call phone.notifyOtaspChanged old otaspMode=" +
mCurrentOtaspMode + " new otaspMode=" + otaspMode);
mCurrentOtaspMode = otaspMode;
phone.notifyOtaspChanged(mCurrentOtaspMode);
}
phone.getIccCard().broadcastIccStateChangedIntent(IccCard.INTENT_VALUE_ICC_IMSI,
null);
} else {
@@ -642,6 +657,11 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
curPlmn = plmn;
}
@Override
protected Phone getPhone() {
return phone;
}
/**
* Handle the result of one of the pollState()-related requests
*/
@@ -1641,10 +1661,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
return false;
}
protected void log(String s) {
Log.d(LOG_TAG, "[CdmaServiceStateTracker] " + s);
}
public String getMdnNumber() {
return mMdn;
}
@@ -1700,6 +1716,32 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
}
}
/**
* Returns OTASP_UNKNOWN, OTASP_NEEDED or OTASP_NOT_NEEDED
*/
int getOtasp() {
int provisioningState;
if (mMin == null || (mMin.length() < 6)) {
if (DBG) Log.d(LOG_TAG, "getOtasp: bad mMin='" + mMin + "'");
provisioningState = OTASP_UNKNOWN;
} else {
if ((mMin.equals(UNACTIVATED_MIN_VALUE)
|| mMin.substring(0,6).equals(UNACTIVATED_MIN2_VALUE))
|| SystemProperties.getBoolean("test_cdma_setup", false)) {
provisioningState = OTASP_NEEDED;
} else {
provisioningState = OTASP_NOT_NEEDED;
}
}
if (DBG) Log.d(LOG_TAG, "getOtasp: state=" + provisioningState);
return provisioningState;
}
@Override
protected void log(String s) {
Log.d(LOG_TAG, "[CdmaServiceStateTracker] " + s);
}
private void hangupAndPowerOff() {
// hang up all active voice calls
phone.mCT.ringingCall.hangupIfAlive();

View File

@@ -22,6 +22,7 @@ import com.android.internal.telephony.DataConnectionTracker;
import com.android.internal.telephony.EventLogTags;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.TelephonyIntents;
@@ -226,6 +227,9 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
phone.getContext().registerReceiver(mIntentReceiver, filter);
// Gsm doesn't support OTASP so its not needed
phone.notifyOtaspChanged(OTASP_NOT_NEEDED);
}
public void dispose() {
@@ -246,6 +250,11 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
if(DBG) Log.d(LOG_TAG, "GsmServiceStateTracker finalized");
}
@Override
public Phone getPhone() {
return phone;
}
/**
* Registration point for transition into GPRS attached.
* @param h handler to notify
@@ -1676,7 +1685,8 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
}
}
private void log(String s) {
@Override
protected void log(String s) {
Log.d(LOG_TAG, "[GsmServiceStateTracker] " + s);
}
}

View File

@@ -56,4 +56,7 @@ public class TestPhoneNotifier implements PhoneNotifier {
public void notifyDataActivity(Phone sender) {
}
public void notifyOtaspChanged(Phone sender, int otaspMode) {
}
}