Add an Indication for Barring Info

Add an indication and request+response to get updated
barring information for the current cell.

Bug: 143231559
Bug: 143226991
Test: compilation && atest VtsHalRadioV1_5TargetTest
Change-Id: I226cf66dd6b9b71a6c020cdd618fe5e2af0baa20
diff --git a/current.txt b/current.txt
index 90a5130..331a87d 100644
--- a/current.txt
+++ b/current.txt
@@ -631,10 +631,10 @@
 ##
 # BEGIN Radio HAL Merge Conflict Avoidance Buffer - STOPSHIP if present
 ##
-2c0587a1e83facba604949c31163486f21eb5b47a29c8f29119a47d3bd052103 android.hardware.radio@1.5::types
-b5cfa87882b416105fe01e8a40a856d36c93d64f1103d77e12b1281cea13b0bd android.hardware.radio@1.5::IRadio
-bc59237dbd93949238081f762710552e76670cb648c0e198138551460ac54b1e android.hardware.radio@1.5::IRadioIndication
-ef10e15cdbe8ba63925302a95962d5679bbda6a4351400cc23e1589ca0e9f94b android.hardware.radio@1.5::IRadioResponse
+73b5418353fe52721267d64592d4d4c1b77fbd1ef4261d964865de88e62ee0be android.hardware.radio@1.5::types
+996f98ffe508a2f6f1755c1511b50067f7883f7c445dea9f3e931385f020b7ab android.hardware.radio@1.5::IRadio
+20d52e66fd548f89bcb98cda42749a591ce8f439a2a7148617adac0c967ad937 android.hardware.radio@1.5::IRadioIndication
+1512f6e1198e1aa0ebcbdb1694d0ed500a3e7791d6f305327866112331d82b66 android.hardware.radio@1.5::IRadioResponse
 55f0a15642869ec98a55ea0a5ac049d3e1a6245ff7750deb6bcb7182057eee83 android.hardware.radio.config@1.3::types
 b27ab0cd40b0b078cdcd024bfe1061c4c4c065f3519eeb9347fa359a3268a5ae android.hardware.radio.config@1.3::IRadioConfig
 742360c775313438b0f82256eac62fb5bbc76a6ae6f388573f3aa142fb2c1eea android.hardware.radio.config@1.3::IRadioConfigIndication
diff --git a/radio/1.5/IRadio.hal b/radio/1.5/IRadio.hal
index d0c5b0d..e41989c 100644
--- a/radio/1.5/IRadio.hal
+++ b/radio/1.5/IRadio.hal
@@ -20,6 +20,7 @@
 import @1.4::IRadio;
 import @1.4::DataProfileInfo;
 import @1.5::AccessNetwork;
+import @1.5::BarringInfo;
 import @1.5::DataProfileInfo;
 import @1.5::IndicationFilter;
 import @1.5::LinkAddress;
@@ -235,4 +236,13 @@
      * Response callback is IRadioResponse.setIndicationFilterResponse()
      */
     oneway setIndicationFilter_1_5(int32_t serial, bitfield<IndicationFilter> indicationFilter);
+
+    /**
+     * Get all the barring info for the current camped cell applicable to the current user.
+     *
+     * @param serial Serial number of request.
+     *
+     * Response callback is IRadioResponse.getBarringInfoResponse()
+     */
+    oneway getBarringInfo(int32_t serial);
 };
diff --git a/radio/1.5/IRadioIndication.hal b/radio/1.5/IRadioIndication.hal
index 879e9ad..cafecbc 100644
--- a/radio/1.5/IRadioIndication.hal
+++ b/radio/1.5/IRadioIndication.hal
@@ -59,4 +59,21 @@
     oneway registrationFailed(
             RadioIndicationType type, CellIdentity cellIdentity, string chosenPlmn,
             bitfield<Domain> domain, int32_t causeCode, int32_t additionalCauseCode);
+
+    /**
+     * Indicate barring information for the user’s access category / access class and PLMN.
+     *
+     * <p>Provide information about the barring status of the cell for the user. The information
+     * provided should describe all barring configurations that are applicable to the current user,
+     * even if the user is not currently barred (due to conditional barring). This informs Android
+     * of likely future (statistical) barring for specific services.
+     *
+     * <p>This indication should be sent whenever the cell’s barring config changes for the current
+     * user, or if the user’s conditional barring status changes due to re-evaluation of the
+     * barring conditions. Barring status will likely change when the device camps for service,
+     * when PLMN selection is completed, when the device attempts to access a conditionally barred
+     * service, and when the System Information including barring info for a camped cell is updated.
+     */
+    oneway barringInfoChanged(
+            RadioIndicationType type, CellIdentity cellIdentity, vec<BarringInfo> barringInfos);
 };
diff --git a/radio/1.5/IRadioResponse.hal b/radio/1.5/IRadioResponse.hal
index f1b7e71..2ed789a 100644
--- a/radio/1.5/IRadioResponse.hal
+++ b/radio/1.5/IRadioResponse.hal
@@ -18,6 +18,7 @@
 
 import @1.0::RadioResponseInfo;
 import @1.4::IRadioResponse;
+import @1.5::BarringInfo;
 import @1.5::SetupDataCallResult;
 
 /**
@@ -157,4 +158,16 @@
      *   RadioError:SYSTEM_ERR
      */
     oneway setIndicationFilterResponse_1_5(RadioResponseInfo info);
+
+    /**
+     * @param info Response info struct containing response type, serial no. and error
+     * @param barringInfos a vector of barring info for all barring service types
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:MODEM_ERR
+     */
+    oneway getBarringInfoResponse(RadioResponseInfo info, vec<BarringInfo> barringInfos);
 };
diff --git a/radio/1.5/types.hal b/radio/1.5/types.hal
index 12c27d0..724d014 100644
--- a/radio/1.5/types.hal
+++ b/radio/1.5/types.hal
@@ -426,7 +426,130 @@
     CellIdentityNr nr;
 };
 
+/**
+ * Combined list of barring services for UTRAN, EUTRAN, and NGRAN.
+ *
+ * Barring information is defined in:
+ * -UTRAN - 3gpp 25.331 Sec 10.2.48.8.6.
+ * -EUTRAN - 3gpp 36.331 Sec 6.3.1 SystemInformationBlockType2
+ * -NGRAN - 3gpp 38.331 Sec 6.3.2 UAC-BarringInfo and 22.261 Sec 6.22.2.[2-3]
+ */
+enum BarringServiceType : int32_t {
+    /** Applicabe to UTRAN */
+    /** Barring for all CS services, including registration */
+    CS_SERVICE,
+    /** Barring for all PS services, including registration */
+    PS_SERVICE,
+    /** Barring for mobile-originated circuit-switched voice calls */
+    CS_VOICE,
+
+    /** Applicable to EUTRAN, NGRAN */
+    /** Barring for mobile-originated signalling for any purpose */
+    MO_SIGNALLING,
+    /** Barring for mobile-originated internet or other interactive data */
+    MO_DATA,
+    /** Barring for circuit-switched fallback calling */
+    CS_FALLBACK,
+    /** Barring for IMS voice calling */
+    MMTEL_VOICE,
+    /** Barring for IMS video calling */
+    MMTEL_VIDEO,
+
+    /** Applicable to UTRAN, EUTRAN, NGRAN */
+    /** Barring for emergency services, either CS or emergency MMTEL */
+    EMERGENCY,
+    /** Barring for short message services */
+    SMS,
+
+    /** Operator-specific barring codes; applicable to NGRAN */
+    OPERATOR_1 = 1001,
+    OPERATOR_2 = 1002,
+    OPERATOR_3 = 1003,
+    OPERATOR_4 = 1004,
+    OPERATOR_5 = 1005,
+    OPERATOR_6 = 1006,
+    OPERATOR_7 = 1007,
+    OPERATOR_8 = 1008,
+    OPERATOR_9 = 1009,
+    OPERATOR_10 = 1010,
+    OPERATOR_11 = 1011,
+    OPERATOR_12 = 1012,
+    OPERATOR_13 = 1013,
+    OPERATOR_14 = 1014,
+    OPERATOR_15 = 1015,
+    OPERATOR_16 = 1016,
+    OPERATOR_17 = 1017,
+    OPERATOR_18 = 1018,
+    OPERATOR_19 = 1019,
+    OPERATOR_20 = 1020,
+    OPERATOR_21 = 1021,
+    OPERATOR_22 = 1022,
+    OPERATOR_23 = 1023,
+    OPERATOR_24 = 1024,
+    OPERATOR_25 = 1025,
+    OPERATOR_26 = 1026,
+    OPERATOR_27 = 1027,
+    OPERATOR_28 = 1028,
+    OPERATOR_29 = 1029,
+    OPERATOR_30 = 1030,
+    OPERATOR_31 = 1031,
+    OPERATOR_32 = 1032,
+};
+
+enum BarringType : int32_t {
+    /** Device is not barred for the given service */
+    NONE,
+    /** Device may be barred based on time and probability factors */
+    CONDITIONAL,
+    /* Device is unconditionally barred */
+    UNCONDITIONAL,
+};
+
+struct ConditionalBarringInfo {
+    /** The barring factor as a percentage 0-100 */
+    int32_t barringFactor;
+
+    /** The number of seconds between re-evaluations of barring */
+    int32_t barringTimeSeconds;
+
+    /**
+     * Indicates whether barring is currently being applied.
+     *
+     * <p>True if the UE applies barring to a conditionally barred
+     * service based on the conditional barring parameters.
+     *
+     * <p>False if the service is conditionally barred but barring
+     * is not currently applied, which could be due to either the
+     * barring criteria not having been evaluated (if the UE has not
+     * attempted to use the service) or due to the criteria being
+     * evaluated and the UE being permitted to use the service
+     * despite conditional barring.
+     */
+    bool isBarred;
+};
+
+safe_union BarringTypeSpecificInfo {
+    /** Barring type is either none or unconditional */
+    Monostate noinit;
+
+    /** Must be included if barring is conditional */
+    ConditionalBarringInfo conditionalBarringInfo;
+};
+
+struct BarringInfo {
+    /** Barring service */
+    BarringServiceType service;
+
+    /** The type of barring applied to the service */
+    BarringType type;
+
+    /** Type-specific barring info if applicable */
+    BarringTypeSpecificInfo typeSpecificInfo;
+};
+
 enum IndicationFilter : @1.2::IndicationFilter {
     /** Control the unsolicited sending of registration failure reports via onRegistrationFailed */
     REGISTRATION_FAILURE = 1 << 5,
+    /** Control the unsolicited sending of barring info updates via onBarringInfo */
+    BARRING_INFO = 1 << 6,
 };
diff --git a/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h b/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h
index c3c9f54..217caf5 100644
--- a/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h
+++ b/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h
@@ -553,6 +553,11 @@
     Return<void> setRadioPowerResponse_1_5(const RadioResponseInfo& info);
 
     Return<void> setIndicationFilterResponse_1_5(const RadioResponseInfo& info);
+
+    Return<void> getBarringInfoResponse(
+            const RadioResponseInfo& info,
+            const ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::BarringInfo>&
+                    barringInfos);
 };
 
 /* Callback class for radio indication */
@@ -748,6 +753,12 @@
             const ::android::hardware::hidl_string& chosenPlmn,
             ::android::hardware::hidl_bitfield<::android::hardware::radio::V1_5::Domain> domain,
             int32_t causeCode, int32_t additionalCauseCode);
+
+    Return<void> barringInfoChanged(
+            RadioIndicationType /*type*/,
+            const ::android::hardware::radio::V1_5::CellIdentity& /*cellIdentity*/,
+            const ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::BarringInfo>&
+            /*barringInfos*/);
 };
 
 // Test environment for Radio HIDL HAL.
diff --git a/radio/1.5/vts/functional/radio_indication.cpp b/radio/1.5/vts/functional/radio_indication.cpp
index 2416605..1483907 100644
--- a/radio/1.5/vts/functional/radio_indication.cpp
+++ b/radio/1.5/vts/functional/radio_indication.cpp
@@ -342,3 +342,11 @@
         int32_t /*causeCode*/, int32_t /*additionalCauseCode*/) {
     return Void();
 }
+
+Return<void> RadioIndication_v1_5::barringInfoChanged(
+        RadioIndicationType /*type*/,
+        const ::android::hardware::radio::V1_5::CellIdentity& /*cellIdentity*/,
+        const ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::BarringInfo>&
+        /*barringInfos*/) {
+    return Void();
+}
diff --git a/radio/1.5/vts/functional/radio_response.cpp b/radio/1.5/vts/functional/radio_response.cpp
index 877945f..644a262 100644
--- a/radio/1.5/vts/functional/radio_response.cpp
+++ b/radio/1.5/vts/functional/radio_response.cpp
@@ -960,3 +960,12 @@
     parent_v1_5.notify(info.serial);
     return Void();
 }
+
+Return<void> RadioResponse_v1_5::getBarringInfoResponse(
+        const RadioResponseInfo& info,
+        const ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::BarringInfo>&
+        /*barringInfos*/) {
+    rspInfo = info;
+    parent_v1_5.notify(info.serial);
+    return Void();
+}