diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index d4f8362f66f41..0eb170c0f1f85 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -616,6 +616,37 @@ public class TelephonyManager { } } + /** + * Returns the IMEI. Return null if IMEI is not available. + * + *
Requires Permission: + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + */ + /** {@hide} */ + public String getImei() { + return getImei(getDefaultSim()); + } + + /** + * Returns the IMEI. Return null if IMEI is not available. + * + *
Requires Permission: + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * + * @param slotId of which deviceID is returned + */ + /** {@hide} */ + public String getImei(int slotId) { + long[] subId = SubscriptionManager.getSubId(slotId); + try { + return getSubscriberInfo().getImeiUsingSubId(subId[0]); + } catch (RemoteException ex) { + return null; + } catch (NullPointerException ex) { + return null; + } + } + /** * Returns the current location of the device. *
diff --git a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl index 4734965b8ee9c..552abafcbc21b 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl @@ -33,6 +33,10 @@ interface IPhoneSubInfo { */ String getDeviceIdUsingSubId(long subId); + /** + * Retrieves the IMEI. + */ + String getImeiUsingSubId(long subId); /** * Retrieves the software version number for the device, e.g., IMEI/SV