summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/android/telephony/PhoneStateListener.java23
-rw-r--r--telephony/java/android/telephony/SubInfoRecord.java25
-rw-r--r--telephony/java/android/telephony/SubscriptionManager.java466
-rw-r--r--telephony/java/com/android/internal/telephony/IMms.aidl46
-rwxr-xr-xtelephony/java/com/android/internal/telephony/ISub.aidl59
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneConstants.java14
-rw-r--r--telephony/java/com/android/internal/telephony/TelephonyIntents.java10
7 files changed, 433 insertions, 210 deletions
diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java
index 350c27e..34da1c9 100644
--- a/telephony/java/android/telephony/PhoneStateListener.java
+++ b/telephony/java/android/telephony/PhoneStateListener.java
@@ -221,18 +221,39 @@ public class PhoneStateListener {
private final Handler mHandler;
+ /**
+ * Create a PhoneStateListener for the Phone with the default subscription.
+ * This class requires Looper.myLooper() not return null. To supply your
+ * own non-null looper use PhoneStateListener(Looper looper) below.
+ */
public PhoneStateListener() {
this(SubscriptionManager.DEFAULT_SUB_ID, Looper.myLooper());
}
/**
+ * Create a PhoneStateListener for the Phone with the default subscription
+ * using a particular non-null Looper.
+ * @hide
+ */
+ public PhoneStateListener(Looper looper) {
+ this(SubscriptionManager.DEFAULT_SUB_ID, looper);
+ }
+
+ /**
+ * Create a PhoneStateListener for the Phone using the specified subscription.
+ * This class requires Looper.myLooper() not return null. To supply your
+ * own non-null Looper use PhoneStateListener(long subId, Looper looper) below.
* @hide
*/
public PhoneStateListener(long subId) {
this(subId, Looper.myLooper());
}
- /** @hide */
+ /**
+ * Create a PhoneStateListener for the Phone using the specified subscription
+ * and non-null Looper.
+ * @hide
+ */
public PhoneStateListener(long subId, Looper looper) {
if (DBG) log("ctor: subId=" + subId + " looper=" + looper);
mSubId = subId;
diff --git a/telephony/java/android/telephony/SubInfoRecord.java b/telephony/java/android/telephony/SubInfoRecord.java
index ced8e2f..55781fa 100644
--- a/telephony/java/android/telephony/SubInfoRecord.java
+++ b/telephony/java/android/telephony/SubInfoRecord.java
@@ -33,34 +33,33 @@ public class SubInfoRecord implements Parcelable {
public int mNameSource;
public int mColor;
public String mNumber;
- public int mDispalyNumberFormat;
+ public int mDisplayNumberFormat;
public int mDataRoaming;
public int[] mSimIconRes;
public SubInfoRecord() {
- this.mSubId = -1;
+ this.mSubId = SubscriptionManager.INVALID_SUB_ID;
this.mIccId = "";
- this.mSlotId = -1;
+ this.mSlotId = SubscriptionManager.INVALID_SLOT_ID;
this.mDisplayName = "";
this.mNameSource = 0;
this.mColor = 0;
this.mNumber = "";
- this.mDispalyNumberFormat = 0;
+ this.mDisplayNumberFormat = 0;
this.mDataRoaming = 0;
this.mSimIconRes = new int[2];
}
-
- public SubInfoRecord(long subId, String iccId, int slotId, String displayname, int nameSource,
- int mColor, String mNumber, int displayFormat, int roaming, int[] iconRes) {
+ public SubInfoRecord(long subId, String iccId, int slotId, String displayName,
+ int nameSource, int mColor, String mNumber, int displayFormat, int roaming, int[] iconRes) {
this.mSubId = subId;
this.mIccId = iccId;
this.mSlotId = slotId;
- this.mDisplayName = displayname;
+ this.mDisplayName = displayName;
this.mNameSource = nameSource;
this.mColor = mColor;
this.mNumber = mNumber;
- this.mDispalyNumberFormat = displayFormat;
+ this.mDisplayNumberFormat = displayFormat;
this.mDataRoaming = roaming;
this.mSimIconRes = iconRes;
}
@@ -74,13 +73,13 @@ public class SubInfoRecord implements Parcelable {
int mNameSource = source.readInt();
int mColor = source.readInt();
String mNumber = source.readString();
- int mDispalyNumberFormat = source.readInt();
+ int mDisplayNumberFormat = source.readInt();
int mDataRoaming = source.readInt();
int[] iconRes = new int[2];
source.readIntArray(iconRes);
return new SubInfoRecord(mSubId, mIccId, mSlotId, mDisplayName, mNameSource, mColor, mNumber,
- mDispalyNumberFormat, mDataRoaming, iconRes);
+ mDisplayNumberFormat, mDataRoaming, iconRes);
}
public SubInfoRecord[] newArray(int size) {
@@ -96,7 +95,7 @@ public class SubInfoRecord implements Parcelable {
dest.writeInt(mNameSource);
dest.writeInt(mColor);
dest.writeString(mNumber);
- dest.writeInt(mDispalyNumberFormat);
+ dest.writeInt(mDisplayNumberFormat);
dest.writeInt(mDataRoaming);
dest.writeIntArray(mSimIconRes);
}
@@ -109,7 +108,7 @@ public class SubInfoRecord implements Parcelable {
return "{mSubId=" + mSubId + ", mIccId=" + mIccId + " mSlotId=" + mSlotId
+ " mDisplayName=" + mDisplayName + " mNameSource=" + mNameSource
+ " mColor=" + mColor + " mNumber=" + mNumber
- + " mDispalyNumberFormat=" + mDispalyNumberFormat + " mDataRoaming=" + mDataRoaming
+ + " mDisplayNumberFormat=" + mDisplayNumberFormat + " mDataRoaming=" + mDataRoaming
+ " mSimIconRes=" + mSimIconRes + "}";
}
}
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 79e9fd5..2bb2404 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -1,31 +1,24 @@
/*
-* Copyright (C) 2011-2014 MediaTek Inc.
-*
-* 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.
-*/
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package android.telephony;
-import static android.Manifest.permission.READ_PHONE_STATE;
-
-import android.app.ActivityManagerNative;
-import android.content.ContentResolver;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Context;
+import android.annotation.SdkConstant;
+import android.annotation.SdkConstant.SdkConstantType;
import android.content.Intent;
-import android.database.Cursor;
-import android.os.UserHandle;
import android.net.Uri;
import android.provider.BaseColumns;
import android.telephony.Rlog;
@@ -34,123 +27,181 @@ import android.os.RemoteException;
import com.android.internal.telephony.ISub;
import com.android.internal.telephony.PhoneConstants;
-import com.android.internal.telephony.TelephonyIntents;
-
-import java.util.ArrayList;
import java.util.List;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
/**
- *@hide
+ * SubscriptionManager is the application interface to SubscriptionController
+ * and provides information about the current Telephony Subscriptions.
+ *
+ * @hide
*/
public class SubscriptionManager implements BaseColumns {
private static final String LOG_TAG = "SUB";
private static final boolean DBG = true;
private static final boolean VDBG = false;
+ // An invalid phone identifier
+ /** @hide */
+ public static final int INVALID_PHONE_ID = -1000;
+
+ // Indicates the caller wants the default phone id.
+ /** @hide */
+ public static final int DEFAULT_PHONE_ID = Integer.MAX_VALUE;
+
+ // An invalid slot identifier
+ /** @hide */
+ public static final int INVALID_SLOT_ID = -1000;
+
+ // Indicates the caller wants the default slot id.
+ /** @hide */
+ public static final int DEFAULT_SLOT_ID = Integer.MAX_VALUE;
+
// An invalid subscription identifier
- public static final long INVALID_SUB_ID = Long.MAX_VALUE;
+ /** @hide */
+ public static final long INVALID_SUB_ID = -1000;
+
+ // Indicates the user should be asked which sub to use.
+ /** @hide */
+ public static final long ASK_USER_SUB_ID = -1001;
- // The default subscription identifier
- public static final long DEFAULT_SUB_ID = Long.MAX_VALUE - 1;
+ // Indicates the caller wants the default sub id.
+ /** @hide */
+ public static final long DEFAULT_SUB_ID = Long.MAX_VALUE;
+ /** @hide */
public static final Uri CONTENT_URI = Uri.parse("content://telephony/siminfo");
+ /** @hide */
public static final int DEFAULT_INT_VALUE = -100;
+ /** @hide */
public static final String DEFAULT_STRING_VALUE = "N/A";
+ /** @hide */
public static final int EXTRA_VALUE_NEW_SIM = 1;
+
+ /** @hide */
public static final int EXTRA_VALUE_REMOVE_SIM = 2;
+ /** @hide */
public static final int EXTRA_VALUE_REPOSITION_SIM = 3;
+ /** @hide */
public static final int EXTRA_VALUE_NOCHANGE = 4;
+ /** @hide */
public static final String INTENT_KEY_DETECT_STATUS = "simDetectStatus";
+ /** @hide */
public static final String INTENT_KEY_SIM_COUNT = "simCount";
+ /** @hide */
public static final String INTENT_KEY_NEW_SIM_SLOT = "newSIMSlot";
+ /** @hide */
public static final String INTENT_KEY_NEW_SIM_STATUS = "newSIMStatus";
/**
* The ICC ID of a SIM.
* <P>Type: TEXT (String)</P>
*/
+ /** @hide */
public static final String ICC_ID = "icc_id";
/**
* <P>Type: INTEGER (int)</P>
*/
+ /** @hide */
public static final String SIM_ID = "sim_id";
-
+ /** @hide */
public static final int SIM_NOT_INSERTED = -1;
/**
* The display name of a SIM.
* <P>Type: TEXT (String)</P>
*/
+ /** @hide */
public static final String DISPLAY_NAME = "display_name";
+ /** @hide */
public static final int DEFAULT_NAME_RES = com.android.internal.R.string.unknownName;
/**
* The display name source of a SIM.
* <P>Type: INT (int)</P>
*/
+ /** @hide */
public static final String NAME_SOURCE = "name_source";
- public static final int DEFAULT_SOURCE = 0;
+ /** @hide */
+ public static final int NAME_SOURCE_UNDEFINDED = -1;
- public static final int SIM_SOURCE = 1;
+ /** @hide */
+ public static final int NAME_SOURCE_DEFAULT_SOURCE = 0;
- public static final int USER_INPUT = 2;
+ /** @hide */
+ public static final int NAME_SOURCE_SIM_SOURCE = 1;
+
+ /** @hide */
+ public static final int NAME_SOURCE_USER_INPUT = 2;
/**
* The color of a SIM.
* <P>Type: INTEGER (int)</P>
*/
+ /** @hide */
public static final String COLOR = "color";
+ /** @hide */
public static final int COLOR_1 = 0;
+ /** @hide */
public static final int COLOR_2 = 1;
+ /** @hide */
public static final int COLOR_3 = 2;
+ /** @hide */
public static final int COLOR_4 = 3;
+ /** @hide */
public static final int COLOR_DEFAULT = COLOR_1;
/**
* The phone number of a SIM.
* <P>Type: TEXT (String)</P>
*/
+ /** @hide */
public static final String NUMBER = "number";
/**
* The number display format of a SIM.
* <P>Type: INTEGER (int)</P>
*/
+ /** @hide */
public static final String DISPLAY_NUMBER_FORMAT = "display_number_format";
- public static final int DISPALY_NUMBER_NONE = 0;
+ /** @hide */
+ public static final int DISPLAY_NUMBER_NONE = 0;
+ /** @hide */
public static final int DISPLAY_NUMBER_FIRST = 1;
+ /** @hide */
public static final int DISPLAY_NUMBER_LAST = 2;
+ /** @hide */
public static final int DISLPAY_NUMBER_DEFAULT = DISPLAY_NUMBER_FIRST;
/**
* Permission for data roaming of a SIM.
* <P>Type: INTEGER (int)</P>
*/
+ /** @hide */
public static final String DATA_ROAMING = "data_roaming";
+ /** @hide */
public static final int DATA_ROAMING_ENABLE = 1;
+ /** @hide */
public static final int DATA_ROAMING_DISABLE = 0;
+ /** @hide */
public static final int DATA_ROAMING_DEFAULT = DATA_ROAMING_DISABLE;
private static final int RES_TYPE_BACKGROUND_DARK = 0;
@@ -159,24 +210,29 @@ public class SubscriptionManager implements BaseColumns {
private static final int[] sSimBackgroundDarkRes = setSimResource(RES_TYPE_BACKGROUND_DARK);
- private static final int[] sSimBackgroundLightRes = setSimResource(RES_TYPE_BACKGROUND_LIGHT);
-
- private static HashMap<Integer, Long> mSimInfo = new HashMap<Integer, Long>();
+ /**
+ * Broadcast Action: The user has changed one of the default subs related to
+ * data, phone calls, or sms</p>
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String SUB_DEFAULT_CHANGED_ACTION =
+ "android.intent.action.SUB_DEFAULT_CHANGED";
+ /** @hide */
public SubscriptionManager() {
if (DBG) logd("SubscriptionManager created");
}
/**
* Get the SubInfoRecord according to an index
- * @param context Context provided by caller
* @param subId The unique SubInfoRecord index in database
* @return SubInfoRecord, maybe null
+ * @hide
*/
- public static SubInfoRecord getSubInfoUsingSubId(Context context, long subId) {
- if (VDBG) logd("[getSubInfoUsingSubIdx]+ subId:" + subId);
- if (subId <= 0) {
- if (VDBG) logd("[getSubInfoUsingSubIdx]- subId <= 0");
+ public static SubInfoRecord getSubInfoUsingSubId(long subId) {
+ if (!isValidSubId(subId)) {
+ logd("[getSubInfoUsingSubIdx]- invalid subId");
return null;
}
@@ -197,11 +253,11 @@ public class SubscriptionManager implements BaseColumns {
/**
* Get the SubInfoRecord according to an IccId
- * @param context Context provided by caller
* @param iccId the IccId of SIM card
* @return SubInfoRecord, maybe null
+ * @hide
*/
- public static List<SubInfoRecord> getSubInfoUsingIccId(Context context, String iccId) {
+ public static List<SubInfoRecord> getSubInfoUsingIccId(String iccId) {
if (VDBG) logd("[getSubInfoUsingIccId]+ iccId=" + iccId);
if (iccId == null) {
logd("[getSubInfoUsingIccId]- null iccid");
@@ -224,14 +280,14 @@ public class SubscriptionManager implements BaseColumns {
/**
* Get the SubInfoRecord according to slotId
- * @param context Context provided by caller
* @param slotId the slot which the SIM is inserted
* @return SubInfoRecord, maybe null
+ * @hide
*/
- public static List<SubInfoRecord> getSubInfoUsingSlotId(Context context, int slotId) {
- if (VDBG) logd("[getSubInfoUsingSlotId]- slotId=" + slotId);
- if (slotId < 0) {
- logd("[getSubInfoUsingSlotId]- return null, slotId < 0");
+ public static List<SubInfoRecord> getSubInfoUsingSlotId(int slotId) {
+ // FIXME: Consider never returning null
+ if (!isValidSlotId(slotId)) {
+ logd("[getSubInfoUsingSlotId]- invalid slotId");
return null;
}
@@ -251,10 +307,10 @@ public class SubscriptionManager implements BaseColumns {
/**
* Get all the SubInfoRecord(s) in subinfo database
- * @param context Context provided by caller
* @return Array list of all SubInfoRecords in database, include thsoe that were inserted before
+ * @hide
*/
- public static List<SubInfoRecord> getAllSubInfoList(Context context) {
+ public static List<SubInfoRecord> getAllSubInfoList() {
if (VDBG) logd("[getAllSubInfoList]+");
List<SubInfoRecord> result = null;
@@ -273,18 +329,16 @@ public class SubscriptionManager implements BaseColumns {
/**
* Get the SubInfoRecord(s) of the currently inserted SIM(s)
- * @param context Context provided by caller
* @return Array list of currently inserted SubInfoRecord(s)
+ * @hide
*/
- public static List<SubInfoRecord> getActivatedSubInfoList(Context context) {
- if (VDBG) logd("[getActivatedSubInfoList]+");
-
+ public static List<SubInfoRecord> getActiveSubInfoList() {
List<SubInfoRecord> result = null;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
- result = iSub.getActivatedSubInfoList();
+ result = iSub.getActiveSubInfoList();
}
} catch (RemoteException ex) {
// ignore it
@@ -295,10 +349,10 @@ public class SubscriptionManager implements BaseColumns {
/**
* Get the SUB count of all SUB(s) in subinfo database
- * @param context Context provided by caller
* @return all SIM count in database, include what was inserted before
+ * @hide
*/
- public static int getAllSubInfoCount(Context context) {
+ public static int getAllSubInfoCount() {
if (VDBG) logd("[getAllSubInfoCount]+");
int result = 0;
@@ -316,17 +370,40 @@ public class SubscriptionManager implements BaseColumns {
}
/**
+ * Get the count of active SUB(s)
+ * @return active SIM count
+ * @hide
+ */
+ public static int getActiveSubInfoCount() {
+ int result = 0;
+
+ try {
+ ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ if (iSub != null) {
+ result = iSub.getActiveSubInfoCount();
+ }
+ } catch (RemoteException ex) {
+ // ignore it
+ }
+
+ return result;
+ }
+
+ /**
* Add a new SubInfoRecord to subinfo database if needed
- * @param context Context provided by caller
* @param iccId the IccId of the SIM card
* @param slotId the slot which the SIM is inserted
* @return the URL of the newly created row or the updated row
+ * @hide
*/
- public static Uri addSubInfoRecord(Context context, String iccId, int slotId) {
+ public static Uri addSubInfoRecord(String iccId, int slotId) {
if (VDBG) logd("[addSubInfoRecord]+ iccId:" + iccId + " slotId:" + slotId);
if (iccId == null) {
logd("[addSubInfoRecord]- null iccId");
}
+ if (!isValidSlotId(slotId)) {
+ logd("[addSubInfoRecord]- invalid slotId");
+ }
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -345,15 +422,15 @@ public class SubscriptionManager implements BaseColumns {
/**
* Set SIM color by simInfo index
- * @param context Context provided by caller
* @param color the color of the SIM
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
+ * @hide
*/
- public static int setColor(Context context, int color, long subId) {
+ public static int setColor(int color, long subId) {
if (VDBG) logd("[setColor]+ color:" + color + " subId:" + subId);
int size = sSimBackgroundDarkRes.length;
- if (subId <= 0 || color < 0 || color >= size) {
+ if (!isValidSubId(subId) || color < 0 || color >= size) {
logd("[setColor]- fail");
return -1;
}
@@ -375,26 +452,30 @@ public class SubscriptionManager implements BaseColumns {
/**
* Set display name by simInfo index
- * @param context Context provided by caller
* @param displayName the display name of SIM card
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
+ * @hide
*/
- public static int setDisplayName(Context context, String displayName, long subId) {
- return setDisplayName(context, displayName, subId, -1);
+ public static int setDisplayName(String displayName, long subId) {
+ return setDisplayName(displayName, subId, NAME_SOURCE_UNDEFINDED);
}
/**
* Set display name by simInfo index with name source
- * @param context Context provided by caller
* @param displayName the display name of SIM card
* @param subId the unique SubInfoRecord index in database
- * @param nameSource, 0: DEFAULT_SOURCE, 1: SIM_SOURCE, 2: USER_INPUT
- * @return the number of records updated
+ * @param nameSource 0: NAME_SOURCE_DEFAULT_SOURCE, 1: NAME_SOURCE_SIM_SOURCE,
+ * 2: NAME_SOURCE_USER_INPUT, -1 NAME_SOURCE_UNDEFINED
+ * @return the number of records updated or -1 if invalid subId
+ * @hide
*/
- public static int setDisplayName(Context context, String displayName, long subId, long nameSource) {
- if (VDBG) logd("[setDisplayName]+ displayName:" + displayName + " subId:" + subId + " nameSource:" + nameSource);
- if (subId <= 0) {
+ public static int setDisplayName(String displayName, long subId, long nameSource) {
+ if (VDBG) {
+ logd("[setDisplayName]+ displayName:" + displayName + " subId:" + subId
+ + " nameSource:" + nameSource);
+ }
+ if (!isValidSubId(subId)) {
logd("[setDisplayName]- fail");
return -1;
}
@@ -416,15 +497,14 @@ public class SubscriptionManager implements BaseColumns {
/**
* Set phone number by subId
- * @param context Context provided by caller
* @param number the phone number of the SIM
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
+ * @hide
*/
- public static int setDispalyNumber(Context context, String number, long subId) {
- if (VDBG) logd("[setDispalyNumber]+ number:" + number + " subId:" + subId);
- if (number == null || subId <= 0) {
- logd("[setDispalyNumber]- fail");
+ public static int setDisplayNumber(String number, long subId) {
+ if (number == null || !isValidSubId(subId)) {
+ logd("[setDisplayNumber]- fail");
return -1;
}
@@ -433,7 +513,7 @@ public class SubscriptionManager implements BaseColumns {
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
- result = iSub.setDispalyNumber(number, subId);
+ result = iSub.setDisplayNumber(number, subId);
}
} catch (RemoteException ex) {
// ignore it
@@ -445,14 +525,14 @@ public class SubscriptionManager implements BaseColumns {
/**
* Set number display format. 0: none, 1: the first four digits, 2: the last four digits
- * @param context Context provided by caller
* @param format the display format of phone number
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
+ * @hide
*/
- public static int setDisplayNumberFormat(Context context, int format, long subId) {
+ public static int setDisplayNumberFormat(int format, long subId) {
if (VDBG) logd("[setDisplayNumberFormat]+ format:" + format + " subId:" + subId);
- if (format < 0 || subId <= 0) {
+ if (format < 0 || !isValidSubId(subId)) {
logd("[setDisplayNumberFormat]- fail, return -1");
return -1;
}
@@ -474,14 +554,14 @@ public class SubscriptionManager implements BaseColumns {
/**
* Set data roaming by simInfo index
- * @param context Context provided by caller
* @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
+ * @hide
*/
- public static int setDataRoaming(Context context, int roaming, long subId) {
+ public static int setDataRoaming(int roaming, long subId) {
if (VDBG) logd("[setDataRoaming]+ roaming:" + roaming + " subId:" + subId);
- if (roaming < 0 || subId <= 0) {
+ if (roaming < 0 || !isValidSubId(subId)) {
logd("[setDataRoaming]- fail");
return -1;
}
@@ -500,10 +580,13 @@ public class SubscriptionManager implements BaseColumns {
return result;
}
+ /** @hide */
public static int getSlotId(long subId) {
- if (VDBG) logd("[getSlotId]+ subId:" + subId);
+ if (!isValidSubId(subId)) {
+ logd("[getSlotId]- fail");
+ }
- int result = 0;
+ int result = INVALID_SLOT_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -518,8 +601,12 @@ public class SubscriptionManager implements BaseColumns {
}
+ /** @hide */
public static long[] getSubId(int slotId) {
- if (VDBG) logd("[getSubId]+ slotId:" + slotId);
+ if (!isValidSlotId(slotId)) {
+ logd("[getSubId]- fail");
+ return null;
+ }
long[] subId = null;
@@ -535,10 +622,14 @@ public class SubscriptionManager implements BaseColumns {
return subId;
}
+ /** @hide */
public static int getPhoneId(long subId) {
- if (VDBG) logd("[getPhoneId]+ subId=" + subId);
+ if (!isValidSubId(subId)) {
+ logd("[getPhoneId]- fail");
+ return INVALID_PHONE_ID;
+ }
- int result = 0;
+ int result = INVALID_PHONE_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -549,7 +640,7 @@ public class SubscriptionManager implements BaseColumns {
// ignore it
}
- if (VDBG) logd("[getPhoneId]- phonId=" + result);
+ if (VDBG) logd("[getPhoneId]- phoneId=" + result);
return result;
}
@@ -583,23 +674,14 @@ public class SubscriptionManager implements BaseColumns {
Rlog.d(LOG_TAG, "[SubManager] " + msg);
}
- public static long normalizeSubId(long subId) {
- long retVal = (subId == DEFAULT_SUB_ID) ? getDefaultSubId() : subId;
- Rlog.d(LOG_TAG, "[SubManager] normalizeSubId subId=" + retVal);
- return retVal;
- }
-
- public static boolean validSubId(long subId) {
- return (subId != DEFAULT_SUB_ID) && (subId != -1);
- }
-
/**
* @return the "system" defaultSubId on a voice capable device this
* will be getDefaultVoiceSubId() and on a data only device it will be
* getDefaultDataSubId().
+ * @hide
*/
public static long getDefaultSubId() {
- long subId = 1;
+ long subId = INVALID_SUB_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -614,8 +696,9 @@ public class SubscriptionManager implements BaseColumns {
return subId;
}
+ /** @hide */
public static long getDefaultVoiceSubId() {
- long subId = 1;
+ long subId = INVALID_SUB_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -626,10 +709,11 @@ public class SubscriptionManager implements BaseColumns {
// ignore it
}
- if (VDBG) logd("getDefaultSubId, sub id = " + subId);
+ if (VDBG) logd("getDefaultVoiceSubId, sub id = " + subId);
return subId;
}
+ /** @hide */
public static void setDefaultVoiceSubId(long subId) {
if (VDBG) logd("setDefaultVoiceSubId sub id = " + subId);
try {
@@ -638,34 +722,78 @@ public class SubscriptionManager implements BaseColumns {
iSub.setDefaultVoiceSubId(subId);
}
} catch (RemoteException ex) {
- // ignore it
+ // ignore it
}
}
- public static long getPreferredSmsSubId() {
- // FIXME add framework support to get the preferred sub
- return getDefaultSubId();
+ /** @hide */
+ public static SubInfoRecord getDefaultVoiceSubInfo() {
+ return getSubInfoUsingSubId(getDefaultVoiceSubId());
}
- public static long getPreferredDataSubId() {
- // FIXME add framework support to get the preferred sub
- return getDefaultSubId();
+ /** @hide */
+ public static int getDefaultVoicePhoneId() {
+ return getPhoneId(getDefaultVoiceSubId());
}
+ /** @hide */
+ public static long getDefaultSmsSubId() {
+ long subId = INVALID_SUB_ID;
+
+ try {
+ ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ if (iSub != null) {
+ subId = iSub.getDefaultSmsSubId();
+ }
+ } catch (RemoteException ex) {
+ // ignore it
+ }
+
+ if (VDBG) logd("getDefaultSmsSubId, sub id = " + subId);
+ return subId;
+ }
+
+ /** @hide */
+ public static void setDefaultSmsSubId(long subId) {
+ if (VDBG) logd("setDefaultSmsSubId sub id = " + subId);
+ try {
+ ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ if (iSub != null) {
+ iSub.setDefaultSmsSubId(subId);
+ }
+ } catch (RemoteException ex) {
+ // ignore it
+ }
+ }
+
+ /** @hide */
+ public static SubInfoRecord getDefaultSmsSubInfo() {
+ return getSubInfoUsingSubId(getDefaultSmsSubId());
+ }
+
+ /** @hide */
+ public static int getDefaultSmsPhoneId() {
+ return getPhoneId(getDefaultSmsSubId());
+ }
+
+ /** @hide */
public static long getDefaultDataSubId() {
+ long subId = INVALID_SUB_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
- return iSub.getDefaultDataSubId();
- } else {
- return -1;
+ subId = iSub.getDefaultDataSubId();
}
} catch (RemoteException ex) {
- return -1;
+ // ignore it
}
+
+ if (VDBG) logd("getDefaultDataSubId, sub id = " + subId);
+ return subId;
}
+ /** @hide */
public static void setDefaultDataSubId(long subId) {
if (VDBG) logd("setDataSubscription sub id = " + subId);
try {
@@ -674,14 +802,22 @@ public class SubscriptionManager implements BaseColumns {
iSub.setDefaultDataSubId(subId);
}
} catch (RemoteException ex) {
- // ignore it
+ // ignore it
}
}
- public static void clearSubInfo()
- {
- if (VDBG) logd("[clearSubInfo]+");
+ /** @hide */
+ public static SubInfoRecord getDefaultDataSubInfo() {
+ return getSubInfoUsingSubId(getDefaultDataSubId());
+ }
+
+ /** @hide */
+ public static int getDefaultDataPhoneId() {
+ return getPhoneId(getDefaultDataSubId());
+ }
+ /** @hide */
+ public static void clearSubInfo() {
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
@@ -694,19 +830,97 @@ public class SubscriptionManager implements BaseColumns {
return;
}
+ //FIXME this is vulnerable to race conditions
+ /** @hide */
+ public static boolean allDefaultsSelected() {
+ if (getDefaultDataSubId() == INVALID_SUB_ID) {
+ return false;
+ }
+ if (getDefaultSmsSubId() == INVALID_SUB_ID) {
+ return false;
+ }
+ if (getDefaultVoiceSubId() == INVALID_SUB_ID) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * If a default is set to subscription which is not active, this will reset that default back to
+ * INVALID_SUB_ID.
+ * @hide
+ */
+ public static void clearDefaultsForInactiveSubIds() {
+ if (VDBG) logd("clearDefaultsForInactiveSubIds");
+ try {
+ ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ if (iSub != null) {
+ iSub.clearDefaultsForInactiveSubIds();
+ }
+ } catch (RemoteException ex) {
+ // ignore it
+ }
+ }
+
+ /** @hide */
+ public static boolean isValidSubId(long subId) {
+ return subId > INVALID_SUB_ID ;
+ }
+
+ /** @hide */
+ public static boolean isValidSlotId(int slotId) {
+ return slotId > INVALID_SLOT_ID && slotId < TelephonyManager.getDefault().getSimCount();
+ }
+
+ /** @hide */
+ public static boolean isValidPhoneId(int phoneId) {
+ return phoneId > INVALID_PHONE_ID
+ && phoneId < TelephonyManager.getDefault().getPhoneCount();
+ }
+
+ /** @hide */
public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId) {
- long [] subId = SubscriptionManager.getSubId(phoneId);
- if ((subId != null) && (subId.length >= 1)) {
- putPhoneIdAndSubIdExtra(intent, phoneId, subId[0]);
+ long[] subIds = SubscriptionManager.getSubId(phoneId);
+ if (subIds != null && subIds.length > 0) {
+ putPhoneIdAndSubIdExtra(intent, phoneId, subIds[0]);
} else {
logd("putPhoneIdAndSubIdExtra: no valid subs");
}
}
+ /** @hide */
public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId, long subId) {
if (VDBG) logd("putPhoneIdAndSubIdExtra: phoneId=" + phoneId + " subId=" + subId);
- intent.putExtra(PhoneConstants.SLOT_KEY, phoneId); //FIXME: RENAME TO PHONE_ID_KEY ??
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
+ intent.putExtra(PhoneConstants.PHONE_KEY, phoneId);
+ //FIXME this is using phoneId and slotId interchangeably
+ //Eventually, this should be removed as it is not the slot id
+ intent.putExtra(PhoneConstants.SLOT_KEY, phoneId);
+ }
+
+ /**
+ * @return the list of subId's that are active,
+ * is never null but the length maybe 0.
+ * @hide
+ */
+ public static long[] getActiveSubIdList() {
+ long[] subId = null;
+
+ try {
+ ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ if (iSub != null) {
+ subId = iSub.getActiveSubIdList();
+ }
+ } catch (RemoteException ex) {
+ // ignore it
+ }
+
+ if (subId == null) {
+ subId = new long[0];
+ }
+
+ return subId;
+
}
}
diff --git a/telephony/java/com/android/internal/telephony/IMms.aidl b/telephony/java/com/android/internal/telephony/IMms.aidl
index cbcef25..63b7a53 100644
--- a/telephony/java/com/android/internal/telephony/IMms.aidl
+++ b/telephony/java/com/android/internal/telephony/IMms.aidl
@@ -19,6 +19,7 @@ package com.android.internal.telephony;
import android.app.PendingIntent;
import android.content.ContentValues;
import android.net.Uri;
+import android.os.Bundle;
/**
* Service interface to handle MMS API requests
@@ -29,7 +30,8 @@ interface IMms {
*
* @param subId the SIM id
* @param callingPkg the package name of the calling app
- * @param pdu the MMS message encoded in standard MMS PDU format
+ * @param contentUri the content uri from which to read MMS message encoded in standard MMS
+ * PDU format
* @param locationUrl the optional location url for where this message should be sent to
* @param configOverrides the carrier-specific messaging configuration values to override for
* sending the message. See {@link android.telephony.MessagingConfigurationManager} for the
@@ -37,8 +39,8 @@ interface IMms {
* @param sentIntent if not NULL this <code>PendingIntent</code> is
* broadcast when the message is successfully sent, or failed
*/
- void sendMessage(long subId, String callingPkg, in byte[] pdu, String locationUrl,
- in ContentValues configOverrides, in PendingIntent sentIntent);
+ void sendMessage(long subId, String callingPkg, in Uri contentUri,
+ String locationUrl, in ContentValues configOverrides, in PendingIntent sentIntent);
/**
* Download an MMS message using known location and transaction id
@@ -47,6 +49,7 @@ interface IMms {
* @param callingPkg the package name of the calling app
* @param locationUrl the location URL of the MMS message to be downloaded, usually obtained
* from the MMS WAP push notification
+ * @param contentUri a contentUri to which the downloaded MMS message will be written
* @param configOverrides the carrier-specific messaging configuration values to override for
* downloading the message. See {@link android.telephony.MessagingConfigurationManager} for the
* value names and types.
@@ -54,7 +57,8 @@ interface IMms {
* broadcast when the message is downloaded, or the download is failed
*/
void downloadMessage(long subId, String callingPkg, String locationUrl,
- in ContentValues configOverrides, in PendingIntent downloadedIntent);
+ in Uri contentUri, in ContentValues configOverrides,
+ in PendingIntent downloadedIntent);
/**
* Update the status of a pending (send-by-IP) MMS message handled by the carrier app.
@@ -78,33 +82,11 @@ interface IMms {
void updateMmsDownloadStatus(int messageRef, in byte[] pdu);
/**
- * Get carrier-dependent configuration value as boolean. For example, if multipart SMS
- * is supported.
- *
- * @param subId the SIM id
- * @param name the configuration name
- * @param defaultValue the default value if fail to find the name
- */
- boolean getCarrierConfigBoolean(long subId, String name, boolean defaultValue);
-
- /**
- * Get carrier-dependent configuration value as int. For example, the MMS message size limit.
- *
- * @param subId the SIM id
- * @param name the configuration name
- * @param defaultValue the default value if fail to find the name
- */
- int getCarrierConfigInt(long subId, String name, int defaultValue);
-
- /**
- * Get carrier-dependent configuration value as String. For example, extra HTTP headers for
- * MMS request.
+ * Get carrier-dependent configuration values.
*
* @param subId the SIM id
- * @param name the configuration name
- * @param defaultValue the default value if fail to find the name
*/
- String getCarrierConfigString(long subId, String name, String defaultValue);
+ Bundle getCarrierConfigValues(long subId);
/**
* Import a text message into system's SMS store
@@ -125,14 +107,14 @@ interface IMms {
* Import a multimedia message into system's MMS store
*
* @param callingPkg the package name of the calling app
- * @param pdu the PDU of the message to import
+ * @param contentUri the content uri from which to read PDU of the message to import
* @param messageId the optional message id
* @param timestampSecs the message timestamp in seconds
* @param seen if the message is seen
* @param read if the message is read
* @return the message URI, null if failed
*/
- Uri importMultimediaMessage(String callingPkg, in byte[] pdu, String messageId,
+ Uri importMultimediaMessage(String callingPkg, in Uri contentUri, String messageId,
long timestampSecs, boolean seen, boolean read);
/**
@@ -189,10 +171,10 @@ interface IMms {
* Add a multimedia message draft to system MMS store
*
* @param callingPkg the package name of the calling app
- * @param pdu the PDU data of the draft MMS
+ * @param contentUri the content Uri from which to read PDU data of the draft MMS
* @return the URI of the stored draft message
*/
- Uri addMultimediaMessageDraft(String callingPkg, in byte[] pdu);
+ Uri addMultimediaMessageDraft(String callingPkg, in Uri contentUri);
/**
* Send a system stored MMS message
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
index 6021ccf..46d0660 100755
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -1,18 +1,18 @@
/*
-* Copyright (C) 2011-2014 MediaTek Inc.
-*
-* 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.
-*/
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.android.internal.telephony;
@@ -22,7 +22,6 @@ import android.telephony.SubInfoRecord;
interface ISub {
/**
* Get the SubInfoRecord according to an index
- * @param context Context provided by caller
* @param subId The unique SubInfoRecord index in database
* @return SubInfoRecord, maybe null
*/
@@ -30,7 +29,6 @@ interface ISub {
/**
* Get the SubInfoRecord according to an IccId
- * @param context Context provided by caller
* @param iccId the IccId of SIM card
* @return SubInfoRecord, maybe null
*/
@@ -38,7 +36,6 @@ interface ISub {
/**
* Get the SubInfoRecord according to slotId
- * @param context Context provided by caller
* @param slotId the slot which the SIM is inserted
* @return SubInfoRecord, maybe null
*/
@@ -46,28 +43,30 @@ interface ISub {
/**
* Get all the SubInfoRecord(s) in subinfo database
- * @param context Context provided by caller
* @return Array list of all SubInfoRecords in database, include thsoe that were inserted before
*/
List<SubInfoRecord> getAllSubInfoList();
/**
* Get the SubInfoRecord(s) of the currently inserted SIM(s)
- * @param context Context provided by caller
* @return Array list of currently inserted SubInfoRecord(s)
*/
- List<SubInfoRecord> getActivatedSubInfoList();
+ List<SubInfoRecord> getActiveSubInfoList();
/**
* Get the SUB count of all SUB(s) in subinfo database
- * @param context Context provided by caller
* @return all SIM count in database, include what was inserted before
*/
int getAllSubInfoCount();
/**
+ * Get the count of active SUB(s)
+ * @return active SIM count
+ */
+ int getActiveSubInfoCount();
+
+ /**
* Add a new SubInfoRecord to subinfo database if needed
- * @param context Context provided by caller
* @param iccId the IccId of the SIM card
* @param slotId the slot which the SIM is inserted
* @return the URL of the newly created row or the updated row
@@ -76,7 +75,6 @@ interface ISub {
/**
* Set SIM color by simInfo index
- * @param context Context provided by caller
* @param color the color of the SIM
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
@@ -85,7 +83,6 @@ interface ISub {
/**
* Set display name by simInfo index
- * @param context Context provided by caller
* @param displayName the display name of SIM card
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
@@ -94,7 +91,6 @@ interface ISub {
/**
* Set display name by simInfo index with name source
- * @param context Context provided by caller
* @param displayName the display name of SIM card
* @param subId the unique SubInfoRecord index in database
* @param nameSource, 0: DEFAULT_SOURCE, 1: SIM_SOURCE, 2: USER_INPUT
@@ -104,16 +100,14 @@ interface ISub {
/**
* Set phone number by subId
- * @param context Context provided by caller
* @param number the phone number of the SIM
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
*/
- int setDispalyNumber(String number, long subId);
+ int setDisplayNumber(String number, long subId);
/**
* Set number display format. 0: none, 1: the first four digits, 2: the last four digits
- * @param context Context provided by caller
* @param format the display format of phone number
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
@@ -122,7 +116,6 @@ interface ISub {
/**
* Set data roaming by simInfo index
- * @param context Context provided by caller
* @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming
* @param subId the unique SubInfoRecord index in database
* @return the number of records updated
@@ -150,4 +143,12 @@ interface ISub {
long getDefaultVoiceSubId();
void setDefaultVoiceSubId(long subId);
+
+ long getDefaultSmsSubId();
+
+ void setDefaultSmsSubId(long subId);
+
+ void clearDefaultsForInactiveSubIds();
+
+ long[] getActiveSubIdList();
}
diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java
index b4b1ea5..62b5596 100644
--- a/telephony/java/com/android/internal/telephony/PhoneConstants.java
+++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java
@@ -136,14 +136,6 @@ public class PhoneConstants {
/** APN type for IA Emergency PDN */
public static final String APN_TYPE_EMERGENCY = "emergency";
- // FIXME: This looks to be used as default phoneId, rename
- // or use SubscriptionManager.DEFAULT_SUB_ID
- public static final int DEFAULT_SUBSCRIPTION = 0;
-
- // FIXME: This looks to be used as invalid phoneId, rename
- // or use SubscriptionManager.INVALID_SUB_ID
- public static final int INVALID_SUBSCRIPTION = -1;
-
public static final int RIL_CARD_MAX_APPS = 8;
public static final int DEFAULT_CARD_INDEX = 0;
@@ -154,10 +146,14 @@ public class PhoneConstants {
public static final int MAX_PHONE_COUNT_TRI_SIM = 3;
- public static final String SUBSCRIPTION_KEY = "subscription";
+ public static final String PHONE_KEY = "phone";
public static final String SLOT_KEY = "slot";
+ // FIXME: This is used to pass a subId via intents, we need to look at its usage, which is
+ // FIXME: extensive, and see if this should be an array of all active subId's or ...?
+ public static final String SUBSCRIPTION_KEY = "subscription";
+
public static final String SUB_SETTING = "subSettings";
public static final int SUB1 = 0;
diff --git a/telephony/java/com/android/internal/telephony/TelephonyIntents.java b/telephony/java/com/android/internal/telephony/TelephonyIntents.java
index 85ceefd..e7aca90 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyIntents.java
+++ b/telephony/java/com/android/internal/telephony/TelephonyIntents.java
@@ -391,4 +391,14 @@ public class TelephonyIntents {
*/
public static final String ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED
= "android.intent.action.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED";
+
+ /**
+ * Broadcast Action: The default sms subscription has changed. This has the following
+ * extra values:</p>
+ * <ul>
+ * <li><em>subscription</em> - A int, the current sms default subscription.</li>
+ * </ul>
+ */
+ public static final String ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
+ = "android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED";
}