Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 284f1ec1 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Adding APIs to get IMEI/MEID

Change-Id: I553b7c019b20a64ff1049f35b0e3999ab82b7cce
parent d504ab14
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -616,6 +616,37 @@ public class TelephonyManager {
        }
    }

    /**
     * Returns the IMEI. Return null if IMEI is not available.
     *
     * <p>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.
     *
     * <p>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.
     *<p>
+4 −0
Original line number Diff line number Diff line
@@ -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