Merge changes I336c21fd,I9bd9c2a9,I33fef133

* changes:
  wifi(implementation): Fix formatting
  wifi(implementation): Dual interface support
  wifi(implementation): Use real iface names
diff --git a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
index f48a95d..d1d7f73 100644
--- a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
+++ b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
@@ -22,6 +22,7 @@
 #include <android/hardware/boot/1.0/IBootControl.h>
 
 #include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
 
 using ::android::hardware::boot::V1_0::IBootControl;
 using ::android::hardware::boot::V1_0::CommandResult;
@@ -33,12 +34,25 @@
 using std::string;
 using std::vector;
 
+// Test environment for Boot HIDL HAL.
+class BootHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static BootHidlEnvironment* Instance() {
+        static BootHidlEnvironment* instance = new BootHidlEnvironment;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IBootControl>(); }
+};
+
 // The main test class for the Boot HIDL HAL.
 class BootHidlTest : public ::testing::VtsHalHidlTargetTestBase {
  public:
   virtual void SetUp() override {
-    boot = ::testing::VtsHalHidlTargetTestBase::getService<IBootControl>();
-    ASSERT_NE(boot, nullptr);
+      boot = ::testing::VtsHalHidlTargetTestBase::getService<IBootControl>(
+          BootHidlEnvironment::Instance()->getServiceName<IBootControl>());
+      ASSERT_NE(boot, nullptr);
   }
 
   virtual void TearDown() override {}
@@ -171,8 +185,10 @@
 }
 
 int main(int argc, char **argv) {
-  ::testing::InitGoogleTest(&argc, argv);
-  int status = RUN_ALL_TESTS();
-  LOG(INFO) << "Test result = " << status;
-  return status;
+    ::testing::AddGlobalTestEnvironment(BootHidlEnvironment::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    BootHidlEnvironment::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    LOG(INFO) << "Test result = " << status;
+    return status;
 }
diff --git a/cas/1.0/default/Android.bp b/cas/1.0/default/Android.bp
index 6da5cc4..544162b 100644
--- a/cas/1.0/default/Android.bp
+++ b/cas/1.0/default/Android.bp
@@ -12,12 +12,6 @@
       "TypeConvert.cpp",
     ],
 
-    product_variables: {
-        treble: {
-            cflags: ["-DUSE_VNDBINDER"],
-        },
-    },
-
     compile_multilib: "32",
     init_rc: ["android.hardware.cas@1.0-service.rc"],
 
diff --git a/cas/1.0/default/service.cpp b/cas/1.0/default/service.cpp
index 3f1df5a..04a8ad9 100644
--- a/cas/1.0/default/service.cpp
+++ b/cas/1.0/default/service.cpp
@@ -31,11 +31,9 @@
 int main() {
     ALOGD("android.hardware.cas@1.0-service starting...");
 
-#ifdef USE_VNDBINDER
     // The CAS HAL may communicate to other vendor components via
     // /dev/vndbinder
     android::ProcessState::initWithDriver("/dev/vndbinder");
-#endif // USE_VNDBINDER
 
     configureRpcThreadpool(8, true /* callerWillJoin */);
 
diff --git a/compatibility_matrix.current.xml b/compatibility_matrix.current.xml
index 55dfab8..5a2563c 100644
--- a/compatibility_matrix.current.xml
+++ b/compatibility_matrix.current.xml
@@ -240,14 +240,6 @@
         </interface>
     </hal>
     <hal format="hidl" optional="true">
-        <name>android.hardware.radio.deprecated</name>
-        <version>1.0</version>
-        <interface>
-            <name>IOemHook</name>
-            <instance>slot1</instance>
-        </interface>
-    </hal>
-    <hal format="hidl" optional="true">
         <name>android.hardware.renderscript</name>
         <version>1.0</version>
         <interface>
diff --git a/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp b/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp
index 6ff566e..691ecca 100644
--- a/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp
+++ b/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp
@@ -21,6 +21,7 @@
 #include <android/hardware/memtrack/1.0/IMemtrack.h>
 
 #include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
 
 #include <fcntl.h>
 #include <algorithm>
@@ -38,11 +39,24 @@
 using std::vector;
 using std::count_if;
 
+// Test environment for Memtrack HIDL HAL.
+class MemtrackHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static MemtrackHidlEnvironment* Instance() {
+        static MemtrackHidlEnvironment* instance = new MemtrackHidlEnvironment;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IMemtrack>(); }
+};
+
 class MemtrackHidlTest : public ::testing::VtsHalHidlTargetTestBase {
  public:
   virtual void SetUp() override {
-    memtrack = ::testing::VtsHalHidlTargetTestBase::getService<IMemtrack>();
-    ASSERT_NE(memtrack, nullptr);
+      memtrack = ::testing::VtsHalHidlTargetTestBase::getService<IMemtrack>(
+          MemtrackHidlEnvironment::Instance()->getServiceName<IMemtrack>());
+      ASSERT_NE(memtrack, nullptr);
   }
 
   virtual void TearDown() override {}
@@ -159,8 +173,10 @@
 }
 
 int main(int argc, char **argv) {
-  ::testing::InitGoogleTest(&argc, argv);
-  int status = RUN_ALL_TESTS();
-  LOG(INFO) << "Test result = " << status;
-  return status;
+    ::testing::AddGlobalTestEnvironment(MemtrackHidlEnvironment::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    MemtrackHidlEnvironment::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    LOG(INFO) << "Test result = " << status;
+    return status;
 }
diff --git a/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
index da49dfc..999b2b4 100644
--- a/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
+++ b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
@@ -23,6 +23,7 @@
 #include <android/hardware/power/1.0/IPower.h>
 
 #include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
 
 #include <fcntl.h>
 #include <algorithm>
@@ -44,11 +45,24 @@
 #define AVAILABLE_GOVERNORS_PATH \
   "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"
 
+// Test environment for Power HIDL HAL.
+class PowerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static PowerHidlEnvironment* Instance() {
+        static PowerHidlEnvironment* instance = new PowerHidlEnvironment;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IPower>(); }
+};
+
 class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
  public:
   virtual void SetUp() override {
-    power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>();
-    ASSERT_NE(power, nullptr);
+      power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
+          PowerHidlEnvironment::Instance()->getServiceName<IPower>());
+      ASSERT_NE(power, nullptr);
   }
 
   virtual void TearDown() override {}
@@ -178,8 +192,10 @@
 }
 
 int main(int argc, char **argv) {
-  ::testing::InitGoogleTest(&argc, argv);
-  int status = RUN_ALL_TESTS();
-  LOG(INFO) << "Test result = " << status;
-  return status;
+    ::testing::AddGlobalTestEnvironment(PowerHidlEnvironment::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    PowerHidlEnvironment::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    LOG(INFO) << "Test result = " << status;
+    return status;
 }
diff --git a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
index dc843f4..4427b15 100644
--- a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
+++ b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
@@ -19,6 +19,7 @@
 #include <android/hardware/power/1.1/IPower.h>
 
 #include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
 
 using ::android::hardware::power::V1_1::IPower;
 using ::android::hardware::power::V1_1::PowerStateSubsystem;
@@ -28,11 +29,24 @@
 using ::android::hardware::Return;
 using ::android::sp;
 
+// Test environment for Power HIDL HAL.
+class PowerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static PowerHidlEnvironment* Instance() {
+        static PowerHidlEnvironment* instance = new PowerHidlEnvironment;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IPower>(); }
+};
+
 class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
  public:
   virtual void SetUp() override {
-    power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>();
-    ASSERT_NE(power, nullptr);
+      power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
+          PowerHidlEnvironment::Instance()->getServiceName<IPower>());
+      ASSERT_NE(power, nullptr);
   }
 
   virtual void TearDown() override {}
@@ -91,8 +105,10 @@
 }
 
 int main(int argc, char **argv) {
-  ::testing::InitGoogleTest(&argc, argv);
-  int status = RUN_ALL_TESTS();
-  LOG(INFO) << "Test result = " << status;
-  return status;
+    ::testing::AddGlobalTestEnvironment(PowerHidlEnvironment::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    PowerHidlEnvironment::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    LOG(INFO) << "Test result = " << status;
+    return status;
 }
diff --git a/power/1.2/Android.bp b/power/1.2/Android.bp
new file mode 100644
index 0000000..0eb73e7
--- /dev/null
+++ b/power/1.2/Android.bp
@@ -0,0 +1,23 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.power@1.2",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+        "IPower.hal",
+    ],
+    interfaces: [
+        "android.hardware.power@1.0",
+        "android.hardware.power@1.1",
+        "android.hidl.base@1.0",
+    ],
+    types: [
+        "PowerHint",
+    ],
+    gen_java: true,
+}
+
diff --git a/power/1.2/IPower.hal b/power/1.2/IPower.hal
new file mode 100644
index 0000000..1c2c7b8
--- /dev/null
+++ b/power/1.2/IPower.hal
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.power@1.2;
+
+import @1.1::IPower;
+
+interface IPower extends @1.1::IPower {
+    /**
+     * 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_1_2(PowerHint hint, int32_t data);
+};
diff --git a/power/1.2/types.hal b/power/1.2/types.hal
new file mode 100644
index 0000000..f7a6cf6
--- /dev/null
+++ b/power/1.2/types.hal
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.power@1.2;
+
+import @1.0::PowerHint;
+
+/** Power hint identifiers passed to powerHintAsync_1_2() */
+enum PowerHint : @1.0::PowerHint {
+   /**
+    * This hint indicates that audio stream is being started. Can be used
+    * for device specific optimizations during starting audio stream. The
+    * data parameter is non-zero when stream starts and zero when audio
+    * stream setup is complete.
+    */
+    AUDIO_STREAMING,
+
+   /**
+    * This hint indicates that low latency audio is active. Can be used
+    * for device specific optimizations towards low latency audio. The
+    * data parameter is non-zero when low latency audio starts and
+    * zero when ends.
+    */
+    AUDIO_LOW_LATENCY,
+
+   /**
+    * These hint indicates that camera is being launched. Can be used
+    * for device specific optimizations during camera launch. The data
+    * parameter is non-zero when camera launch starts and zero when launch
+    * is complete.
+    */
+    CAMERA_LAUNCH,
+
+   /**
+    * This hint indicates that camera stream is being started. Can be used
+    * for device specific optimizations during starting camera stream. The
+    * data parameter is non-zero when stream starts and zero when ends.
+    */
+    CAMERA_STREAMING,
+
+   /**
+    * This hint indicates that camera shot is being taken. Can be used
+    * for device specific optimizations during taking camera shot. The
+    * data parameter is non-zero when camera shot starts and zero when ends.
+    */
+    CAMERA_SHOT,
+};
diff --git a/power/1.2/vts/functional/Android.bp b/power/1.2/vts/functional/Android.bp
new file mode 100644
index 0000000..d615e85
--- /dev/null
+++ b/power/1.2/vts/functional/Android.bp
@@ -0,0 +1,26 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_test {
+    name: "VtsHalPowerV1_2TargetTest",
+    defaults: ["VtsHalTargetTestDefaults"],
+    srcs: ["VtsHalPowerV1_2TargetTest.cpp"],
+    static_libs: [
+        "android.hardware.power@1.0",
+        "android.hardware.power@1.1",
+        "android.hardware.power@1.2",
+    ],
+}
diff --git a/power/1.2/vts/functional/VtsHalPowerV1_2TargetTest.cpp b/power/1.2/vts/functional/VtsHalPowerV1_2TargetTest.cpp
new file mode 100644
index 0000000..5e92997
--- /dev/null
+++ b/power/1.2/vts/functional/VtsHalPowerV1_2TargetTest.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "power_hidl_hal_test"
+#include <android-base/logging.h>
+#include <android/hardware/power/1.2/IPower.h>
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
+
+using ::android::sp;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::power::V1_2::IPower;
+using ::android::hardware::power::V1_2::PowerHint;
+
+// Test environment for Power HIDL HAL.
+class PowerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static PowerHidlEnvironment* Instance() {
+        static PowerHidlEnvironment* instance = new PowerHidlEnvironment;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IPower>(); }
+};
+
+class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    virtual void SetUp() override {
+        power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
+            PowerHidlEnvironment::Instance()->getServiceName<IPower>());
+        ASSERT_NE(power, nullptr);
+    }
+
+    sp<IPower> power;
+};
+
+// Sanity check Power::PowerHintAsync_1_2 on good and bad inputs.
+TEST_F(PowerHidlTest, PowerHintAsync_1_2) {
+    std::vector<PowerHint> hints;
+    for (uint32_t i = static_cast<uint32_t>(PowerHint::VSYNC);
+         i <= static_cast<uint32_t>(PowerHint::CAMERA_SHOT); ++i) {
+        hints.emplace_back(static_cast<PowerHint>(i));
+    }
+    PowerHint badHint = static_cast<PowerHint>(0xFF);
+    hints.emplace_back(badHint);
+
+    Return<void> ret;
+    for (auto& hint : hints) {
+        ret = power->powerHintAsync_1_2(hint, 30000);
+        ASSERT_TRUE(ret.isOk());
+
+        ret = power->powerHintAsync_1_2(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::AUDIO_STREAMING, PowerHint::CAMERA_LAUNCH,
+                                     PowerHint::CAMERA_STREAMING, PowerHint::CAMERA_SHOT};
+    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_1_2(*iter, 0);
+            ASSERT_TRUE(ret.isOk());
+        }
+        for (auto iter = hints2.begin(); iter != hints2.end(); iter++) {
+            ret = power->powerHintAsync_1_2(*iter, 30000);
+            ASSERT_TRUE(ret.isOk());
+        }
+    } while (std::next_permutation(hints2.begin(), hints2.end(), compareHints));
+}
+
+int main(int argc, char** argv) {
+    ::testing::AddGlobalTestEnvironment(PowerHidlEnvironment::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    PowerHidlEnvironment::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    LOG(INFO) << "Test result = " << status;
+    return status;
+}