Deprecated getDeviceId and added getMeid and getImei
Added two new public APIs getMeid and getImei. Deprecated the exisintg getDeviceId API because it can't return a constant id when phone type changes. Test: CTS and manual bug: 34233620, 10831289 Change-Id: Iad4c05d2fd2efc538214f466861497c973882dfe
This commit is contained in:
@@ -39946,13 +39946,17 @@ package android.telephony {
|
||||
method public int getDataActivity();
|
||||
method public int getDataNetworkType();
|
||||
method public int getDataState();
|
||||
method public java.lang.String getDeviceId();
|
||||
method public java.lang.String getDeviceId(int);
|
||||
method public deprecated java.lang.String getDeviceId();
|
||||
method public deprecated java.lang.String getDeviceId(int);
|
||||
method public java.lang.String getDeviceSoftwareVersion();
|
||||
method public java.lang.String[] getForbiddenPlmns();
|
||||
method public java.lang.String getGroupIdLevel1();
|
||||
method public java.lang.String getIccAuthentication(int, int, java.lang.String);
|
||||
method public java.lang.String getImei();
|
||||
method public java.lang.String getImei(int);
|
||||
method public java.lang.String getLine1Number();
|
||||
method public java.lang.String getMeid();
|
||||
method public java.lang.String getMeid(int);
|
||||
method public java.lang.String getMmsUAProfUrl();
|
||||
method public java.lang.String getMmsUserAgent();
|
||||
method public deprecated java.util.List<android.telephony.NeighboringCellInfo> getNeighboringCellInfo();
|
||||
|
||||
@@ -43343,8 +43343,8 @@ package android.telephony {
|
||||
method public deprecated boolean getDataEnabled(int);
|
||||
method public int getDataNetworkType();
|
||||
method public int getDataState();
|
||||
method public java.lang.String getDeviceId();
|
||||
method public java.lang.String getDeviceId(int);
|
||||
method public deprecated java.lang.String getDeviceId();
|
||||
method public deprecated java.lang.String getDeviceId(int);
|
||||
method public java.lang.String getDeviceSoftwareVersion();
|
||||
method public java.lang.String[] getForbiddenPlmns();
|
||||
method public java.lang.String getGroupIdLevel1();
|
||||
@@ -43352,6 +43352,8 @@ package android.telephony {
|
||||
method public java.lang.String getImei();
|
||||
method public java.lang.String getImei(int);
|
||||
method public java.lang.String getLine1Number();
|
||||
method public java.lang.String getMeid();
|
||||
method public java.lang.String getMeid(int);
|
||||
method public java.lang.String getMmsUAProfUrl();
|
||||
method public java.lang.String getMmsUserAgent();
|
||||
method public deprecated java.util.List<android.telephony.NeighboringCellInfo> getNeighboringCellInfo();
|
||||
|
||||
@@ -40138,13 +40138,17 @@ package android.telephony {
|
||||
method public int getDataActivity();
|
||||
method public int getDataNetworkType();
|
||||
method public int getDataState();
|
||||
method public java.lang.String getDeviceId();
|
||||
method public java.lang.String getDeviceId(int);
|
||||
method public deprecated java.lang.String getDeviceId();
|
||||
method public deprecated java.lang.String getDeviceId(int);
|
||||
method public java.lang.String getDeviceSoftwareVersion();
|
||||
method public java.lang.String[] getForbiddenPlmns();
|
||||
method public java.lang.String getGroupIdLevel1();
|
||||
method public java.lang.String getIccAuthentication(int, int, java.lang.String);
|
||||
method public java.lang.String getImei();
|
||||
method public java.lang.String getImei(int);
|
||||
method public java.lang.String getLine1Number();
|
||||
method public java.lang.String getMeid();
|
||||
method public java.lang.String getMeid(int);
|
||||
method public java.lang.String getMmsUAProfUrl();
|
||||
method public java.lang.String getMmsUserAgent();
|
||||
method public deprecated java.util.List<android.telephony.NeighboringCellInfo> getNeighboringCellInfo();
|
||||
|
||||
@@ -23,8 +23,8 @@ import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.annotation.SdkConstant.SdkConstantType;
|
||||
import android.annotation.WorkerThread;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.WorkerThread;
|
||||
import android.app.ActivityThread;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ContentResolver;
|
||||
@@ -50,6 +50,7 @@ import android.util.Log;
|
||||
|
||||
import com.android.ims.internal.IImsServiceController;
|
||||
import com.android.ims.internal.IImsServiceFeatureListener;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.telecom.ITelecomService;
|
||||
import com.android.internal.telephony.CellNetworkScanResult;
|
||||
import com.android.internal.telephony.IPhoneSubInfo;
|
||||
@@ -940,7 +941,11 @@ public class TelephonyManager {
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||
*
|
||||
* @deprecated Use (@link getImei} which returns IMEI for GSM or (@link getMeid} which returns
|
||||
* MEID for CDMA.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getDeviceId() {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
@@ -962,7 +967,11 @@ public class TelephonyManager {
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||
*
|
||||
* @param slotIndex of which deviceID is returned
|
||||
*
|
||||
* @deprecated Use (@link getImei} which returns IMEI for GSM or (@link getMeid} which returns
|
||||
* MEID for CDMA.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getDeviceId(int slotIndex) {
|
||||
// FIXME this assumes phoneId == slotIndex
|
||||
try {
|
||||
@@ -978,29 +987,25 @@ public class TelephonyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the IMEI. Return null if IMEI is not available.
|
||||
* Returns the IMEI (International Mobile Equipment Identity). Return null if IMEI is not
|
||||
* available.
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public String getImei() {
|
||||
return getImei(getDefaultSim());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the IMEI. Return null if IMEI is not available.
|
||||
* Returns the IMEI (International Mobile Equipment Identity). Return null if IMEI is not
|
||||
* available.
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||
*
|
||||
* @param slotIndex of which deviceID is returned
|
||||
*
|
||||
* @hide
|
||||
* @param slotIndex of which IMEI is returned
|
||||
*/
|
||||
@SystemApi
|
||||
public String getImei(int slotIndex) {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony == null) return null;
|
||||
@@ -1014,6 +1019,37 @@ public class TelephonyManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MEID (Mobile Equipment Identifier). Return null if MEID is not available.
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||
*/
|
||||
public String getMeid() {
|
||||
return getMeid(getDefaultSim());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MEID (Mobile Equipment Identifier). Return null if MEID is not available.
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||
*
|
||||
* @param slotIndex of which MEID is returned
|
||||
*/
|
||||
public String getMeid(int slotIndex) {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony == null) return null;
|
||||
|
||||
try {
|
||||
return telephony.getMeidForSlot(slotIndex, getOpPackageName());
|
||||
} catch (RemoteException ex) {
|
||||
return null;
|
||||
} catch (NullPointerException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the NAI. Return null if NAI is not available.
|
||||
*
|
||||
@@ -4056,9 +4092,19 @@ public class TelephonyManager {
|
||||
return SubscriptionManager.getPhoneId(SubscriptionManager.getDefaultSubscriptionId());
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
/**
|
||||
* @return default SIM's slot index. If SIM is not inserted, return default SIM slot index.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public int getDefaultSim() {
|
||||
return SubscriptionManager.getSlotIndex(SubscriptionManager.getDefaultSubscriptionId());
|
||||
int slotIndex = SubscriptionManager.getSlotIndex(
|
||||
SubscriptionManager.getDefaultSubscriptionId());
|
||||
if (slotIndex == SubscriptionManager.SIM_NOT_INSERTED) {
|
||||
slotIndex = SubscriptionManager.DEFAULT_SIM_SLOT_INDEX;
|
||||
}
|
||||
return slotIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1095,6 +1095,16 @@ interface ITelephony {
|
||||
*/
|
||||
String getImeiForSlot(int slotIndex, String callingPackage);
|
||||
|
||||
/**
|
||||
* Returns the MEID for the given slot.
|
||||
*
|
||||
* @param slotIndex - device slot.
|
||||
* @param callingPackage The package making the call.
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||
*/
|
||||
String getMeidForSlot(int slotIndex, String callingPackage);
|
||||
|
||||
/**
|
||||
* Returns the device software version.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user