Merge "supplicant(vts): Remove dependency on libwifi_hal" into oc-dr1-dev
diff --git a/current.txt b/current.txt
index 986e0ec..d93352a 100644
--- a/current.txt
+++ b/current.txt
@@ -197,7 +197,7 @@
 
 4b65763663a94a3920134011691f8fbb42ccb7b7795589efddc049a9106047d6 android.hardware.oemlock@1.0::IOemLock
 e02cd3722cb5e8fa51179f5defacb4f7866f903c9c7c51dc01a3148473a71525 android.hardware.oemlock@1.0::types
-9f69e783fa2c482d90b2f799ddd33378a92d22a261983df6b492358e01f4d791 android.hardware.power@1.1::IPower
+224f9d22a367a0016f09b6dc676f53f1446697d9dc747163032329e5da552de5 android.hardware.power@1.1::IPower
 574fd9758b7cab4922c72cc5a9f36d1cd48ffd3425fdd776426653280d3d4138 android.hardware.power@1.1::types
 f79edf50a378a9c9bb737f93f205dab91b4c63ea49723afc6f856c138203ea81 android.hardware.radio@1.1::IRadio
 fcc5c8c88b85a9f63fba67d9e674da466c72a98ca287f343fb5721d098713f86 android.hardware.radio@1.1::IRadioIndication
diff --git a/power/1.1/IPower.hal b/power/1.1/IPower.hal
index 0c0f211..086904e 100644
--- a/power/1.1/IPower.hal
+++ b/power/1.1/IPower.hal
@@ -33,4 +33,18 @@
      */
     getSubsystemLowPowerStats()
             generates (vec<PowerStateSubsystem> subsystems, Status retval);
+
+    /**
+     * powerHintAsync() is called to pass hints on power requirements which
+     * may result in adjustment of power/performance parameters of the
+     * cpufreq governor and other controls.
+     *
+     * A particular platform may choose to ignore any hint.
+     *
+     * @param hint PowerHint which is passed
+     * @param data contains additional information about the hint
+     * and is described along with the comments for each of the hints.
+     */
+    oneway powerHintAsync(PowerHint hint, int32_t data);
+
 };
diff --git a/power/1.1/default/Power.cpp b/power/1.1/default/Power.cpp
index bf7c1fc..b5d0c84 100644
--- a/power/1.1/default/Power.cpp
+++ b/power/1.1/default/Power.cpp
@@ -165,6 +165,11 @@
     return Void();
 }
 
+Return<void> Power::powerHintAsync(PowerHint hint, int32_t data) {
+    // just call the normal power hint in this oneway function
+    return powerHint(hint, data);
+}
+
 } // namespace implementation
 }  // namespace V1_1
 }  // namespace power
diff --git a/power/1.1/default/Power.h b/power/1.1/default/Power.h
index ea9e8c3..e779d64 100644
--- a/power/1.1/default/Power.h
+++ b/power/1.1/default/Power.h
@@ -46,6 +46,7 @@
 
     // Methods from ::android::hardware::power::V1_1::IPower follow.
     Return<void> getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override;
+    Return<void> powerHintAsync(PowerHint hint, int32_t data) override;
 
     // Methods from ::android::hidl::base::V1_0::IBase follow.
 
diff --git a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
index 1d0d50f..dc843f4 100644
--- a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
+++ b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
@@ -23,6 +23,7 @@
 using ::android::hardware::power::V1_1::IPower;
 using ::android::hardware::power::V1_1::PowerStateSubsystem;
 using ::android::hardware::power::V1_0::Status;
+using ::android::hardware::power::V1_0::PowerHint;
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::sp;
@@ -54,6 +55,41 @@
   ASSERT_TRUE(s == Status::SUCCESS || s == Status::FILESYSTEM_ERROR);
 }
 
+// Sanity check Power::powerHintAsync on good and bad inputs.
+TEST_F(PowerHidlTest, PowerHintAsync) {
+    PowerHint badHint = static_cast<PowerHint>(0xA);
+    auto hints = {PowerHint::VSYNC,        PowerHint::INTERACTION, PowerHint::VIDEO_ENCODE,
+                  PowerHint::VIDEO_DECODE, PowerHint::LOW_POWER,   PowerHint::SUSTAINED_PERFORMANCE,
+                  PowerHint::VR_MODE,      PowerHint::LAUNCH,      badHint};
+    Return<void> ret;
+    for (auto hint : hints) {
+        ret = power->powerHintAsync(hint, 30000);
+        ASSERT_TRUE(ret.isOk());
+
+        ret = power->powerHintAsync(hint, 0);
+        ASSERT_TRUE(ret.isOk());
+    }
+
+    // Turning these hints on in different orders triggers different code paths,
+    // so iterate over possible orderings.
+    std::vector<PowerHint> hints2 = {PowerHint::LAUNCH, PowerHint::VR_MODE,
+                                     PowerHint::SUSTAINED_PERFORMANCE, PowerHint::INTERACTION};
+    auto compareHints = [](PowerHint l, PowerHint r) {
+        return static_cast<uint32_t>(l) < static_cast<uint32_t>(r);
+    };
+    std::sort(hints2.begin(), hints2.end(), compareHints);
+    do {
+        for (auto iter = hints2.begin(); iter != hints2.end(); iter++) {
+            ret = power->powerHintAsync(*iter, 0);
+            ASSERT_TRUE(ret.isOk());
+        }
+        for (auto iter = hints2.begin(); iter != hints2.end(); iter++) {
+            ret = power->powerHintAsync(*iter, 30000);
+            ASSERT_TRUE(ret.isOk());
+        }
+    } while (std::next_permutation(hints2.begin(), hints2.end(), compareHints));
+}
+
 int main(int argc, char **argv) {
   ::testing::InitGoogleTest(&argc, argv);
   int status = RUN_ALL_TESTS();