diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 83b909852d8f3..040e3b2fb82e5 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -6000,6 +6000,7 @@ public class TelephonyManager { * Returns the IMS private user identity (IMPI) that was loaded from the ISIM. * @return the IMPI, or null if not present or not loaded * @hide + * @deprecated use {@link #getImsPrivateUserIdentity()} */ @UnsupportedAppUsage public String getIsimImpi() { @@ -6017,6 +6018,35 @@ public class TelephonyManager { } } + /** + * Returns the IMS private user identity (IMPI) of the subscription that was loaded from the + * ISIM records {@link #APPTYPE_ISIM}. This value is fetched from the Elementary file EF_IMPI. + * The contents of the file is a Ip Multimedia Service Private User Identity of the user + * as defined in the section 4.2.2 of 3GPP TS 131 103. + * + * @return IMPI (IMS private user identity) of type string. + * @throws IllegalStateException in case the ISIM has’t been loaded + * @throws SecurityException if the caller does not have the required permission/privileges + * @hide + */ + @NonNull + @RequiresPermission(android.Manifest.permission.USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER) + @RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION) + public String getImsPrivateUserIdentity() { + try { + IPhoneSubInfo info = getSubscriberInfoService(); + if (info == null) { + Rlog.e(TAG, "getImsPrivateUserIdentity(): IPhoneSubInfo instance is NULL"); + throw new RuntimeException("IMPI error: Subscriber Info is null"); + } + return info.getImsPrivateUserIdentity(getSubId(), getOpPackageName(), + getAttributionTag()); + } catch (RemoteException | NullPointerException | IllegalArgumentException ex) { + Rlog.e(TAG, "getImsPrivateUserIdentity() Exception = " + ex); + throw new RuntimeException(ex.getMessage()); + } + } + /** * Returns the IMS home network domain name that was loaded from the ISIM {@see #APPTYPE_ISIM}. * @return the IMS domain name. Returns {@code null} if ISIM hasn't been loaded or IMS domain diff --git a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl index 3dfc81eafb77c..c8e6225e1d8c4 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl @@ -179,6 +179,19 @@ interface IPhoneSubInfo { */ String getIsimImpi(int subId); + /** + * Fetches the ISIM PrivateUserIdentity (EF_IMPI) based on subId + * + * @param subId subscriptionId + * @return IMPI (IMS private user identity) of type string or null if EF_IMPI is not available. + * @throws IllegalArgumentException if the subscriptionId is not valid + * @throws IllegalStateException in case the ISIM hasn’t been loaded. + * @throws SecurityException if the caller does not have the required permission + */ + @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + + "android.Manifest.permission.USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER)") + String getImsPrivateUserIdentity(int subId, String callingPackage, String callingFeatureId); + /** * Returns the IMS home network domain name that was loaded from the ISIM. * @return the IMS domain name, or null if not present or not loaded