Merge "Update neuralnetworks HAL to allow collecting execution duration."
diff --git a/audio/5.0/config/api/current.txt b/audio/5.0/config/api/current.txt
index 822237e..17f38c1 100644
--- a/audio/5.0/config/api/current.txt
+++ b/audio/5.0/config/api/current.txt
@@ -20,8 +20,10 @@
     enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_COMMUNICATION;
     enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_DEFAULT;
     enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_ECHO_REFERENCE;
     enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_FM_TUNER;
     enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_HDMI;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_HDMI_ARC;
     enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_IP;
     enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_LINE;
     enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_LOOPBACK;
@@ -91,6 +93,10 @@
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_ERLC;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_HE_V1;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_HE_V2;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LATM;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LATM_HE_V1;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LATM_HE_V2;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LATM_LC;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LC;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LD;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LTP;
@@ -106,7 +112,9 @@
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AMR_WB_PLUS;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_APE;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_APTX;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_APTX_ADAPTIVE;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_APTX_HD;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_CELT;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_DOLBY_TRUEHD;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_DSD;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_DTS;
@@ -122,6 +130,8 @@
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_HE_AAC_V2;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_IEC61937;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_LDAC;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_LHDC;
+    enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_LHDC_LL;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_MAT_1_0;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_MAT_2_0;
     enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_MAT_2_1;
diff --git a/audio/5.0/config/audio_policy_configuration.xsd b/audio/5.0/config/audio_policy_configuration.xsd
index efe93b3..ee3a437 100644
--- a/audio/5.0/config/audio_policy_configuration.xsd
+++ b/audio/5.0/config/audio_policy_configuration.xsd
@@ -277,6 +277,8 @@
             <xs:enumeration value="AUDIO_DEVICE_IN_PROXY"/>
             <xs:enumeration value="AUDIO_DEVICE_IN_USB_HEADSET"/>
             <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_BLE"/>
+            <xs:enumeration value="AUDIO_DEVICE_IN_HDMI_ARC"/>
+            <xs:enumeration value="AUDIO_DEVICE_IN_ECHO_REFERENCE"/>
             <xs:enumeration value="AUDIO_DEVICE_IN_DEFAULT"/>
             <xs:enumeration value="AUDIO_DEVICE_IN_STUB"/>
         </xs:restriction>
@@ -364,6 +366,14 @@
             <xs:enumeration value="AUDIO_FORMAT_MAT_2_1"/>
             <xs:enumeration value="AUDIO_FORMAT_AAC_XHE"/>
             <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_XHE"/>
+            <xs:enumeration value="AUDIO_FORMAT_AAC_LATM"/>
+            <xs:enumeration value="AUDIO_FORMAT_AAC_LATM_LC"/>
+            <xs:enumeration value="AUDIO_FORMAT_AAC_LATM_HE_V1"/>
+            <xs:enumeration value="AUDIO_FORMAT_AAC_LATM_HE_V2"/>
+            <xs:enumeration value="AUDIO_FORMAT_CELT"/>
+            <xs:enumeration value="AUDIO_FORMAT_APTX_ADAPTIVE"/>
+            <xs:enumeration value="AUDIO_FORMAT_LHDC"/>
+            <xs:enumeration value="AUDIO_FORMAT_LHDC_LL"/>
         </xs:restriction>
     </xs:simpleType>
     <xs:simpleType name="extendableAudioFormat">
diff --git a/audio/common/5.0/types.hal b/audio/common/5.0/types.hal
index b4e9470..ffe4506 100644
--- a/audio/common/5.0/types.hal
+++ b/audio/common/5.0/types.hal
@@ -235,6 +235,12 @@
     LDAC                = 0x23000000UL,
     /** Dolby Metadata-enhanced Audio Transmission */
     MAT                 = 0x24000000UL,
+    AAC_LATM            = 0x25000000UL,
+    CELT                = 0x26000000UL,
+    APTX_ADAPTIVE       = 0x27000000UL,
+    LHDC                = 0x28000000UL,
+    LHDC_LL             = 0x29000000UL,
+
     /** Deprecated */
     MAIN_MASK           = 0xFF000000UL,
     SUB_MASK            = 0x00FFFFFFUL,
@@ -306,6 +312,9 @@
     MAT_1_0             = (MAT | MAT_SUB_1_0),
     MAT_2_0             = (MAT | MAT_SUB_2_0),
     MAT_2_1             = (MAT | MAT_SUB_2_1),
+    AAC_LATM_LC         = (AAC_LATM | AAC_SUB_LC),
+    AAC_LATM_HE_V1      = (AAC_LATM | AAC_SUB_HE_V1),
+    AAC_LATM_HE_V2      = (AAC_LATM | AAC_SUB_HE_V2),
 };
 
 /**
diff --git a/audio/effect/2.0/xml/audio_effects_conf.xsd b/audio/effect/2.0/xml/audio_effects_conf.xsd
index df281b3..b97b847 100644
--- a/audio/effect/2.0/xml/audio_effects_conf.xsd
+++ b/audio/effect/2.0/xml/audio_effects_conf.xsd
@@ -39,6 +39,7 @@
       <xs:enumeration value="voice_recognition"/>
       <xs:enumeration value="voice_communication"/>
       <xs:enumeration value="unprocessed"/>
+      <xs:enumeration value="voice_performance"/>
     </xs:restriction>
   </xs:simpleType>
   <xs:simpleType name="streamOutputType">
diff --git a/audio/effect/5.0/xml/api/current.txt b/audio/effect/5.0/xml/api/current.txt
index 4a7f88b..473bb10 100644
--- a/audio/effect/5.0/xml/api/current.txt
+++ b/audio/effect/5.0/xml/api/current.txt
@@ -74,6 +74,7 @@
     enum_constant public static final audio.effects.V5_0.StreamInputType voice_call;
     enum_constant public static final audio.effects.V5_0.StreamInputType voice_communication;
     enum_constant public static final audio.effects.V5_0.StreamInputType voice_downlink;
+    enum_constant public static final audio.effects.V5_0.StreamInputType voice_performance;
     enum_constant public static final audio.effects.V5_0.StreamInputType voice_recognition;
     enum_constant public static final audio.effects.V5_0.StreamInputType voice_uplink;
   }
diff --git a/camera/metadata/3.4/types.hal b/camera/metadata/3.4/types.hal
index 61a399e..28c56c8 100644
--- a/camera/metadata/3.4/types.hal
+++ b/camera/metadata/3.4/types.hal
@@ -75,6 +75,14 @@
 
     ANDROID_DEPTH_END_3_4,
 
+    /** android.logicalMultiCamera.activePhysicalId [dynamic, byte, public]
+     *
+     * <p>String containing the ID of the underlying active physical camera.</p>
+     */
+    ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID = android.hardware.camera.metadata@3.3::CameraMetadataTag:ANDROID_LOGICAL_MULTI_CAMERA_END_3_3,
+
+    ANDROID_LOGICAL_MULTI_CAMERA_END_3_4,
+
 };
 
 /*
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index c98e328..1556c08 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -114,6 +114,8 @@
 using ::android::hardware::camera::device::V1_0::FrameCallbackFlag;
 using ::android::hardware::camera::device::V1_0::HandleTimestampMessage;
 using ::android::hardware::camera::metadata::V3_4::CameraMetadataEnumAndroidSensorInfoColorFilterArrangement;
+using ::android::hardware::camera::metadata::V3_4::CameraMetadataTag;
+using ::android::hardware::camera::device::V3_4::PhysicalCameraMetadata;
 using ::android::hardware::MessageQueue;
 using ::android::hardware::kSynchronizedReadWrite;
 using ::android::hidl::allocator::V1_0::IAllocator;
@@ -587,8 +589,8 @@
     };
 
     struct DeviceCb : public V3_5::ICameraDeviceCallback {
-        DeviceCb(CameraHidlTest *parent, bool checkMonochromeResult) : mParent(parent),
-                mCheckMonochromeResult(checkMonochromeResult) {}
+        DeviceCb(CameraHidlTest *parent, int deviceVersion, const camera_metadata_t *staticMeta) :
+                mParent(parent), mDeviceVersion(deviceVersion), mStaticMetadata(staticMeta) {}
 
         Return<void> processCaptureResult_3_4(
                 const hidl_vec<V3_4::CaptureResult>& results) override;
@@ -607,10 +609,12 @@
         void waitForBuffersReturned();
 
      private:
-        bool processCaptureResultLocked(const CaptureResult& results);
+        bool processCaptureResultLocked(const CaptureResult& results,
+                hidl_vec<PhysicalCameraMetadata> physicalCameraMetadata);
 
         CameraHidlTest *mParent; // Parent object
-        bool mCheckMonochromeResult;
+        int mDeviceVersion;
+        const camera_metadata_t *mStaticMetadata;
         bool hasOutstandingBuffersLocked();
 
         /* members for requestStreamBuffers() and returnStreamBuffers()*/
@@ -755,6 +759,8 @@
     void verifyStreamCombination(sp<device::V3_5::ICameraDevice> cameraDevice3_5,
             const ::android::hardware::camera::device::V3_4::StreamConfiguration &config3_4,
             bool expectedStatus);
+    void verifyLogicalCameraResult(const camera_metadata_t* staticMetadata,
+            const ::android::hardware::camera::common::V1_0::helper::CameraMetadata& resultMetadata);
 
     void verifyBuffersReturned(sp<device::V3_2::ICameraDeviceSession> session,
             int deviceVerison, int32_t streamId, sp<DeviceCb> cb,
@@ -1008,7 +1014,7 @@
     bool notify = false;
     std::unique_lock<std::mutex> l(mParent->mLock);
     for (size_t i = 0 ; i < results.size(); i++) {
-        notify = processCaptureResultLocked(results[i].v3_2);
+        notify = processCaptureResultLocked(results[i].v3_2, results[i].physicalCameraMetadata);
     }
 
     l.unlock();
@@ -1027,8 +1033,9 @@
 
     bool notify = false;
     std::unique_lock<std::mutex> l(mParent->mLock);
+    ::android::hardware::hidl_vec<PhysicalCameraMetadata> noPhysMetadata;
     for (size_t i = 0 ; i < results.size(); i++) {
-        notify = processCaptureResultLocked(results[i]);
+        notify = processCaptureResultLocked(results[i], noPhysMetadata);
     }
 
     l.unlock();
@@ -1039,7 +1046,8 @@
     return Void();
 }
 
-bool CameraHidlTest::DeviceCb::processCaptureResultLocked(const CaptureResult& results) {
+bool CameraHidlTest::DeviceCb::processCaptureResultLocked(const CaptureResult& results,
+        hidl_vec<PhysicalCameraMetadata> physicalCameraMetadata) {
     bool notify = false;
     uint32_t frameNumber = results.frameNumber;
 
@@ -1080,6 +1088,20 @@
             ADD_FAILURE();
             return notify;
         }
+
+        std::vector<::android::hardware::camera::device::V3_2::CameraMetadata> physResultMetadata;
+        physResultMetadata.resize(physicalCameraMetadata.size());
+        for (size_t i = 0; i < physicalCameraMetadata.size(); i++) {
+            physResultMetadata[i].resize(physicalCameraMetadata[i].fmqMetadataSize);
+            if (!request->resultQueue->read(physResultMetadata[i].data(),
+                    physicalCameraMetadata[i].fmqMetadataSize)) {
+                ALOGE("%s: Frame %d: Cannot read physical camera metadata from fmq,"
+                        "size = %" PRIu64, __func__, frameNumber,
+                        physicalCameraMetadata[i].fmqMetadataSize);
+                ADD_FAILURE();
+                return notify;
+            }
+        }
         resultSize = resultMetadata.size();
     } else if (results.result.size() > 0) {
         resultMetadata.setToExternal(const_cast<uint8_t *>(
@@ -1137,8 +1159,20 @@
         request->collectedResult.sort();
 
         // Verify final result metadata
-        if (mCheckMonochromeResult) {
-            mParent->verifyMonochromeCameraResult(request->collectedResult);
+        bool isAtLeast_3_5 = mDeviceVersion >= CAMERA_DEVICE_API_VERSION_3_5;
+        if (isAtLeast_3_5) {
+            bool isMonochrome = Status::OK ==
+                    CameraHidlTest::isMonochromeCamera(mStaticMetadata);
+            if (isMonochrome) {
+                mParent->verifyMonochromeCameraResult(request->collectedResult);
+            }
+
+            // Verify logical camera result metadata
+            bool isLogicalCamera =
+                    Status::OK == CameraHidlTest::isLogicalMultiCamera(mStaticMetadata);
+            if (isLogicalCamera) {
+                mParent->verifyLogicalCameraResult(mStaticMetadata, request->collectedResult);
+            }
         }
     }
 
@@ -5058,7 +5092,7 @@
         ASSERT_EQ(Status::OK, s);
         staticMeta = clone_camera_metadata(
                 reinterpret_cast<const camera_metadata_t*>(metadata.data()));
-         ASSERT_NE(nullptr, staticMeta);
+        ASSERT_NE(nullptr, staticMeta);
     });
     ASSERT_TRUE(ret.isOk());
 
@@ -5070,9 +5104,7 @@
         *supportsPartialResults = (*partialResultCount > 1);
     }
 
-    bool checkMonochromeResultTags = Status::OK == isMonochromeCamera(staticMeta) &&
-            deviceVersion >= CAMERA_DEVICE_API_VERSION_3_5;
-    sp<DeviceCb> cb = new DeviceCb(this, checkMonochromeResultTags);
+    sp<DeviceCb> cb = new DeviceCb(this, deviceVersion, staticMeta);
     sp<ICameraDeviceSession> session;
     ret = device3_x->open(
         cb,
@@ -5210,9 +5242,7 @@
         *supportsPartialResults = (*partialResultCount > 1);
     }
 
-    bool checkMonochromeResultTags = Status::OK == isMonochromeCamera(staticMeta) &&
-            deviceVersion >= CAMERA_DEVICE_API_VERSION_3_5;
-    sp<DeviceCb> cb = new DeviceCb(this, checkMonochromeResultTags);
+    sp<DeviceCb> cb = new DeviceCb(this, deviceVersion, staticMeta);
     ret = device3_x->open(
         cb,
         [&](auto status, const auto& newSession) {
@@ -5441,6 +5471,22 @@
         });
         ASSERT_TRUE(ret.isOk());
     }
+
+    // Make sure ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID is available in
+    // result keys.
+    if (deviceVersion >= CAMERA_DEVICE_API_VERSION_3_5) {
+        camera_metadata_ro_entry entry;
+        int retcode = find_camera_metadata_ro_entry(metadata,
+                ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, &entry);
+        if ((0 == retcode) && (entry.count > 0)) {
+                ASSERT_NE(std::find(entry.data.i32, entry.data.i32 + entry.count,
+                    static_cast<int32_t>(
+                            CameraMetadataTag::ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID)),
+                    entry.data.i32 + entry.count);
+        } else {
+            ADD_FAILURE() << "Get camera availableResultKeys failed!";
+        }
+    }
 }
 
 void CameraHidlTest::verifyCameraCharacteristics(Status status, const CameraMetadata& chars) {
@@ -5649,6 +5695,24 @@
     cb->waitForBuffersReturned();
 }
 
+void CameraHidlTest::verifyLogicalCameraResult(const camera_metadata_t* staticMetadata,
+        const ::android::hardware::camera::common::V1_0::helper::CameraMetadata& resultMetadata) {
+    std::unordered_set<std::string> physicalIds;
+    Status rc = getPhysicalCameraIds(staticMetadata, &physicalIds);
+    ASSERT_TRUE(Status::OK == rc);
+    ASSERT_TRUE(physicalIds.size() > 1);
+
+    camera_metadata_ro_entry entry;
+    // Check mainPhysicalId
+    entry = resultMetadata.find(ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID);
+    if (entry.count > 0) {
+        std::string mainPhysicalId(reinterpret_cast<const char *>(entry.data.u8));
+        ASSERT_NE(physicalIds.find(mainPhysicalId), physicalIds.end());
+    } else {
+        ADD_FAILURE() << "Get LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID failed!";
+    }
+}
+
 // Open a device session with empty callbacks and return static metadata.
 void CameraHidlTest::openEmptyDeviceSession(const std::string &name, sp<ICameraProvider> provider,
         sp<ICameraDeviceSession> *session /*out*/, camera_metadata_t **staticMeta /*out*/,
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index 0dd174a..94ffe80 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -443,7 +443,7 @@
     </hal>
     <hal format="hidl" optional="true">
         <name>android.hardware.usb</name>
-        <version>1.0-1</version>
+        <version>1.0-2</version>
         <interface>
             <name>IUsb</name>
             <instance>default</instance>
diff --git a/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc1Hal.h b/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc1Hal.h
index 08d604e..c9836e5 100644
--- a/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc1Hal.h
+++ b/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc1Hal.h
@@ -28,7 +28,7 @@
 
 using V2_0::BufferDescriptor;
 using V2_0::Error;
-using android::hardware::graphics::common::V1_0::BufferUsage;
+using android::hardware::graphics::common::V1_1::BufferUsage;
 
 namespace detail {
 
@@ -72,6 +72,8 @@
 
     Error createDescriptor_2_1(const IMapper::BufferDescriptorInfo& descriptorInfo,
                                BufferDescriptor* outDescriptor) override {
+        if (gralloc1UsageUnsupported(descriptorInfo.usage))
+             return Error::BAD_DESCRIPTOR;
         return createDescriptor(
             V2_0::IMapper::BufferDescriptorInfo{
                 descriptorInfo.width, descriptorInfo.height, descriptorInfo.layerCount,
@@ -163,6 +165,16 @@
         return consumerUsage;
     }
 
+    static bool gralloc1UsageUnsupported(uint64_t usage) {
+        // Certain newer public usage bits should not be used with gralloc1.
+        // We use a blacklist instead of a whitelist here in order to avoid
+        // breaking private usage flags.
+        constexpr uint64_t unsupportedMask = BufferUsage::GPU_CUBE_MAP |
+                                             BufferUsage::GPU_MIPMAP_COMPLETE;
+
+        return usage & unsupportedMask;
+    }
+
    private:
     using BaseType2_0 = V2_0::passthrough::detail::Gralloc1HalImpl<Hal>;
     using BaseType2_0::createDescriptor;
diff --git a/light/2.0/default/Android.bp b/light/2.0/default/Android.bp
index 8b5f780..72cc873 100644
--- a/light/2.0/default/Android.bp
+++ b/light/2.0/default/Android.bp
@@ -31,13 +31,11 @@
 
 }
 
-cc_binary {
-    name: "android.hardware.light@2.0-service",
+cc_defaults {
+    name: "light_service_defaults",
     relative_install_path: "hw",
     defaults: ["hidl_defaults"],
     vendor: true,
-    init_rc: ["android.hardware.light@2.0-service.rc"],
-    srcs: ["service.cpp"],
 
     shared_libs: [
         "liblog",
@@ -49,5 +47,19 @@
         "libhidltransport",
         "android.hardware.light@2.0",
     ],
+}
 
-}
\ No newline at end of file
+cc_binary {
+    name: "android.hardware.light@2.0-service",
+    defaults: ["light_service_defaults"],
+    init_rc: ["android.hardware.light@2.0-service.rc"],
+    srcs: ["service.cpp"],
+}
+
+cc_binary {
+    name: "android.hardware.light@2.0-service-lazy",
+    overrides: ["android.hardware.light@2.0-service"],
+    defaults: ["light_service_defaults"],
+    init_rc: ["android.hardware.light@2.0-service-lazy.rc"],
+    srcs: ["serviceLazy.cpp"],
+}
diff --git a/light/2.0/default/android.hardware.light@2.0-service-lazy.rc b/light/2.0/default/android.hardware.light@2.0-service-lazy.rc
new file mode 100644
index 0000000..8a3a59c
--- /dev/null
+++ b/light/2.0/default/android.hardware.light@2.0-service-lazy.rc
@@ -0,0 +1,9 @@
+service vendor.light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service-lazy
+    interface android.hardware.light@2.0::ILight default
+    oneshot
+    disabled
+    class hal
+    user system
+    group system
+    # shutting off lights while powering-off
+    shutdown critical
diff --git a/light/2.0/default/service.cpp b/light/2.0/default/service.cpp
index 70ae565..20f0578 100644
--- a/light/2.0/default/service.cpp
+++ b/light/2.0/default/service.cpp
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "android.hardware.light@2.0-service"
-
 #include <android/hardware/light/2.0/ILight.h>
 #include <hidl/LegacySupport.h>
 
diff --git a/light/2.0/default/serviceLazy.cpp b/light/2.0/default/serviceLazy.cpp
new file mode 100644
index 0000000..5324f46
--- /dev/null
+++ b/light/2.0/default/serviceLazy.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2019 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.
+ */
+
+#include <android/hardware/light/2.0/ILight.h>
+#include <hidl/LegacySupport.h>
+
+using android::hardware::defaultLazyPassthroughServiceImplementation;
+using android::hardware::light::V2_0::ILight;
+
+int main() {
+    return defaultLazyPassthroughServiceImplementation<ILight>();
+}
diff --git a/neuralnetworks/1.0/vts/functional/Android.bp b/neuralnetworks/1.0/vts/functional/Android.bp
index dd6f934..2920cec 100644
--- a/neuralnetworks/1.0/vts/functional/Android.bp
+++ b/neuralnetworks/1.0/vts/functional/Android.bp
@@ -22,6 +22,9 @@
     ],
     defaults: ["VtsHalTargetTestDefaults"],
     export_include_dirs: ["."],
+    shared_libs: [
+        "libnativewindow",
+    ],
     static_libs: [
         "android.hardware.neuralnetworks@1.0",
         "android.hardware.neuralnetworks@1.1",
@@ -47,6 +50,9 @@
         "ValidateRequest.cpp",
         "VtsHalNeuralnetworks.cpp",
     ],
+    shared_libs: [
+        "libnativewindow",
+    ],
     static_libs: [
         "android.hardware.neuralnetworks@1.0",
         "android.hardware.neuralnetworks@1.1",
diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal
index 8bc28b4..bd8354f 100644
--- a/neuralnetworks/1.2/types.hal
+++ b/neuralnetworks/1.2/types.hal
@@ -114,17 +114,17 @@
  */
 enum OperationType : @1.1::OperationType {
     // TODO(b/116445845): Sync docs when all ops are implemented.
-    ARGMAX = 38,
-    ARGMIN = 39,
-    PAD_V2 = 40,
+    ABS = 38,
+    ARGMAX = 39,
+    ARGMIN = 40,
     AXIS_ALIGNED_BBOX_TRANSFORM = 41,
     BIDIRECTIONAL_SEQUENCE_LSTM = 42,
     BIDIRECTIONAL_SEQUENCE_RNN = 43,
     BOX_WITH_NMS_LIMIT = 44,
     CAST = 45,
     CHANNEL_SHUFFLE = 46,
-    DETECTION_OUTPUT = 47,
-    EMBEDDING_LOOKUP_SPARSE = 48,
+    DETECTION_POSTPROCESSING = 47,
+    EQUAL = 48,
     EXP = 49,
     EXPAND_DIMS = 50,
     GATHER = 51,
@@ -133,47 +133,43 @@
     GREATER_EQUAL = 54,
     GROUPED_CONV_2D = 55,
     HEATMAP_MAX_KEYPOINT = 56,
-    LESS = 57,
-    LESS_EQUAL = 58,
-    LOG = 59,
-    LOGICAL_AND = 60,
-    LOGICAL_NOT = 61,
-    LOGICAL_OR = 62,
-    LOG_SOFTMAX = 63,
-    MAXIMUM = 64,
-    MINIMUM = 65,
-    NEG = 66,
-    POW = 67,
-    PRELU = 68,
-    PRIOR_BOX = 69,
-    QUANTIZE = 70,
-    QUANTIZED_16BIT_LSTM = 71,
-    RANDOM_MULTINOMIAL = 72,
-    REDUCE_PROD = 73,
-    ROI_ALIGN = 74,
-    RSQRT = 75,
-    SELECT = 76,
-    SIN = 77,
-    SLICE = 78,
-    SPARSE_TO_DENSE = 79,
-    SPLIT = 80,
-    SQRT = 81,
-    TILE = 82,
-    TOPK_V2 = 83,
-    TRANSPOSE_CONV_2D = 84,
-    UNIDIRECTIONAL_SEQUENCE_LSTM = 85,
-    UNIDIRECTIONAL_SEQUENCE_RNN = 86,
-    DETECTION_POSTPROCESSING = 87,
-    ABS = 88,
-    ROI_POOLING = 89,
-    EQUAL = 90,
-    NOT_EQUAL = 91,
-    REDUCE_SUM = 92,
-    REDUCE_MAX = 93,
-    REDUCE_MIN = 94,
-    REDUCE_ANY = 95,
-    REDUCE_ALL = 96,
-    INSTANCE_NORMALIZATION = 97,
+    INSTANCE_NORMALIZATION = 57,
+    LESS = 58,
+    LESS_EQUAL = 59,
+    LOG = 60,
+    LOGICAL_AND = 61,
+    LOGICAL_NOT = 62,
+    LOGICAL_OR = 63,
+    LOG_SOFTMAX = 64,
+    MAXIMUM = 65,
+    MINIMUM = 66,
+    NEG = 67,
+    NOT_EQUAL = 68,
+    PAD_V2 = 69,
+    POW = 70,
+    PRELU = 71,
+    QUANTIZE = 72,
+    QUANTIZED_16BIT_LSTM = 73,
+    RANDOM_MULTINOMIAL = 74,
+    REDUCE_ALL = 75,
+    REDUCE_ANY = 76,
+    REDUCE_MAX = 77,
+    REDUCE_MIN = 78,
+    REDUCE_PROD = 79,
+    REDUCE_SUM = 80,
+    ROI_ALIGN = 81,
+    ROI_POOLING = 82,
+    RSQRT = 83,
+    SELECT = 84,
+    SIN = 85,
+    SLICE = 86,
+    SPLIT = 87,
+    SQRT = 88,
+    TILE = 89,
+    TOPK_V2 = 90,
+    TRANSPOSE_CONV_2D = 91,
+    UNIDIRECTIONAL_SEQUENCE_LSTM = 92,
+    UNIDIRECTIONAL_SEQUENCE_RNN = 93,
     /* ADDING A NEW FUNDAMENTAL OPERATION REQUIRES UPDATING THE VALUE OF
      * OperationTypeRange::OPERATION_FUNDAMENTAL_MAX.
      */
@@ -187,7 +183,7 @@
  */
 enum OperationTypeRange : uint32_t {
     OPERATION_FUNDAMENTAL_MIN = 0,
-    OPERATION_FUNDAMENTAL_MAX = 97,
+    OPERATION_FUNDAMENTAL_MAX = 93,
     OPERATION_OEM_MIN = 10000,
     OPERATION_OEM_MAX = 10000,
 };
diff --git a/radio/1.4/IRadio.hal b/radio/1.4/IRadio.hal
index dd69607..21c5097 100644
--- a/radio/1.4/IRadio.hal
+++ b/radio/1.4/IRadio.hal
@@ -128,6 +128,10 @@
      * does not support the emergency service category or emergency uniform resource names, the
      * field 'categories' or 'urns' may be ignored.
      *
+     * 'fromEmergencyDialer' indicates if this request originated from emergency dialer/shortcut,
+     * which means an explicit intent from the user to dial an emergency number. The modem must
+     * treat this as an actual emergency dial and not try to disambiguate.
+     *
      * If 'isTesting' is true, this request is for testing purpose, and must not be sent to a real
      * emergency service; otherwise it's for a real emergency call request.
      *
@@ -142,12 +146,14 @@
      *     of the call.
      * @param urns the emergency Uniform Resource Names (URN)
      * @param routing @1.4::EmergencyCallRouting the emergency call routing information.
+     * @param fromEmergencyDialer Flag indicating if this request originated from emergency dialer.
+     * @param isTesting Flag indicating if this request is for testing purpose.
      *
      * Response function is IRadioResponse.emergencyDialResponse()
      */
     oneway emergencyDial(int32_t serial, Dial dialInfo,
             bitfield<EmergencyServiceCategory> categories, vec<string> urns,
-            EmergencyCallRouting routing, bool isTesting);
+            EmergencyCallRouting routing, bool fromEmergencyDialer, bool isTesting);
 
     /**
      * Starts a network scan
diff --git a/sensors/2.0/default/Android.bp b/sensors/2.0/default/Android.bp
index db0b148..d83a9c3 100644
--- a/sensors/2.0/default/Android.bp
+++ b/sensors/2.0/default/Android.bp
@@ -35,4 +35,5 @@
         "libpower",
         "libutils",
     ],
+    vintf_fragments: ["android.hardware.sensors@2.0.xml"],
 }
diff --git a/sensors/2.0/default/android.hardware.sensors@2.0.xml b/sensors/2.0/default/android.hardware.sensors@2.0.xml
new file mode 100644
index 0000000..1acc8e6
--- /dev/null
+++ b/sensors/2.0/default/android.hardware.sensors@2.0.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+    <hal format="hidl">
+        <name>android.hardware.sensors</name>
+        <transport>hwbinder</transport>
+        <version>2.0</version>
+        <interface>
+            <name>ISensors</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</manifest>
diff --git a/tv/cec/2.0/Android.bp b/tv/cec/2.0/Android.bp
new file mode 100644
index 0000000..998cb23
--- /dev/null
+++ b/tv/cec/2.0/Android.bp
@@ -0,0 +1,46 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.tv.cec@2.0",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+        "IHdmiCec.hal",
+        "IHdmiCecCallback.hal",
+    ],
+    interfaces: [
+        "android.hidl.base@1.0",
+        "android.hidl.safe_union@1.0",
+    ],
+    types: [
+        "AbortReason",
+        "CecAllDeviceTypeValue",
+        "CecDeviceFeature",
+        "CecDeviceInfo",
+        "CecDeviceType",
+        "CecLogicalAddress",
+        "CecMessage",
+        "CecMessageType",
+        "CecPowerState",
+        "CecRcProfile",
+        "CecRcProfile1",
+        "CecRcProfileId",
+        "CecRcProfileSource",
+        "CecTopologyEvent",
+        "CecTopologyEventType",
+        "CecUICommandCodes",
+        "CecVersion",
+        "HdmiPortInfo",
+        "HdmiPortType",
+        "HotplugEvent",
+        "MaxLength",
+        "OptionKey",
+        "Result",
+        "SendMessageResult",
+    ],
+    gen_java: true,
+}
+
diff --git a/tv/cec/2.0/IHdmiCec.hal b/tv/cec/2.0/IHdmiCec.hal
new file mode 100644
index 0000000..0723bad
--- /dev/null
+++ b/tv/cec/2.0/IHdmiCec.hal
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2019 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.tv.cec@2.0;
+
+import IHdmiCecCallback;
+
+/**
+ * HDMI-CEC HAL interface definition.
+ */
+interface IHdmiCec {
+    /**
+     * Passes Primary Device Type that must be used in this system.
+     *
+     * HAL must use it to allocate logical address as specified in CEC section
+     * 11.3.2 of the CEC spec 2.0b. Then CEC commands addressed the given
+     * logical address can be filtered in.
+     * This method shall be able to be called up to twice to support two Primary
+     * Device Type as specified in CEC Table 11-8 of the CEC spec 2.0b.
+     *
+     * @param deviceType that must be used in this system. It must be a valid
+     *        value in CecDeviceType for the call to succeed.
+     * @return result Result status of the operation. SUCCESS if successful,
+     *         FAILURE_INVALID_ARGS if the given device type is invalid,
+     *         FAILURE_BUSY if device or resource is busy
+     */
+    @callflow(next={"*"})
+    addDeviceType(CecDeviceType deviceType) generates (Result result);
+
+    /**
+     * Clears all Primary Device Types.
+     *
+     * It is used when the system plan to reconfigure Primary Device Type,
+     * hence to tell HAL to release all logical address associated to them,
+     * and change the state back to the beginning.
+     */
+    @callflow(next="addDeviceType")
+    @exit
+    clearDeviceTypes();
+
+    /**
+     * Set All Device Types for a Primary Device Type.
+     *
+     * This value must be used in REPORT_FEATURES message to response
+     * GIVE_FEATURES message in HAL.
+     *
+     * @param allDeviceTypes device all device types for a Primary Device Type.
+     */
+    @callflow(next="addDeviceType")
+    setAllDeviceTypes(CecAllDeviceTypes allDeviceTypes);
+
+    /**
+     * Set Device Features for a Primary Device Type.
+     *
+     * This value must be used in REPORT_FEATURES message to response
+     * GIVE_FEATURES message in HAL.
+     *
+     * @param deviceType The device Primary Device Type.
+     * @param deviceFeatures device features for a Primary Device Type.
+     */
+    @callflow(next="addDeviceType")
+    setDeviceFeatures(CecDeviceType deviceType,
+                      CecDeviceFeatures deviceFeatures);
+
+    /**
+     * Set Remote Control Profile for a Primary Device Type.
+     *
+     * This value must be used in REPORT_FEATURES message to response
+     * GIVE_FEATURES message in HAL.
+     *
+     * @param deviceType The device Primary Device Type.
+     * @param rcProliles remote control profiles for a Primary Device Type.
+     */
+    @callflow(next="addDeviceType")
+    setRcProfile(CecDeviceType deviceType, CecRcProfile rcProfile);
+
+    /**
+     * Retrieve CEC device information.
+     *
+     * CEC section 11.3 of the CEC spec 2.0b specify that a device should not
+     * ask for static information that another device has already supplied.
+     * Therefore, CEC 2.0 software stack need a map to store all cec
+     * devices’ information of current CEC network.
+     * The device information is broadcasted by a device after it allocates a
+     * logical address.  Messages used to send out these information are
+     * REPORT_FEATURES, REPORT_PHYSICAL_ADDRESS, DEVICE_VENDOR_ID.
+     * The spec also requires less than 1 second between REPORT_FEATURES and
+     * REPORT_PHYSICAL_ADDRESS message, and less than 2 second between
+     * REPORT_PHYSICAL_ADDRESS and DEVICE_VENDOR_ID. An Implementation of
+     * device information map in hal can help to meet the timing constraints.
+     * Logical addressing is part of the process to build this map, so the
+     * implementation shall include allocating logical address too.
+     * Whenever a device plug/unplug, the topology of CEC network changes.
+     * The hal implementation shall update devices’ information map, and
+     * send out onTopologyEvent to Android system. Then Android system
+     * will use readDeviceInfo to retreive latest devices’ information of CEC
+     * network.
+     * If SYSTEM_CEC_CONTROL is false, the hal implementation need continue to
+     * maintain and update device information map, and send out pending
+     * onTopologyEvent to Android system when SYSTEM_CEC_CONTROL is
+     * changed to true.
+     *
+     * @param logicalAddress logical address of CEC device.
+     * @param physicalAddress physical address of CEC device.
+     * @return CecDeviceInfo from device information map.
+     * @return result Result status of the operation. SUCCESS if successful,
+     *         FAILURE_INVALID_ARGS if logical or physical address is invalid.
+     *         FAILURE_INVALID_STATE if device information isn't available yet.
+     */
+    @callflow(next="onTopologyChangeEvent")
+    readDeviceInfo(CecLogicalAddress logicalAddress,
+                   CecPhysicalAddress physicalAddress)
+        generates (Result result, CecDeviceInfo deviceInfo);
+
+   /**
+     * Transmits HDMI-CEC message to other HDMI device.
+     *
+     * The method must be designed to return in a certain amount of time and not
+     * hanging forever. This method MUST complete with in 1 second.
+     *
+     * It must try retransmission at least once as specified in the section '7.1
+     * Frame Re-transmissions' of the CEC Spec 1.4b.
+     *
+     * @param message CEC message to be sent to other HDMI device.
+     * @return result Result status of the operation. SUCCESS if successful,
+     *         NACK if the sent message is not acknowledged,
+     *         BUSY if the CEC bus is busy.
+     */
+    @callflow(next="*")
+    sendMessage(CecMessage message) generates (SendMessageResult result);
+
+    /**
+     * Set the callback
+     *
+     * It is used by the framework to receive CecMessages, HDMI hotplug event
+     * and topology update event. Only one callback client is supported.
+     *
+     * @param callback Callback object to pass hdmi events to the system. The
+     *        previously registered callback must be replaced with this one.
+     */
+    @callflow(next={"*"})
+    @entry
+    setCallback(IHdmiCecCallback callback);
+
+   /**
+     * Gets the hdmi port information of underlying hardware.
+     *
+     * @return infos The list of HDMI port information
+     */
+    @callflow(next={"*"})
+    getPortInfo() generates (vec<HdmiPortInfo> infos);
+
+    /**
+     * Sets flags controlling the way HDMI-CEC service works down to HAL
+     * implementation. Those flags must be used in case the feature needs update
+     * in HAL itself, firmware or microcontroller.
+     *
+     * @param key The key of the option to be updated with a new value.
+     * @param value Value to be set.
+     */
+    @callflow(next="*")
+    setOption(OptionKey key, bool value);
+
+    /**
+     * Passes the updated language information of Android system. Contains
+     * three-letter code as defined in ISO/FDIS 639-2. Must be used for HAL to
+     * respond to <Get Menu Language> while in standby mode.
+     *
+     * @param language Three-letter code defined in ISO/FDIS 639-2. Must be
+     *        lowercase letters. (e.g., eng for English)
+     */
+    @callflow(next="*")
+    setLanguage(string language);
+
+    /**
+     * Configures ARC circuit in the hardware logic to start or stop the
+     * feature.
+     *
+     * @param portId Port id to be configured.
+     * @param enable Flag must be either true to start the feature or false to
+     *        stop it.
+     */
+    @callflow(next="*")
+    enableAudioReturnChannel(HdmiPortId portId, bool enable);
+
+    /**
+     * Gets the connection status of the specified port.
+     *
+     * It's specified in CEC section 10.8 of the CEC spec 2.0b
+     *
+     * @param portId Port id to be inspected for the connection status.
+     * @return status True if a device is connected, otherwise false.
+     */
+    @callflow(next="*")
+    isConnected(HdmiPortId portId) generates (bool connected);
+};
diff --git a/tv/cec/2.0/IHdmiCecCallback.hal b/tv/cec/2.0/IHdmiCecCallback.hal
new file mode 100644
index 0000000..1a8a489
--- /dev/null
+++ b/tv/cec/2.0/IHdmiCecCallback.hal
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2019 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.tv.cec@2.0;
+
+interface IHdmiCecCallback {
+    /**
+     * The callback function that must be called by HAL implementation to notify
+     * the system of new CEC message arrival.
+     */
+    oneway onCecMessage(CecMessage message);
+
+    /**
+     * The callback function that must be called by HAL implementation to notify
+     * the system of new hotplug event.
+     */
+    oneway onHotplugEvent(HotplugEvent event);
+
+    /**
+     * The callback function must be called by HAL implementation to notify the
+     * system whenever CEC device information of CEC network change.
+     * HAL shall be ready for readDeviceInfo call before invoke this callback.
+     * This event is triggered by topology change of whole CEC network. It's
+     * different from HotplugEvent which is triggered between devices which are
+     * connected directly through HDMI cable.
+     */
+    oneway onTopologyEvent(CecTopologyEvent event);
+};
diff --git a/tv/cec/2.0/default/Android.bp b/tv/cec/2.0/default/Android.bp
new file mode 100644
index 0000000..6e624e3
--- /dev/null
+++ b/tv/cec/2.0/default/Android.bp
@@ -0,0 +1,42 @@
+cc_library_shared {
+    name: "android.hardware.tv.cec@2.0-impl",
+    defaults: ["hidl_defaults"],
+    vendor: true,
+    relative_install_path: "hw",
+    srcs: ["HdmiCec.cpp"],
+
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "liblog",
+        "libbase",
+        "libutils",
+        "libhardware",
+        "android.hardware.tv.cec@2.0",
+    ],
+
+}
+
+cc_binary {
+    name: "android.hardware.tv.cec@2.0-service",
+    vintf_fragments: ["android.hardware.tv.cec@2.0-service.xml"],
+    defaults: ["hidl_defaults"],
+    relative_install_path: "hw",
+    vendor: true,
+    init_rc: ["android.hardware.tv.cec@2.0-service.rc"],
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libdl",
+        "libbase",
+        "libutils",
+        "libhardware_legacy",
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "android.hardware.tv.cec@2.0",
+    ],
+
+}
diff --git a/tv/cec/2.0/default/HdmiCec.cpp b/tv/cec/2.0/default/HdmiCec.cpp
new file mode 100644
index 0000000..f451719
--- /dev/null
+++ b/tv/cec/2.0/default/HdmiCec.cpp
@@ -0,0 +1,421 @@
+/*
+ * Copyright (C) 2019 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 "android.hardware.tv.cec@2.0-impl"
+#include <android-base/logging.h>
+
+#include <hardware/hardware.h>
+#include <hardware/hdmi_cec.h>
+#include "HdmiCec.h"
+
+namespace android {
+namespace hardware {
+namespace tv {
+namespace cec {
+namespace V2_0 {
+namespace implementation {
+
+static_assert(CEC_DEVICE_INACTIVE == static_cast<int>(CecDeviceType::INACTIVE),
+              "CecDeviceType::INACTIVE must match legacy value.");
+static_assert(CEC_DEVICE_TV == static_cast<int>(CecDeviceType::TV),
+              "CecDeviceType::TV must match legacy value.");
+static_assert(CEC_DEVICE_RECORDER == static_cast<int>(CecDeviceType::RECORDER),
+              "CecDeviceType::RECORDER must match legacy value.");
+static_assert(CEC_DEVICE_TUNER == static_cast<int>(CecDeviceType::TUNER),
+              "CecDeviceType::TUNER must match legacy value.");
+static_assert(CEC_DEVICE_PLAYBACK == static_cast<int>(CecDeviceType::PLAYBACK),
+              "CecDeviceType::PLAYBACK must match legacy value.");
+static_assert(CEC_DEVICE_AUDIO_SYSTEM == static_cast<int>(CecDeviceType::AUDIO_SYSTEM),
+              "CecDeviceType::AUDIO_SYSTEM must match legacy value.");
+/* TODO: Adjust for cec@2.0
+static_assert(CEC_DEVICE_MAX == static_cast<int>(CecDeviceType::MAX),
+        "CecDeviceType::MAX must match legacy value.");
+*/
+static_assert(CEC_ADDR_TV == static_cast<int>(CecLogicalAddress::TV),
+              "CecLogicalAddress::TV must match legacy value.");
+static_assert(CEC_ADDR_RECORDER_1 == static_cast<int>(CecLogicalAddress::RECORDER_1),
+              "CecLogicalAddress::RECORDER_1 must match legacy value.");
+static_assert(CEC_ADDR_RECORDER_2 == static_cast<int>(CecLogicalAddress::RECORDER_2),
+              "CecLogicalAddress::RECORDER_2 must match legacy value.");
+static_assert(CEC_ADDR_TUNER_1 == static_cast<int>(CecLogicalAddress::TUNER_1),
+              "CecLogicalAddress::TUNER_1 must match legacy value.");
+static_assert(CEC_ADDR_PLAYBACK_1 == static_cast<int>(CecLogicalAddress::PLAYBACK_1),
+              "CecLogicalAddress::PLAYBACK_1 must match legacy value.");
+static_assert(CEC_ADDR_AUDIO_SYSTEM == static_cast<int>(CecLogicalAddress::AUDIO_SYSTEM),
+              "CecLogicalAddress::AUDIO_SYSTEM must match legacy value.");
+static_assert(CEC_ADDR_TUNER_2 == static_cast<int>(CecLogicalAddress::TUNER_2),
+              "CecLogicalAddress::TUNER_2 must match legacy value.");
+static_assert(CEC_ADDR_TUNER_3 == static_cast<int>(CecLogicalAddress::TUNER_3),
+              "CecLogicalAddress::TUNER_3 must match legacy value.");
+static_assert(CEC_ADDR_PLAYBACK_2 == static_cast<int>(CecLogicalAddress::PLAYBACK_2),
+              "CecLogicalAddress::PLAYBACK_2 must match legacy value.");
+static_assert(CEC_ADDR_RECORDER_3 == static_cast<int>(CecLogicalAddress::RECORDER_3),
+              "CecLogicalAddress::RECORDER_3 must match legacy value.");
+static_assert(CEC_ADDR_TUNER_4 == static_cast<int>(CecLogicalAddress::TUNER_4),
+              "CecLogicalAddress::TUNER_4 must match legacy value.");
+static_assert(CEC_ADDR_PLAYBACK_3 == static_cast<int>(CecLogicalAddress::PLAYBACK_3),
+              "CecLogicalAddress::PLAYBACK_3 must match legacy value.");
+/* TODO: Adjust for cec@2.0
+static_assert(CEC_ADDR_FREE_USE == static_cast<int>(CecLogicalAddress::FREE_USE),
+        "CecLogicalAddress::FREE_USE must match legacy value.");
+*/
+static_assert(CEC_ADDR_UNREGISTERED == static_cast<int>(CecLogicalAddress::UNREGISTERED),
+              "CecLogicalAddress::UNREGISTERED must match legacy value.");
+static_assert(CEC_ADDR_BROADCAST == static_cast<int>(CecLogicalAddress::BROADCAST),
+              "CecLogicalAddress::BROADCAST must match legacy value.");
+
+static_assert(CEC_MESSAGE_FEATURE_ABORT == static_cast<int>(CecMessageType::FEATURE_ABORT),
+              "CecMessageType::FEATURE_ABORT must match legacy value.");
+static_assert(CEC_MESSAGE_IMAGE_VIEW_ON == static_cast<int>(CecMessageType::IMAGE_VIEW_ON),
+              "CecMessageType::IMAGE_VIEW_ON must match legacy value.");
+static_assert(CEC_MESSAGE_TUNER_STEP_INCREMENT ==
+                      static_cast<int>(CecMessageType::TUNER_STEP_INCREMENT),
+              "CecMessageType::TUNER_STEP_INCREMENT must match legacy value.");
+static_assert(CEC_MESSAGE_TUNER_STEP_DECREMENT ==
+                      static_cast<int>(CecMessageType::TUNER_STEP_DECREMENT),
+              "CecMessageType::TUNER_STEP_DECREMENT must match legacy value.");
+static_assert(CEC_MESSAGE_TUNER_DEVICE_STATUS ==
+                      static_cast<int>(CecMessageType::TUNER_DEVICE_STATUS),
+              "CecMessageType::TUNER_DEVICE_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_TUNER_DEVICE_STATUS ==
+                      static_cast<int>(CecMessageType::GIVE_TUNER_DEVICE_STATUS),
+              "CecMessageType::GIVE_TUNER_DEVICE_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_RECORD_ON == static_cast<int>(CecMessageType::RECORD_ON),
+              "CecMessageType::RECORD_ON must match legacy value.");
+static_assert(CEC_MESSAGE_RECORD_STATUS == static_cast<int>(CecMessageType::RECORD_STATUS),
+              "CecMessageType::RECORD_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_RECORD_OFF == static_cast<int>(CecMessageType::RECORD_OFF),
+              "CecMessageType::RECORD_OFF must match legacy value.");
+static_assert(CEC_MESSAGE_TEXT_VIEW_ON == static_cast<int>(CecMessageType::TEXT_VIEW_ON),
+              "CecMessageType::TEXT_VIEW_ON must match legacy value.");
+static_assert(CEC_MESSAGE_RECORD_TV_SCREEN == static_cast<int>(CecMessageType::RECORD_TV_SCREEN),
+              "CecMessageType::RECORD_TV_SCREEN must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_DECK_STATUS == static_cast<int>(CecMessageType::GIVE_DECK_STATUS),
+              "CecMessageType::GIVE_DECK_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_STANDBY == static_cast<int>(CecMessageType::STANDBY),
+              "CecMessageType::STANDBY must match legacy value.");
+static_assert(CEC_MESSAGE_PLAY == static_cast<int>(CecMessageType::PLAY),
+              "CecMessageType::PLAY must match legacy value.");
+static_assert(CEC_MESSAGE_DECK_CONTROL == static_cast<int>(CecMessageType::DECK_CONTROL),
+              "CecMessageType::DECK_CONTROL must match legacy value.");
+static_assert(CEC_MESSAGE_TIMER_CLEARED_STATUS ==
+                      static_cast<int>(CecMessageType::TIMER_CLEARED_STATUS),
+              "CecMessageType::TIMER_CLEARED_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_USER_CONTROL_PRESSED ==
+                      static_cast<int>(CecMessageType::USER_CONTROL_PRESSED),
+              "CecMessageType::USER_CONTROL_PRESSED must match legacy value.");
+static_assert(CEC_MESSAGE_USER_CONTROL_RELEASED ==
+                      static_cast<int>(CecMessageType::USER_CONTROL_RELEASED),
+              "CecMessageType::USER_CONTROL_RELEASED must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_OSD_NAME == static_cast<int>(CecMessageType::GIVE_OSD_NAME),
+              "CecMessageType::GIVE_OSD_NAME must match legacy value.");
+static_assert(CEC_MESSAGE_SET_OSD_NAME == static_cast<int>(CecMessageType::SET_OSD_NAME),
+              "CecMessageType::SET_OSD_NAME must match legacy value.");
+static_assert(CEC_MESSAGE_SYSTEM_AUDIO_MODE_REQUEST ==
+                      static_cast<int>(CecMessageType::SYSTEM_AUDIO_MODE_REQUEST),
+              "CecMessageType::SYSTEM_AUDIO_MODE_REQUEST must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_AUDIO_STATUS == static_cast<int>(CecMessageType::GIVE_AUDIO_STATUS),
+              "CecMessageType::GIVE_AUDIO_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_SET_SYSTEM_AUDIO_MODE ==
+                      static_cast<int>(CecMessageType::SET_SYSTEM_AUDIO_MODE),
+              "CecMessageType::SET_SYSTEM_AUDIO_MODE must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_AUDIO_STATUS ==
+                      static_cast<int>(CecMessageType::REPORT_AUDIO_STATUS),
+              "CecMessageType::REPORT_AUDIO_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS ==
+                      static_cast<int>(CecMessageType::GIVE_SYSTEM_AUDIO_MODE_STATUS),
+              "CecMessageType::GIVE_SYSTEM_AUDIO_MODE_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_SYSTEM_AUDIO_MODE_STATUS ==
+                      static_cast<int>(CecMessageType::SYSTEM_AUDIO_MODE_STATUS),
+              "CecMessageType::SYSTEM_AUDIO_MODE_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_ROUTING_CHANGE == static_cast<int>(CecMessageType::ROUTING_CHANGE),
+              "CecMessageType::ROUTING_CHANGE must match legacy value.");
+static_assert(CEC_MESSAGE_ROUTING_INFORMATION ==
+                      static_cast<int>(CecMessageType::ROUTING_INFORMATION),
+              "CecMessageType::ROUTING_INFORMATION must match legacy value.");
+static_assert(CEC_MESSAGE_ACTIVE_SOURCE == static_cast<int>(CecMessageType::ACTIVE_SOURCE),
+              "CecMessageType::ACTIVE_SOURCE must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_PHYSICAL_ADDRESS ==
+                      static_cast<int>(CecMessageType::GIVE_PHYSICAL_ADDRESS),
+              "CecMessageType::GIVE_PHYSICAL_ADDRESS must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_PHYSICAL_ADDRESS ==
+                      static_cast<int>(CecMessageType::REPORT_PHYSICAL_ADDRESS),
+              "CecMessageType::REPORT_PHYSICAL_ADDRESS must match legacy value.");
+static_assert(CEC_MESSAGE_REQUEST_ACTIVE_SOURCE ==
+                      static_cast<int>(CecMessageType::REQUEST_ACTIVE_SOURCE),
+              "CecMessageType::REQUEST_ACTIVE_SOURCE must match legacy value.");
+static_assert(CEC_MESSAGE_SET_STREAM_PATH == static_cast<int>(CecMessageType::SET_STREAM_PATH),
+              "CecMessageType::SET_STREAM_PATH must match legacy value.");
+static_assert(CEC_MESSAGE_DEVICE_VENDOR_ID == static_cast<int>(CecMessageType::DEVICE_VENDOR_ID),
+              "CecMessageType::DEVICE_VENDOR_ID must match legacy value.");
+static_assert(CEC_MESSAGE_VENDOR_COMMAND == static_cast<int>(CecMessageType::VENDOR_COMMAND),
+              "CecMessageType::VENDOR_COMMAND must match legacy value.");
+static_assert(CEC_MESSAGE_VENDOR_REMOTE_BUTTON_DOWN ==
+                      static_cast<int>(CecMessageType::VENDOR_REMOTE_BUTTON_DOWN),
+              "CecMessageType::VENDOR_REMOTE_BUTTON_DOWN must match legacy value.");
+static_assert(CEC_MESSAGE_VENDOR_REMOTE_BUTTON_UP ==
+                      static_cast<int>(CecMessageType::VENDOR_REMOTE_BUTTON_UP),
+              "CecMessageType::VENDOR_REMOTE_BUTTON_UP must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_DEVICE_VENDOR_ID ==
+                      static_cast<int>(CecMessageType::GIVE_DEVICE_VENDOR_ID),
+              "CecMessageType::GIVE_DEVICE_VENDOR_ID must match legacy value.");
+static_assert(CEC_MESSAGE_MENU_REQUEST == static_cast<int>(CecMessageType::MENU_REQUEST),
+              "CecMessageType::MENU_REQUEST must match legacy value.");
+static_assert(CEC_MESSAGE_MENU_STATUS == static_cast<int>(CecMessageType::MENU_STATUS),
+              "CecMessageType::MENU_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_DEVICE_POWER_STATUS ==
+                      static_cast<int>(CecMessageType::GIVE_DEVICE_POWER_STATUS),
+              "CecMessageType::GIVE_DEVICE_POWER_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_POWER_STATUS ==
+                      static_cast<int>(CecMessageType::REPORT_POWER_STATUS),
+              "CecMessageType::REPORT_POWER_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_GET_MENU_LANGUAGE == static_cast<int>(CecMessageType::GET_MENU_LANGUAGE),
+              "CecMessageType::GET_MENU_LANGUAGE must match legacy value.");
+static_assert(CEC_MESSAGE_SELECT_ANALOG_SERVICE ==
+                      static_cast<int>(CecMessageType::SELECT_ANALOG_SERVICE),
+              "CecMessageType::SELECT_ANALOG_SERVICE must match legacy value.");
+static_assert(CEC_MESSAGE_SELECT_DIGITAL_SERVICE ==
+                      static_cast<int>(CecMessageType::SELECT_DIGITAL_SERVICE),
+              "CecMessageType::SELECT_DIGITAL_SERVICE must match legacy value.");
+static_assert(CEC_MESSAGE_SET_DIGITAL_TIMER == static_cast<int>(CecMessageType::SET_DIGITAL_TIMER),
+              "CecMessageType::SET_DIGITAL_TIMER must match legacy value.");
+static_assert(CEC_MESSAGE_CLEAR_DIGITAL_TIMER ==
+                      static_cast<int>(CecMessageType::CLEAR_DIGITAL_TIMER),
+              "CecMessageType::CLEAR_DIGITAL_TIMER must match legacy value.");
+static_assert(CEC_MESSAGE_SET_AUDIO_RATE == static_cast<int>(CecMessageType::SET_AUDIO_RATE),
+              "CecMessageType::SET_AUDIO_RATE must match legacy value.");
+static_assert(CEC_MESSAGE_INACTIVE_SOURCE == static_cast<int>(CecMessageType::INACTIVE_SOURCE),
+              "CecMessageType::INACTIVE_SOURCE must match legacy value.");
+static_assert(CEC_MESSAGE_CEC_VERSION == static_cast<int>(CecMessageType::CEC_VERSION),
+              "CecMessageType::CEC_VERSION must match legacy value.");
+static_assert(CEC_MESSAGE_GET_CEC_VERSION == static_cast<int>(CecMessageType::GET_CEC_VERSION),
+              "CecMessageType::GET_CEC_VERSION must match legacy value.");
+static_assert(CEC_MESSAGE_VENDOR_COMMAND_WITH_ID ==
+                      static_cast<int>(CecMessageType::VENDOR_COMMAND_WITH_ID),
+              "CecMessageType::VENDOR_COMMAND_WITH_ID must match legacy value.");
+static_assert(CEC_MESSAGE_CLEAR_EXTERNAL_TIMER ==
+                      static_cast<int>(CecMessageType::CLEAR_EXTERNAL_TIMER),
+              "CecMessageType::CLEAR_EXTERNAL_TIMER must match legacy value.");
+static_assert(CEC_MESSAGE_SET_EXTERNAL_TIMER ==
+                      static_cast<int>(CecMessageType::SET_EXTERNAL_TIMER),
+              "CecMessageType::SET_EXTERNAL_TIMER must match legacy value.");
+static_assert(CEC_MESSAGE_INITIATE_ARC == static_cast<int>(CecMessageType::INITIATE_ARC),
+              "CecMessageType::INITIATE_ARC must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_ARC_INITIATED ==
+                      static_cast<int>(CecMessageType::REPORT_ARC_INITIATED),
+              "CecMessageType::REPORT_ARC_INITIATED must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_ARC_TERMINATED ==
+                      static_cast<int>(CecMessageType::REPORT_ARC_TERMINATED),
+              "CecMessageType::REPORT_ARC_TERMINATED must match legacy value.");
+static_assert(CEC_MESSAGE_REQUEST_ARC_INITIATION ==
+                      static_cast<int>(CecMessageType::REQUEST_ARC_INITIATION),
+              "CecMessageType::REQUEST_ARC_INITIATION must match legacy value.");
+static_assert(CEC_MESSAGE_REQUEST_ARC_TERMINATION ==
+                      static_cast<int>(CecMessageType::REQUEST_ARC_TERMINATION),
+              "CecMessageType::REQUEST_ARC_TERMINATION must match legacy value.");
+static_assert(CEC_MESSAGE_TERMINATE_ARC == static_cast<int>(CecMessageType::TERMINATE_ARC),
+              "CecMessageType::TERMINATE_ARC must match legacy value.");
+static_assert(CEC_MESSAGE_ABORT == static_cast<int>(CecMessageType::ABORT),
+              "CecMessageType::ABORT must match legacy value.");
+
+static_assert(ABORT_UNRECOGNIZED_MODE == static_cast<int>(AbortReason::UNRECOGNIZED_MODE),
+              "AbortReason::UNRECOGNIZED_MODE must match legacy value.");
+static_assert(ABORT_NOT_IN_CORRECT_MODE == static_cast<int>(AbortReason::NOT_IN_CORRECT_MODE),
+              "AbortReason::NOT_IN_CORRECT_MODE must match legacy value.");
+static_assert(ABORT_CANNOT_PROVIDE_SOURCE == static_cast<int>(AbortReason::CANNOT_PROVIDE_SOURCE),
+              "AbortReason::CANNOT_PROVIDE_SOURCE must match legacy value.");
+static_assert(ABORT_INVALID_OPERAND == static_cast<int>(AbortReason::INVALID_OPERAND),
+              "AbortReason::INVALID_OPERAND must match legacy value.");
+static_assert(ABORT_REFUSED == static_cast<int>(AbortReason::REFUSED),
+              "AbortReason::REFUSED must match legacy value.");
+static_assert(ABORT_UNABLE_TO_DETERMINE == static_cast<int>(AbortReason::UNABLE_TO_DETERMINE),
+              "AbortReason::UNABLE_TO_DETERMINE must match legacy value.");
+
+static_assert(HDMI_RESULT_SUCCESS == static_cast<int>(SendMessageResult::SUCCESS),
+              "SendMessageResult::SUCCESS must match legacy value.");
+static_assert(HDMI_RESULT_NACK == static_cast<int>(SendMessageResult::NACK),
+              "SendMessageResult::NACK must match legacy value.");
+static_assert(HDMI_RESULT_BUSY == static_cast<int>(SendMessageResult::BUSY),
+              "SendMessageResult::BUSY must match legacy value.");
+static_assert(HDMI_RESULT_FAIL == static_cast<int>(SendMessageResult::FAIL),
+              "SendMessageResult::FAIL must match legacy value.");
+
+static_assert(HDMI_INPUT == static_cast<int>(HdmiPortType::INPUT),
+              "HdmiPortType::INPUT must match legacy value.");
+static_assert(HDMI_OUTPUT == static_cast<int>(HdmiPortType::OUTPUT),
+              "HdmiPortType::OUTPUT must match legacy value.");
+
+static_assert(HDMI_OPTION_WAKEUP == static_cast<int>(OptionKey::WAKEUP),
+              "OptionKey::WAKEUP must match legacy value.");
+static_assert(HDMI_OPTION_ENABLE_CEC == static_cast<int>(OptionKey::ENABLE_CEC),
+              "OptionKey::ENABLE_CEC must match legacy value.");
+static_assert(HDMI_OPTION_SYSTEM_CEC_CONTROL == static_cast<int>(OptionKey::SYSTEM_CEC_CONTROL),
+              "OptionKey::SYSTEM_CEC_CONTROL must match legacy value.");
+
+sp<IHdmiCecCallback> HdmiCec::mCallback = nullptr;
+
+HdmiCec::HdmiCec(hdmi_cec_device_t* device) : mDevice(device) {}
+
+// Methods from ::android::hardware::tv::cec::V2_0::IHdmiCec follow.
+Return<Result> HdmiCec::addDeviceType(CecDeviceType deviceType) {
+    // TODO implement
+    if (deviceType <= CecDeviceType::MAX) {
+        return Result::SUCCESS;
+    } else {
+        return Result::FAILURE_INVALID_ARGS;
+    }
+}
+
+Return<void> HdmiCec::clearDeviceTypes() {
+    // TODO implement
+    return Void();
+}
+
+Return<void> HdmiCec::setAllDeviceTypes(CecAllDeviceTypes allDeviceTypes) {
+    // TODO implement
+    if (allDeviceTypes == 1) {
+    }
+    return Void();
+}
+
+Return<void> HdmiCec::setDeviceFeatures(CecDeviceType deviceType,
+                                        CecDeviceFeatures /* deviceFeatures */) {
+    // TODO implement
+    if (deviceType != CecDeviceType::MAX) {
+    }
+    return Void();
+}
+
+Return<void> HdmiCec::setRcProfile(CecDeviceType deviceType, const CecRcProfile& /* rcProfile */) {
+    // TODO implement
+    if (deviceType != CecDeviceType::MAX) {
+    }
+    return Void();
+}
+
+Return<void> HdmiCec::readDeviceInfo(CecLogicalAddress logicalAddress,
+                                     CecPhysicalAddress physicalAddress,
+                                     const readDeviceInfo_cb _hidl_cb) {
+    // TODO implement
+    CecDeviceInfo deviceInfo;
+
+    if (logicalAddress == CecLogicalAddress::TV) {
+        _hidl_cb(Result::SUCCESS, deviceInfo);
+        if (physicalAddress) {
+        }
+    }
+    return Void();
+}
+
+Return<SendMessageResult> HdmiCec::sendMessage(const CecMessage& message) {
+    cec_message_t legacyMessage{
+            .initiator = static_cast<cec_logical_address_t>(message.initiator),
+            .destination = static_cast<cec_logical_address_t>(message.destination),
+            .length = message.body.size(),
+    };
+    for (size_t i = 0; i < message.body.size(); ++i) {
+        legacyMessage.body[i] = static_cast<unsigned char>(message.body[i]);
+    }
+    return static_cast<SendMessageResult>(mDevice->send_message(mDevice, &legacyMessage));
+}
+
+Return<void> HdmiCec::setCallback(const sp<IHdmiCecCallback>& callback) {
+    if (mCallback != nullptr) {
+        mCallback->unlinkToDeath(this);
+        mCallback = nullptr;
+    }
+
+    if (callback != nullptr) {
+        mCallback = callback;
+        mCallback->linkToDeath(this, 0 /*cookie*/);
+        mDevice->register_event_callback(mDevice, eventCallback, nullptr);
+    }
+    return Void();
+}
+
+Return<void> HdmiCec::getPortInfo(getPortInfo_cb _hidl_cb) {
+    struct hdmi_port_info* legacyPorts;
+    int numPorts;
+    hidl_vec<HdmiPortInfo> portInfos;
+    mDevice->get_port_info(mDevice, &legacyPorts, &numPorts);
+    portInfos.resize(numPorts);
+    for (int i = 0; i < numPorts; ++i) {
+        portInfos[i] = {.type = static_cast<HdmiPortType>(legacyPorts[i].type),
+                        .portId = static_cast<HdmiPortId>(legacyPorts[i].port_id),
+                        .cecSupported = legacyPorts[i].cec_supported != 0,
+                        .arcSupported = legacyPorts[i].arc_supported != 0,
+                        .physicalAddress = legacyPorts[i].physical_address};
+    }
+    _hidl_cb(portInfos);
+    return Void();
+}
+
+Return<void> HdmiCec::setOption(OptionKey key, bool value) {
+    mDevice->set_option(mDevice, static_cast<int>(key), value ? 1 : 0);
+    return Void();
+}
+
+Return<void> HdmiCec::setLanguage(const hidl_string& language) {
+    if (language.size() != 3) {
+        LOG(ERROR) << "Wrong language code: expected 3 letters, but it was " << language.size()
+                   << ".";
+        return Void();
+    }
+    const char* languageStr = language.c_str();
+    int convertedLanguage = ((languageStr[0] & 0xFF) << 16) | ((languageStr[1] & 0xFF) << 8) |
+                            (languageStr[2] & 0xFF);
+    mDevice->set_option(mDevice, HDMI_OPTION_SET_LANG, convertedLanguage);
+    return Void();
+}
+
+Return<void> HdmiCec::enableAudioReturnChannel(HdmiPortId portId, bool enable) {
+    mDevice->set_audio_return_channel(mDevice, portId, enable ? 1 : 0);
+    return Void();
+}
+
+Return<bool> HdmiCec::isConnected(HdmiPortId portId) {
+    return mDevice->is_connected(mDevice, portId) > 0;
+}
+
+IHdmiCec* HIDL_FETCH_IHdmiCec(const char* hal) {
+    hdmi_cec_device_t* hdmi_cec_device;
+    int ret = 0;
+    const hw_module_t* hw_module = nullptr;
+
+    ret = hw_get_module(HDMI_CEC_HARDWARE_MODULE_ID, &hw_module);
+    if (ret == 0) {
+        ret = hdmi_cec_open(hw_module, &hdmi_cec_device);
+        if (ret != 0) {
+            LOG(ERROR) << "hdmi_cec_open " << hal << " failed: " << ret;
+        }
+    } else {
+        LOG(ERROR) << "hw_get_module " << hal << " failed: " << ret;
+    }
+
+    if (ret == 0) {
+        return new HdmiCec(hdmi_cec_device);
+    } else {
+        LOG(ERROR) << "Passthrough failed to load legacy HAL.";
+        return nullptr;
+    }
+}
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace cec
+}  // namespace tv
+}  // namespace hardware
+}  // namespace android
diff --git a/tv/cec/2.0/default/HdmiCec.h b/tv/cec/2.0/default/HdmiCec.h
new file mode 100644
index 0000000..ab54770
--- /dev/null
+++ b/tv/cec/2.0/default/HdmiCec.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#ifndef ANDROID_HARDWARE_TV_CEC_V2_0_HDMICEC_H
+#define ANDROID_HARDWARE_TV_CEC_V2_0_HDMICEC_H
+
+#include <algorithm>
+
+#include <android/hardware/tv/cec/2.0/IHdmiCec.h>
+#include <hardware/hardware.h>
+#include <hardware/hdmi_cec.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+namespace android {
+namespace hardware {
+namespace tv {
+namespace cec {
+namespace V2_0 {
+namespace implementation {
+
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::tv::cec::V2_0::CecLogicalAddress;
+using ::android::hardware::tv::cec::V2_0::CecMessage;
+using ::android::hardware::tv::cec::V2_0::CecPhysicalAddress;
+using ::android::hardware::tv::cec::V2_0::HdmiPortId;
+using ::android::hardware::tv::cec::V2_0::HdmiPortInfo;
+using ::android::hardware::tv::cec::V2_0::IHdmiCec;
+using ::android::hardware::tv::cec::V2_0::IHdmiCecCallback;
+using ::android::hardware::tv::cec::V2_0::MaxLength;
+using ::android::hardware::tv::cec::V2_0::OptionKey;
+using ::android::hardware::tv::cec::V2_0::Result;
+using ::android::hardware::tv::cec::V2_0::SendMessageResult;
+
+struct HdmiCec : public IHdmiCec, public hidl_death_recipient {
+    HdmiCec(hdmi_cec_device_t* device);
+    // Methods from ::android::hardware::tv::cec::V2_0::IHdmiCec follow.
+    Return<Result> addDeviceType(CecDeviceType deviceType) override;
+    Return<void> clearDeviceTypes() override;
+    Return<void> setAllDeviceTypes(CecAllDeviceTypes allDeviceTypes) override;
+    Return<void> setDeviceFeatures(CecDeviceType deviceType,
+                                   CecDeviceFeatures /* deviceFeatures */) override;
+    Return<void> setRcProfile(CecDeviceType deviceType,
+                              const CecRcProfile& /* rcProfile */) override;
+    Return<void> readDeviceInfo(CecLogicalAddress logicalAddress,
+                                CecPhysicalAddress physicalAddress,
+                                const readDeviceInfo_cb _hidl_cb) override;
+    Return<SendMessageResult> sendMessage(const CecMessage& message) override;
+    Return<void> setCallback(const sp<IHdmiCecCallback>& callback) override;
+    Return<void> getPortInfo(getPortInfo_cb _hidl_cb) override;
+    Return<void> setOption(OptionKey key, bool value) override;
+    Return<void> setLanguage(const hidl_string& language) override;
+    Return<void> enableAudioReturnChannel(HdmiPortId portId, bool enable) override;
+    Return<bool> isConnected(HdmiPortId portId) override;
+
+    static void eventCallback(const hdmi_event_t* event, void* /* arg */) {
+        if (mCallback != nullptr && event != nullptr) {
+            if (event->type == HDMI_EVENT_CEC_MESSAGE) {
+                size_t length =
+                        std::min(event->cec.length, static_cast<size_t>(MaxLength::MESSAGE_BODY));
+                CecMessage cecMessage{
+                        .initiator = static_cast<CecLogicalAddress>(event->cec.initiator),
+                        .destination = static_cast<CecLogicalAddress>(event->cec.destination),
+                };
+                cecMessage.body.resize(length);
+                for (size_t i = 0; i < length; ++i) {
+                    cecMessage.body[i] = static_cast<uint8_t>(event->cec.body[i]);
+                }
+                mCallback->onCecMessage(cecMessage);
+            } else if (event->type == HDMI_EVENT_HOT_PLUG) {
+                HotplugEvent hotplugEvent{
+                        .connected = event->hotplug.connected > 0,
+                        .portId = static_cast<HdmiPortId>(event->hotplug.port_id)};
+                mCallback->onHotplugEvent(hotplugEvent);
+            }
+        }
+    }
+
+    virtual void serviceDied(uint64_t /*cookie*/,
+                             const wp<::android::hidl::base::V1_0::IBase>& /*who*/) {
+        setCallback(nullptr);
+    }
+
+   private:
+    static sp<IHdmiCecCallback> mCallback;
+    const hdmi_cec_device_t* mDevice;
+};
+
+extern "C" IHdmiCec* HIDL_FETCH_IHdmiCec(const char* name);
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace cec
+}  // namespace tv
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_TV_CEC_V2_0_HDMICEC_H
diff --git a/tv/cec/2.0/default/OWNERS b/tv/cec/2.0/default/OWNERS
new file mode 100644
index 0000000..1b3d095
--- /dev/null
+++ b/tv/cec/2.0/default/OWNERS
@@ -0,0 +1,4 @@
+nchalko@google.com
+amyjojo@google.com
+shubang@google.com
+quxiangfang@google.com
diff --git a/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.rc b/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.rc
new file mode 100644
index 0000000..1e8cd80
--- /dev/null
+++ b/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.rc
@@ -0,0 +1,4 @@
+service vendor.cec-hal-2-0 /vendor/bin/hw/android.hardware.tv.cec@2.0-service
+    class hal
+    user system
+    group system
diff --git a/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.xml b/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.xml
new file mode 100644
index 0000000..61fb1bb
--- /dev/null
+++ b/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+    <hal format="hidl">
+        <name>android.hardware.tv.cec</name>
+        <transport>hwbinder</transport>
+        <version>2.0</version>
+        <interface>
+            <name>IHdmiCec</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</manifest>
diff --git a/tv/cec/2.0/default/service.cpp b/tv/cec/2.0/default/service.cpp
new file mode 100644
index 0000000..dacc38c
--- /dev/null
+++ b/tv/cec/2.0/default/service.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2019 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 "android.hardware.tv.cec@2.0-service"
+
+#include <android/hardware/tv/cec/2.0/IHdmiCec.h>
+#include <hidl/LegacySupport.h>
+
+using android::hardware::defaultPassthroughServiceImplementation;
+using android::hardware::tv::cec::V2_0::IHdmiCec;
+
+int main() {
+    return defaultPassthroughServiceImplementation<IHdmiCec>();
+}
diff --git a/tv/cec/2.0/types.hal b/tv/cec/2.0/types.hal
new file mode 100644
index 0000000..cad6c39
--- /dev/null
+++ b/tv/cec/2.0/types.hal
@@ -0,0 +1,548 @@
+/*
+ * Copyright (C) 2019 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.tv.cec@2.0;
+
+import android.hidl.safe_union@1.0;
+
+/**
+ * CEC device type as specified in CEC Table 11-7 of the CEC spec 2.0b.
+ */
+enum CecDeviceType : int32_t {
+    INACTIVE = -1,
+    TV = 0,
+    RECORDER = 1,
+    TUNER = 3,
+    PLAYBACK = 4,
+    AUDIO_SYSTEM = 5,
+    PURE_CEC_SWITCH = 6,
+    PROCESSOR = 7,
+    MAX = PROCESSOR,
+};
+
+/**
+ * CEC logical address as specified in CEC Table 11-9 of the CEC spec 2.0b.
+ */
+enum CecLogicalAddress : int32_t {
+    TV = 0,
+    RECORDER_1 = 1,
+    RECORDER_2 = 2,
+    TUNER_1 = 3,
+    PLAYBACK_1 = 4,
+    AUDIO_SYSTEM = 5,
+    TUNER_2 = 6,
+    TUNER_3 = 7,
+    PLAYBACK_2 = 8,
+    RECORDER_3 = 9,
+    TUNER_4 = 10,
+    PLAYBACK_3 = 11,
+    BACKUP_1 = 12, // backup1 for Playback/Recording/Tuner/Processor device
+    BACKUP_2 = 13, // backup2 for Playback/Recording/Tuner/Processor device
+    SPECIFIC_USE = 14,
+    UNREGISTERED = 15, // as Initiator address
+    BROADCAST = 15, // as Destination address
+};
+
+/**
+ * HDMI CEC message types.
+ *
+ * The assigned values represent opcode used in CEC frame as specified in
+ * Section 11.10 of the CEC spec 2.0b on top of Section CEC 15 of the CEC
+ * Spec 1.4b.
+ */
+enum CecMessageType : int32_t {
+    FEATURE_ABORT = 0x00,
+    IMAGE_VIEW_ON = 0x04,
+    TUNER_STEP_INCREMENT = 0x05,
+    TUNER_STEP_DECREMENT = 0x06,
+    TUNER_DEVICE_STATUS = 0x07,
+    GIVE_TUNER_DEVICE_STATUS = 0x08,
+    RECORD_ON = 0x09,
+    RECORD_STATUS = 0x0A,
+    RECORD_OFF = 0x0B,
+    TEXT_VIEW_ON = 0x0D,
+    RECORD_TV_SCREEN = 0x0F,
+    GIVE_DECK_STATUS = 0x1A,
+    DECK_STATUS = 0x1B,
+    SET_MENU_LANGUAGE = 0x32,
+    CLEAR_ANALOG_TIMER = 0x33,
+    SET_ANALOG_TIMER = 0x34,
+    TIMER_STATUS = 0x35,
+    STANDBY = 0x36,
+    PLAY = 0x41,
+    DECK_CONTROL = 0x42,
+    TIMER_CLEARED_STATUS = 0x43,
+    USER_CONTROL_PRESSED = 0x44,
+    USER_CONTROL_RELEASED = 0x45,
+    GIVE_OSD_NAME = 0x46,
+    SET_OSD_NAME = 0x47,
+    SET_OSD_STRING = 0x64,
+    SET_TIMER_PROGRAM_TITLE = 0x67,
+    SYSTEM_AUDIO_MODE_REQUEST = 0x70,
+    GIVE_AUDIO_STATUS = 0x71,
+    SET_SYSTEM_AUDIO_MODE = 0x72,
+    REPORT_AUDIO_STATUS = 0x7A,
+    GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D,
+    SYSTEM_AUDIO_MODE_STATUS = 0x7E,
+    ROUTING_CHANGE = 0x80,
+    ROUTING_INFORMATION = 0x81,
+    ACTIVE_SOURCE = 0x82,
+    GIVE_PHYSICAL_ADDRESS = 0x83,
+    REPORT_PHYSICAL_ADDRESS = 0x84,
+    REQUEST_ACTIVE_SOURCE = 0x85,
+    SET_STREAM_PATH = 0x86,
+    DEVICE_VENDOR_ID = 0x87,
+    VENDOR_COMMAND = 0x89,
+    VENDOR_REMOTE_BUTTON_DOWN = 0x8A,
+    VENDOR_REMOTE_BUTTON_UP = 0x8B,
+    GIVE_DEVICE_VENDOR_ID = 0x8C,
+    MENU_REQUEST = 0x8D,
+    MENU_STATUS = 0x8E,
+    GIVE_DEVICE_POWER_STATUS = 0x8F,
+    REPORT_POWER_STATUS = 0x90,
+    GET_MENU_LANGUAGE = 0x91,
+    SELECT_ANALOG_SERVICE = 0x92,
+    SELECT_DIGITAL_SERVICE = 0x93,
+    SET_DIGITAL_TIMER = 0x97,
+    CLEAR_DIGITAL_TIMER = 0x99,
+    SET_AUDIO_RATE = 0x9A,
+    INACTIVE_SOURCE = 0x9D,
+    CEC_VERSION = 0x9E,
+    GET_CEC_VERSION = 0x9F,
+    VENDOR_COMMAND_WITH_ID = 0xA0,
+    CLEAR_EXTERNAL_TIMER = 0xA1,
+    SET_EXTERNAL_TIMER = 0xA2,
+    REPORT_SHORT_AUDIO_DESCRIPTOR = 0xA3,
+    REQUEST_SHORT_AUDIO_DESCRIPTOR = 0xA4,
+    GIVE_FEATURES = 0XA5,
+    REPORT_FEATURES = 0xA6,
+    REQUEST_CURRENT_LATENCY = 0xA7,
+    REPORT_CURRENT_LATENCY = 0xA8,
+    INITIATE_ARC = 0xC0,
+    REPORT_ARC_INITIATED = 0xC1,
+    REPORT_ARC_TERMINATED = 0xC2,
+    REQUEST_ARC_INITIATION = 0xC3,
+    REQUEST_ARC_TERMINATION = 0xC4,
+    TERMINATE_ARC = 0xC5,
+    ABORT = 0xFF,
+    POLLING_MESSAGE = 0xFFFFFF00, // used for cec polling message
+};
+
+/**
+ * Abort Reason as specified in CEC Table 29 of the CEC spec 1.4b.
+ */
+enum AbortReason : int32_t {
+    UNRECOGNIZED_MODE = 0,
+    NOT_IN_CORRECT_MODE = 1,
+    CANNOT_PROVIDE_SOURCE = 2,
+    INVALID_OPERAND = 3,
+    REFUSED = 4,
+    UNABLE_TO_DETERMINE = 5,
+};
+
+enum MaxLength : int32_t {
+    MESSAGE_BODY = 14,
+};
+
+struct CecMessage {
+    /** logical address of sender */
+    CecLogicalAddress initiator;
+
+    /** logical address of receiver */
+    CecLogicalAddress destination;
+
+    /** cec message type */
+    CecMessageType cecMessageType;
+
+    /**
+     * The maximum size of body is 14 (MaxLength::MESSAGE_BODY) as specified in
+     * the section 6 of the CEC Spec 1.4b. Overflowed data must be ignored.
+     */
+    vec<uint8_t> body;
+};
+
+/**
+ * error code used for send_message.
+ */
+enum SendMessageResult : int32_t {
+    SUCCESS = 0,
+    NACK = 1, // not acknowledged
+    BUSY = 2, // bus is busy
+    FAIL = 3,
+};
+
+/**
+ * CEC All Device Type Value as specified in Table 11-30 of the CEC spec 2.0b.
+ */
+enum CecAllDeviceTypeValue : uint8_t {
+    RESERVED_DEVICE_2 = 1 << 0,
+    RESERVED_DEVICE_1 = 1 << 1,
+    CEC_SWITCH_DEVICE = 1 << 2,
+    AUDIO_DEVICE = 1 << 3,
+    PLAYBACK_DEVICE = 1 << 4,
+    TUNER_DEVICE = 1 << 5,
+    RECORDING_DEVICE = 1 << 6,
+    TV_DEVICE   = 1 << 7,
+};
+
+/**
+ * CEC All Device Types
+ *
+ * It is a combination of all supported type from CecAllDeviceTypeValue.
+ * For example a record with tuner functionalitye,
+ * cecAllDeviceTypes = ((CecAllDeviceTypeValue::RECORDING_DEVICE)
+ *                     |(CecAllDeviceTypeValue::TUNER_DEVICE))
+ */
+typedef bitfield<CecAllDeviceTypeValue> CecAllDeviceTypes;
+
+/**
+ * CEC Versions as specified in CEC Table 11-30 of the CEC spec 2.0b.
+ */
+enum CecVersion : int32_t {
+    V_1_3_A   = 0x04,
+    V_1_4   = 0x05, // indicate CEC 1.4, 1.4a or 1.4b
+    V_2_0   = 0x06,
+};
+
+/**
+ * Device Feature
+ *
+ * It is specified in CEC Table 11-30 of the CEC spec 2.0b. As a uint32 there
+ * is room for future extensions aka DeviceFeature2 through DeviceFeature4.
+ */
+enum CecDeviceFeature : uint32_t {
+    RESERVED = 1 << 0,
+    SOURCE_SUPPORT_ARC_RX = 1 << 1,
+    SINK_SUPPORT_ARC_TX = 1 << 2,
+    SOURCE_SUPPORT_SET_AUDIO_RATE = 1 << 3,
+    SUPPORT_CONTROLLED_BY_DECK = 1 << 4,
+    TV_SUPPORT_SET_OSD_STRINGS = 1 << 5,
+    TV_SUPPORT_RECORD_TV_SCREEN = 1 << 6,
+};
+
+/**
+ * CEC Device Features
+ *
+ * It is a combination of all supported features from CecDeviceFeature.
+ * For example a TV with OSD and ARC capabilities,
+ *   CecDeviceFeatures = ((CecDeviceFeature::TV_SUPPORT_SET_OSD_STRINGS)
+ *                       |(CecDeviceFeature::SINK_SUPPORT_ARC_TX))
+ */
+typedef bitfield<CecDeviceFeature> CecDeviceFeatures;
+
+/**
+ * Remote Control Profile
+ *
+ * It is specified in CEC Table 11-30 of the CEC spec 2.0b.
+ */
+enum CecRcProfileId : uint8_t {
+    NONE = 0,   // TV doesn’t support any of these profiles
+    RC_PROFILE_1 = 0x02, // minimalistic zapper (low button count)
+    RC_PROFILE_2 = 0x06, // intermediate between profile 1 and profile 3
+    RC_PROFILE_3 = 0x0A, // typical TV remote
+    RC_PROFILE_4 = 0x0E, // extended form of profile 3
+};
+
+/**
+ * Remote Control Profile Source
+ *
+ * It is specified in CEC Table 11-30 of the CEC spec 2.0b.
+ */
+enum CecRcProfileSource : uint8_t {
+    MEDIA_CONTEXT_SENSITIVE = 1 << 0, // source can handle UI command 0x11
+    MEDIA_TO = 1 << 1, // source can handle UI command 0x10
+    CONTENTS = 1 << 2, // source can handle UI command 0x0B
+    DEVICE_SETUP = 1 << 3, // source can handle UI command 0x0A
+    DEVICE_ROOT = 1 << 4, // source can handle UI command 0x09
+    SOURCE_FLAG = 1 << 6, // Indicate the profile is for source
+};
+
+/**
+ * Remote Control Profile for either TV or Source.
+ */
+safe_union CecRcProfile1 {
+    /** CEC remote control profile for TV. */
+    CecRcProfileId profileId;
+
+    /* CEC remote control profile for source
+     *
+     * It is a combination of all supported profiles from CecRcProfileSource.
+     * For example a playback device support root menu and setup menu,
+     * profileSource = ((CecRcProfileSource::DEVICE_ROOT)
+     *                  |(CecRcProfileSource::DEVICE_SETUP)
+     *                  |(CecRcProfileSource::SOURCE_FLAG))
+     */
+    bitfield<CecRcProfileSource> profileSource;
+};
+
+/**
+ * CEC Remote Control Profiles
+ *
+ * CEC 2.0 only use one byte to represent Remote Control Profile.
+ */
+struct CecRcProfile {
+   CecRcProfile1 rcProfile1;
+};
+
+/**
+ * CEC device power states as specified in CEC Table 11-10 of the CEC spec 2.0b
+ */
+enum CecPowerState : int8_t {
+    ON = 0,
+    STANDBY = 1,
+    ON_TO_STANDBY = 2,
+    STANDBY_TO_ON = 4,
+    UNKNOWN = 0xFF, // some devices may not report power status
+};
+
+/** CEC physical address of device */
+typedef uint16_t CecPhysicalAddress;
+
+/**
+ * CEC device information
+ *
+ * It is initially built during addressing specified in CEC section 11.3 of
+ * the CEC spec 2.0b. It may be updated with cec devices's status changed.
+ */
+struct CecDeviceInfo {
+    /** CEC version which device supports */
+    CecVersion version;
+
+    /** CEC device primary type */
+    CecDeviceType devceType;
+
+    /** CEC all device types */
+    CecAllDeviceTypes allDeviceTypes;
+
+    /** CEC device features */
+    CecDeviceFeatures deviceFeatures;
+
+    /** CEC Device Remote Control Profile */
+    CecRcProfile rcProfile;
+
+    /** CEC Device Vendor ID */
+    uint32_t vendorId;
+
+    /** logical address of device */
+    CecLogicalAddress logicalAddress;
+
+    /** physical of device */
+    CecPhysicalAddress physicalAddress;
+
+    /** power status of device */
+    CecPowerState powerState;
+};
+
+/**
+ * Topology Event Type.
+ */
+enum CecTopologyEventType : int32_t {
+    DEVICE_ADDED,
+    DEVICE_REMOVED,
+    DEVICE_UPDATED,
+};
+
+/**
+ * Topology Event.
+ */
+struct CecTopologyEvent {
+    CecTopologyEventType eventType;
+    CecLogicalAddress logicalAddress;
+    CecPhysicalAddress physicalAddress;
+
+    /** true if the event is about the device which the system run on */
+    bool isHostDevice;
+};
+
+
+/**
+ * CEC UI Command Codes as specified in CEC Table 11-31 of the CEC spec 2.0b
+ */
+enum CecUICommandCodes : int32_t {
+    SELECT_OK = 0x00,
+    UP = 0x01,
+    DOWN = 0x02,
+    LEFT = 0x03,
+    RIGHT = 0x04,
+    RIGHT_UP = 0x05,
+    RIGHT_DOWN = 0x06,
+    LEFT_UP = 0x07,
+    LEFT_DOWN = 0x08,
+    DEVICE_ROOT_MENU = 0x09,
+    DEVICE_SETUP_MENU = 0x0A,
+    CONTENTS_MENU = 0x0B,
+    FAVORITE_MENU = 0x0C,
+    BACK = 0x0D,
+    MEDIA_TOP_MENU = 0x10,
+    MEDIA_CONTEXT_SENSITIVE_MENU = 0x11,
+    NUMBER_ENTRY_MODE = 0x1D,
+    NUMBER_11 = 0x1E,
+    NUMBER_12 = 0x1F,
+    NUMBER_0 = 0x20, // or NUMBER 10
+    NUMBER_1 = 0x21,
+    NUMBER_2 = 0x22,
+    NUMBER_3 = 0x23,
+    NUMBER_4 = 0x24,
+    NUMBER_5 = 0x25,
+    NUMBER_6 = 0x26,
+    NUMBER_7 = 0x27,
+    NUMBER_8 = 0x28,
+    NUMBER_9 = 0x29,
+    DOT = 0x2A,
+    ENTER = 0x2B,
+    CLEAR = 0x2C,
+    NEXT_FAVORITE = 0x2F,
+    CHANNEL_UP = 0x30,
+    CHANNEL_DOWN = 0x31,
+    PREVIOUS_CHANNEL = 0x32,
+    SOUND_SELECT = 0x33,
+    INPUT_SELECT = 0x34,
+    DISPLAY_INFORMATION = 0x35,
+    HELP = 0x36,
+    PAGE_UP = 0x37,
+    PAGE_DOWN = 0x38,
+    POWER = 0x40,
+    VOLUME_UP = 0x41,
+    VOLUME_DOWN = 0x42,
+    MUTE = 0x43,
+    PLAY = 0x44,
+    STOP = 0x45,
+    PAUSE = 0x46,
+    RECORD = 0x47,
+    REWIND = 0x48,
+    FAST_FORWARD = 0x49,
+    EJECT = 0x4A,
+    SKIP_FORWARD = 0x4B,
+    SKIP_BACKWARD = 0x4C,
+    STOP_RECORD = 0x4D,
+    PAUSE_RECORD = 0x4E,
+    ANGLE = 0x50,
+    SUB_PICTURE = 0x51,
+    VIDEO_ON_DEMAND = 0x52,
+    ELECTRONIC_PROGRAM_GUIDE = 0x53,
+    TIMER_PROGRAMMING = 0x54,
+    INITIAL_CONFIGURATION = 0x55,
+    SELECT_BROADCAST_TYPE = 0x56,
+    SELECT_SOUND_PRESENTATION = 0x57,
+    AUDIO_DESCRIPTION = 0x58,
+    INTERNET = 0x59,
+    THREE_DIMENSIONAL_MODE = 0x5A,
+    PLAY_FUNCTION = 0x60,
+    PAUSE_PLAY_FUNCTION = 0x61,
+    RECORD_FUNCTION = 0x62,
+    PAUSE_RECORD_FUNCTION = 0x63,
+    STOP_FUNCTION = 0x64,
+    MUTE_FUNCTION = 0x65,
+    RESTORE_VOLUME_FUNCTION = 0x66,
+    TUNE_FUNCTION = 0x67,
+    SELECT_MEDIA_FUNCTION = 0x68,
+    SELECT_AV_INPUT_FUNCTION = 0x69,
+    SELECT_AUDIO_INPUT_FUNCTION = 0x6A,
+    POWER_TOGGLE_FUNCTION = 0x6B,
+    POWER_OFF_FUNCTION = 0x6C,
+    POWER_ON_FUNCTION = 0x6D,
+    F1 = 0x71, // BLUE
+    F2 = 0x72, // RED
+    F3 = 0x73, // GREEN
+    F4 = 0x74, // YELLOW
+    F5 = 0x75,
+    DATA = 0x76,
+};
+
+/**
+ * HDMI port type.
+ */
+enum HdmiPortType : int32_t {
+    INPUT = 0,
+    OUTPUT = 1,
+};
+
+/**
+ * Options used for IHdmiCec.setOption()
+ */
+enum OptionKey : int32_t {
+    /**
+     * When set to false, HAL does not wake up the system upon receiving <Image
+     * View On> or <Text View On>. Used when user changes the TV settings to
+     * disable the auto TV on functionality.
+     * Deprecated since <Image View On> and <Text View On> become mandatory
+     * featrues for CEC device. Use ENABLE_CEC OptionKey to disable CEC
+     * functionality instead.
+     * True by Default
+     */
+    WAKEUP = 1,
+
+    /**
+     * When set to false, all the CEC commands are discarded. if logical address
+     * is ever used, it shall be released. Used when user changes the TV
+     * settings to disable CEC functionality.
+     * True by default.
+     *
+     */
+    ENABLE_CEC = 2,
+
+    /**
+     * Setting this flag to false means Android system must stop handling CEC
+     * service and yield the control over to the microprocessor that is powered
+     * on through the standby mode.The microprocessor shall keep current logical
+     * and physical address. It shall response POLLING_MESSAGE, GIVE_FEATURES,
+     * GIVE_DEVICE_POWER_STATUS,GIVE_DEVICE_VENDOR_ID and GIVE_PHYSICAL_ADDRESS
+     * to allow other CEC devices to build CEC devices map specified in CEC
+     * section 11.3 of the CEC spec 2.0b.
+     * When set to true, the system must gain the control over, hence telling
+     * the microprocessor to start forwarding CEC messages to Android system.
+     * For example, this may be called when system goes in and out of
+     * standby mode to notify the microprocessor that it should start/stop
+     * handling CEC commands on behalf of the system.
+     * True by default.
+     */
+    SYSTEM_CEC_CONTROL = 3,
+
+    /* Option 4 not used */
+};
+
+/**
+ * Hdmi port ID.
+ *
+ * It shall start from 1 which corresponds to HDMI "port 1".
+ */
+typedef uint32_t HdmiPortId;
+
+/** Hdmi hotplug event */
+struct HotplugEvent {
+    bool connected;
+    HdmiPortId portId;
+};
+
+/**
+ * HDMI port descriptor
+ */
+struct HdmiPortInfo {
+    HdmiPortType type;
+    HdmiPortId portId;
+    bool cecSupported;
+    bool arcSupported;
+    CecPhysicalAddress physicalAddress;
+};
+
+enum Result : int32_t {
+    SUCCESS = 0,
+    FAILURE_UNKNOWN = 1,
+    FAILURE_INVALID_ARGS = 2,
+    FAILURE_INVALID_STATE = 3,
+    FAILURE_NOT_SUPPORTED = 4,
+    FAILURE_BUSY = 5,
+};
diff --git a/usb/1.2/Android.bp b/usb/1.2/Android.bp
new file mode 100644
index 0000000..55ffad0
--- /dev/null
+++ b/usb/1.2/Android.bp
@@ -0,0 +1,29 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.usb@1.2",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+        "IUsb.hal",
+        "IUsbCallback.hal",
+    ],
+    interfaces: [
+        "android.hardware.usb@1.0",
+        "android.hardware.usb@1.1",
+        "android.hidl.base@1.0",
+    ],
+    types: [
+        "ContaminantDetectionStatus",
+        "ContaminantProtectionMode",
+        "ContaminantProtectionStatus",
+        "PortStatus",
+        "Status",
+    ],
+    gen_java: true,
+    gen_java_constants: true,
+}
+
diff --git a/usb/1.2/IUsb.hal b/usb/1.2/IUsb.hal
new file mode 100644
index 0000000..ecc911e
--- /dev/null
+++ b/usb/1.2/IUsb.hal
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 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.usb@1.2;
+
+import android.hardware.usb@1.1::IUsb;
+
+/**
+ * The setCallback function in V1_0 is used to register the V1_2
+ * IUsbCallback object as well. The implementation can use the
+ * castFrom method to cast the IUsbCallback object.
+ */
+interface IUsb extends @1.1::IUsb {
+    /**
+     * When supportsEnableContaminantPresenceDetection is true,
+     * enableContaminantPresenceDetection enables/disables contaminant
+     * presence detection algorithm. Calling enableContaminantPresenceDetection
+     * when supportsEnableContaminantPresenceDetection is false does
+     * not have any effect.
+     * Change in contantaminant presence status should notify should
+     * be notified to the client via notifyPortStatusChange_1_2 through
+     * PortStatus.
+     *
+     * @param portName name of the port.
+     * @param enable true Enable contaminant presence detection algorithm.
+     *               false Disable contaminant presence detection algorithm.
+     */
+    oneway enableContaminantPresenceDetection(string portName, bool enable);
+
+    /**
+     * When supportsEnableContaminantPresenceProtection is true,
+     * enableContaminantPresenceProtection enables/disables contaminant
+     * presence protection algorithm. Calling
+     * enableContaminantPresenceProtection
+     * when supportsEnableContaminantPresenceProtection is false does
+     * not have any effect.
+     * Used to enable/disable contaminant presence protection algorithm.
+     * Enabling port protection algoritm must make the lower layers to autonomously
+     * act on taking the corresponding preventive measure mentioned at
+     * ContaminantProtectionModes when contaminant is detected on the USB Port.
+     * Calling this method with enable set to true must set to contaminantProtectionEnabled
+     * to true upon success and vice versa.
+     * currentContaminantProtectionMode should be updated whenever there is a
+     * change in the status of contaminant presence protection algorithm.
+     *
+     * @param portName name of the port.
+     * @param enable true Reduce capabilities of the port to protect port
+     *                    from damage due to contaminant presence.
+     *               false No action is taken upon contaminant presence.
+     */
+    oneway enableContaminantPresenceProtection(string portName, bool enable);
+};
diff --git a/usb/1.2/IUsbCallback.hal b/usb/1.2/IUsbCallback.hal
new file mode 100644
index 0000000..8cc16df
--- /dev/null
+++ b/usb/1.2/IUsbCallback.hal
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 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.usb@1.2;
+
+import android.hardware.usb@1.1::IUsbCallback;
+import android.hardware.usb@1.0::Status;
+
+/**
+ * Callback object used for all the IUsb async methods which expects a result.
+ * Caller is expected to register the callback object using setCallback method
+ * to receive updates on the PortStatus.
+ */
+interface IUsbCallback extends @1.1::IUsbCallback {
+    /**
+     * Used to convey the current port status to the caller.
+     * Must be called either when PortState changes due to the port partner or
+     * when caller requested for the PortStatus update through queryPortStatus.
+     *
+     * @param currentPortStatus vector object of current status(PortStatus
+     * of all the typeC ports in the device.
+     * @param retval SUCCESS when the required information was enquired form
+     *               kernel and the PortStatus_1_2 object was built.
+     *               ERROR otherwise.
+     */
+    oneway notifyPortStatusChange_1_2(vec<PortStatus> currentPortStatus,
+        @1.0::Status retval);
+};
+
diff --git a/usb/1.2/types.hal b/usb/1.2/types.hal
new file mode 100644
index 0000000..081a643
--- /dev/null
+++ b/usb/1.2/types.hal
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2018 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.usb@1.2;
+
+import android.hardware.usb@1.1::PortStatus_1_1;
+import android.hardware.usb@1.0::Status;
+
+enum Status : @1.0::Status {
+    /**
+     * Error value returned when the operation is not supported.
+     */
+    NOT_SUPPORTED = 4,
+};
+
+@export
+enum ContaminantDetectionStatus : uint32_t {
+    /**
+     * Contaminant presence detection is not supported.
+     */
+    NOT_SUPPORTED = 0,
+
+    /**
+     * Contaminant presence detection is supported but disabled.
+     */
+    DISABLED = 1,
+
+    /**
+     * Contaminant presence detection is enabled and contaminant not detected.
+     */
+    NOT_DETECTED = 2,
+
+    /**
+     * Contaminant presence detection is enabled and contaminant detected.
+     */
+    DETECTED = 3,
+};
+
+@export
+enum ContaminantProtectionMode : uint32_t {
+    /**
+     * No action performed upon detection of contaminant presence.
+     */
+    NONE = 0,
+
+    /**
+     * Upon detection of contaminant presence, Port is forced to sink only
+     * mode where a port shall only detect chargers until contaminant presence
+     * is no longer detected.
+     */
+    FORCE_SINK = 1 << 0,
+
+    /**
+     * Upon detection of contaminant presence, Port is forced to source only
+     * mode where a port shall only detect usb accessories such as headsets
+     * until contaminant presence is no longer detected.
+     */
+    FORCE_SOURCE = 1 << 1,
+
+    /**
+     * Upon detection of contaminant presence, port is disabled until contaminant
+     * presence is no longer detected. In the disabled state port will
+     * not respond to connection of chargers or usb accessories.
+     */
+    FORCE_DISABLE = 1 << 2,
+};
+
+@export
+enum ContaminantProtectionStatus : ContaminantProtectionMode {
+    /**
+     * Client disabled cotaminant protection by calling
+     * enableContaminantPresencePortProtection set to false. Low level drivers should
+     * not autmomously take any corrective action when contaminant presence is detected.
+     */
+    DISABLED = 1 << 3,
+};
+
+struct PortStatus {
+    PortStatus_1_1 status_1_1;
+
+    /**
+     * Contaminant presence protection modes supported by the port.
+     */
+    bitfield<ContaminantProtectionMode> supportedContaminantProtectionModes;
+
+    /**
+     * Client can enable/disable contaminant presence protection through
+     * enableContaminantPresenceProtection when true.
+     */
+    bool supportsEnableContaminantPresenceProtection;
+
+    /**
+     * Contaminant presence protection modes currently active for the port.
+     */
+    ContaminantProtectionStatus contaminantProtectionStatus;
+
+    /**
+     * Client can enable/disable contaminant presence detection through
+     * enableContaminantPresenceDetection when true.
+     */
+    bool supportsEnableContaminantPresenceDetection;
+
+    /**
+     * Current status of contaminant detection algorithm.
+     */
+    ContaminantDetectionStatus contaminantDetectionStatus;
+};