Merge RQ3A.210705.001 to aosp-master - DO NOT MERGE

Merged-In: Ibc4a224f15c8acb2cbbdf0aefb336162f02e2b48
Merged-In: I583dbf265ecf36a4084420b4e0054920170615e1
Merged-In: I583dbf265ecf36a4084420b4e0054920170615e1
Change-Id: Ic56dae6c093e501cb9841265e44bcc5fccf39378
diff --git a/Android.bp b/Android.bp
index d0eded4..bf1f8ff 100644
--- a/Android.bp
+++ b/Android.bp
@@ -3,3 +3,34 @@
               "hardware/google/pixel",
               "hardware/qcom/bootctrl"],
 }
+
+package {
+    default_applicable_licenses: ["device_google_crosshatch_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+// See: http://go/android-license-faq
+license {
+    name: "device_google_crosshatch_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-BSD",
+        "SPDX-license-identifier-GPL-2.0",
+        "SPDX-license-identifier-MIT",
+        "legacy_unencumbered",
+    ],
+    // large-scale-change unable to identify any license_text files
+}
diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk
index eba44f8..8d8688c 100644
--- a/BoardConfig-common.mk
+++ b/BoardConfig-common.mk
@@ -15,6 +15,7 @@
 #
 
 include build/make/target/board/BoardConfigMainlineCommon.mk
+include build/make/target/board/BoardConfigPixelCommon.mk
 
 TARGET_BOARD_PLATFORM := sdm845
 TARGET_BOARD_INFO_FILE := device/google/crosshatch/board-info.txt
@@ -97,7 +98,7 @@
     libfstab
 
 ifneq ($(filter %_mainline,$(TARGET_PRODUCT)),)
-BOARD_AVB_VBMETA_SYSTEM := system system_ext
+BOARD_AVB_VBMETA_SYSTEM := system system_ext product
 BOARD_AVB_VBMETA_SYSTEM_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
 BOARD_AVB_VBMETA_SYSTEM_ALGORITHM := SHA256_RSA2048
 BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
diff --git a/CleanSpec.mk b/CleanSpec.mk
index eebe141..70ec95f 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -167,3 +167,11 @@
 
 # Use stable aidl power HAL
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.power@1.3-service.pixel-libperfmgr.rc)
+
+# Update to USB HAL 1.2
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.usb@1.1-service.crosshatch)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.usb@1.1-service.crosshatch.rc)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/vintf/manifest/android.hardware.usb@1.1-service.crosshatch.xml)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.usb@1.2-service.crosshatch)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.usb@1.2-service.crosshatch.rc)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/vintf/manifest/android.hardware.usb@1.2-service.crosshatch.xml)
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..018a8b8
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,4 @@
+third_party {
+  # would be NOTICE save for sdm845/original-kernel-headers/
+  license_type: RESTRICTED
+}
diff --git a/aosp_blueline.mk b/aosp_blueline.mk
index 624d5da..6598167 100644
--- a/aosp_blueline.mk
+++ b/aosp_blueline.mk
@@ -18,7 +18,7 @@
 # All components inherited here go to system image
 #
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
 
 # Enable mainline checking
 # TODO(b/138706293): enable Enable mainline checking later
@@ -49,8 +49,11 @@
 # STOPSHIP deal with Qualcomm stuff later
 # PRODUCT_RESTRICT_VENDOR_FILES := all
 
-PRODUCT_PACKAGES += com.android.vndk.current.on_vendor
-
+# Keep the VNDK APEX in /system partition for REL branches as these branches are
+# expected to have stable API/ABI surfaces.
+ifneq (REL,$(PLATFORM_VERSION_CODENAME))
+  PRODUCT_PACKAGES += com.android.vndk.current.on_vendor
+endif
 
 PRODUCT_MANUFACTURER := Google
 PRODUCT_NAME := aosp_blueline
diff --git a/aosp_crosshatch.mk b/aosp_crosshatch.mk
index c921d36..8632b92 100644
--- a/aosp_crosshatch.mk
+++ b/aosp_crosshatch.mk
@@ -18,7 +18,7 @@
 # All components inherited here go to system image
 #
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
 
 # Enable mainline checking
 # TODO(b/138706293): enable Enable mainline checking later
@@ -49,8 +49,11 @@
 # STOPSHIP deal with Qualcomm stuff later
 # PRODUCT_RESTRICT_VENDOR_FILES := all
 
-PRODUCT_PACKAGES += com.android.vndk.current.on_vendor
-
+# Keep the VNDK APEX in /system partition for REL branches as these branches are
+# expected to have stable API/ABI surfaces.
+ifneq (REL,$(PLATFORM_VERSION_CODENAME))
+  PRODUCT_PACKAGES += com.android.vndk.current.on_vendor
+endif
 
 PRODUCT_MANUFACTURER := Google
 PRODUCT_NAME := aosp_crosshatch
diff --git a/blueline/overlay/frameworks/base/core/res/res/xml/power_profile.xml b/blueline/overlay/frameworks/base/core/res/res/xml/power_profile.xml
index 844a1fb..8cf30bd 100644
--- a/blueline/overlay/frameworks/base/core/res/res/xml/power_profile.xml
+++ b/blueline/overlay/frameworks/base/core/res/res/xml/power_profile.xml
@@ -190,7 +190,7 @@
     <item name="wifi.controller.rx">125</item>
     <!-- Tx current for wifi radio in mA-->
     <item name="wifi.controller.tx">350</item>
-    <!-- Operating volatage for wifi radio in mV.-->
+    <!-- Operating voltage for wifi radio in mV.-->
     <item name="wifi.controller.voltage">3700</item>
 
     <!-- Idle current for bluetooth in mA.-->
diff --git a/blueline/overlay_packages/SettingsOverlayG013A/Android.bp b/blueline/overlay_packages/SettingsOverlayG013A/Android.bp
index b6a76e6..d0ecd02 100644
--- a/blueline/overlay_packages/SettingsOverlayG013A/Android.bp
+++ b/blueline/overlay_packages/SettingsOverlayG013A/Android.bp
@@ -1,4 +1,8 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 runtime_resource_overlay {
     name: "SettingsOverlayG013A",
     product_specific: true,
-}
\ No newline at end of file
+}
diff --git a/blueline/overlay_packages/SettingsOverlayG013B/Android.bp b/blueline/overlay_packages/SettingsOverlayG013B/Android.bp
index cf4dad7..f25c812 100644
--- a/blueline/overlay_packages/SettingsOverlayG013B/Android.bp
+++ b/blueline/overlay_packages/SettingsOverlayG013B/Android.bp
@@ -1,4 +1,8 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 runtime_resource_overlay {
     name: "SettingsOverlayG013B",
     product_specific: true,
-}
\ No newline at end of file
+}
diff --git a/bootctrl/Android.bp b/bootctrl/Android.bp
index e9d83b0..c29bf7d 100644
--- a/bootctrl/Android.bp
+++ b/bootctrl/Android.bp
@@ -14,6 +14,10 @@
 // limitations under the License.
 //
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_library {
     name: "bootctrl.sdm845",
     defaults: ["bootctrl_hal_defaults"],
diff --git a/crosshatch/overlay/frameworks/base/core/res/res/xml/power_profile.xml b/crosshatch/overlay/frameworks/base/core/res/res/xml/power_profile.xml
index bcdc66a..90d8a4f 100644
--- a/crosshatch/overlay/frameworks/base/core/res/res/xml/power_profile.xml
+++ b/crosshatch/overlay/frameworks/base/core/res/res/xml/power_profile.xml
@@ -190,7 +190,7 @@
     <item name="wifi.controller.rx">125</item>
     <!-- Tx current for wifi radio in mA-->
     <item name="wifi.controller.tx">350</item>
-    <!-- Operating volatage for wifi radio in mV.-->
+    <!-- Operating voltage for wifi radio in mV.-->
     <item name="wifi.controller.voltage">3700</item>
 
     <!-- Idle current for bluetooth in mA.-->
diff --git a/crosshatch/overlay/packages/apps/overlays/NoCutoutOverlay/Android.mk b/crosshatch/overlay/packages/apps/overlays/NoCutoutOverlay/Android.mk
index 0602439..f326820 100644
--- a/crosshatch/overlay/packages/apps/overlays/NoCutoutOverlay/Android.mk
+++ b/crosshatch/overlay/packages/apps/overlays/NoCutoutOverlay/Android.mk
@@ -9,6 +9,8 @@
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 
 LOCAL_PACKAGE_NAME := NoCutoutOverlay
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_RRO_PACKAGE)
diff --git a/crosshatch/overlay_packages/SettingsOverlayG013C/Android.bp b/crosshatch/overlay_packages/SettingsOverlayG013C/Android.bp
index 5dcbc04..322f5a3 100644
--- a/crosshatch/overlay_packages/SettingsOverlayG013C/Android.bp
+++ b/crosshatch/overlay_packages/SettingsOverlayG013C/Android.bp
@@ -1,4 +1,8 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 runtime_resource_overlay {
     name: "SettingsOverlayG013C",
     product_specific: true,
-}
\ No newline at end of file
+}
diff --git a/crosshatch/overlay_packages/SettingsOverlayG013D/Android.bp b/crosshatch/overlay_packages/SettingsOverlayG013D/Android.bp
index cee7d1b..f7130be 100644
--- a/crosshatch/overlay_packages/SettingsOverlayG013D/Android.bp
+++ b/crosshatch/overlay_packages/SettingsOverlayG013D/Android.bp
@@ -1,4 +1,8 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 runtime_resource_overlay {
     name: "SettingsOverlayG013D",
     product_specific: true,
-}
\ No newline at end of file
+}
diff --git a/device.mk b/device.mk
index f2f082d..cfebbf5 100644
--- a/device.mk
+++ b/device.mk
@@ -241,7 +241,8 @@
     frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \
     frameworks/native/data/etc/android.hardware.vulkan.compute-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.compute.xml \
     frameworks/native/data/etc/android.hardware.vulkan.version-1_1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \
-    frameworks/native/data/etc/android.software.vulkan.deqp.level-2020-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \
+    frameworks/native/data/etc/android.software.vulkan.deqp.level-2021-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \
+    frameworks/native/data/etc/android.software.opengles.deqp.level-2021-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.opengles.deqp.level.xml \
     frameworks/native/data/etc/android.hardware.telephony.carrierlock.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.carrierlock.xml \
     frameworks/native/data/etc/android.hardware.se.omapi.uicc.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.se.omapi.uicc.xml \
     frameworks/native/data/etc/android.hardware.strongbox_keystore.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.strongbox_keystore.xml \
@@ -291,6 +292,10 @@
     persist.camera.is_type=5 \
     persist.camera.gzoom.at=0
 
+# b/166675194
+PRODUCT_PROPERTY_OVERRIDES += \
+    ro.vendor.camera.provider24.disable_mem_init=1
+
 # camera google face detection
 PRODUCT_PROPERTY_OVERRIDES += \
     persist.camera.googfd.enable=1
@@ -367,8 +372,10 @@
 
 # Light HAL
 PRODUCT_PACKAGES += \
-    lights.$(PRODUCT_PLATFORM) \
+    lights.qcom \
     hardware.google.light@1.0-service
+PRODUCT_PROPERTY_OVERRIDES += \
+    ro.hardware.lights=qcom
 
 # Memtrack/Vibrator HALs
 PRODUCT_PACKAGES += \
@@ -434,7 +441,7 @@
     device/google/crosshatch/nfc/libese-nxp.conf:$(TARGET_COPY_OUT_VENDOR)/etc/libese-nxp.conf
 
 PRODUCT_PACKAGES += \
-    android.hardware.usb@1.1-service.crosshatch
+    android.hardware.usb@1.2-service.crosshatch
 
 PRODUCT_PACKAGES += \
     libmm-omxcore \
@@ -888,6 +895,9 @@
     persist.vendor.verbose_logging_enabled=false
 endif
 
+# Pixel Logger
+include hardware/google/pixel/PixelLogger/PixelLogger.mk
+
 include hardware/google/pixel/pixelstats/device.mk
 include hardware/google/pixel/mm/device_legacy.mk
 include hardware/google/pixel/thermal/device.mk
diff --git a/dumpstate/Android.mk b/dumpstate/Android.mk
index a5cb24b..7e76483 100644
--- a/dumpstate/Android.mk
+++ b/dumpstate/Android.mk
@@ -17,6 +17,8 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_MODULE := android.hardware.dumpstate@1.1-service.crosshatch
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
 LOCAL_INIT_RC := android.hardware.dumpstate@1.1-service.crosshatch.rc
 LOCAL_MODULE_RELATIVE_PATH := hw
 
diff --git a/gpt-utils/Android.bp b/gpt-utils/Android.bp
index 1a13322..a4ff872 100644
--- a/gpt-utils/Android.bp
+++ b/gpt-utils/Android.bp
@@ -15,6 +15,15 @@
 //
 
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "device_google_crosshatch_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-BSD
+    default_applicable_licenses: ["device_google_crosshatch_license"],
+}
+
 cc_library {
     name: "libgptutils.crosshatch",
     vendor: true,
diff --git a/gpt-utils/gpt-utils.cpp b/gpt-utils/gpt-utils.cpp
index f21e14f..b32e72f 100644
--- a/gpt-utils/gpt-utils.cpp
+++ b/gpt-utils/gpt-utils.cpp
@@ -157,11 +157,18 @@
     else
         r = read(fd, buf, len);
 
-    if (r < 0)
+    if (r < 0) {
         fprintf(stderr, "block dev %s failed: %s\n", rw ? "write" : "read",
                 strerror(errno));
-    else
-        r = 0;
+    } else {
+        if (rw) {
+            r = fsync(fd);
+            if (r < 0)
+                fprintf(stderr, "fsync failed: %s\n", strerror(errno));
+        } else {
+            r = 0;
+        }
+    }
 
     return r;
 }
diff --git a/health/Android.bp b/health/Android.bp
index 534f12d..2b27346 100644
--- a/health/Android.bp
+++ b/health/Android.bp
@@ -14,6 +14,10 @@
  * limitations under the License.
  */
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_binary {
     name: "android.hardware.health@2.0-service.crosshatch",
     init_rc: ["android.hardware.health@2.0-service.crosshatch.rc"],
diff --git a/init.hardware.rc b/init.hardware.rc
index a065339..00960b3 100644
--- a/init.hardware.rc
+++ b/init.hardware.rc
@@ -771,7 +771,7 @@
     class core
     user root
     group root
-    writepid /dev/cpuset/system-background/tasks
+    task_profiles ServiceCapacityLow
 
 service ppd /vendor/bin/mm-pp-dpps
     class late_start
@@ -792,21 +792,6 @@
 on property:init.svc.vendor.hwcomposer-2-3=running
     start ppd
 
-# b/70518189 vDSO experiments
-on property:sys.vdso=*
-    write /sys/module/vdso/parameters/enable_32 1
-    write /sys/module/vdso/parameters/enable_64 1
-
-on property:sys.vdso=false
-    write /sys/module/vdso/parameters/enable_32 0
-    write /sys/module/vdso/parameters/enable_64 0
-
-on property:sys.vdso=64
-    write /sys/module/vdso/parameters/enable_32 0
-
-on property:sys.vdso=32
-    write /sys/module/vdso/parameters/enable_64 0
-
 on property:ro.boot.mode=sota
     setprop ro.boot.sota enabled
 
diff --git a/init.hardware.xr.rc b/init.hardware.xr.rc
index 983f13e..cbbd776 100644
--- a/init.hardware.xr.rc
+++ b/init.hardware.xr.rc
@@ -21,11 +21,6 @@
 import /vendor/etc/init/hw/init.${ro.boot.hardware.platform}.common.rc
 
 on init
-    # Temporarily stop booting into VR directly due to battery drain.
-    # TODO(b/131327495): Re-enable this once VrHeadsetPowerPolicyService or its
-    #                    equivalent lands in Android master.
-    setprop ro.boot.vr 0
-
     # Setup cpusets used by the VR services.
     mkdir /dev/cpuset/kernel 0750 root system
     write /dev/cpuset/kernel/cpus 0
diff --git a/json-c/Android.mk b/json-c/Android.mk
index 9cd1e23..1e04f3c 100644
--- a/json-c/Android.mk
+++ b/json-c/Android.mk
@@ -1,6 +1,9 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_MODULE := libjson
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-MIT legacy_unencumbered
+LOCAL_LICENSE_CONDITIONS := notice unencumbered
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/COPYING
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
 LOCAL_SRC_FILES := arraylist.c \
 		debug.c \
diff --git a/keymaster/Android.bp b/keymaster/Android.bp
index afbfc41..0e8bb14 100644
--- a/keymaster/Android.bp
+++ b/keymaster/Android.bp
@@ -13,6 +13,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_binary {
     name: "wait_for_strongbox",
     relative_install_path: "hw",
diff --git a/nfc/libnfc-nci.conf b/nfc/libnfc-nci.conf
index e17401a..90dcbe7 100644
--- a/nfc/libnfc-nci.conf
+++ b/nfc/libnfc-nci.conf
@@ -96,3 +96,9 @@
 # 0: General implementation
 # 1: Legacy implementation
 LEGACY_MIFARE_READER=0
+
+###############################################################################
+# Nfc recovery implementation
+# 0: Crash Nfc Service
+# 1: Toggle Nfc state
+RECOVERY_OPTION=1
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index d12c096..3d62ae9 100755
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -318,15 +318,12 @@
 
     <!-- Default list of files pinned by the Pinner Service -->
     <string-array translatable="false" name="config_defaultPinnerServiceFiles">
-        <item>"/system/framework/arm64/boot-framework.oat"</item>
         <item>"/system/framework/framework.jar"</item>
-        <item>"/system/framework/oat/arm64/services.odex"</item>
         <item>"/system/framework/services.jar"</item>
         <item>"/apex/com.android.art/javalib/core-oj.jar"</item>
         <item>"/apex/com.android.art/javalib/core-libart.jar"</item>
         <item>"/apex/com.android.media/javalib/updatable-media.jar"</item>
         <item>"/system_ext/priv-app/SystemUIGoogle/SystemUIGoogle.apk"</item>
-        <item>"/system_ext/priv-app/SystemUIGoogle/oat/arm64/SystemUIGoogle.odex"</item>
         <item>"/system/lib64/libsurfaceflinger.so"</item>
     </string-array>
 
@@ -336,17 +333,6 @@
     <!-- Should the pinner service pin the Home application? -->
     <bool name="config_pinnerHomeApp">true</bool>
 
-    <!-- List of files pinned by the Pinner Service with the JIT Zygote boot image b/119800099 -->
-    <string-array translatable="false" name="config_jitzygoteBootImagePinnerServiceFiles">
-        <item>"/system/framework/framework.jar"</item>
-        <item>"/system/framework/services.jar"</item>
-        <item>"/apex/com.android.art/javalib/core-oj.jar"</item>
-        <item>"/apex/com.android.art/javalib/core-libart.jar"</item>
-        <item>"/apex/com.android.media/javalib/updatable-media.jar"</item>
-        <item>"/system_ext/priv-app/SystemUIGoogle/SystemUIGoogle.apk"</item>
-        <item>"/system/lib64/libsurfaceflinger.so"</item>
-    </string-array>
-
     <!-- Enable system navigation keys. -->
     <bool name="config_supportSystemNavigationKeys">true</bool>
 
diff --git a/overlay/packages/services/Telephony/res/values/config.xml b/overlay/packages/services/Telephony/res/values/config.xml
index c269e3d..bc75132 100644
--- a/overlay/packages/services/Telephony/res/values/config.xml
+++ b/overlay/packages/services/Telephony/res/values/config.xml
@@ -29,6 +29,9 @@
     <!-- String indicating the package name of the device ImsService implementation for RCS. -->
     <string name="config_ims_rcs_package" translatable="false">com.android.service.ims</string>
 
+    <!-- Whether or not to support RCS User Capability Exchange -->
+    <bool name="config_rcs_user_capability_exchange_enabled">false</bool>
+
     <!-- This device supports the AudioManager Telephony audio device and output onto this
          device using {@link AudioDeviceInfo#TYPE_TELEPHONY}.
          This is used to support carriers which generate a recording tone to the remote party
diff --git a/pixelstats/Android.bp b/pixelstats/Android.bp
index 211a311..21360ff 100644
--- a/pixelstats/Android.bp
+++ b/pixelstats/Android.bp
@@ -13,6 +13,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_binary {
   name: "pixelstats-vendor",
   init_rc: ["pixelstats-vendor.crosshatch.rc"],
@@ -32,4 +36,3 @@
   static_libs: ["chre_client"],
   header_libs: ["chre_api"],
 }
-
diff --git a/powerstats/Android.bp b/powerstats/Android.bp
index ad273df..d7b5a2b 100644
--- a/powerstats/Android.bp
+++ b/powerstats/Android.bp
@@ -12,6 +12,10 @@
 // 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 {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_binary {
     name: "android.hardware.power.stats@1.0-service.pixel",
     relative_install_path: "hw",
diff --git a/rro_overlays/WifiOverlay/Android.bp b/rro_overlays/WifiOverlay/Android.bp
index c2089a1..3929ea9 100644
--- a/rro_overlays/WifiOverlay/Android.bp
+++ b/rro_overlays/WifiOverlay/Android.bp
@@ -1,3 +1,7 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 runtime_resource_overlay {
     name: "WifiOverlay",
     theme: "WifiOverlay",
diff --git a/sdm845/thermal-engine/Android.mk b/sdm845/thermal-engine/Android.mk
index 5e477c6..12de449 100644
--- a/sdm845/thermal-engine/Android.mk
+++ b/sdm845/thermal-engine/Android.mk
@@ -7,6 +7,8 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := libThermal_headers
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-BSD
+LOCAL_LICENSE_CONDITIONS := notice
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
 LOCAL_VENDOR_MODULE := true
 include $(BUILD_HEADER_LIBRARY)
diff --git a/self-extractors/qcom/staging/Android.mk b/self-extractors/qcom/staging/Android.mk
index 7a4baae..430749a 100644
--- a/self-extractors/qcom/staging/Android.mk
+++ b/self-extractors/qcom/staging/Android.mk
@@ -4,22 +4,36 @@
 include $(CLEAR_VARS)
 LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
 LOCAL_MODULE := ims
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../COPYRIGHT $(LOCAL_PATH)/../LICENSE
 LOCAL_MODULE_TAGS := optional
 LOCAL_BUILT_MODULE_STEM := package.apk
 LOCAL_MODULE_OWNER := qcom
 LOCAL_MODULE_CLASS := APPS
 LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
 LOCAL_CERTIFICATE := platform
+# Disable dexpreopt and <uses-library> check because the APK depends on
+# libraries that are not present as modules in the build system.
+LOCAL_ENFORCE_USES_LIBRARIES := false
+LOCAL_DEX_PREOPT := false
 include $(BUILD_PREBUILT)
 
 include $(CLEAR_VARS)
 LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
 LOCAL_MODULE := QtiTelephonyService
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../COPYRIGHT $(LOCAL_PATH)/../LICENSE
 LOCAL_MODULE_TAGS := optional
 LOCAL_BUILT_MODULE_STEM := package.apk
 LOCAL_MODULE_OWNER := qcom
 LOCAL_MODULE_CLASS := APPS
 LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
 LOCAL_CERTIFICATE := platform
+# Disable dexpreopt and <uses-library> check because the APK depends on
+# libraries that are not present as modules in the build system.
+LOCAL_ENFORCE_USES_LIBRARIES := false
+LOCAL_DEX_PREOPT := false
 include $(BUILD_PREBUILT)
 endif
diff --git a/self-extractors_blueline/qcom/staging/Android.mk b/self-extractors_blueline/qcom/staging/Android.mk
index f76f159..74be334 100644
--- a/self-extractors_blueline/qcom/staging/Android.mk
+++ b/self-extractors_blueline/qcom/staging/Android.mk
@@ -4,22 +4,36 @@
 include $(CLEAR_VARS)
 LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
 LOCAL_MODULE := ims
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../COPYRIGHT $(LOCAL_PATH)/../LICENSE
 LOCAL_MODULE_TAGS := optional
 LOCAL_BUILT_MODULE_STEM := package.apk
 LOCAL_MODULE_OWNER := qcom
 LOCAL_MODULE_CLASS := APPS
 LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
 LOCAL_CERTIFICATE := platform
+# Disable dexpreopt and <uses-library> check because the APK depends on
+# libraries that are not present as modules in the build system.
+LOCAL_ENFORCE_USES_LIBRARIES := false
+LOCAL_DEX_PREOPT := false
 include $(BUILD_PREBUILT)
 
 include $(CLEAR_VARS)
 LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
 LOCAL_MODULE := QtiTelephonyService
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../COPYRIGHT $(LOCAL_PATH)/../LICENSE
 LOCAL_MODULE_TAGS := optional
 LOCAL_BUILT_MODULE_STEM := package.apk
 LOCAL_MODULE_OWNER := qcom
 LOCAL_MODULE_CLASS := APPS
 LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
 LOCAL_CERTIFICATE := platform
+# Disable dexpreopt and <uses-library> check because the APK depends on
+# libraries that are not present as modules in the build system.
+LOCAL_ENFORCE_USES_LIBRARIES := false
+LOCAL_DEX_PREOPT := false
 include $(BUILD_PREBUILT)
 endif
diff --git a/small_hals/Android.bp b/small_hals/Android.bp
index 2828c83..4bd4670 100644
--- a/small_hals/Android.bp
+++ b/small_hals/Android.bp
@@ -1,4 +1,8 @@
 // A binary for small, single-threaded HALs
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_binary {
     name: "small_hals.crosshatch-service",
     defaults: ["hidl_defaults"],
diff --git a/teeui/tests/blueline/Android.bp b/teeui/tests/blueline/Android.bp
index 7d528d9..8f3fa28 100644
--- a/teeui/tests/blueline/Android.bp
+++ b/teeui/tests/blueline/Android.bp
@@ -1,3 +1,7 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_test_host {
     name: "system.teeui_localization_rendering_test.blueline",
     cflags: [
@@ -15,4 +19,3 @@
         "libteeui_localization_rendering_test",
     ],
 }
-
diff --git a/teeui/tests/crosshatch/Android.bp b/teeui/tests/crosshatch/Android.bp
index 437cc1f..29bccad 100644
--- a/teeui/tests/crosshatch/Android.bp
+++ b/teeui/tests/crosshatch/Android.bp
@@ -1,3 +1,7 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_test_host {
     name: "system.teeui_localization_rendering_test.crosshatch",
     cflags: [
@@ -15,4 +19,3 @@
         "libteeui_localization_rendering_test",
     ],
 }
-
diff --git a/ueventd.hardware.rc b/ueventd.hardware.rc
index 166670d..0f72ac4 100644
--- a/ueventd.hardware.rc
+++ b/ueventd.hardware.rc
@@ -50,7 +50,6 @@
 /dev/adsprpc-smd          0664   system     system
 /dev/adsprpc-smd-secure   0644   system     system
 
-/dev/hw_random            0600   root       root
 /dev/sdsprpc-smd          0660   system     system
 
 /dev/wcd-dsp-glink        0660   system     audio
diff --git a/usb/Android.bp b/usb/Android.bp
index 9873ee1..ffc7b5c 100644
--- a/usb/Android.bp
+++ b/usb/Android.bp
@@ -13,18 +13,23 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_binary {
-    name: "android.hardware.usb@1.1-service.crosshatch",
+    name: "android.hardware.usb@1.2-service.crosshatch",
     relative_install_path: "hw",
-    init_rc: ["android.hardware.usb@1.1-service.crosshatch.rc"],
+    init_rc: ["android.hardware.usb@1.2-service.crosshatch.rc"],
     vintf_fragments: [
-        "android.hardware.usb@1.1-service.crosshatch.xml",
+        "android.hardware.usb@1.2-service.crosshatch.xml",
         "android.hardware.usb.gadget@1.1-service.crosshatch.xml",
     ],
     srcs: ["service.cpp", "Usb.cpp", "UsbGadget.cpp"],
     shared_libs: [
         "android.hardware.usb@1.0",
         "android.hardware.usb@1.1",
+        "android.hardware.usb@1.2",
         "android.hardware.usb.gadget@1.0",
         "android.hardware.usb.gadget@1.1",
         "libbase",
diff --git a/usb/Usb.cpp b/usb/Usb.cpp
index b3bac21..3aa5aa6 100644
--- a/usb/Usb.cpp
+++ b/usb/Usb.cpp
@@ -14,20 +14,21 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "android.hardware.usb@1.1-service.crosshatch"
+#define LOG_TAG "android.hardware.usb@1.2-service.crosshatch"
 
+#include <android-base/file.h>
 #include <android-base/logging.h>
 #include <android-base/parseint.h>
 #include <android-base/strings.h>
 #include <assert.h>
-#include <chrono>
 #include <dirent.h>
 #include <pthread.h>
-#include <regex>
 #include <stdio.h>
 #include <sys/types.h>
-#include <thread>
 #include <unistd.h>
+#include <chrono>
+#include <regex>
+#include <thread>
 #include <unordered_map>
 
 #include <cutils/uevent.h>
@@ -40,7 +41,7 @@
 namespace android {
 namespace hardware {
 namespace usb {
-namespace V1_1 {
+namespace V1_2 {
 namespace implementation {
 
 // Set by the signal handler to destroy the thread
@@ -69,6 +70,34 @@
   return -1;
 }
 
+Status queryMoistureDetectionStatus(hidl_vec<PortStatus> *currentPortStatus_1_2) {
+  std::string enabled, status, path, DetectedPath;
+
+  if (currentPortStatus_1_2 == NULL || currentPortStatus_1_2->size() == 0) {
+      ALOGE("currentPortStatus_1_2 is not available");
+      return Status::ERROR;
+  }
+
+  (*currentPortStatus_1_2)[0].supportedContaminantProtectionModes = 0;
+  (*currentPortStatus_1_2)[0].supportedContaminantProtectionModes |=
+      V1_2::ContaminantProtectionMode::FORCE_SINK;
+  (*currentPortStatus_1_2)[0].contaminantProtectionStatus =
+      V1_2::ContaminantProtectionStatus::NONE;
+  (*currentPortStatus_1_2)[0].contaminantDetectionStatus =
+      V1_2::ContaminantDetectionStatus::DISABLED;
+  (*currentPortStatus_1_2)[0].supportsEnableContaminantPresenceDetection = false;
+  (*currentPortStatus_1_2)[0].supportsEnableContaminantPresenceProtection = false;
+
+  (*currentPortStatus_1_2)[0].contaminantDetectionStatus =
+      V1_2::ContaminantDetectionStatus::NOT_DETECTED;
+
+  ALOGI("ContaminantDetectionStatus:%d ContaminantProtectionStatus:%d",
+        (*currentPortStatus_1_2)[0].contaminantDetectionStatus,
+        (*currentPortStatus_1_2)[0].contaminantProtectionStatus);
+
+  return Status::SUCCESS;
+}
+
 std::string appendRoleNodeHelper(const std::string &portName,
                                  PortRoleType type) {
   std::string node("/sys/class/typec/" + portName);
@@ -94,7 +123,7 @@
   } else if (role.type == PortRoleType::DATA_ROLE) {
     if (role.role == static_cast<uint32_t>(PortDataRole::HOST)) return "host";
     if (role.role == static_cast<uint32_t>(PortDataRole::DEVICE))
-      return "device";
+          return "device";
   } else if (role.type == PortRoleType::MODE) {
     if (role.role == static_cast<uint32_t>(PortMode_1_1::UFP)) return "sink";
     if (role.role == static_cast<uint32_t>(PortMode_1_1::DFP)) return "source";
@@ -169,7 +198,7 @@
       // There are no uevent signals which implies role swap timed out.
       if (err == ETIMEDOUT) {
         ALOGI("uevents wait timedout");
-      // Sanity check.
+      // Partner check.
       } else if (!usb->mPartnerUp) {
         goto wait_again;
       // Role switch succeeded since usb->mPartnerUp is true.
@@ -398,195 +427,204 @@
  * The caller of this method would reconstruct the V1_0::PortStatus
  * object if required.
  */
-Status getPortStatusHelper(hidl_vec<PortStatus_1_1> *currentPortStatus_1_1,
-    bool V1_0) {
-  std::unordered_map<std::string, bool> names;
-  Status result = getTypeCPortNamesHelper(&names);
-  int i = -1;
+Status getPortStatusHelper(hidl_vec<PortStatus> *currentPortStatus_1_2, HALVersion version) {
+    std::unordered_map<std::string, bool> names;
+    Status result = getTypeCPortNamesHelper(&names);
+    int i = -1;
 
-  if (result == Status::SUCCESS) {
-    currentPortStatus_1_1->resize(names.size());
-    for (std::pair<std::string, bool> port : names) {
-      i++;
-      ALOGI("%s", port.first.c_str());
-      (*currentPortStatus_1_1)[i].status.portName = port.first;
+    if (result == Status::SUCCESS) {
+        currentPortStatus_1_2->resize(names.size());
+        for (std::pair<std::string, bool> port : names) {
+            i++;
+            ALOGI("%s", port.first.c_str());
+            (*currentPortStatus_1_2)[i].status_1_1.status.portName = port.first;
 
-      uint32_t currentRole;
-      if (getCurrentRoleHelper(port.first, port.second,
-                               PortRoleType::POWER_ROLE,
-                               &currentRole) == Status::SUCCESS) {
-        (*currentPortStatus_1_1)[i].status.currentPowerRole =
-            static_cast<PortPowerRole>(currentRole);
-      } else {
-        ALOGE("Error while retreiving portNames");
-        goto done;
-      }
+            uint32_t currentRole;
+            if (getCurrentRoleHelper(port.first, port.second, PortRoleType::POWER_ROLE,
+                                     &currentRole) == Status::SUCCESS) {
+                (*currentPortStatus_1_2)[i].status_1_1.status.currentPowerRole =
+                    static_cast<PortPowerRole>(currentRole);
+            } else {
+                ALOGE("Error while retrieving portNames");
+                goto done;
+            }
 
-      if (getCurrentRoleHelper(port.first, port.second, PortRoleType::DATA_ROLE,
-                               &currentRole) == Status::SUCCESS) {
-        (*currentPortStatus_1_1)[i].status.currentDataRole =
-            static_cast<PortDataRole>(currentRole);
-      } else {
-        ALOGE("Error while retreiving current port role");
-        goto done;
-      }
+            if (getCurrentRoleHelper(port.first, port.second, PortRoleType::DATA_ROLE,
+                                     &currentRole) == Status::SUCCESS) {
+                (*currentPortStatus_1_2)[i].status_1_1.status.currentDataRole =
+                    static_cast<PortDataRole>(currentRole);
+            } else {
+                ALOGE("Error while retrieving current port role");
+                goto done;
+            }
 
-      if (getCurrentRoleHelper(port.first, port.second, PortRoleType::MODE,
-                               &currentRole) == Status::SUCCESS) {
-        (*currentPortStatus_1_1)[i].currentMode =
-            static_cast<PortMode_1_1>(currentRole);
-        (*currentPortStatus_1_1)[i].status.currentMode =
-            static_cast<V1_0::PortMode>(currentRole);
-      } else {
-        ALOGE("Error while retreiving current data role");
-        goto done;
-      }
+            if (getCurrentRoleHelper(port.first, port.second, PortRoleType::MODE, &currentRole) ==
+                Status::SUCCESS) {
+                (*currentPortStatus_1_2)[i].status_1_1.currentMode =
+                    static_cast<PortMode_1_1>(currentRole);
+                (*currentPortStatus_1_2)[i].status_1_1.status.currentMode =
+                    static_cast<V1_0::PortMode>(currentRole);
+            } else {
+                ALOGE("Error while retrieving current data role");
+                goto done;
+            }
 
-      (*currentPortStatus_1_1)[i].status.canChangeMode = true;
-      (*currentPortStatus_1_1)[i].status.canChangeDataRole =
-          port.second ? canSwitchRoleHelper(port.first, PortRoleType::DATA_ROLE)
-                      : false;
-      (*currentPortStatus_1_1)[i].status.canChangePowerRole =
-          port.second
-              ? canSwitchRoleHelper(port.first, PortRoleType::POWER_ROLE)
-              : false;
+            (*currentPortStatus_1_2)[i].status_1_1.status.canChangeMode = true;
+            (*currentPortStatus_1_2)[i].status_1_1.status.canChangeDataRole =
+                port.second ? canSwitchRoleHelper(port.first, PortRoleType::DATA_ROLE) : false;
+            (*currentPortStatus_1_2)[i].status_1_1.status.canChangePowerRole =
+                port.second ? canSwitchRoleHelper(port.first, PortRoleType::POWER_ROLE) : false;
 
-      ALOGI("connected:%d canChangeMode:%d canChagedata:%d canChangePower:%d",
-            port.second, (*currentPortStatus_1_1)[i].status.canChangeMode,
-            (*currentPortStatus_1_1)[i].status.canChangeDataRole,
-            (*currentPortStatus_1_1)[i].status.canChangePowerRole);
+            if (version == HALVersion::V1_0) {
+                ALOGI("HAL version V1_0");
+                (*currentPortStatus_1_2)[i].status_1_1.status.supportedModes = V1_0::PortMode::DRP;
+            } else {
+                if (version == HALVersion::V1_1)
+                    ALOGI("HAL version V1_1");
+                else
+                    ALOGI("HAL version V1_2");
+                (*currentPortStatus_1_2)[i].status_1_1.supportedModes = 0 | PortMode_1_1::DRP;
+                (*currentPortStatus_1_2)[i].status_1_1.status.supportedModes = V1_0::PortMode::NONE;
+                (*currentPortStatus_1_2)[i].status_1_1.status.currentMode = V1_0::PortMode::NONE;
+            }
 
-      if (V1_0) {
-        (*currentPortStatus_1_1)[i].status.supportedModes = V1_0::PortMode::DFP;
-      } else {
-        (*currentPortStatus_1_1)[i].supportedModes = PortMode_1_1::UFP | PortMode_1_1::DFP;
-        (*currentPortStatus_1_1)[i].status.supportedModes = V1_0::PortMode::NONE;
-        (*currentPortStatus_1_1)[i].status.currentMode = V1_0::PortMode::NONE;
-      }
+            ALOGI(
+                "%d:%s connected:%d canChangeMode:%d canChagedata:%d canChangePower:%d "
+                "supportedModes:%d",
+                i, port.first.c_str(), port.second,
+                (*currentPortStatus_1_2)[i].status_1_1.status.canChangeMode,
+                (*currentPortStatus_1_2)[i].status_1_1.status.canChangeDataRole,
+                (*currentPortStatus_1_2)[i].status_1_1.status.canChangePowerRole,
+                (*currentPortStatus_1_2)[i].status_1_1.supportedModes);
+        }
+        return Status::SUCCESS;
     }
-    return Status::SUCCESS;
-  }
 done:
-  return Status::ERROR;
+    return Status::ERROR;
+}
+
+void queryVersionHelper(Usb *usb, hidl_vec<PortStatus> *currentPortStatus_1_2) {
+    hidl_vec<V1_1::PortStatus_1_1> currentPortStatus_1_1;
+    hidl_vec<V1_0::PortStatus> currentPortStatus;
+    Status status;
+    sp<V1_1::IUsbCallback> callback_V1_1 = V1_1::IUsbCallback::castFrom(usb->mCallback_1_0);
+    sp<IUsbCallback> callback_V1_2 = IUsbCallback::castFrom(usb->mCallback_1_0);
+
+    pthread_mutex_lock(&usb->mLock);
+    if (usb->mCallback_1_0 != NULL) {
+        if (callback_V1_2 != NULL) {
+            status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_2);
+            if (status == Status::SUCCESS)
+                queryMoistureDetectionStatus(currentPortStatus_1_2);
+        } else if (callback_V1_1 != NULL) {
+            status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_1);
+            currentPortStatus_1_1.resize(currentPortStatus_1_2->size());
+            for (unsigned long i = 0; i < currentPortStatus_1_2->size(); i++)
+                currentPortStatus_1_1[i] = (*currentPortStatus_1_2)[i].status_1_1;
+        } else {
+            status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_0);
+            currentPortStatus.resize(currentPortStatus_1_2->size());
+            for (unsigned long i = 0; i < currentPortStatus_1_2->size(); i++)
+                currentPortStatus[i] = (*currentPortStatus_1_2)[i].status_1_1.status;
+        }
+
+        Return<void> ret;
+
+        if (callback_V1_2 != NULL)
+            ret = callback_V1_2->notifyPortStatusChange_1_2(*currentPortStatus_1_2, status);
+        else if (callback_V1_1 != NULL)
+            ret = callback_V1_1->notifyPortStatusChange_1_1(currentPortStatus_1_1, status);
+        else
+            ret = usb->mCallback_1_0->notifyPortStatusChange(currentPortStatus, status);
+
+        if (!ret.isOk())
+            ALOGE("queryPortStatus_1_2 error %s", ret.description().c_str());
+    } else {
+        ALOGI("Notifying userspace skipped. Callback is NULL");
+    }
+    pthread_mutex_unlock(&usb->mLock);
 }
 
 Return<void> Usb::queryPortStatus() {
-  hidl_vec<PortStatus_1_1> currentPortStatus_1_1;
-  hidl_vec<V1_0::PortStatus> currentPortStatus;
-  Status status;
-  sp<IUsbCallback> callback_V1_1 = IUsbCallback::castFrom(mCallback_1_0);
+    hidl_vec<PortStatus> currentPortStatus_1_2;
 
-  pthread_mutex_lock(&mLock);
-  if (mCallback_1_0 != NULL) {
-    if (callback_V1_1 != NULL) {
-      status = getPortStatusHelper(&currentPortStatus_1_1, false);
-    } else {
-      status = getPortStatusHelper(&currentPortStatus_1_1, true);
-      currentPortStatus.resize(currentPortStatus_1_1.size());
-      for (unsigned long i = 0; i < currentPortStatus_1_1.size(); i++)
-        currentPortStatus[i] = currentPortStatus_1_1[i].status;
-    }
+    queryVersionHelper(this, &currentPortStatus_1_2);
+    return Void();
+}
 
-    Return<void> ret;
+Return<void> Usb::enableContaminantPresenceDetection(const hidl_string & /*portName*/,
+                                                     bool /*enable*/) {
+    hidl_vec<PortStatus> currentPortStatus_1_2;
 
-    if (callback_V1_1 != NULL)
-      ret = callback_V1_1->notifyPortStatusChange_1_1(currentPortStatus_1_1, status);
-    else
-      ret = mCallback_1_0->notifyPortStatusChange(currentPortStatus, status);
+    queryVersionHelper(this, &currentPortStatus_1_2);
+    return Void();
+}
 
-    if (!ret.isOk())
-      ALOGE("queryPortStatus_1_1 error %s", ret.description().c_str());
-  } else {
-    ALOGI("Notifying userspace skipped. Callback is NULL");
-  }
-  pthread_mutex_unlock(&mLock);
+Return<void> Usb::enableContaminantPresenceProtection(const hidl_string & /*portName*/,
+                                                      bool /*enable*/) {
+    hidl_vec<PortStatus> currentPortStatus_1_2;
 
-  return Void();
+    queryVersionHelper(this, &currentPortStatus_1_2);
+    return Void();
 }
 
 /* uevent_event() data that is persistent across uevents. */
 struct data {
   int uevent_fd;
-  android::hardware::usb::V1_1::implementation::Usb *usb;
+  android::hardware::usb::V1_2::implementation::Usb *usb;
 };
 
 // Report connection & disconnection of devices into the USB-C connector.
 static void uevent_event(uint32_t /*epevents*/, struct data *payload) {
-  char msg[UEVENT_MSG_LEN + 2];
-  char *cp;
-  int n;
+    char msg[UEVENT_MSG_LEN + 2];
+    char *cp;
+    int n;
 
-  n = uevent_kernel_multicast_recv(payload->uevent_fd, msg, UEVENT_MSG_LEN);
-  if (n <= 0) return;
-  if (n >= UEVENT_MSG_LEN) /* overflow -- discard */
-    return;
+    n = uevent_kernel_multicast_recv(payload->uevent_fd, msg, UEVENT_MSG_LEN);
+    if (n <= 0)
+        return;
+    if (n >= UEVENT_MSG_LEN) /* overflow -- discard */
+        return;
 
-  msg[n] = '\0';
-  msg[n + 1] = '\0';
-  cp = msg;
+    msg[n] = '\0';
+    msg[n + 1] = '\0';
+    cp = msg;
 
-  while (*cp) {
-    if (std::regex_match(cp, std::regex("(add)(.*)(-partner)"))) {
-       ALOGI("partner added");
-       pthread_mutex_lock(&payload->usb->mPartnerLock);
-       payload->usb->mPartnerUp = true;
-       pthread_cond_signal(&payload->usb->mPartnerCV);
-       pthread_mutex_unlock(&payload->usb->mPartnerLock);
-    } else if (!strncmp(cp, "DEVTYPE=typec_", strlen("DEVTYPE=typec_"))) {
-      hidl_vec<PortStatus_1_1> currentPortStatus_1_1;
-      ALOGI("uevent received %s", cp);
-      pthread_mutex_lock(&payload->usb->mLock);
-      if (payload->usb->mCallback_1_0 != NULL) {
-        sp<IUsbCallback> callback_V1_1 = IUsbCallback::castFrom(payload->usb->mCallback_1_0);
-        Return<void> ret;
+    while (*cp) {
+        if (std::regex_match(cp, std::regex("(add)(.*)(-partner)"))) {
+            ALOGI("partner added");
+            pthread_mutex_lock(&payload->usb->mPartnerLock);
+            payload->usb->mPartnerUp = true;
+            pthread_cond_signal(&payload->usb->mPartnerCV);
+            pthread_mutex_unlock(&payload->usb->mPartnerLock);
+        } else if (!strncmp(cp, "DEVTYPE=typec_", strlen("DEVTYPE=typec_"))) {
+            hidl_vec<PortStatus> currentPortStatus_1_2;
+            queryVersionHelper(payload->usb, &currentPortStatus_1_2);
 
-        // V1_1 callback
-        if (callback_V1_1 != NULL) {
-          Status status = getPortStatusHelper(&currentPortStatus_1_1, false);
-          ret = callback_V1_1->notifyPortStatusChange_1_1(
-              currentPortStatus_1_1, status);
-        } else { // V1_0 callback
-          Status status = getPortStatusHelper(&currentPortStatus_1_1, true);
-
-          /*
-           * Copying the result from getPortStatusHelper
-           * into V1_0::PortStatus to pass back through
-           * the V1_0 callback object.
-           */
-          hidl_vec<V1_0::PortStatus> currentPortStatus;
-          currentPortStatus.resize(currentPortStatus_1_1.size());
-          for (unsigned long i = 0; i < currentPortStatus_1_1.size(); i++)
-            currentPortStatus[i] = currentPortStatus_1_1[i].status;
-
-          ret = payload->usb->mCallback_1_0->notifyPortStatusChange(
-              currentPortStatus, status);
+            // Role switch is not in progress and port is in disconnected state
+            if (!pthread_mutex_trylock(&payload->usb->mRoleSwitchLock)) {
+                for (unsigned long i = 0; i < currentPortStatus_1_2.size(); i++) {
+                    DIR *dp =
+                        opendir(std::string("/sys/class/typec/" +
+                                            std::string(currentPortStatus_1_2[i]
+                                                            .status_1_1.status.portName.c_str()) +
+                                            "-partner")
+                                    .c_str());
+                    if (dp == NULL) {
+                        // PortRole role = {.role = static_cast<uint32_t>(PortMode::UFP)};
+                        switchToDrp(currentPortStatus_1_2[i].status_1_1.status.portName);
+                    } else {
+                        closedir(dp);
+                    }
+                }
+                pthread_mutex_unlock(&payload->usb->mRoleSwitchLock);
+            }
+            break;
         }
-        if (!ret.isOk()) ALOGE("error %s", ret.description().c_str());
-      } else {
-        ALOGI("Notifying userspace skipped. Callback is NULL");
-      }
-      pthread_mutex_unlock(&payload->usb->mLock);
-
-      //Role switch is not in progress and port is in disconnected state
-      if (!pthread_mutex_trylock(&payload->usb->mRoleSwitchLock)) {
-        for (unsigned long i = 0; i < currentPortStatus_1_1.size(); i++) {
-          DIR *dp = opendir(std::string("/sys/class/typec/"
-              + std::string(currentPortStatus_1_1[i].status.portName.c_str())
-              + "-partner").c_str());
-          if (dp == NULL) {
-              //PortRole role = {.role = static_cast<uint32_t>(PortMode::UFP)};
-              switchToDrp(currentPortStatus_1_1[i].status.portName);
-          } else {
-              closedir(dp);
-          }
+        /* advance to after the next \0 */
+        while (*cp++) {
         }
-        pthread_mutex_unlock(&payload->usb->mRoleSwitchLock);
-      }
-      break;
     }
-    /* advance to after the next \0 */
-    while (*cp++) {}
-  }
 }
 
 void *work(void *param) {
@@ -605,7 +643,7 @@
   }
 
   payload.uevent_fd = uevent_fd;
-  payload.usb = (android::hardware::usb::V1_1::implementation::Usb *)param;
+  payload.usb = (android::hardware::usb::V1_2::implementation::Usb *)param;
 
   fcntl(uevent_fd, F_SETFL, O_NONBLOCK);
 
@@ -659,63 +697,66 @@
 }
 
 Return<void> Usb::setCallback(const sp<V1_0::IUsbCallback> &callback) {
+    sp<V1_1::IUsbCallback> callback_V1_1 = V1_1::IUsbCallback::castFrom(callback);
+    sp<IUsbCallback> callback_V1_2 = IUsbCallback::castFrom(callback);
 
-  sp<IUsbCallback> callback_V1_1 = IUsbCallback::castFrom(callback);
-
-  if (callback != NULL)
-      if (callback_V1_1 == NULL)
-          ALOGI("Registering 1.0 callback");
-
-  pthread_mutex_lock(&mLock);
-  /*
-   * When both the old callback and new callback values are NULL,
-   * there is no need to spin off the worker thread.
-   * When both the values are not NULL, we would already have a
-   * worker thread running, so updating the callback object would
-   * be suffice.
-   */
-  if ((mCallback_1_0 == NULL && callback == NULL) ||
-      (mCallback_1_0 != NULL && callback != NULL)) {
-    /*
-     * Always store as V1_0 callback object. Type cast to V1_1
-     * when the callback is actually invoked.
-     */
-    mCallback_1_0 = callback;
-    pthread_mutex_unlock(&mLock);
-    return Void();
-  }
-
-  mCallback_1_0 = callback;
-  ALOGI("registering callback");
-
-  // Kill the worker thread if the new callback is NULL.
-  if (mCallback_1_0 == NULL) {
-    pthread_mutex_unlock(&mLock);
-    if (!pthread_kill(mPoll, SIGUSR1)) {
-      pthread_join(mPoll, NULL);
-      ALOGI("pthread destroyed");
+    if (callback != NULL) {
+        if (callback_V1_2 != NULL)
+            ALOGI("Registering 1.2 callback");
+        else if (callback_V1_1 != NULL)
+            ALOGI("Registering 1.1 callback");
     }
+
+    pthread_mutex_lock(&mLock);
+    /*
+     * When both the old callback and new callback values are NULL,
+     * there is no need to spin off the worker thread.
+     * When both the values are not NULL, we would already have a
+     * worker thread running, so updating the callback object would
+     * be suffice.
+     */
+    if ((mCallback_1_0 == NULL && callback == NULL) ||
+        (mCallback_1_0 != NULL && callback != NULL)) {
+        /*
+         * Always store as V1_0 callback object. Type cast to V1_1
+         * when the callback is actually invoked.
+         */
+        mCallback_1_0 = callback;
+        pthread_mutex_unlock(&mLock);
+        return Void();
+    }
+
+    mCallback_1_0 = callback;
+    ALOGI("registering callback");
+
+    // Kill the worker thread if the new callback is NULL.
+    if (mCallback_1_0 == NULL) {
+        pthread_mutex_unlock(&mLock);
+        if (!pthread_kill(mPoll, SIGUSR1)) {
+            pthread_join(mPoll, NULL);
+            ALOGI("pthread destroyed");
+        }
+        return Void();
+    }
+
+    destroyThread = false;
+    signal(SIGUSR1, sighandler);
+
+    /*
+     * Create a background thread if the old callback value is NULL
+     * and being updated with a new value.
+     */
+    if (pthread_create(&mPoll, NULL, work, this)) {
+        ALOGE("pthread creation failed %d", errno);
+        mCallback_1_0 = NULL;
+    }
+
+    pthread_mutex_unlock(&mLock);
     return Void();
-  }
-
-  destroyThread = false;
-  signal(SIGUSR1, sighandler);
-
-  /*
-   * Create a background thread if the old callback value is NULL
-   * and being updated with a new value.
-   */
-  if (pthread_create(&mPoll, NULL, work, this)) {
-    ALOGE("pthread creation failed %d", errno);
-    mCallback_1_0 = NULL;
-  }
-
-  pthread_mutex_unlock(&mLock);
-  return Void();
 }
 
 }  // namespace implementation
-}  // namespace V1_0
+}  // namespace V1_2
 }  // namespace usb
 }  // namespace hardware
 }  // namespace android
diff --git a/usb/Usb.h b/usb/Usb.h
index 09bfdf9..03990b1 100644
--- a/usb/Usb.h
+++ b/usb/Usb.h
@@ -1,9 +1,8 @@
-#ifndef ANDROID_HARDWARE_USB_V1_1_USB_H
-#define ANDROID_HARDWARE_USB_V1_1_USB_H
+#pragma once
 
-#include <android/hardware/usb/1.1/IUsb.h>
-#include <android/hardware/usb/1.1/types.h>
-#include <android/hardware/usb/1.1/IUsbCallback.h>
+#include <android/hardware/usb/1.2/IUsb.h>
+#include <android/hardware/usb/1.2/IUsbCallback.h>
+#include <android/hardware/usb/1.2/types.h>
 #include <hidl/Status.h>
 #include <utils/Log.h>
 
@@ -17,27 +16,30 @@
 namespace android {
 namespace hardware {
 namespace usb {
-namespace V1_1 {
+namespace V1_2 {
 namespace implementation {
 
-using ::android::hardware::usb::V1_0::PortRole;
-using ::android::hardware::usb::V1_0::PortRoleType;
-using ::android::hardware::usb::V1_0::PortDataRole;
-using ::android::hardware::usb::V1_0::PortPowerRole;
-using ::android::hardware::usb::V1_0::Status;
-using ::android::hardware::usb::V1_1::IUsb;
-using ::android::hardware::usb::V1_1::IUsbCallback;
-using ::android::hardware::usb::V1_1::PortMode_1_1;
-using ::android::hardware::usb::V1_1::PortStatus_1_1;
-using ::android::hidl::base::V1_0::DebugInfo;
-using ::android::hidl::base::V1_0::IBase;
+using ::android::sp;
 using ::android::hardware::hidl_array;
 using ::android::hardware::hidl_memory;
 using ::android::hardware::hidl_string;
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::sp;
+using ::android::hardware::usb::V1_0::PortDataRole;
+using ::android::hardware::usb::V1_0::PortPowerRole;
+using ::android::hardware::usb::V1_0::PortRole;
+using ::android::hardware::usb::V1_0::PortRoleType;
+using ::android::hardware::usb::V1_0::Status;
+using ::android::hardware::usb::V1_1::PortMode_1_1;
+using ::android::hardware::usb::V1_1::PortStatus_1_1;
+using ::android::hardware::usb::V1_2::IUsb;
+using ::android::hardware::usb::V1_2::IUsbCallback;
+using ::android::hardware::usb::V1_2::PortStatus;
+using ::android::hidl::base::V1_0::DebugInfo;
+using ::android::hidl::base::V1_0::IBase;
+
+enum class HALVersion { V1_0, V1_1, V1_2 };
 
 struct Usb : public IUsb {
     Usb();
@@ -45,7 +47,8 @@
     Return<void> switchRole(const hidl_string& portName, const V1_0::PortRole& role) override;
     Return<void> setCallback(const sp<V1_0::IUsbCallback>& callback) override;
     Return<void> queryPortStatus() override;
-
+    Return<void> enableContaminantPresenceDetection(const hidl_string &portName, bool enable);
+    Return<void> enableContaminantPresenceProtection(const hidl_string &portName, bool enable);
 
     sp<V1_0::IUsbCallback> mCallback_1_0;
     // Protects mCallback variable
@@ -64,9 +67,7 @@
 };
 
 }  // namespace implementation
-}  // namespace V1_0
+}  // namespace V1_2
 }  // namespace usb
 }  // namespace hardware
 }  // namespace android
-
-#endif  // ANDROID_HARDWARE_USB_V1_1_USB_H
diff --git a/usb/android.hardware.usb@1.1-service.crosshatch.rc b/usb/android.hardware.usb@1.2-service.crosshatch.rc
similarity index 81%
rename from usb/android.hardware.usb@1.1-service.crosshatch.rc
rename to usb/android.hardware.usb@1.2-service.crosshatch.rc
index dc2a170..7d9534c 100644
--- a/usb/android.hardware.usb@1.1-service.crosshatch.rc
+++ b/usb/android.hardware.usb@1.2-service.crosshatch.rc
@@ -1,4 +1,4 @@
-service vendor.usb-hal-1-1 /vendor/bin/hw/android.hardware.usb@1.1-service.crosshatch
+service vendor.usb-hal-1-2 /vendor/bin/hw/android.hardware.usb@1.2-service.crosshatch
     class hal
     user root
     group root system shell mtp
diff --git a/usb/android.hardware.usb@1.1-service.crosshatch.xml b/usb/android.hardware.usb@1.2-service.crosshatch.xml
similarity index 89%
rename from usb/android.hardware.usb@1.1-service.crosshatch.xml
rename to usb/android.hardware.usb@1.2-service.crosshatch.xml
index 5ce2ff4..25ecf65 100644
--- a/usb/android.hardware.usb@1.1-service.crosshatch.xml
+++ b/usb/android.hardware.usb@1.2-service.crosshatch.xml
@@ -2,7 +2,7 @@
     <hal format="hidl">
         <name>android.hardware.usb</name>
         <transport>hwbinder</transport>
-        <version>1.1</version>
+        <version>1.2</version>
         <interface>
             <name>IUsb</name>
             <instance>default</instance>
diff --git a/usb/service.cpp b/usb/service.cpp
index 2b50540..272b939 100644
--- a/usb/service.cpp
+++ b/usb/service.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "android.hardware.usb@1.1-service.crosshatch"
+#define LOG_TAG "android.hardware.usb@1.2-service.crosshatch"
 
 #include <hidl/HidlTransportSupport.h>
 #include "Usb.h"
@@ -29,8 +29,8 @@
 // Generated HIDL files
 using android::hardware::usb::gadget::V1_1::IUsbGadget;
 using android::hardware::usb::gadget::V1_1::implementation::UsbGadget;
-using android::hardware::usb::V1_1::IUsb;
-using android::hardware::usb::V1_1::implementation::Usb;
+using android::hardware::usb::V1_2::IUsb;
+using android::hardware::usb::V1_2::implementation::Usb;
 
 using android::OK;
 using android::status_t;
diff --git a/vibrator/Android.bp b/vibrator/Android.bp
index f80dc63..042eb37 100644
--- a/vibrator/Android.bp
+++ b/vibrator/Android.bp
@@ -13,6 +13,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_library_shared {
     name: "android.hardware.vibrator@1.2-impl.crosshatch",
     relative_install_path: "hw",
diff --git a/voice_processing/Android.bp b/voice_processing/Android.bp
index 48d21dd..2fe366e 100644
--- a/voice_processing/Android.bp
+++ b/voice_processing/Android.bp
@@ -12,6 +12,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_library_shared {
     name: "libqcomvoiceprocessingdescriptors",
     srcs: ["voice_processing_descriptors.c"],