From 217a388aefecb0541346fa64f67e91c7e24fe2a5 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 Merged-In: Ie2b0c390948c82ccbb94187a6ded9affd162f5ab (cherry picked from commit 1b28fdd6ddf1c1d2efa274f8941589c2f7792465) --- 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 ac8581a835119..473cb17566dfe 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -8595,6 +8595,7 @@ package android.telephony { method @Nullable public static android.content.ComponentName getDefaultRespondViaMessageApplication(@NonNull android.content.Context, boolean); 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(); @@ -8632,6 +8633,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); @@ -8659,8 +8661,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"; @@ -8673,6 +8675,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 b1b1a15ec8eed..1a289a4aa46e8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3019,16 +3019,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 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 216b87f89b90e..0fe3d901bb1d7 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -499,7 +499,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 e99465d587648..435a9f7af9529 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -10909,14 +10909,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 @@ -11113,6 +11165,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 2f18049e7e714..eedfc6a53e096 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1990,6 +1990,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. */