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

Commit db6a3919 authored by David Kelly's avatar David Kelly
Browse files

Type Allocation Code & Manufacturer Code



- Addition of getTypeAllocationCode & getManufacturerCode to
android.telephony.TelephonyManager.

- The Type Allocation Code is the first eight characters of the IMEI.
The Type Allocation Code identifies a particular GSM device model.

- The Manufacturer Code is the first eight characters of the MEID.
The Manufacturer Code identifies the manufacturer of a CDMA device.

- The reasoning behind adding getTypeAllocationCode is to be
able to obtain the Type Allocation Code without requiring the
READ_PHONE_STATE permission. Currently in order to obtain the
Type Allocation Code a substring operation must be performed on
getImei which is protected by the READ_PHONE_STATE permission.

- The reasoning behind adding getManufacturerCode is to be
able to obtain the Manufacturer Code without requiring the
READ_PHONE_STATE permission. Currently in order to obtain the
Manufacturer Code a substring operation must be performed on
getMeid which is protected by the READ_PHONE_STATE permission.

- The reasoning that these additional methods do not require the
READ_PHONE_STATE permission is that neither the Type Allocation
Code nor the Manufacturer Code can identify a unique device.
The Type Allocation Code and the Manufacturer Code are analogous
to other device information such as device model or device
screen dimensions.

Test: run cts -m CtsTelephonyTestCases
Bug: 74613795
Change-Id: I5a586b5a362b39aae13357329efb19eb93f0434c
Signed-off-by: default avatarDavid Kelly <dkelly@afilias.info>
parent bc103bdf
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -40832,9 +40832,13 @@ package android.telephony {
    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 getTypeAllocationCode();
    method public java.lang.String getTypeAllocationCode(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 getManufacturerCode();
    method public java.lang.String getManufacturerCode(int);
    method public java.lang.String getMmsUAProfUrl();
    method public java.lang.String getMmsUserAgent();
    method public java.lang.String getNai();
+54 −0
Original line number Diff line number Diff line
@@ -1229,6 +1229,33 @@ public class TelephonyManager {
        }
    }

    /**
     * Returns the Type Allocation Code from the IMEI. Return null if Type Allocation Code is not
     * available.
     */
    public String getTypeAllocationCode() {
        return getTypeAllocationCode(getSlotIndex());
    }

    /**
     * Returns the Type Allocation Code from the IMEI. Return null if Type Allocation Code is not
     * available.
     *
     * @param slotIndex of which Type Allocation Code is returned
     */
    public String getTypeAllocationCode(int slotIndex) {
        ITelephony telephony = getITelephony();
        if (telephony == null) return null;

        try {
            return telephony.getTypeAllocationCodeForSlot(slotIndex);
        } catch (RemoteException ex) {
            return null;
        } catch (NullPointerException ex) {
            return null;
        }
    }

    /**
     * Returns the MEID (Mobile Equipment Identifier). Return null if MEID is not available.
     *
@@ -1264,6 +1291,33 @@ public class TelephonyManager {
        }
    }

    /**
     * Returns the Manufacturer Code from the MEID. Return null if Manufacturer Code is not
     * available.
     */
    public String getManufacturerCode() {
        return getManufacturerCode(getSlotIndex());
    }

    /**
     * Returns the Manufacturer Code from the MEID. Return null if Manufacturer Code is not
     * available.
     *
     * @param slotIndex of which Type Allocation Code is returned
     */
    public String getManufacturerCode(int slotIndex) {
        ITelephony telephony = getITelephony();
        if (telephony == null) return null;

        try {
            return telephony.getManufacturerCodeForSlot(slotIndex);
        } catch (RemoteException ex) {
            return null;
        } catch (NullPointerException ex) {
            return null;
        }
    }

    /**
     * Returns the Network Access Identifier (NAI). Return null if NAI is not available.
     *
+14 −0
Original line number Diff line number Diff line
@@ -1197,6 +1197,13 @@ interface ITelephony {
     */
    String getImeiForSlot(int slotIndex, String callingPackage);

    /**
     * Returns the Type Allocation Code from the IMEI for the given slot.
     *
     * @param slotIndex - Which slot to retrieve the Type Allocation Code from.
     */
    String getTypeAllocationCodeForSlot(int slotIndex);

    /**
     * Returns the MEID for the given slot.
     *
@@ -1207,6 +1214,13 @@ interface ITelephony {
     */
    String getMeidForSlot(int slotIndex, String callingPackage);

    /**
     * Returns the Manufacturer Code from the MEID for the given slot.
     *
     * @param slotIndex - Which slot to retrieve the Manufacturer Code from.
     */
    String getManufacturerCodeForSlot(int slotIndex);

    /**
     * Returns the device software version.
     *