From a4c9bc800303ac6e605dbcb228b9798c8fee9699 Mon Sep 17 00:00:00 2001 From: jimsun Date: Tue, 13 Sep 2022 18:24:41 +0800 Subject: [PATCH] Create module-specific Hal versions Bug: 243072871 Test: cts test Change-Id: Ib4bd4e42677b6d506a509a0097b86dd4a9acb012 --- core/api/test-current.txt | 12 +- core/api/test-lint-baseline.txt | 4 + .../android/telephony/TelephonyManager.java | 121 +++++++++++++++++- .../internal/telephony/ITelephony.aidl | 6 + 4 files changed, 137 insertions(+), 6 deletions(-) diff --git a/core/api/test-current.txt b/core/api/test-current.txt index d8419a87edc2a..30dd3b64acdac 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -2622,13 +2622,23 @@ package android.telephony { method public int getCarrierIdListVersion(); method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List getCertsFromCarrierPrivilegeAccessRules(); method @NonNull public java.util.List getDevicePolicyOverrideApns(@NonNull android.content.Context); + method @NonNull public android.util.Pair getHalVersion(int); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getLine1AlphaTag(); - method public android.util.Pair getRadioHalVersion(); + method @Deprecated public android.util.Pair getRadioHalVersion(); method public boolean modifyDevicePolicyOverrideApn(@NonNull android.content.Context, int, @NonNull android.telephony.data.ApnSetting); 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.Manifest.permission.BIND_TELECOM_CONNECTION_SERVICE) public void setVoiceServiceStateOverride(boolean); + field public static final int HAL_SERVICE_DATA = 1; // 0x1 + field public static final int HAL_SERVICE_IMS = 7; // 0x7 + field public static final int HAL_SERVICE_MESSAGING = 2; // 0x2 + field public static final int HAL_SERVICE_MODEM = 3; // 0x3 + field public static final int HAL_SERVICE_NETWORK = 4; // 0x4 + field public static final int HAL_SERVICE_SIM = 5; // 0x5 + field public static final int HAL_SERVICE_VOICE = 6; // 0x6 + field public static final android.util.Pair HAL_VERSION_UNKNOWN; + field public static final android.util.Pair HAL_VERSION_UNSUPPORTED; field public static final int UNKNOWN_CARRIER_ID_LIST_VERSION = -1; // 0xffffffff } diff --git a/core/api/test-lint-baseline.txt b/core/api/test-lint-baseline.txt index f9b8a30068801..8e21d8c2cb56c 100644 --- a/core/api/test-lint-baseline.txt +++ b/core/api/test-lint-baseline.txt @@ -567,6 +567,10 @@ MissingNullability: android.telephony.SmsManager#checkSmsShortCodeDestination(St Missing nullability on parameter `destAddress` in method `checkSmsShortCodeDestination` MissingNullability: android.telephony.SmsManager#checkSmsShortCodeDestination(String, String) parameter #1: Missing nullability on parameter `countryIso` in method `checkSmsShortCodeDestination` +MissingNullability: android.telephony.TelephonyManager#HAL_VERSION_UNKNOWN: + Missing nullability on field `HAL_VERSION_UNKNOWN` in class `class android.telephony.TelephonyManager` +MissingNullability: android.telephony.TelephonyManager#HAL_VERSION_UNSUPPORTED: + Missing nullability on field `HAL_VERSION_UNSUPPORTED` in class `class android.telephony.TelephonyManager` MissingNullability: android.telephony.TelephonyManager#getLine1AlphaTag(): Missing nullability on method `getLine1AlphaTag` return MissingNullability: android.telephony.TelephonyManager#getRadioHalVersion(): diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index d473c6ab794ac..541573cad3ece 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -14957,21 +14957,132 @@ public class TelephonyManager { * @return a Pair of (major version, minor version) or (-1,-1) if unknown. * * @hide + * + * @deprecated Use {@link #getHalVersion} instead. */ + @Deprecated @UnsupportedAppUsage @TestApi public Pair getRadioHalVersion() { + return getHalVersion(HAL_SERVICE_RADIO); + } + + /** @hide */ + public static final int HAL_SERVICE_RADIO = 0; + + /** + * HAL service type that supports the HAL APIs implementation of IRadioData + * {@link RadioDataProxy} + * @hide + */ + @TestApi + public static final int HAL_SERVICE_DATA = 1; + + /** + * HAL service type that supports the HAL APIs implementation of IRadioMessaging + * {@link RadioMessagingProxy} + * @hide + */ + @TestApi + public static final int HAL_SERVICE_MESSAGING = 2; + + /** + * HAL service type that supports the HAL APIs implementation of IRadioModem + * {@link RadioModemProxy} + * @hide + */ + @TestApi + public static final int HAL_SERVICE_MODEM = 3; + + /** + * HAL service type that supports the HAL APIs implementation of IRadioNetwork + * {@link RadioNetworkProxy} + * @hide + */ + @TestApi + public static final int HAL_SERVICE_NETWORK = 4; + + /** + * HAL service type that supports the HAL APIs implementation of IRadioSim + * {@link RadioSimProxy} + * @hide + */ + @TestApi + public static final int HAL_SERVICE_SIM = 5; + + /** + * HAL service type that supports the HAL APIs implementation of IRadioVoice + * {@link RadioVoiceProxy} + * @hide + */ + @TestApi + public static final int HAL_SERVICE_VOICE = 6; + + /** + * HAL service type that supports the HAL APIs implementation of IRadioIms + * {@link RadioImsProxy} + * @hide + */ + @TestApi + public static final int HAL_SERVICE_IMS = 7; + + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"HAL_SERVICE_"}, + value = { + HAL_SERVICE_RADIO, + HAL_SERVICE_DATA, + HAL_SERVICE_MESSAGING, + HAL_SERVICE_MODEM, + HAL_SERVICE_NETWORK, + HAL_SERVICE_SIM, + HAL_SERVICE_VOICE, + HAL_SERVICE_IMS, + }) + public @interface HalService {} + + /** + * The HAL Version indicating that the version is unknown or invalid. + * @hide + */ + @TestApi + public static final Pair HAL_VERSION_UNKNOWN = new Pair(-1, -1); + + /** + * The HAL Version indicating that the version is unsupported. + * @hide + */ + @TestApi + public static final Pair HAL_VERSION_UNSUPPORTED = new Pair(-2, -2); + + /** + * Retrieve the HAL Version of a specific service for this device. + * + * Get the HAL version for a specific HAL interface for test purposes. + * + * @param halService the service id to query. + * @return a Pair of (major version, minor version), HAL_VERSION_UNKNOWN if unknown + * or HAL_VERSION_UNSUPPORTED if unsupported. + * + * @hide + */ + @TestApi + public @NonNull Pair getHalVersion(@HalService int halService) { try { ITelephony service = getITelephony(); if (service != null) { - int version = service.getRadioHalVersion(); - if (version == -1) return new Pair(-1, -1); - return new Pair(version / 100, version % 100); + int version = service.getHalVersion(halService); + if (version != -1) { + return new Pair(version / 100, version % 100); + } + } else { + throw new IllegalStateException("telephony service is null."); } } catch (RemoteException e) { - Log.e(TAG, "getRadioHalVersion() RemoteException", e); + Log.e(TAG, "getHalVersion() RemoteException", e); + e.rethrowAsRuntimeException(); } - return new Pair(-1, -1); + return HAL_VERSION_UNKNOWN; } /** diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 648866b6662da..abf4cde623231 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -2158,6 +2158,12 @@ interface ITelephony { */ int getRadioHalVersion(); + /** + * Get the HAL Version of a specific service + * encoded as 100 * MAJOR_VERSION + MINOR_VERSION or -1 if unknown + */ + int getHalVersion(int service); + /** * Get the current calling package name. */