From 7717acd174795936756226a4bc367fdcb7b49c5d Mon Sep 17 00:00:00 2001 From: Youhan Wang Date: Wed, 11 May 2016 10:24:10 -0700 Subject: [PATCH] Add getEsn(). Bug:27612001 Change-Id: I0cb61cd8a7604e2cc6959b181672fe63a1673447 --- .../android/telephony/TelephonyManager.java | 33 +++++++++++++++++++ .../internal/telephony/ITelephony.aidl | 11 +++++++ 2 files changed, 44 insertions(+) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index b661a22db8ba3..55d0d02e0fc0e 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -5214,4 +5214,37 @@ public class TelephonyManager { return null; } + /** + * Return the Electronic Serial Number. + * + * Requires that the calling app has READ_PRIVILEGED_PHONE_STATE permission + * + * @return ESN or null if error. + * @hide + */ + public String getEsn() { + return getEsn(getDefaultSubscription()); + } + + /** + * Return the Electronic Serial Number. + * + * Requires that the calling app has READ_PRIVILEGED_PHONE_STATE permission + * + * @param subId the subscription ID that this request applies to. + * @return ESN or null if error. + * @hide + */ + public String getEsn(int subId) { + try { + ITelephony service = getITelephony(); + if (service != null) { + return service.getEsn(subId); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#getEsn", e); + } + return null; + } + } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index e72d7227452c5..598b36e09bbbf 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1076,4 +1076,15 @@ interface ITelephony { * @return Application ID for specificied app type or null if no uicc or error. */ String getAidForAppType(int subId, int appType); + + /** + * Return the Electronic Serial Number. + * + * Requires that the calling app has READ_PRIVILEGED_PHONE_STATE permission + * + * @param subId the subscription ID that this request applies to. + * @return ESN or null if error. + * @hide + */ + String getEsn(int subId); }