Merge "Audio HAL: More generalization for types imports"
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
index 7909ac1..a5c8eb8 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
@@ -37,6 +37,7 @@
 constexpr int DOOR_2_LEFT = (int)VehicleAreaDoor::ROW_2_LEFT;
 constexpr int DOOR_2_RIGHT = (int)VehicleAreaDoor::ROW_2_RIGHT;
 constexpr int WINDOW_1_LEFT = (int)VehicleAreaWindow::ROW_1_LEFT;
+constexpr int WINDOW_1_RIGHT = (int)VehicleAreaWindow::ROW_1_RIGHT;
 constexpr int WINDOW_2_LEFT = (int)VehicleAreaWindow::ROW_2_LEFT;
 constexpr int WINDOW_2_RIGHT = (int)VehicleAreaWindow::ROW_2_RIGHT;
 constexpr int FAN_DIRECTION_FACE = (int)VehicleHvacFanDirection::FACE;
@@ -379,11 +380,8 @@
                 .areaConfigs = {VehicleAreaConfig{.areaId = HVAC_ALL}},
                 // TODO(bryaneyler): Ideally, this is generated dynamically from
                 // kHvacPowerProperties.
-                .configArray =
-                    {
-                        toInt(VehicleProperty::HVAC_FAN_SPEED),
-                        toInt(VehicleProperty::HVAC_FAN_DIRECTION)
-                    }},
+                .configArray = {toInt(VehicleProperty::HVAC_FAN_SPEED),
+                                toInt(VehicleProperty::HVAC_FAN_DIRECTION)}},
      .initialValue = {.int32Values = {1}}},
 
     {
@@ -575,16 +573,45 @@
                 .access = VehiclePropertyAccess::READ_WRITE,
                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                 .areaConfigs = {VehicleAreaConfig{.areaId = DOOR_1_LEFT},
-                                VehicleAreaConfig{.areaId = DOOR_1_RIGHT}}},
+                                VehicleAreaConfig{.areaId = DOOR_1_RIGHT},
+                                VehicleAreaConfig{.areaId = DOOR_2_LEFT},
+                                VehicleAreaConfig{.areaId = DOOR_2_RIGHT}}},
      .initialAreaValues = {{DOOR_1_LEFT, {.int32Values = {1}}},
-                           {DOOR_1_RIGHT, {.int32Values = {1}}}}},
+                           {DOOR_1_RIGHT, {.int32Values = {1}}},
+                           {DOOR_2_LEFT, {.int32Values = {1}}},
+                           {DOOR_2_RIGHT, {.int32Values = {1}}}}},
+
+    {.config = {.prop = toInt(VehicleProperty::DOOR_POS),
+                .access = VehiclePropertyAccess::READ_WRITE,
+                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
+                .areaConfigs = {VehicleAreaConfig{.areaId = DOOR_1_LEFT},
+                                VehicleAreaConfig{.areaId = DOOR_1_RIGHT},
+                                VehicleAreaConfig{.areaId = DOOR_2_LEFT},
+                                VehicleAreaConfig{.areaId = DOOR_2_RIGHT}}},
+     .initialAreaValues = {{DOOR_1_LEFT, {.int32Values = {0}}},
+                           {DOOR_1_RIGHT, {.int32Values = {0}}},
+                           {DOOR_2_LEFT, {.int32Values = {0}}},
+                           {DOOR_2_RIGHT, {.int32Values = {0}}}}},
 
     {.config = {.prop = toInt(VehicleProperty::WINDOW_LOCK),
                 .access = VehiclePropertyAccess::READ_WRITE,
                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
-                .areaConfigs = {VehicleAreaConfig{.areaId = WINDOW_1_LEFT | WINDOW_2_LEFT |
+                .areaConfigs = {VehicleAreaConfig{.areaId = WINDOW_1_RIGHT | WINDOW_2_LEFT |
                                                             WINDOW_2_RIGHT}}},
-     .initialAreaValues = {{WINDOW_1_LEFT | WINDOW_2_LEFT | WINDOW_2_RIGHT, {.int32Values = {0}}}}},
+     .initialAreaValues = {{WINDOW_1_RIGHT | WINDOW_2_LEFT | WINDOW_2_RIGHT,
+                            {.int32Values = {0}}}}},
+
+    {.config = {.prop = toInt(VehicleProperty::WINDOW_POS),
+                .access = VehiclePropertyAccess::READ_WRITE,
+                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
+                .areaConfigs = {VehicleAreaConfig{.areaId = WINDOW_1_LEFT},
+                                VehicleAreaConfig{.areaId = WINDOW_1_RIGHT},
+                                VehicleAreaConfig{.areaId = WINDOW_2_LEFT},
+                                VehicleAreaConfig{.areaId = WINDOW_2_RIGHT}}},
+     .initialAreaValues = {{WINDOW_1_LEFT, {.int32Values = {0}}},
+                           {WINDOW_1_RIGHT, {.int32Values = {0}}},
+                           {WINDOW_2_LEFT, {.int32Values = {0}}},
+                           {WINDOW_2_RIGHT, {.int32Values = {0}}}}},
 
     {.config =
          {
diff --git a/camera/device/3.2/ICameraDeviceSession.hal b/camera/device/3.2/ICameraDeviceSession.hal
index 225e52b..278be5d 100644
--- a/camera/device/3.2/ICameraDeviceSession.hal
+++ b/camera/device/3.2/ICameraDeviceSession.hal
@@ -91,11 +91,11 @@
      * later configureStreams() call by the framework, and all the gralloc
      * buffers for it must be freed after the configureStreams() call returns.
      *
-     * If the stream is new, the maxBuffer field of the stream structure must be
-     * set to 0. The usage must be set to the consumer usage flags. The HAL
-     * device must set these fields in the configureStreams() return values.
-     * These fields are then used by the framework and the platform gralloc
-     * module to allocate the gralloc buffers for each stream.
+     * If the stream is new, the client must set the consumer usage flags in
+     * requestedConfiguration. Upon return, the HAL device must set producerUsage,
+     * maxBuffers, and other fields in the configureStreams() return values. These
+     * fields are then used by the framework and the platform gralloc module to
+     * allocate the gralloc buffers for each stream.
      *
      * Newly allocated buffers may be included in a capture request at any time
      * by the framework. Once a gralloc buffer is returned to the framework
diff --git a/current.txt b/current.txt
index e19fb63..5d50629 100644
--- a/current.txt
+++ b/current.txt
@@ -386,7 +386,7 @@
 
 # ABI preserving changes to HALs during Android Q
 2a55e224aa9bc62c0387cd85ad3c97e33f0c33a4e1489cbae86b2523e6f9df35 android.hardware.camera.device@3.2::ICameraDevice
-f61b616732d8f374e030f90575d7eba3ecc99d209a05b945949ba892bcb81e1d android.hardware.camera.device@3.2::ICameraDeviceSession
+8caf9104dc6885852c0b117d853dd93f6d4b61a0a365138295eb8bcd41b36423 android.hardware.camera.device@3.2::ICameraDeviceSession
 684702a60deef03a1e8093961dc0a18c555c857ad5a77ba7340b0635ae01eb70 android.hardware.camera.device@3.4::ICameraDeviceSession
 291638a1b6d4e63283e9e722ab5049d9351717ffa2b66162124f84d1aa7c2835 android.hardware.camera.metadata@3.2::types
 dd2436f251a90f3e5e7ed773b1aeae21e381b00ae26b10ebe3a1001c894e5980 android.hardware.camera.metadata@3.3::types
diff --git a/wifi/1.3/IWifiStaIface.hal b/wifi/1.3/IWifiStaIface.hal
index 0dc6128..81c0c38 100644
--- a/wifi/1.3/IWifiStaIface.hal
+++ b/wifi/1.3/IWifiStaIface.hal
@@ -17,6 +17,7 @@
 package android.hardware.wifi@1.3;
 
 import @1.0::WifiStatus;
+import @1.0::MacAddress;
 import @1.2::IWifiStaIface;
 
 /**
@@ -41,4 +42,15 @@
      * @return stats Instance of |LinkLayerStats|.
      */
     getLinkLayerStats_1_3() generates (WifiStatus status, StaLinkLayerStats stats);
+
+    /**
+     * Gets the factory MAC address of the Sta Interface
+     * @return status WifiStatus of the operation
+     *         Possible status codes:
+     *         |WifiStatusCode.SUCCESS|,
+     *         |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
+     *         |WifiStatusCode.ERROR_UNKNOWN|
+     * @return mac Factory MAC address of the Sta Interface
+     */
+     getFactoryMacAddress() generates (WifiStatus status, MacAddress mac);
 };
diff --git a/wifi/1.3/default/wifi_sta_iface.cpp b/wifi/1.3/default/wifi_sta_iface.cpp
index b0fa1ae..f7157a3 100644
--- a/wifi/1.3/default/wifi_sta_iface.cpp
+++ b/wifi/1.3/default/wifi_sta_iface.cpp
@@ -255,6 +255,13 @@
                            mac);
 }
 
+Return<void> WifiStaIface::getFactoryMacAddress(
+    getFactoryMacAddress_cb hidl_status_cb) {
+    return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+                           &WifiStaIface::getFactoryMacAddressInternal,
+                           hidl_status_cb);
+}
+
 std::pair<WifiStatus, std::string> WifiStaIface::getNameInternal() {
     return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
 }
@@ -633,6 +640,13 @@
     return createWifiStatus(WifiStatusCode::SUCCESS);
 }
 
+std::pair<WifiStatus, std::array<uint8_t, 6>>
+WifiStaIface::getFactoryMacAddressInternal() {
+    std::array<uint8_t, 6> mac =
+        iface_tool_.GetFactoryMacAddress(ifname_.c_str());
+    return {createWifiStatus(WifiStatusCode::SUCCESS), mac};
+}
+
 }  // namespace implementation
 }  // namespace V1_3
 }  // namespace wifi
diff --git a/wifi/1.3/default/wifi_sta_iface.h b/wifi/1.3/default/wifi_sta_iface.h
index bc3090f..69cb82a 100644
--- a/wifi/1.3/default/wifi_sta_iface.h
+++ b/wifi/1.3/default/wifi_sta_iface.h
@@ -109,6 +109,8 @@
         getDebugRxPacketFates_cb hidl_status_cb) override;
     Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac,
                                setMacAddress_cb hidl_status_cb) override;
+    Return<void> getFactoryMacAddress(
+        getFactoryMacAddress_cb hidl_status_cb) override;
 
    private:
     // Corresponding worker functions for the HIDL methods.
@@ -155,6 +157,8 @@
     std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
     getDebugRxPacketFatesInternal();
     WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
+    std::pair<WifiStatus, std::array<uint8_t, 6>>
+    getFactoryMacAddressInternal();
 
     std::string ifname_;
     std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
diff --git a/wifi/1.3/vts/functional/Android.bp b/wifi/1.3/vts/functional/Android.bp
index f5a0999..53c8f08 100644
--- a/wifi/1.3/vts/functional/Android.bp
+++ b/wifi/1.3/vts/functional/Android.bp
@@ -20,6 +20,7 @@
     srcs: [
         "VtsHalWifiV1_3TargetTest.cpp",
         "wifi_chip_hidl_test.cpp",
+        "wifi_sta_iface_hidl_test.cpp",
     ],
     static_libs: [
         "VtsHalWifiV1_0TargetTestUtil",
diff --git a/wifi/1.3/vts/functional/VtsHalWifiV1_3TargetTest.cpp b/wifi/1.3/vts/functional/VtsHalWifiV1_3TargetTest.cpp
index b410a48..faf426e 100644
--- a/wifi/1.3/vts/functional/VtsHalWifiV1_3TargetTest.cpp
+++ b/wifi/1.3/vts/functional/VtsHalWifiV1_3TargetTest.cpp
@@ -19,6 +19,8 @@
 
 #include "wifi_hidl_test_utils.h"
 
+using ::android::hardware::wifi::V1_3::IWifi;
+
 // Test environment for Wifi HIDL HAL.
 class WifiHidlEnvironment_1_3 : public WifiHidlEnvironment {
    public:
diff --git a/wifi/1.3/vts/functional/wifi_sta_iface_hidl_test.cpp b/wifi/1.3/vts/functional/wifi_sta_iface_hidl_test.cpp
new file mode 100644
index 0000000..e195ade
--- /dev/null
+++ b/wifi/1.3/vts/functional/wifi_sta_iface_hidl_test.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Staache 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.
+ */
+
+#include <numeric>
+#include <vector>
+
+#include <android-base/logging.h>
+
+#include <android/hardware/wifi/1.3/IWifiStaIface.h>
+
+#include <VtsHalHidlTargetTestBase.h>
+
+#include "wifi_hidl_call_util.h"
+#include "wifi_hidl_test_utils.h"
+
+using ::android::sp;
+using ::android::hardware::wifi::V1_0::WifiStatusCode;
+using ::android::hardware::wifi::V1_3::IWifiStaIface;
+
+/**
+ * Fixture to use for all STA Iface HIDL interface tests.
+ */
+class WifiStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    virtual void SetUp() override {
+        wifi_sta_iface_ = IWifiStaIface::castFrom(getWifiStaIface());
+        ASSERT_NE(nullptr, wifi_sta_iface_.get());
+    }
+
+    virtual void TearDown() override { stopWifi(); }
+
+   protected:
+    sp<IWifiStaIface> wifi_sta_iface_;
+};
+
+/*
+ * GetFactoryMacAddress:
+ * Ensures that calls to get factory MAC address will retrieve a non-zero MAC
+ * and return a success status code.
+ */
+TEST_F(WifiStaIfaceHidlTest, GetFactoryMacAddress) {
+    const auto& status_and_mac =
+        HIDL_INVOKE(wifi_sta_iface_, getFactoryMacAddress);
+    EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_mac.first.code);
+    const int num_elements = sizeof(status_and_mac.second) / sizeof(uint8_t);
+    EXPECT_EQ(6, num_elements);
+    for (int i = 0; i < num_elements; i++) {
+        EXPECT_NE(0, status_and_mac.second[i]);
+    }
+}