Merge "Update automotive makefile."
diff --git a/current.txt b/current.txt
index 3c147cb..937e7b1 100644
--- a/current.txt
+++ b/current.txt
@@ -449,7 +449,7 @@
 92714960d1a53fc2ec557302b41c7cc93d2636d8364a44bd0f85be0c92927ff8 android.hardware.neuralnetworks@1.2::IExecutionCallback
 83885d366f22ada42c00d8854f0b7e7ba4cf73ddf80bb0d8e168ce132cec57ea android.hardware.neuralnetworks@1.2::IPreparedModel
 e1c734d1545e1a4ae749ff1dd9704a8e594c59aea7c8363159dc258e93e0df3b android.hardware.neuralnetworks@1.2::IPreparedModelCallback
-769f8650631eef7a3ceedc8cf130f4b99eb52fe698a11609d55de32985a3dddf android.hardware.neuralnetworks@1.2::types
+c752cff336d86762c26dc82e7e037f4962b815b1a068d2319d40a3d068e26f68 android.hardware.neuralnetworks@1.2::types
 cf7a4ba516a638f9b82a249c91fb603042c2d9ca43fd5aad9cf6c0401ed2a5d7 android.hardware.nfc@1.2::INfc
 abf98c2ae08bf765db54edc8068e36d52eb558cff6706b6fd7c18c65a1f3fc18 android.hardware.nfc@1.2::types
 4cb252dc6372a874aef666b92a6e9529915aa187521a700f0789065c3c702ead android.hardware.power.stats@1.0::IPowerStats
diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal
index ab17598..4a8664f 100644
--- a/neuralnetworks/1.2/types.hal
+++ b/neuralnetworks/1.2/types.hal
@@ -218,6 +218,7 @@
      *         ) / sum(1)
      *
      * Supported tensor {@link OperandType}:
+     * * {@link OperandType::TENSOR_FLOAT16} (since API level 29)
      * * {@link OperandType::TENSOR_FLOAT32}
      * * {@link OperandType::TENSOR_QUANT8_ASYMM}
      *
@@ -333,7 +334,7 @@
      *         ) + bias[channel]
      *
      * Supported tensor {@link OperandType} configurations:
-     * * 32 bit Floating point :
+     * * 32 bit floating point:
      * * * {@link OperandType::TENSOR_FLOAT32} for input, filter, output, and bias.
      *
      * * Quantized:
@@ -342,15 +343,15 @@
      * * * input.scale * filter.scale).
      *
      * Available since API level 29:
+     * * 16 bit floating point:
+     * * * {@link OperandType::TENSOR_FLOAT16} for input, filter, output, and bias.
+     *
      * * Quantized with symmetric per channel quantization for the filter:
      * * * {@link OperandType::TENSOR_QUANT8_ASYMM} for input, and output.
      * * * {@link OperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter.
      * * * {@link OperandType::TENSOR_INT32} for bias (scale set to 0.0,
      * * * each value scaling is separate and equal to input.scale * filter.scales[channel]).
      *
-     * * 16 bit Floating point:
-     * * {@link OperandType::TENSOR_FLOAT16} for input, filter, output, and bias.
-     *
      * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout.
      * With the default data layout NHWC, the data is stored in the order of:
      * [batch, height, width, channels]. Alternatively, the data layout could
@@ -482,7 +483,7 @@
      *         ) + bias[k * channel_multiplier + q]
      *
      * Supported tensor {@link OperandType} configurations:
-     * * 32 bit Floating point :
+     * * 32 bit floating point:
      * * * {@link OperandType::TENSOR_FLOAT32} for input, filter, output, and bias.
      *
      * * Quantized:
@@ -491,6 +492,9 @@
      * * * input.scale * filter.scale).
      *
      * Available since API level 29:
+     * * 16 bit floating point:
+     * * * {@link OperandType::TENSOR_FLOAT16} for input, filter, output, and bias.
+     *
      * * Quantized with symmetric per channel quantization for the filter:
      * * * {@link OperandType::TENSOR_QUANT8_ASYMM} for input, and output.
      * * * {@link OperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter.
@@ -1010,6 +1014,7 @@
      *     output = 1 / (1 + exp(-input))
      *
      * Supported tensor {@link OperandType}:
+     * * {@link OperandType::TENSOR_FLOAT16} (since API level 29)
      * * {@link OperandType::TENSOR_FLOAT32}
      * * {@link OperandType::TENSOR_QUANT8_ASYMM}
      *
@@ -1315,6 +1320,7 @@
      *         )
      *
      * Supported tensor {@link OperandType}:
+     * * {@link OperandType::TENSOR_FLOAT16} (since API level 29)
      * * {@link OperandType::TENSOR_FLOAT32}
      * * {@link OperandType::TENSOR_QUANT8_ASYMM}
      *
@@ -1623,6 +1629,7 @@
      * independently on each 1-D slice along specified dimension.
      *
      * Supported tensor {@link OperandType}:
+     * * {@link OperandType::TENSOR_FLOAT16} (since API level 29)
      * * {@link OperandType::TENSOR_FLOAT32}
      * * {@link OperandType::TENSOR_QUANT8_ASYMM}
      *
@@ -1631,8 +1638,12 @@
      *
      * Inputs:
      * * 0: A 2-D or 4-D tensor, specifying the tensor to be reshaped.
-     * * 1: An {@link OperandType::FLOAT32} scalar, specifying the positive
-     *      scaling factor for the exponent, beta.
+     * * 1: A scalar, specifying the positive scaling factor for the exponent,
+     *      beta. If input0 is of {@link OperandType::TENSOR_FLOAT32} or
+     *      {@link OperandType::TENSOR_QUANT8_ASYMM}, the scalar must be of
+     *      {@link OperandType::FLOAT32}. If input0 is of {@link
+     *      OperandType::TENSOR_FLOAT16}, then the scalar must be of {@link
+     *      OperandType::FLOAT16}.
      * * 2: An optional {@link OperandType::INT32} scalar, default to -1,
      *      specifying the dimension the activation would be performed on.
      *      Negative index is used to specify axis from the end (e.g. -1 for
@@ -2706,11 +2717,17 @@
      * * 10: An {@link OperandType::INT32} scalar, only used when input7 is
      *       set to true, specifying the maximum number of detections when
      *       applying NMS algorithm for each single class.
-     * * 11: An {@link OperandType::FLOAT32} scalar, score_threshold. Boxes
-     *       with scores lower than the threshold are filtered before sending
-     *       to the NMS algorithm.
-     * * 12: An {@link OperandType::FLOAT32} scalar, specifying the IoU
-     *       threshold for hard NMS.
+     * * 11: A scalar, score_threshold. Boxes with scores lower than the
+     *       threshold are filtered before sending to the NMS algorithm. The
+     *       scalar must be of {@link OperandType::FLOAT16} if input0 is of
+     *       {@link OperandType::TENSOR_FLOAT16} and of {@link
+     *       OperandType::FLOAT32} if input0 is of {@link
+     *       OperandType::TENSOR_FLOAT32}.
+     * * 12: A scalar, specifying the IoU threshold for hard NMS. The scalar
+     *       must be of {@link OperandType::FLOAT16} if input0 is of {@link
+     *       OperandType::TENSOR_FLOAT16} and of {@link
+     *       OperandType::FLOAT32} if input0 is of {@link
+     *       OperandType::TENSOR_FLOAT32}.
      * * 13: An {@link OperandType::BOOL} scalar, set to true to include
      *       background class in the list of label map for the output, set
      *       to false to not include the background. When the background
@@ -3007,11 +3024,11 @@
      * where channel_multiplier = depth_out / num_groups
      *
      * Supported tensor {@link OperandType} configurations:
-     * * 32 bit Floating point :
-     * * * {@link OperandType::TENSOR_FLOAT32} for input, filter, output, and bias.
+     * * 16 bit floating point:
+     * * * {@link OperandType::TENSOR_FLOAT16} for input, filter, output, and bias.
      *
-     * * 16 bit Floating point:
-     * * {@link OperandType::TENSOR_FLOAT16} for input, filter, output, and bias.
+     * * 32 bit floating point:
+     * * * {@link OperandType::TENSOR_FLOAT32} for input, filter, output, and bias.
      *
      * * Quantized:
      * * * {@link OperandType::TENSOR_QUANT8_ASYMM} for input, filter, and output.
@@ -3188,12 +3205,21 @@
      *
      * Inputs:
      * * 0: An n-D tensor, specifying the tensor to be normalized.
-     * * 1: An {@link OperandType::FLOAT32} scalar, specifying gamma, the
-     *      scale applied to the normalized tensor.
-     * * 2: An {@link OperandType::FLOAT32} scalar, specifying beta, the
-     *      offset applied to the normalized tensor.
-     * * 3: An {@link OperandType::FLOAT32} scalar, specifying epsilon, the
-     *      small value added to variance to avoid dividing by zero.
+     * * 1: A scalar, specifying gamma, the scale applied to the normalized
+     *      tensor. The scalar must be of {@link OperandType::FLOAT16} if
+     *      input0 is of {@link OperandType::TENSOR_FLOAT16} and of {@link
+     *      OperandType::FLOAT32} if input0 is of {@link
+     *      OperandType::TENSOR_FLOAT32}.
+     * * 2: A scalar, specifying beta, the offset applied to the normalized
+     *      tensor. The scalar must be of {@link OperandType::FLOAT16} if
+     *      input0 is of {@link OperandType::TENSOR_FLOAT16} and of {@link
+     *      OperandType::FLOAT32} if input0 is of {@link
+     *      OperandType::TENSOR_FLOAT32}.
+     * * 3: A scalar, specifying epsilon, the small value added to variance to
+     *      avoid dividing by zero. The scalar must be of {@link OperandType::FLOAT16} if
+     *      input0 is of {@link OperandType::TENSOR_FLOAT16} and of {@link
+     *      OperandType::FLOAT32} if input0 is of {@link
+     *      OperandType::TENSOR_FLOAT32}.
      * * 4: An {@link OperandType::BOOL} scalar, set to true to specify
      *      NCHW data layout for input0 and output0. Set to false for NHWC.
      *
@@ -3475,10 +3501,12 @@
      *      padding[i, 1] specifies the number of elements to be padded after
      *      the end of dimension i.
      * * 2: An scalar specifying the value to use for padding input0.
+     *      For input tensor of {@link OperandType::TENSOR_FLOAT16}, the
+     *      pad value must be of {@link OperandType::FLOAT16}.
      *      For input tensor of {@link OperandType::TENSOR_FLOAT32}, the
-     *      pad value should be of {@link OperandType::FLOAT32}.
+     *      pad value must be of {@link OperandType::FLOAT32}.
      *      For input tensor of {@link OperandType::TENSOR_QUANT8_ASYMM},
-     *      the pad value should be of {@link OperandType::INT32}. The
+     *      the pad value must be of {@link OperandType::INT32}. The
      *      scale and zeroPoint are assumed to be the same as in input0.
      *
      * Outputs:
@@ -3627,25 +3655,25 @@
      *      weights.
      * * 5: The recurrent-to-input weights.
      *      A 2-D tensor of type {@link OperandType::TENSOR_QUANT8_ASYMM}
-     *      and shape [outputSize, inputSize] specifying recurrent-to-input part
+     *      and shape [outputSize, outputSize] specifying recurrent-to-input part
      *      of weights for fully-connected layer inside the LSTM cell.
      *      Quantization zero point and scale must be the same across all the
      *      weights.
      * * 6: The recurrent-to-forget weights.
      *      A 2-D tensor of type {@link OperandType::TENSOR_QUANT8_ASYMM}
-     *      and shape [outputSize, inputSize] specifying recurrent-to-forget
+     *      and shape [outputSize, outputSize] specifying recurrent-to-forget
      *      part of weights for fully-connected layer inside the LSTM cell.
      *      Quantization zero point and scale must be the same across all the
      *      weights.
      * * 7: The recurrent-to-cell weights.
      *      A 2-D tensor of type {@link OperandType::TENSOR_QUANT8_ASYMM}
-     *      and shape [outputSize, inputSize] specifying recurrent-to-cell part
+     *      and shape [outputSize, outputSize] specifying recurrent-to-cell part
      *      of weights for fully-connected layer inside the LSTM cell.
      *      Quantization zero point and scale must be the same across all the
      *      weights.
      * * 8: The recurrent-to-output weights.
      *      A 2-D tensor of type {@link OperandType::TENSOR_QUANT8_ASYMM}
-     *      and shape [outputSize, inputSize] specifying recurrent-to-output
+     *      and shape [outputSize, outputSize] specifying recurrent-to-output
      *      part of weights for fully-connected layer inside the LSTM cell.
      *      Quantization zero point and scale must be the same across all the
      *      weights.
@@ -4205,7 +4233,10 @@
      * padding.
      *
      * Supported tensor {@link OperandCode} configurations:
-     * * 32 bit Floating point :
+     * * 16 bit floating point:
+     * * * {@link OperandType::TENSOR_FLOAT16} for input, filter, output, and bias.
+     *
+     * * 32 bit floating point:
      * * * {@link OperandType::TENSOR_FLOAT32} for input, filter, output, and bias.
      *
      * * Quantized:
@@ -4213,7 +4244,6 @@
      * * * {@link OperandType::TENSOR_INT32} for bias (with scale set to
      * * * input.scale * filter.scale).
      *
-     * Available since API level 29:
      * * Quantized with symmetric per channel quantization for the filter:
      * * * {@link OperandType::TENSOR_QUANT8_ASYMM} for input, and output.
      * * * {@link OperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter.
diff --git a/radio/1.4/vts/functional/radio_hidl_hal_api.cpp b/radio/1.4/vts/functional/radio_hidl_hal_api.cpp
index 15a8acc..4f347cd 100644
--- a/radio/1.4/vts/functional/radio_hidl_hal_api.cpp
+++ b/radio/1.4/vts/functional/radio_hidl_hal_api.cpp
@@ -563,3 +563,116 @@
                                       RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
     }
 }
+
+/*
+ * Test IRadio.getAllowedCarriers_1_4() for the response returned.
+ */
+TEST_F(RadioHidlTest_v1_4, getAllowedCarriers_1_4) {
+    serial = GetRandomSerialNumber();
+
+    radio_v1_4->getAllowedCarriers_1_4(serial);
+    EXPECT_EQ(std::cv_status::no_timeout, wait());
+    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_4->rspInfo.type);
+    EXPECT_EQ(serial, radioRsp_v1_4->rspInfo.serial);
+
+    ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_4->rspInfo.error,
+                                 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
+}
+
+/**
+ * Test IRadio.setAllowedCarriers_1_4() for the response returned.
+ */
+TEST_F(RadioHidlTest_v1_4, setAllowedCarriers_1_4) {
+    serial = GetRandomSerialNumber();
+    CarrierRestrictionsWithPriority carrierRestrictions;
+    memset(&carrierRestrictions, 0, sizeof(carrierRestrictions));
+    carrierRestrictions.allowedCarriers.resize(1);
+    carrierRestrictions.excludedCarriers.resize(0);
+    carrierRestrictions.allowedCarriers[0].mcc = hidl_string("123");
+    carrierRestrictions.allowedCarriers[0].mnc = hidl_string("456");
+    carrierRestrictions.allowedCarriers[0].matchType = CarrierMatchType::ALL;
+    carrierRestrictions.allowedCarriers[0].matchData = hidl_string();
+    carrierRestrictions.allowedCarriersPrioritized = true;
+    SimLockMultiSimPolicy multisimPolicy = SimLockMultiSimPolicy::NO_MULTISIM_POLICY;
+
+    radio_v1_4->setAllowedCarriers_1_4(serial, carrierRestrictions, multisimPolicy);
+    EXPECT_EQ(std::cv_status::no_timeout, wait());
+    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_4->rspInfo.type);
+    EXPECT_EQ(serial, radioRsp_v1_4->rspInfo.serial);
+
+    ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_4->rspInfo.error,
+                                 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
+
+    if (radioRsp_v1_4->rspInfo.error == RadioError::NONE) {
+        /* Verify the update of the SIM status. This might need some time */
+        if (cardStatus.base.base.cardState != CardState::ABSENT) {
+            updateSimCardStatus();
+            auto startTime = std::chrono::system_clock::now();
+            while (cardStatus.base.base.cardState != CardState::RESTRICTED &&
+                   std::chrono::duration_cast<chrono::seconds>(std::chrono::system_clock::now() -
+                                                               startTime)
+                                   .count() < 10) {
+                /* Set 2 seconds as interval to check card status */
+                sleep(2);
+                updateSimCardStatus();
+            }
+            EXPECT_EQ(CardState::RESTRICTED, cardStatus.base.base.cardState);
+        }
+
+        /* Verify that configuration was set correctly, retrieving it from the modem */
+        serial = GetRandomSerialNumber();
+
+        radio_v1_4->getAllowedCarriers_1_4(serial);
+        EXPECT_EQ(std::cv_status::no_timeout, wait());
+        EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_4->rspInfo.type);
+        EXPECT_EQ(serial, radioRsp_v1_4->rspInfo.serial);
+        EXPECT_EQ(RadioError::NONE, radioRsp_v1_4->rspInfo.error);
+
+        EXPECT_EQ(1, radioRsp_v1_4->carrierRestrictionsResp.allowedCarriers.size());
+        EXPECT_EQ(0, radioRsp_v1_4->carrierRestrictionsResp.excludedCarriers.size());
+        ASSERT_TRUE(hidl_string("123") ==
+                    radioRsp_v1_4->carrierRestrictionsResp.allowedCarriers[0].mcc);
+        ASSERT_TRUE(hidl_string("456") ==
+                    radioRsp_v1_4->carrierRestrictionsResp.allowedCarriers[0].mnc);
+        EXPECT_EQ(CarrierMatchType::ALL,
+                  radioRsp_v1_4->carrierRestrictionsResp.allowedCarriers[0].matchType);
+        ASSERT_TRUE(radioRsp_v1_4->carrierRestrictionsResp.allowedCarriersPrioritized);
+        EXPECT_EQ(SimLockMultiSimPolicy::NO_MULTISIM_POLICY, radioRsp_v1_4->multiSimPolicyResp);
+
+        sleep(10);
+
+        /**
+         * Another test case of the API to cover to allow carrier.
+         * If the API is supported, this is also used to reset to no carrier restriction
+         * status for cardStatus.
+         */
+        memset(&carrierRestrictions, 0, sizeof(carrierRestrictions));
+        carrierRestrictions.allowedCarriers.resize(0);
+        carrierRestrictions.excludedCarriers.resize(0);
+        carrierRestrictions.allowedCarriersPrioritized = false;
+
+        serial = GetRandomSerialNumber();
+        radio_v1_4->setAllowedCarriers_1_4(serial, carrierRestrictions, multisimPolicy);
+        EXPECT_EQ(std::cv_status::no_timeout, wait());
+        EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_4->rspInfo.type);
+        EXPECT_EQ(serial, radioRsp_v1_4->rspInfo.serial);
+
+        EXPECT_EQ(RadioError::NONE, radioRsp_v1_4->rspInfo.error);
+
+        if (cardStatus.base.base.cardState != CardState::ABSENT) {
+            /* Resetting back to no carrier restriction needs some time */
+            updateSimCardStatus();
+            auto startTime = std::chrono::system_clock::now();
+            while (cardStatus.base.base.cardState == CardState::RESTRICTED &&
+                   std::chrono::duration_cast<chrono::seconds>(std::chrono::system_clock::now() -
+                                                               startTime)
+                                   .count() < 10) {
+                /* Set 2 seconds as interval to check card status */
+                sleep(2);
+                updateSimCardStatus();
+            }
+            EXPECT_NE(CardState::RESTRICTED, cardStatus.base.base.cardState);
+            sleep(10);
+        }
+    }
+}
diff --git a/radio/1.4/vts/functional/radio_hidl_hal_utils_v1_4.h b/radio/1.4/vts/functional/radio_hidl_hal_utils_v1_4.h
index ed689c6..de7742c 100644
--- a/radio/1.4/vts/functional/radio_hidl_hal_utils_v1_4.h
+++ b/radio/1.4/vts/functional/radio_hidl_hal_utils_v1_4.h
@@ -67,6 +67,10 @@
     // Data
     ::android::hardware::radio::V1_4::DataRegStateResult dataRegResp;
 
+    // SimLock status
+    ::android::hardware::radio::V1_4::CarrierRestrictionsWithPriority carrierRestrictionsResp;
+    ::android::hardware::radio::V1_4::SimLockMultiSimPolicy multiSimPolicyResp;
+
     RadioResponse_v1_4(RadioHidlTest_v1_4& parent_v1_4);
     virtual ~RadioResponse_v1_4() = default;
 
diff --git a/radio/1.4/vts/functional/radio_response.cpp b/radio/1.4/vts/functional/radio_response.cpp
index 6e9cd43..e7842a9 100644
--- a/radio/1.4/vts/functional/radio_response.cpp
+++ b/radio/1.4/vts/functional/radio_response.cpp
@@ -862,12 +862,18 @@
     return Void();
 }
 
-Return<void> RadioResponse_v1_4::setAllowedCarriersResponse_1_4(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse_v1_4::setAllowedCarriersResponse_1_4(const RadioResponseInfo& info) {
+    rspInfo = info;
+    parent_v1_4.notify(info.serial);
     return Void();
 }
 
 Return<void> RadioResponse_v1_4::getAllowedCarriersResponse_1_4(
-        const RadioResponseInfo& /*info*/, const CarrierRestrictionsWithPriority& /*carriers*/,
-        SimLockMultiSimPolicy /*multiSimPolicy*/) {
+        const RadioResponseInfo& info, const CarrierRestrictionsWithPriority& carriers,
+        SimLockMultiSimPolicy multiSimPolicy) {
+    rspInfo = info;
+    carrierRestrictionsResp = carriers;
+    multiSimPolicyResp = multiSimPolicy;
+    parent_v1_4.notify(info.serial);
     return Void();
 }