Snap for 5736565 from 954f4fef652f87a41c6a11c8d3d5da2f6df53797 to qt-c2f2-release

Change-Id: Ida99791ab641a0a744aed4f89c99501a42eb5284
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 4288d0d..3a30cea 100644
--- a/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp
@@ -59,6 +59,11 @@
  * each received location.
  */
 TEST_F(GnssHalTest, GetLocationLowPower) {
+    if (!IsGnssHalVersion_1_1()) {
+        ALOGI("Test GetLocationLowPower skipped. GNSS HAL version is greater than 1.1.");
+        return;
+    }
+
     const int kMinIntervalMsec = 5000;
     const int kLocationTimeoutSubsequentSec = (kMinIntervalMsec / 1000) * 2;
     const int kNoLocationPeriodSec = (kMinIntervalMsec / 1000) / 2;
diff --git a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
index 6e0887f..39736cc 100644
--- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
@@ -416,6 +416,70 @@
 }
 
 /*
+ * GetLocationLowPower:
+ * Turns on location, waits for at least 5 locations allowing max of LOCATION_TIMEOUT_SUBSEQUENT_SEC
+ * between one location and the next. Also ensure that MIN_INTERVAL_MSEC is respected by waiting
+ * NO_LOCATION_PERIOD_SEC and verfiy that no location is received. Also perform validity checks on
+ * each received location.
+ */
+TEST_F(GnssHalTest, GetLocationLowPower) {
+    if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::LOW_POWER_MODE)) {
+        ALOGI("Test GetLocationLowPower skipped. LOW_POWER_MODE capability not supported.");
+        return;
+    }
+
+    const int kMinIntervalMsec = 5000;
+    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
+    gnss_cb_->location_cbq_.reset();
+    StartAndCheckLocations(kLocationsToCheck);
+    StopAndClearLocations();
+    gnss_cb_->location_cbq_.reset();
+
+    // Start of Low Power Mode test
+    SetPositionMode(kMinIntervalMsec, kLowPowerMode);
+
+    // 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
+
+        gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, kNoLocationPeriodSec);
+        const int locationCalledCount = gnss_cb_->location_cbq_.calledCount();
+
+        // Tolerate (ignore) one extra location right after the first one
+        // to handle startup edge case scheduling limitations in some implementations
+        if ((i == 1) && (locationCalledCount == 2)) {
+            CheckLocation(gnss_cb_->last_location_, true);
+            continue;  // restart the quiet wait period after this too-fast location
+        }
+        EXPECT_LE(locationCalledCount, i);
+        if (locationCalledCount != i) {
+            ALOGW("GetLocationLowPower test - not enough locations received. %d vs. %d expected ",
+                  locationCalledCount, i);
+        }
+
+        if (!gnss_cb_->location_cbq_.retrieve(
+                    gnss_cb_->last_location_,
+                    kLocationTimeoutSubsequentSec - kNoLocationPeriodSec)) {
+            ALOGW("GetLocationLowPower test - timeout awaiting location %d", i);
+        } else {
+            CheckLocation(gnss_cb_->last_location_, true);
+        }
+    }
+
+    StopAndClearLocations();
+}
+
+/*
  * MapConstellationType:
  * Given a GnssConstellationType_2_0 type constellation, maps to its equivalent
  * GnssConstellationType_1_0 type constellation. For constellations that do not have
@@ -537,6 +601,8 @@
  */
 TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
     if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::SATELLITE_BLACKLIST)) {
+        ALOGI("Test BlacklistIndividualSatellites skipped. SATELLITE_BLACKLIST capability"
+              " not supported.");
         return;
     }
 
@@ -680,6 +746,7 @@
  */
 TEST_F(GnssHalTest, BlacklistConstellation) {
     if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::SATELLITE_BLACKLIST)) {
+        ALOGI("Test BlacklistConstellation skipped. SATELLITE_BLACKLIST capability not supported.");
         return;
     }
 
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
index 30b9694..fa5ace6 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
@@ -790,7 +790,7 @@
 TEST_F(GraphicsComposerHidlCommandTest, PRESENT_DISPLAY_NO_LAYER_STATE_CHANGES) {
     mWriter->selectDisplay(mPrimaryDisplay);
     mComposerClient->setPowerMode(mPrimaryDisplay, IComposerClient::PowerMode::ON);
-    mComposerClient->setColorMode(mPrimaryDisplay, ColorMode::SRGB);
+    mComposerClient->setColorMode(mPrimaryDisplay, ColorMode::NATIVE);
 
     auto handle = allocate();
     ASSERT_NE(nullptr, handle);
diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp
index 0648b34..02c4c9c 100644
--- a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp
+++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp
@@ -182,6 +182,14 @@
         mReader = std::make_unique<TestCommandReader>();
         mGralloc = std::make_shared<Gralloc>();
 
+        std::vector<ColorMode> colorModes = mComposerClient->getColorModes(mPrimaryDisplay);
+        if (std::find(colorModes.begin(), colorModes.end(), ColorMode::SRGB) == colorModes.end()) {
+            mHasReadbackBuffer = false;
+            return;
+        }
+        mWriter->selectDisplay(mPrimaryDisplay);
+        ASSERT_NO_FATAL_FAILURE(mComposerClient->setColorMode(mPrimaryDisplay, ColorMode::SRGB,
+                                                              RenderIntent::COLORIMETRIC));
         mComposerClient->getRaw()->getReadbackBufferAttributes(
             mPrimaryDisplay,
             [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
@@ -471,12 +479,12 @@
 
 TEST_F(GraphicsComposerReadbackTest, SingleSolidColorLayer) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
-    mWriter->selectDisplay(mPrimaryDisplay);
-    ASSERT_NO_FATAL_FAILURE(mComposerClient->setColorMode(mPrimaryDisplay, ColorMode::SRGB,
-                                                          RenderIntent::COLORIMETRIC));
 
     auto layer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
     IComposerClient::Rect coloredSquare({0, 0, mDisplayWidth, mDisplayHeight});
@@ -515,12 +523,13 @@
 
 TEST_F(GraphicsComposerReadbackTest, SetLayerBuffer) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-
     ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
                                   mDisplayHeight, mPixelFormat, mDataspace);
     ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
@@ -562,13 +571,13 @@
 
 TEST_F(GraphicsComposerReadbackTest, SetLayerBufferNoEffect) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-    ASSERT_NO_FATAL_FAILURE(mComposerClient->setColorMode(mPrimaryDisplay, ColorMode::SRGB,
-                                                          RenderIntent::COLORIMETRIC));
 
     auto layer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
     IComposerClient::Rect coloredSquare({0, 0, mDisplayWidth, mDisplayHeight});
@@ -611,12 +620,13 @@
 
 TEST_F(GraphicsComposerReadbackTest, ClientComposition) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-
     std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
     fillColorsArea(expectedColors, mDisplayWidth, {0, 0, mDisplayWidth, mDisplayHeight / 4}, RED);
     fillColorsArea(expectedColors, mDisplayWidth,
@@ -690,11 +700,13 @@
 
 TEST_F(GraphicsComposerReadbackTest, DeviceAndClientComposition) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
     ASSERT_NO_FATAL_FAILURE(
         mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kClientTargetSlotCount));
 
@@ -776,12 +788,13 @@
 
 TEST_F(GraphicsComposerReadbackTest, SetLayerDamage) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelformat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-
     IComposerClient::Rect redRect = {0, 0, mDisplayWidth / 4, mDisplayHeight / 4};
 
     std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
@@ -842,14 +855,13 @@
 
 TEST_F(GraphicsComposerReadbackTest, SetLayerPlaneAlpha) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-    ASSERT_NO_FATAL_FAILURE(mComposerClient->setColorMode(mPrimaryDisplay, ColorMode::SRGB,
-                                                          RenderIntent::COLORIMETRIC));
-
     auto layer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
     layer->setColor(RED);
     layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
@@ -886,12 +898,13 @@
 
 TEST_F(GraphicsComposerReadbackTest, SetLayerSourceCrop) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-
     std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
     fillColorsArea(expectedColors, mDisplayWidth, {0, 0, mDisplayWidth, mDisplayHeight / 4}, RED);
     fillColorsArea(expectedColors, mDisplayWidth,
@@ -931,14 +944,13 @@
 
 TEST_F(GraphicsComposerReadbackTest, SetLayerZOrder) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-    ASSERT_NO_FATAL_FAILURE(mComposerClient->setColorMode(mPrimaryDisplay, ColorMode::SRGB,
-                                                          RenderIntent::COLORIMETRIC));
-
     IComposerClient::Rect redRect = {0, 0, mDisplayWidth, mDisplayHeight / 2};
     IComposerClient::Rect blueRect = {0, mDisplayHeight / 4, mDisplayWidth, mDisplayHeight};
     auto redLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
@@ -1081,12 +1093,13 @@
 
 TEST_P(GraphicsComposerBlendModeReadbackTest, None) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-
     std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
 
     setBackgroundColor(BLACK);
@@ -1118,12 +1131,13 @@
 // alpha of .2, expected 10.2
 TEST_P(GraphicsComposerBlendModeReadbackTest, DISABLED_Coverage) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-
     std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
 
     setBackgroundColor(BLACK);
@@ -1153,12 +1167,13 @@
 
 TEST_P(GraphicsComposerBlendModeReadbackTest, Premultiplied) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
 
-    mWriter->selectDisplay(mPrimaryDisplay);
-
     std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
 
     setBackgroundColor(BLACK);
@@ -1193,10 +1208,6 @@
     void SetUp() override {
         GraphicsComposerReadbackTest::SetUp();
 
-        mWriter->selectDisplay(mPrimaryDisplay);
-        ASSERT_NO_FATAL_FAILURE(mComposerClient->setColorMode(mPrimaryDisplay, ColorMode::SRGB,
-                                                              RenderIntent::COLORIMETRIC));
-
         auto backgroundLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
         backgroundLayer->setColor({0, 0, 0, 0});
         backgroundLayer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
@@ -1230,6 +1241,9 @@
 
 TEST_F(GraphicsComposerTransformReadbackTest, FLIP_H) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
@@ -1262,6 +1276,9 @@
 
 TEST_F(GraphicsComposerTransformReadbackTest, FLIP_V) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }
@@ -1295,6 +1312,9 @@
 
 TEST_F(GraphicsComposerTransformReadbackTest, ROT_180) {
     if (!mHasReadbackBuffer) {
+        std::cout << "Readback not supported or unsuppported pixelFormat/dataspace or SRGB not a "
+                     "valid color mode"
+                  << std::endl;
         GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
         return;
     }