am 0304c529: am 82611e6d: Merge "Add getSimStateForSubscriber and additional SIM_STATE_XXXX values" into lmp-mr1-dev

* commit '0304c529b6a166547aaf104a46bc876780ba7416':
  Add getSimStateForSubscriber and additional SIM_STATE_XXXX values
This commit is contained in:
Wink Saville
2014-12-04 21:17:43 +00:00
committed by Android Git Automerger
4 changed files with 98 additions and 60 deletions

View File

@@ -1103,5 +1103,35 @@ public class SubscriptionManager {
return Boolean.parseBoolean(TelephonyManager.getTelephonyProperty(phoneId,
TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, null));
}
/**
* Returns a constant indicating the state of sim for the subscription.
*
* @param subId
*
* {@See TelephonyManager#SIM_STATE_UNKNOWN}
* {@See TelephonyManager#SIM_STATE_ABSENT}
* {@See TelephonyManager#SIM_STATE_PIN_REQUIRED}
* {@See TelephonyManager#SIM_STATE_PUK_REQUIRED}
* {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED}
* {@See TelephonyManager#SIM_STATE_READY}
* {@See TelephonyManager#SIM_STATE_NOT_READY}
* {@See TelephonyManager#SIM_STATE_PERM_DISABLED}
* {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR}
*
* {@hide}
*/
public static int getSimStateForSubscriber(int subId) {
int simState;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
simState = iSub.getSimStateForSubscriber(subId);
} catch (RemoteException ex) {
simState = TelephonyManager.SIM_STATE_UNKNOWN;
}
logd("getSimStateForSubscriber: simState=" + simState + " subId=" + subId);
return simState;
}
}

View File

@@ -1416,10 +1416,14 @@ public class TelephonyManager {
//
//
/** SIM card state: Unknown. Signifies that the SIM is in transition
* between states. For example, when the user inputs the SIM pin
* under PIN_REQUIRED state, a query for sim status returns
* this state before turning to SIM_STATE_READY. */
/**
* SIM card state: Unknown. Signifies that the SIM is in transition
* between states. For example, when the user inputs the SIM pin
* under PIN_REQUIRED state, a query for sim status returns
* this state before turning to SIM_STATE_READY.
*
* These are the ordinal value of IccCardConstants.State.
*/
public static final int SIM_STATE_UNKNOWN = 0;
/** SIM card state: no SIM card is available in the device */
public static final int SIM_STATE_ABSENT = 1;
@@ -1427,14 +1431,22 @@ public class TelephonyManager {
public static final int SIM_STATE_PIN_REQUIRED = 2;
/** SIM card state: Locked: requires the user's SIM PUK to unlock */
public static final int SIM_STATE_PUK_REQUIRED = 3;
/** SIM card state: Locked: requries a network PIN to unlock */
/** SIM card state: Locked: requires a network PIN to unlock */
public static final int SIM_STATE_NETWORK_LOCKED = 4;
/** SIM card state: Ready */
public static final int SIM_STATE_READY = 5;
/** SIM card state: SIM Card Error, Sim Card is present but faulty
/** SIM card state: SIM Card is NOT READY
*@hide
*/
public static final int SIM_STATE_CARD_IO_ERROR = 6;
public static final int SIM_STATE_NOT_READY = 6;
/** SIM card state: SIM Card Error, permanently disabled
*@hide
*/
public static final int SIM_STATE_PERM_DISABLED = 7;
/** SIM card state: SIM Card Error, present but faulty
*@hide
*/
public static final int SIM_STATE_CARD_IO_ERROR = 8;
/**
* @return true if a ICC card is present
@@ -1464,8 +1476,7 @@ public class TelephonyManager {
}
/**
* Returns a constant indicating the state of the
* device SIM card.
* Returns a constant indicating the state of the default SIM card.
*
* @see #SIM_STATE_UNKNOWN
* @see #SIM_STATE_ABSENT
@@ -1473,6 +1484,8 @@ public class TelephonyManager {
* @see #SIM_STATE_PUK_REQUIRED
* @see #SIM_STATE_NETWORK_LOCKED
* @see #SIM_STATE_READY
* @see #SIM_STATE_NOT_READY
* @see #SIM_STATE_PERM_DISABLED
* @see #SIM_STATE_CARD_IO_ERROR
*/
public int getSimState() {
@@ -1480,10 +1493,9 @@ public class TelephonyManager {
}
/**
* Returns a constant indicating the state of the
* device SIM card in a slot.
* Returns a constant indicating the state of the device SIM card in a slot.
*
* @param slotId
* @param slotIdx
*
* @see #SIM_STATE_UNKNOWN
* @see #SIM_STATE_ABSENT
@@ -1491,39 +1503,20 @@ public class TelephonyManager {
* @see #SIM_STATE_PUK_REQUIRED
* @see #SIM_STATE_NETWORK_LOCKED
* @see #SIM_STATE_READY
* @see #SIM_STATE_NOT_READY
* @see #SIM_STATE_PERM_DISABLED
* @see #SIM_STATE_CARD_IO_ERROR
*/
/** {@hide} */
// FIXME the argument to pass is subId ??
public int getSimState(int slotId) {
int[] subId = SubscriptionManager.getSubId(slotId);
public int getSimState(int slotIdx) {
int[] subId = SubscriptionManager.getSubId(slotIdx);
if (subId == null || subId.length == 0) {
return SIM_STATE_ABSENT;
}
// FIXME Do not use a property to determine SIM_STATE, call
// appropriate method on some object.
int phoneId = SubscriptionManager.getPhoneId(subId[0]);
String prop = getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_SIM_STATE, "");
if ("ABSENT".equals(prop)) {
return SIM_STATE_ABSENT;
}
else if ("PIN_REQUIRED".equals(prop)) {
return SIM_STATE_PIN_REQUIRED;
}
else if ("PUK_REQUIRED".equals(prop)) {
return SIM_STATE_PUK_REQUIRED;
}
else if ("NETWORK_LOCKED".equals(prop)) {
return SIM_STATE_NETWORK_LOCKED;
}
else if ("READY".equals(prop)) {
return SIM_STATE_READY;
}
else if ("CARD_IO_ERROR".equals(prop)) {
return SIM_STATE_CARD_IO_ERROR;
}
else {
Rlog.d(TAG, "getSimState:- empty subId return SIM_STATE_ABSENT");
return SIM_STATE_UNKNOWN;
}
int simState = SubscriptionManager.getSimStateForSubscriber(subId[0]);
Rlog.d(TAG, "getSimState: simState=" + simState + " slotIdx=" + slotIdx);
return simState;
}
/**
@@ -1535,7 +1528,7 @@ public class TelephonyManager {
* @see #getSimState
*/
public String getSimOperator() {
int subId = mSubscriptionManager.getDefaultDataSubId();
int subId = SubscriptionManager.getDefaultDataSubId();
if (!SubscriptionManager.isUsableSubIdValue(subId)) {
subId = SubscriptionManager.getDefaultSmsSubId();
if (!SubscriptionManager.isUsableSubIdValue(subId)) {
@@ -2754,8 +2747,6 @@ public class TelephonyManager {
* @hide
*/
public static void setTelephonyProperty(int phoneId, String property, String value) {
Rlog.d(TAG, "setTelephonyProperty property: " + property + " phoneId: " + phoneId +
" value: " + value);
String propVal = "";
String p[] = null;
String prop = SystemProperties.get(property);
@@ -2769,7 +2760,8 @@ public class TelephonyManager {
}
if (!SubscriptionManager.isValidPhoneId(phoneId)) {
Rlog.d(TAG, "setTelephonyProperty invalid phone id");
Rlog.d(TAG, "setTelephonyProperty: invalid phoneId=" + phoneId +
" property=" + property + " value: " + value + " prop=" + prop);
return;
}
@@ -2788,13 +2780,15 @@ public class TelephonyManager {
}
}
// TODO: workaround for QC
if (property.length() > SystemProperties.PROP_NAME_MAX || propVal.length() > SystemProperties.PROP_VALUE_MAX) {
Rlog.d(TAG, "setTelephonyProperty length too long:" + property + ", " + propVal);
if (property.length() > SystemProperties.PROP_NAME_MAX
|| propVal.length() > SystemProperties.PROP_VALUE_MAX) {
Rlog.d(TAG, "setTelephonyProperty: property to long phoneId=" + phoneId +
" property=" + property + " value: " + value + " propVal=" + propVal);
return;
}
Rlog.d(TAG, "setTelephonyProperty property=" + property + " propVal=" + propVal);
Rlog.d(TAG, "setTelephonyProperty: success phoneId=" + phoneId +
" property=" + property + " value: " + value + " propVal=" + propVal);
SystemProperties.set(property, propVal);
}
@@ -2900,13 +2894,16 @@ public class TelephonyManager {
propVal = values[phoneId];
}
}
Rlog.d(TAG, "getTelephonyProperty: return propVal='" + propVal + "' phoneId=" + phoneId
+ " property='" + property + "' defaultVal='" + defaultVal + "' prop=" + prop);
return propVal == null ? defaultVal : propVal;
}
/** @hide */
public int getSimCount() {
// FIXME Need to get it from Telephony Dev Controller when that gets implemented!
// and then this method shouldn't be used at all!
if(isMultiSimEnabled()) {
//FIXME Need to get it from Telephony Devcontroller
return 2;
} else {
return 1;

View File

@@ -164,4 +164,11 @@ interface ISub {
void clearDefaultsForInactiveSubIds();
int[] getActiveSubIdList();
/**
* Get the SIM state for the subscriber
* @return SIM state as the ordinal of IccCardConstants.State
*/
int getSimStateForSubscriber(int subId);
}

View File

@@ -15,12 +15,14 @@
*/
package com.android.internal.telephony;
import android.telephony.TelephonyManager;
/**
* {@hide}
*/
public class IccCardConstants {
/* The extra data for broacasting intent INTENT_ICC_STATE_CHANGE */
/* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */
public static final String INTENT_KEY_ICC_STATE = "ss";
/* UNKNOWN means the ICC state is unknown */
public static final String INTENT_VALUE_ICC_UNKNOWN = "UNKNOWN";
@@ -38,7 +40,7 @@ public class IccCardConstants {
public static final String INTENT_VALUE_ICC_IMSI = "IMSI";
/* LOADED means all ICC records, including IMSI, are loaded */
public static final String INTENT_VALUE_ICC_LOADED = "LOADED";
/* The extra data for broacasting intent INTENT_ICC_STATE_CHANGE */
/* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */
public static final String INTENT_KEY_LOCKED_REASON = "reason";
/* PIN means ICC is locked on PIN1 */
public static final String INTENT_VALUE_LOCKED_ON_PIN = "PIN";
@@ -56,17 +58,19 @@ public class IccCardConstants {
* UNKNOWN is a transient state, for example, after user inputs ICC pin under
* PIN_REQUIRED state, the query for ICC status returns UNKNOWN before it
* turns to READY
*
* The ordinal values much match {@link TelephonyManager#SIM_STATE_UNKNOWN} ...
*/
public enum State {
UNKNOWN,
ABSENT,
PIN_REQUIRED,
PUK_REQUIRED,
NETWORK_LOCKED,
READY,
NOT_READY,
PERM_DISABLED,
CARD_IO_ERROR;
UNKNOWN, /** ordinal(0) == {@See TelephonyManager#SIM_STATE_UNKNOWN} */
ABSENT, /** ordinal(1) == {@See TelephonyManager#SIM_STATE_ABSENT} */
PIN_REQUIRED, /** ordinal(2) == {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} */
PUK_REQUIRED, /** ordinal(3) == {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} */
NETWORK_LOCKED, /** ordinal(4) == {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} */
READY, /** ordinal(5) == {@See TelephonyManager#SIM_STATE_READY} */
NOT_READY, /** ordinal(6) == {@See TelephonyManager#SIM_STATE_NOT_READY} */
PERM_DISABLED, /** ordinal(7) == {@See TelephonyManager#SIM_STATE_PERM_DISABLED} */
CARD_IO_ERROR; /** ordinal(8) == {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR} */
public boolean isPinLocked() {
return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED));