Merge "Fix KM VTS tests for Strongbox implementations"
diff --git a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h
index 95080d1..91adfc1 100644
--- a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h
+++ b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h
@@ -45,29 +45,37 @@
                         xmlFilePath, xsdFilePath)
 
 /** Validate an XML according to an xsd.
- * The XML file must be in at least one of the provided locations.
- * If multiple are found, all are validated.
+ * All file named xmlFileName in each xmlFileLocations folder must be valid if present.
+ * @tparam atLeastOneRequired If true, at least one file has to be found.
+ *                           If false, no found file is a success.
  */
+template <bool atLeastOneRequired = true>
 ::testing::AssertionResult validateXmlMultipleLocations(
     const char* xmlFileNameExpr, const char* xmlFileLocationsExpr, const char* xsdFilePathExpr,
     const char* xmlFileName, std::vector<const char*> xmlFileLocations, const char* xsdFilePath);
 
-/** ASSERT that an XML is valid according to an xsd.
- * The XML file must be in at least one of the provided locations.
- * If multiple are found, all are validated.
- */
-#define ASSERT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \
-    ASSERT_PRED_FORMAT3(                                                                    \
-        ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations,    \
+/** ASSERT that all found XML are valid according to an xsd. */
+#define ASSERT_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath)         \
+    ASSERT_PRED_FORMAT3(                                                                        \
+        ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations<false>, \
         xmlFileName, xmlFileLocations, xsdFilePath)
 
-/** EXPECT an XML to be valid according to an xsd.
- * The XML file must be in at least one of the provided locations.
- * If multiple are found, all are validated.
- */
-#define EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \
-    EXPECT_PRED_FORMAT3(                                                                    \
-        ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations,    \
+/** EXPECT that all found XML are valid according to an xsd. */
+#define EXPECT_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath)         \
+    EXPECT_PRED_FORMAT3(                                                                        \
+        ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations<false>, \
+        xmlFileName, xmlFileLocations, xsdFilePath)
+
+/** ASSERT that all found XML are valid according to an xsd. At least one must be found. */
+#define ASSERT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath)    \
+    ASSERT_PRED_FORMAT3(                                                                       \
+        ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations<true>, \
+        xmlFileName, xmlFileLocations, xsdFilePath)
+
+/** EXPECT that all found XML are valid according to an xsd. At least one must be found. */
+#define EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath)    \
+    EXPECT_PRED_FORMAT3(                                                                       \
+        ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations<true>, \
         xmlFileName, xmlFileLocations, xsdFilePath)
 
 }  // namespace utility
diff --git a/audio/common/all-versions/test/utility/src/ValidateXml.cpp b/audio/common/all-versions/test/utility/src/ValidateXml.cpp
index 5030af5..1a906d6 100644
--- a/audio/common/all-versions/test/utility/src/ValidateXml.cpp
+++ b/audio/common/all-versions/test/utility/src/ValidateXml.cpp
@@ -129,6 +129,7 @@
     return ::testing::AssertionSuccess();
 }
 
+template <bool atLeastOneRequired>
 ::testing::AssertionResult validateXmlMultipleLocations(
     const char* xmlFileNameExpr, const char* xmlFileLocationsExpr, const char* xsdFilePathExpr,
     const char* xmlFileName, std::vector<const char*> xmlFileLocations, const char* xsdFilePath) {
@@ -150,7 +151,7 @@
         }
     }
 
-    if (foundFiles.empty()) {
+    if (atLeastOneRequired && foundFiles.empty()) {
         errors.push_back("No xml file found in provided locations.\n");
     }
 
@@ -160,9 +161,20 @@
            << "     While validating all: " << xmlFileNameExpr
            << "\n                 Which is: " << xmlFileName
            << "\n In the following folders: " << xmlFileLocationsExpr
-           << "\n                 Which is: " << ::testing::PrintToString(xmlFileLocations);
+           << "\n                 Which is: " << ::testing::PrintToString(xmlFileLocations)
+           << (atLeastOneRequired ? "Where at least one file must be found."
+                                  : "Where no file might exist.");
 }
 
+template ::testing::AssertionResult validateXmlMultipleLocations<true>(const char*, const char*,
+                                                                       const char*, const char*,
+                                                                       std::vector<const char*>,
+                                                                       const char*);
+template ::testing::AssertionResult validateXmlMultipleLocations<false>(const char*, const char*,
+                                                                        const char*, const char*,
+                                                                        std::vector<const char*>,
+                                                                        const char*);
+
 }  // namespace utility
 }  // namespace test
 }  // namespace common
diff --git a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index dab9f7c..9c9b749 100644
--- a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -106,7 +106,10 @@
 static auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
 static auto okOrNotSupportedOrInvalidArgs = {Result::OK, Result::NOT_SUPPORTED,
                                              Result::INVALID_ARGUMENTS};
+static auto okOrInvalidStateOrNotSupported = {Result::OK, Result::INVALID_STATE,
+                                              Result::NOT_SUPPORTED};
 static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED};
+static auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED};
 
 class AudioHidlTestEnvironment : public ::Environment {
    public:
@@ -555,11 +558,11 @@
             address.device = deviceType;
             auto ret = device->setConnectedState(address, state);
             ASSERT_TRUE(ret.isOk());
-            if (res == Result::NOT_SUPPORTED) {
+            if (ret == Result::NOT_SUPPORTED) {
                 doc::partialTest("setConnectedState is not supported");
                 return;
             }
-            ASSERT_OK(res);
+            ASSERT_OK(ret);
         }
     }
 }
@@ -949,8 +952,6 @@
 TEST_IO_STREAM(standby, "Make sure the stream can be put in stanby",
                ASSERT_OK(stream->standby()))  // can not fail
 
-static constexpr auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED};
-
 TEST_IO_STREAM(startNoMmap, "Starting a mmaped stream before mapping it should fail",
                ASSERT_RESULT(invalidStateOrNotSupported, stream->start()))
 
@@ -1070,11 +1071,15 @@
 TEST_P(InputStreamTest, getCapturePosition) {
     doc::test(
         "The capture position of a non prepared stream should not be "
-        "retrievable");
+        "retrievable or 0");
     uint64_t frames;
     uint64_t time;
     ASSERT_OK(stream->getCapturePosition(returnIn(res, frames, time)));
-    ASSERT_RESULT(invalidStateOrNotSupported, res);
+    ASSERT_RESULT(okOrInvalidStateOrNotSupported, res);
+    if (res == Result::OK) {
+        ASSERT_EQ(0U, frames);
+        ASSERT_LE(0U, time);
+    }
 }
 
 TEST_P(InputStreamTest, updateSinkMetadata) {
diff --git a/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp b/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp
index d0bc690..bf080d3 100644
--- a/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp
+++ b/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp
@@ -27,6 +27,6 @@
     using namespace android::effectsConfig;
 
     std::vector<const char*> locations(std::begin(DEFAULT_LOCATIONS), std::end(DEFAULT_LOCATIONS));
-    EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations,
-                                            "/data/local/tmp/audio_effects_conf_V2_0.xsd");
+    EXPECT_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations,
+                                        "/data/local/tmp/audio_effects_conf_V2_0.xsd");
 }
diff --git a/camera/device/3.4/default/ExternalCameraDevice.cpp b/camera/device/3.4/default/ExternalCameraDevice.cpp
index e093822..e7361dd 100644
--- a/camera/device/3.4/default/ExternalCameraDevice.cpp
+++ b/camera/device/3.4/default/ExternalCameraDevice.cpp
@@ -90,7 +90,7 @@
 }
 
 Return<Status> ExternalCameraDevice::setTorchMode(TorchMode) {
-    return Status::METHOD_NOT_SUPPORTED;
+    return Status::OPERATION_NOT_SUPPORTED;
 }
 
 Return<void> ExternalCameraDevice::open(
diff --git a/camera/provider/2.4/default/ExternalCameraProvider.cpp b/camera/provider/2.4/default/ExternalCameraProvider.cpp
index a4046d0..1cec0e5 100644
--- a/camera/provider/2.4/default/ExternalCameraProvider.cpp
+++ b/camera/provider/2.4/default/ExternalCameraProvider.cpp
@@ -105,8 +105,9 @@
 
 Return<void> ExternalCameraProvider::isSetTorchModeSupported(
         isSetTorchModeSupported_cb _hidl_cb) {
-    // No torch mode support for USB camera
-    _hidl_cb (Status::OK, false);
+    // setTorchMode API is supported, though right now no external camera device
+    // has a flash unit.
+    _hidl_cb (Status::OK, true);
     return Void();
 }
 
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index 0d92c37..439333d 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -3649,6 +3649,7 @@
                                         static_cast<int32_t>(PixelFormat::IMPLEMENTATION_DEFINED)};
     uint64_t bufferId = 1;
     uint32_t frameNumber = 1;
+    float isoTol = .03f;
     ::android::hardware::hidl_vec<uint8_t> settings;
 
     for (const auto& name : cameraDeviceNames) {
@@ -3778,7 +3779,8 @@
             ASSERT_TRUE(inflightReqs[i].collectedResult.exists(ANDROID_SENSOR_SENSITIVITY));
             camera_metadata_entry_t isoResult = inflightReqs[i].collectedResult.find(
                     ANDROID_SENSOR_SENSITIVITY);
-            ASSERT_TRUE(isoResult.data.i32[0] == isoValues[i]);
+            ASSERT_TRUE(std::abs(isoResult.data.i32[0] - isoValues[i]) <=
+                        std::round(isoValues[i]*isoTol));
         }
 
         ret = session->close();
@@ -4044,10 +4046,10 @@
                                << static_cast<uint32_t>(inflightReq.errorCode);
                 }
             }
-
-            ret = session->close();
-            ASSERT_TRUE(ret.isOk());
         }
+
+        ret = session->close();
+        ASSERT_TRUE(ret.isOk());
     }
 }
 
diff --git a/configstore/1.0/ISurfaceFlingerConfigs.hal b/configstore/1.0/ISurfaceFlingerConfigs.hal
index 5f975bd..1de7570 100644
--- a/configstore/1.0/ISurfaceFlingerConfigs.hal
+++ b/configstore/1.0/ISurfaceFlingerConfigs.hal
@@ -61,11 +61,16 @@
     hasWideColorDisplay() generates (OptionalBool value);
 
     /**
-     * hwHdrDisplay indicates that the device has
-     * or can support an HDR (High Dynamic Range) display.
-     * Typically an HDR display is also wide-color.
+     * hwHDRDisplay indicates that the device has an High Dynamic Range display.
+     * A display is considered High Dynamic Range if it
+     *
+     *     1. is a wide color gamut display, typically DCI-P3 or lager
+     *     2. has high luminance capability, typically 540 nits or higher at 10% OPR
+     *
      * Indicate support for this feature by setting
      * TARGET_HAS_HDR_DISPLAY to true in BoardConfig.mk
+     * TARGET_HAS_WIDE_COLOR_DISPLAY must be set to true when
+     * TARGET_HAS_HDR_DISPLAY is true.
      */
     hasHDRDisplay() generates (OptionalBool value);
 
diff --git a/current.txt b/current.txt
index 267f6b0..af70147 100644
--- a/current.txt
+++ b/current.txt
@@ -385,6 +385,7 @@
 10ff2fae516346b86121368ce5790d5accdfcb73983246b813f3d488b66db45a android.hardware.wifi.supplicant@1.1::ISupplicantStaNetwork
 
 # ABI preserving changes to HALs during Android Q
+da33234403ff5d60f3473711917b9948e6484a4260b5247acdafb111193a9de2 android.hardware.configstore@1.0::ISurfaceFlingerConfigs
 574e8f1499436fb4075894dcae0b36682427956ecb114f17f1fe22d116a83c6b android.hardware.neuralnetworks@1.0::IPreparedModel
 1a5ae9793223658174258b523763c557abad6fb917df0b8e3cc097fc89035811 android.hardware.neuralnetworks@1.0::types
 4310eb8272f085914952f3bfb73a8f8bb477a80e8b93596f0ea5acb58546b66d android.hardware.neuralnetworks@1.1::types
diff --git a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
index 010a46d..c26f60a 100644
--- a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
+++ b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
@@ -404,7 +404,11 @@
   ASSERT_TRUE(result.isOk());
   EXPECT_TRUE(result);
 
-  auto resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_ALL);
+  auto resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_POSITION);
+
+  ASSERT_TRUE(resultVoid.isOk());
+
+  resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_TIME);
 
   ASSERT_TRUE(resultVoid.isOk());
 
@@ -472,6 +476,16 @@
   }
 }
 
+/*
+ * SchedulingCapabilities:
+ * Verifies that 2018+ hardware supports Scheduling capabilities.
+ */
+TEST_F(GnssHalTest, SchedulingCapabilities) {
+    if (info_called_count_ > 0 && last_info_.yearOfHw >= 2018) {
+        EXPECT_TRUE(last_capabilities_ & IGnssCallback::Capabilities::SCHEDULING);
+    }
+}
+
 int main(int argc, char** argv) {
   ::testing::AddGlobalTestEnvironment(GnssHidlEnvironment::Instance());
   ::testing::InitGoogleTest(&argc, argv);
diff --git a/gnss/1.1/vts/functional/gnss_hal_test.cpp b/gnss/1.1/vts/functional/gnss_hal_test.cpp
index 46d61e5..433f5cb 100644
--- a/gnss/1.1/vts/functional/gnss_hal_test.cpp
+++ b/gnss/1.1/vts/functional/gnss_hal_test.cpp
@@ -83,6 +83,7 @@
      */
     while (wait(TIMEOUT_SEC) == std::cv_status::no_timeout) {
     }
+    location_called_count_ = 0;
 }
 
 void GnssHalTest::SetPositionMode(const int min_interval_msec, const bool low_power_mode) {
@@ -97,17 +98,17 @@
     EXPECT_TRUE(result);
 }
 
-bool GnssHalTest::StartAndGetSingleLocation() {
+bool GnssHalTest::StartAndCheckFirstLocation() {
     auto result = gnss_hal_->start();
 
     EXPECT_TRUE(result.isOk());
     EXPECT_TRUE(result);
 
     /*
-     * GPS signals initially optional for this test, so don't expect fast fix,
-     * or no timeout, unless signal is present
+     * GnssLocationProvider support of AGPS SUPL & XtraDownloader is not available in VTS,
+     * so allow time to demodulate ephemeris over the air.
      */
-    const int kFirstGnssLocationTimeoutSeconds = 15;
+    const int kFirstGnssLocationTimeoutSeconds = 75;
 
     wait(kFirstGnssLocationTimeoutSeconds);
     EXPECT_EQ(location_called_count_, 1);
@@ -195,7 +196,7 @@
 
     SetPositionMode(kMinIntervalMsec, kLowPowerMode);
 
-    EXPECT_TRUE(StartAndGetSingleLocation());
+    EXPECT_TRUE(StartAndCheckFirstLocation());
 
     for (int i = 1; i < count; i++) {
         EXPECT_EQ(std::cv_status::no_timeout, wait(kLocationTimeoutSubsequentSec));
diff --git a/gnss/1.1/vts/functional/gnss_hal_test.h b/gnss/1.1/vts/functional/gnss_hal_test.h
index 269366a..64478b5 100644
--- a/gnss/1.1/vts/functional/gnss_hal_test.h
+++ b/gnss/1.1/vts/functional/gnss_hal_test.h
@@ -107,12 +107,15 @@
     void SetUpGnssCallback();
 
     /*
-     * StartAndGetSingleLocation:
-     * Helper function to get one Location and check fields
+     * StartAndCheckFirstLocation:
+     *   Helper function to start location, and check the first one.
+     *
+     *   <p> Note this leaves the Location request active, to enable Stop call vs. other call
+     *   reordering tests.
      *
      * returns  true if a location was successfully generated
      */
-    bool StartAndGetSingleLocation();
+    bool StartAndCheckFirstLocation();
 
     /*
      * CheckLocation:
diff --git a/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp b/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp
index cce46f1..c9f840e 100644
--- a/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp
@@ -60,24 +60,46 @@
  */
 TEST_F(GnssHalTest, GetLocationLowPower) {
     const int kMinIntervalMsec = 5000;
-    const int kLocationTimeoutSubsequentSec = (kMinIntervalMsec / 1000) + 1;
-    const int kNoLocationPeriodSec = 2;
+    const int kLocationTimeoutSubsequentSec = (kMinIntervalMsec / 1000) * 2;
+    const int kNoLocationPeriodSec = (kMinIntervalMsec / 1000) / 2;
     const int kLocationsToCheck = 5;
     const bool kLowPowerMode = true;
 
+    // Warmup period - VTS doesn't have AGPS access via GnssLocationProvider
+    StartAndCheckLocations(5);
+    StopAndClearLocations();
+
+    // Start of Low Power Mode test
     SetPositionMode(kMinIntervalMsec, kLowPowerMode);
 
-    EXPECT_TRUE(StartAndGetSingleLocation());
+    // Don't expect true - as without AGPS access
+    if (!StartAndCheckFirstLocation()) {
+        ALOGW("GetLocationLowPower test - no first low power location received.");
+    }
 
     for (int i = 1; i < kLocationsToCheck; i++) {
         // Verify that kMinIntervalMsec is respected by waiting kNoLocationPeriodSec and
         // ensure that no location is received yet
+
         wait(kNoLocationPeriodSec);
-        EXPECT_EQ(location_called_count_, i);
-        EXPECT_EQ(std::cv_status::no_timeout,
-                  wait(kLocationTimeoutSubsequentSec - kNoLocationPeriodSec));
-        EXPECT_EQ(location_called_count_, i + 1);
-        CheckLocation(last_location_, true);
+        // Tolerate (ignore) one extra location right after the first one
+        // to handle startup edge case scheduling limitations in some implementations
+        if ((i == 1) && (location_called_count_ == 2)) {
+            CheckLocation(last_location_, true);
+            continue;  // restart the quiet wait period after this too-fast location
+        }
+        EXPECT_LE(location_called_count_, i);
+        if (location_called_count_ != i) {
+            ALOGW("GetLocationLowPower test - not enough locations received. %d vs. %d expected ",
+                  location_called_count_, i);
+        }
+
+        if (std::cv_status::no_timeout !=
+            wait(kLocationTimeoutSubsequentSec - kNoLocationPeriodSec)) {
+            ALOGW("GetLocationLowPower test - timeout awaiting location %d", i);
+        } else {
+            CheckLocation(last_location_, true);
+        }
     }
 
     StopAndClearLocations();
@@ -177,7 +199,8 @@
 
     StartAndCheckLocations(kLocationsToAwait);
 
-    EXPECT_GE((int)list_gnss_sv_status_.size(), kLocationsToAwait);
+    // Tolerate 1 less sv status to handle edge cases in reporting.
+    EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait);
     ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(),
           kLocationsToAwait);
 
@@ -217,7 +240,8 @@
     location_called_count_ = 0;
     StartAndCheckLocations(kLocationsToAwait);
 
-    EXPECT_GE((int)list_gnss_sv_status_.size(), kLocationsToAwait);
+    // Tolerate 1 less sv status to handle edge cases in reporting.
+    EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait);
     ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(),
           kLocationsToAwait);
     for (const auto& gnss_sv_status : list_gnss_sv_status_) {
@@ -236,13 +260,13 @@
     ASSERT_TRUE(result.isOk());
     EXPECT_TRUE(result);
 
-    location_called_count_ = 0;
     StopAndClearLocations();
     list_gnss_sv_status_.clear();
 
     StartAndCheckLocations(kLocationsToAwait);
 
-    EXPECT_GE((int)list_gnss_sv_status_.size(), kLocationsToAwait);
+    // Tolerate 1 less sv status to handle edge cases in reporting.
+    EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait);
     ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(),
           kLocationsToAwait);
 
@@ -278,7 +302,8 @@
 
     StartAndCheckLocations(kLocationsToAwait);
 
-    EXPECT_GE((int)list_gnss_sv_status_.size(), kLocationsToAwait);
+    // Tolerate 1 less sv status to handle edge cases in reporting.
+    EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait);
     ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(),
           kLocationsToAwait);
 
@@ -328,7 +353,8 @@
     location_called_count_ = 0;
     StartAndCheckLocations(kLocationsToAwait);
 
-    EXPECT_GE((int)list_gnss_sv_status_.size(), kLocationsToAwait);
+    // Tolerate 1 less sv status to handle edge cases in reporting.
+    EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait);
     ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(),
           kLocationsToAwait);
     for (const auto& gnss_sv_status : list_gnss_sv_status_) {
@@ -353,23 +379,8 @@
  * Ensure successfully injecting a location.
  */
 TEST_F(GnssHalTest, InjectBestLocation) {
-    GnssLocation gnssLocation = {.gnssLocationFlags = 0,  // set below
-                                 .latitudeDegrees = 43.0,
-                                 .longitudeDegrees = -180,
-                                 .altitudeMeters = 1000,
-                                 .speedMetersPerSec = 0,
-                                 .bearingDegrees = 0,
-                                 .horizontalAccuracyMeters = 0.1,
-                                 .verticalAccuracyMeters = 0.1,
-                                 .speedAccuracyMetersPerSecond = 0.1,
-                                 .bearingAccuracyDegrees = 0.1,
-                                 .timestamp = 1534567890123L};
-    gnssLocation.gnssLocationFlags |=
-        GnssLocationFlags::HAS_LAT_LONG | GnssLocationFlags::HAS_ALTITUDE |
-        GnssLocationFlags::HAS_SPEED | GnssLocationFlags::HAS_HORIZONTAL_ACCURACY |
-        GnssLocationFlags::HAS_VERTICAL_ACCURACY | GnssLocationFlags::HAS_SPEED_ACCURACY |
-        GnssLocationFlags::HAS_BEARING | GnssLocationFlags::HAS_BEARING_ACCURACY;
-
+    StartAndCheckLocations(1);
+    GnssLocation gnssLocation = last_location_;
     CheckLocation(gnssLocation, true);
 
     auto result = gnss_hal_->injectBestLocation(gnssLocation);
@@ -377,7 +388,7 @@
     ASSERT_TRUE(result.isOk());
     EXPECT_TRUE(result);
 
-    auto resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_ALL);
+    auto resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_POSITION);
 
     ASSERT_TRUE(resultVoid.isOk());
 }
@@ -428,7 +439,7 @@
             EXPECT_GE(data.position.ageSeconds, 0);
         }
 
-        EXPECT_GE(data.time.timeEstimate, 1514764800000);  // Jan 01 2018 00:00:00
+        EXPECT_GE(data.time.timeEstimate, 1483228800000);  // Jan 01 2017 00:00:00 GMT.
 
         EXPECT_GT(data.time.timeUncertaintyNs, 0);
 
diff --git a/keymaster/4.0/IKeymasterDevice.hal b/keymaster/4.0/IKeymasterDevice.hal
index 74d13d8..85a25c6 100644
--- a/keymaster/4.0/IKeymasterDevice.hal
+++ b/keymaster/4.0/IKeymasterDevice.hal
@@ -753,7 +753,7 @@
      *     attestationIdManufacturer  [716] EXPLICIT OCTET_STRING OPTIONAL,
      *     attestationIdModel         [717] EXPLICIT OCTET_STRING OPTIONAL,
      *     vendorPatchLevel           [718] EXPLICIT INTEGER OPTIONAL,
-     *     bootPatchLevel             [718] EXPLICIT INTEGER OPTIONAL,
+     *     bootPatchLevel             [719] EXPLICIT INTEGER OPTIONAL,
      * }
      *
      * The above schema is mostly a straightforward translation of the IKeymasterDevice tag/value