From 1b28fdd6ddf1c1d2efa274f8941589c2f7792465 Mon Sep 17 00:00:00 2001 From: Shuo Qian Date: Wed, 13 Nov 2019 17:41:59 -0800 Subject: [PATCH] Introduce APIs for Emergency Number Database version 1) Test API to override file partition for testing 2) System API to notify Telephony Emergency Number database installation complete 3) Remove broadcast mechanism Test: gts Bug: 136027884 Change-Id: Ie2b0c390948c82ccbb94187a6ded9affd162f5ab --- api/system-current.txt | 5 +- api/test-current.txt | 3 + core/res/AndroidManifest.xml | 1 - .../EmergencyNumberDbInstallReceiver.java | 7 +- .../android/telephony/TelephonyManager.java | 83 ++++++++++++++++++- .../internal/telephony/ITelephony.aidl | 15 ++++ 6 files changed, 104 insertions(+), 10 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 412e0959570c1..c5af04483b497 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -8658,6 +8658,7 @@ package android.telephony { method @NonNull public static String getDefaultSimCountryIso(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getDeviceSoftwareVersion(int); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean getEmergencyCallbackMode(); + method public int getEmergencyNumberDbVersion(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimDomain(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimIst(); method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Map getLogicalToPhysicalSlotMapping(); @@ -8697,6 +8698,7 @@ package android.telephony { method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isVideoCallingEnabled(); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean isVisualVoicemailEnabled(android.telecom.PhoneAccountHandle); method public boolean needsOtaServiceProvisioning(); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void notifyOtaEmergencyNumberDbInstalled(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean rebootRadio(); method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.MODIFY_PHONE_STATE}) public void requestCellInfoUpdate(@NonNull android.os.WorkSource, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CellInfoCallback); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void requestNumberVerification(@NonNull android.telephony.PhoneNumberRange, long, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.NumberVerificationCallback); @@ -8725,8 +8727,8 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean switchSlots(int[]); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void toggleRadioOnOff(); method public void updateServiceLocation(); + method @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public void updateTestOtaEmergencyNumberDbFilePath(@NonNull String); field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final String ACTION_ANOMALY_REPORTED = "android.telephony.action.ANOMALY_REPORTED"; - field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final String ACTION_OTA_EMERGENCY_NUMBER_DB_INSTALLED = "android.telephony.action.OTA_EMERGENCY_NUMBER_DB_INSTALLED"; field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED"; field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED"; field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED"; @@ -8739,6 +8741,7 @@ package android.telephony { field public static final String EXTRA_SIM_STATE = "android.telephony.extra.SIM_STATE"; field public static final String EXTRA_VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL = "android.telephony.extra.VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL"; field public static final String EXTRA_VOICEMAIL_SCRAMBLED_PIN_STRING = "android.telephony.extra.VOICEMAIL_SCRAMBLED_PIN_STRING"; + field public static final int INVALID_EMERGENCY_NUMBER_DB_VERSION = -1; // 0xffffffff field public static final int KEY_TYPE_EPDG = 1; // 0x1 field public static final int KEY_TYPE_WLAN = 2; // 0x2 field public static final long NETWORK_TYPE_BITMASK_1xRTT = 64L; // 0x40L diff --git a/api/test-current.txt b/api/test-current.txt index c6b02b9e649b1..da04adcd87343 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3132,16 +3132,19 @@ package android.telephony { method public int getCarrierIdListVersion(); method public java.util.List getCarrierPackageNamesForIntent(android.content.Intent); method @Nullable public static android.content.ComponentName getDefaultRespondViaMessageApplication(@NonNull android.content.Context, boolean); + method public int getEmergencyNumberDbVersion(); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getLine1AlphaTag(); method @NonNull @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public String getNetworkCountryIso(int); method public android.util.Pair getRadioHalVersion(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void refreshUiccProfile(); method @Deprecated public void setCarrierTestOverride(String, String, String, String, String, String, String); method public void setCarrierTestOverride(String, String, String, String, String, String, String, String, String); + method @RequiresPermission("android.permission.READ_ACTIVE_EMERGENCY_SESSION") public void updateTestOtaEmergencyNumberDbFilePath(@NonNull String); field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1 field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0 field public static final int CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED = -1; // 0xffffffff + field public static final int INVALID_EMERGENCY_NUMBER_DB_VERSION = -1; // 0xffffffff field public static final int UNKNOWN_CARRIER_ID_LIST_VERSION = -1; // 0xffffffff } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index e1ca1f6f346c9..d758ceb8b3eab 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -497,7 +497,6 @@ - diff --git a/services/core/java/com/android/server/updates/EmergencyNumberDbInstallReceiver.java b/services/core/java/com/android/server/updates/EmergencyNumberDbInstallReceiver.java index cb0b45ceaf050..c78a8e62cf855 100644 --- a/services/core/java/com/android/server/updates/EmergencyNumberDbInstallReceiver.java +++ b/services/core/java/com/android/server/updates/EmergencyNumberDbInstallReceiver.java @@ -37,9 +37,8 @@ public class EmergencyNumberDbInstallReceiver extends ConfigUpdateInstallReceive Slog.i(TAG, "Emergency number database is updated in file partition"); // Notify EmergencyNumberTracker for emergency number installation complete. - Intent notifyInstallComplete = new Intent( - TelephonyManager.ACTION_OTA_EMERGENCY_NUMBER_DB_INSTALLED); - context.sendBroadcast( - notifyInstallComplete, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); + TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( + Context.TELEPHONY_SERVICE); + telephonyManager.notifyOtaEmergencyNumberDbInstalled(); } } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 64b5aa5539c77..96cd31153e41f 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -11086,14 +11086,66 @@ public class TelephonyManager { } /** - * Broadcast intent action for Ota emergency number database installation complete. + * Indicates Emergency number database version is invalid. * * @hide */ - @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @TestApi @SystemApi - public static final String ACTION_OTA_EMERGENCY_NUMBER_DB_INSTALLED = - "android.telephony.action.OTA_EMERGENCY_NUMBER_DB_INSTALLED"; + public static final int INVALID_EMERGENCY_NUMBER_DB_VERSION = -1; + + /** + * Notify Telephony for OTA emergency number database installation complete. + * + *

Requires permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + @SystemApi + public void notifyOtaEmergencyNumberDbInstalled() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + telephony.notifyOtaEmergencyNumberDbInstalled(); + } else { + throw new IllegalStateException("telephony service is null."); + } + } catch (RemoteException ex) { + Log.e(TAG, "notifyOtaEmergencyNumberDatabaseInstalled RemoteException", ex); + ex.rethrowAsRuntimeException(); + } + } + + /** + * Override the file path for testing OTA emergency number database in a file partition. + * + * @param otaFilePath The test OTA emergency number database file path; + * if "RESET", recover the original database file partition. + * Format: @ + * + *

Requires permission: + * {@link android.Manifest.permission#READ_ACTIVE_EMERGENCY_SESSION} + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) + @SystemApi + @TestApi + public void updateTestOtaEmergencyNumberDbFilePath(@NonNull String otaFilePath) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + telephony.updateTestOtaEmergencyNumberDbFilePath(otaFilePath); + } else { + throw new IllegalStateException("telephony service is null."); + } + } catch (RemoteException ex) { + Log.e(TAG, "notifyOtaEmergencyNumberDatabaseInstalled RemoteException", ex); + ex.rethrowAsRuntimeException(); + } + } /** * Returns whether {@link TelephonyManager#ACTION_EMERGENCY_ASSISTANCE emergency assistance} is @@ -11291,6 +11343,29 @@ public class TelephonyManager { return false; } + /** + * A test API to return the emergency number db version. + * + *

Requires Permission: + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * + * @hide + */ + @TestApi + @SystemApi + public int getEmergencyNumberDbVersion() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.getEmergencyNumberDbVersion(getSubId()); + } + } catch (RemoteException ex) { + Log.e(TAG, "getEmergencyNumberDbVersion RemoteException", ex); + ex.rethrowAsRuntimeException(); + } + return INVALID_EMERGENCY_NUMBER_DB_VERSION; + } + /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = {"SET_OPPORTUNISTIC_SUB"}, value = { diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index e96a0787c9af6..eca290b96336d 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -2047,6 +2047,21 @@ interface ITelephony { */ List getEmergencyNumberListTestMode(); + /** + * A test API to return the emergency number db version. + */ + int getEmergencyNumberDbVersion(int subId); + + /** + * Notify Telephony for OTA emergency number database installation complete. + */ + void notifyOtaEmergencyNumberDbInstalled(); + + /** + * Override the file partition name for testing OTA emergency number database. + */ + void updateTestOtaEmergencyNumberDbFilePath(String otaFilePath); + /** * Enable or disable a logical modem stack associated with the slotIndex. */