From db6a391957f51c6ed9a768f0c39c61ff7a4f3603 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Mon, 12 Mar 2018 14:17:24 +0000 Subject: [PATCH] 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: David Kelly --- api/current.txt | 4 ++ .../android/telephony/TelephonyManager.java | 54 +++++++++++++++++++ .../internal/telephony/ITelephony.aidl | 14 +++++ 3 files changed, 72 insertions(+) diff --git a/api/current.txt b/api/current.txt index 1ae46d5d8a0eb..9ffd50f27c12d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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(); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index e0b465d26a4ad..3bc7341216e72 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -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. * diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 3fd1d04c465ac..70354b212f25e 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -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. *