gps: update gps driver 129.20.23.513912 am: 63d85c21e8

Original change: https://googleplex-android-review.googlesource.com/c/device/google/gs101/+/15743517

Change-Id: I3b068cf749a96b1b52287115d19e3638e07140f3
diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk
index 4689c68..a3dcda0 100644
--- a/BoardConfig-common.mk
+++ b/BoardConfig-common.mk
@@ -53,22 +53,23 @@
 BOARD_BOOTCONFIG += androidboot.boot_devices=14700000.ufs
 
 TARGET_NO_BOOTLOADER := true
-TARGET_NO_RADIOIMAGE := true
-ifeq (,$(TARGET_PREBUILT_KERNEL))
-TARGET_NO_KERNEL := true
-ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
-BOARD_PREBUILT_BOOTIMAGE := $(TARGET_KERNEL_DIR)/boot.img
-else
-BOARD_PREBUILT_BOOTIMAGE := $(TARGET_KERNEL_DIR)/boot-user.img
-endif
-else
 TARGET_NO_KERNEL := false
-endif
+TARGET_NO_RADIOIMAGE := true
 BOARD_USES_GENERIC_KERNEL_IMAGE := true
 BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT := true
 BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT := true
 TARGET_RECOVERY_WIPE := device/google/gs101/conf/recovery.wipe
-TARGET_RECOVERY_FSTAB := device/google/gs101/conf/fstab.gs101
+
+# This is the fstab file that will be included in the recovery image.  Note that
+# recovery doesn't care about the encryption settings, so it doesn't matter
+# whether we use the normal or the fips fstab here.
+#
+# Since this is a generated file, it's necessary to use intermediates-dir-for in
+# order to refer to it correctly.  And since intermediates-dir-for isn't defined
+# yet when this file is included, it's necessary to use a deferred variable
+# assignment ( = ) rather than an immediate variable assignment ( := ).
+TARGET_RECOVERY_FSTAB = $(call intermediates-dir-for,ETC,fstab.gs101)/fstab.gs101
+
 TARGET_RECOVERY_PIXEL_FORMAT := ABGR_8888
 TARGET_RECOVERY_UI_MARGIN_HEIGHT := 165
 TARGET_RECOVERY_UI_LIB := \
diff --git a/conf/Android.bp b/conf/Android.bp
new file mode 100644
index 0000000..de57a14
--- /dev/null
+++ b/conf/Android.bp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+// By default this device uses hardware-wrapped keys for storage encryption,
+// which is intended to offer increased security over the traditional method
+// (software keys).  However, hardware-wrapped keys aren't compatible with
+// FIPS-140 certification of the encryption hardware, and hence we have to
+// disable the use of them in FIPS mode.  This requires having two fstab files:
+// one for the default mode, and one for FIPS mode selectable via
+// androidboot.fstab_suffix on the kernel command line.  These fstabs should be
+// identical with the exception of the encryption settings, so to keep them in
+// sync the rules below generate them from a template file.
+
+genrule {
+    name: "gen_fstab.gs101",
+    srcs: ["fstab.gs101.in"],
+    out: ["fstab.gs101"],
+    cmd: "sed -e s/@fileencryption@/::inlinecrypt_optimized+wrappedkey_v0/" +
+        " -e s/@metadata_encryption@/:wrappedkey_v0/ $(in) > $(out)",
+}
+
+genrule {
+    name: "gen_fstab.gs101-fips",
+    srcs: ["fstab.gs101.in"],
+    out: ["fstab.gs101-fips"],
+    cmd: "sed -e s/@fileencryption@/aes-256-xts/" +
+        " -e s/@metadata_encryption@/aes-256-xts/ $(in) > $(out)",
+}
+
+prebuilt_etc {
+    name: "fstab.gs101",
+    src: ":gen_fstab.gs101",
+    vendor: true,
+    vendor_ramdisk_available: true,
+}
+
+prebuilt_etc {
+    name: "fstab.gs101-fips",
+    src: ":gen_fstab.gs101-fips",
+    vendor: true,
+    vendor_ramdisk_available: true,
+}
diff --git a/conf/fstab.gs101 b/conf/fstab.gs101.in
similarity index 94%
rename from conf/fstab.gs101
rename to conf/fstab.gs101.in
index ef56f87..2481fbc 100644
--- a/conf/fstab.gs101
+++ b/conf/fstab.gs101.in
@@ -17,7 +17,7 @@
 /dev/block/platform/14700000.ufs/by-name/misc            /misc                       emmc    defaults                 wait
 /dev/block/platform/14700000.ufs/by-name/metadata        /metadata                   ext4    noatime,nosuid,nodev,data=journal,commit=1    wait,check,formattable,first_stage_mount,metadata_csum
 /dev/block/platform/14700000.ufs/by-name/pvmfw           /pvmfw                      emmc    defaults                 wait,slotselect,avb=pvmfw,first_stage_mount
-/dev/block/platform/14700000.ufs/by-name/userdata        /data                       f2fs    noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065,fsync_mode=nobarrier,inlinecrypt,compress_extension=apk,compress_extension=apex,compress_extension=so,atgc,checkpoint_merge    latemount,wait,check,quota,formattable,sysfs_path=/dev/sys/block/bootdevice,checkpoint=fs,reservedsize=128M,fileencryption=::inlinecrypt_optimized+wrappedkey_v0,metadata_encryption=:wrappedkey_v0,keydirectory=/metadata/vold/metadata_encryption,fscompress,readahead_size_kb=128
+/dev/block/platform/14700000.ufs/by-name/userdata        /data                       f2fs    noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065,fsync_mode=nobarrier,inlinecrypt,compress_extension=apk,compress_extension=apex,compress_extension=so,atgc,checkpoint_merge    latemount,wait,check,quota,formattable,sysfs_path=/dev/sys/block/bootdevice,checkpoint=fs,reservedsize=128M,fileencryption=@fileencryption@,metadata_encryption=@metadata_encryption@,keydirectory=/metadata/vold/metadata_encryption,fscompress,readahead_size_kb=128
 /dev/block/platform/14700000.ufs/by-name/vbmeta          /vbmeta                     emmc    defaults                 slotselect,first_stage_mount
 /dev/block/zram0                                         none                        swap    defaults                 zramsize=3221225472,max_comp_streams=8,zram_backingdev_size=512M
 /devices/platform/11110000.usb*                          auto                        vfat    defaults                 voldmanaged=usb:auto
diff --git a/conf/init.gs101.rc b/conf/init.gs101.rc
index 7cef09b..603b26f 100644
--- a/conf/init.gs101.rc
+++ b/conf/init.gs101.rc
@@ -310,7 +310,7 @@
     class_start animation
 
     # Mount RW partitions which need run fsck
-    mount_all /vendor/etc/fstab.gs101 --late
+    mount_all --late
 
 on post-fs-data
     # Log data folder
@@ -507,7 +507,7 @@
     setprop ro.radio.noril yes
 
 on fs
-    mount_all /vendor/etc/fstab.gs101 --early
+    mount_all --early
     restorecon_recursive /mnt/vendor/efs
     chown radio system /mnt/vendor/efs
     restorecon_recursive /mnt/vendor/efs_backup
diff --git a/conf/init.gs101.usb.rc b/conf/init.gs101.usb.rc
index 7c76381..749d4b4 100644
--- a/conf/init.gs101.usb.rc
+++ b/conf/init.gs101.usb.rc
@@ -68,6 +68,9 @@
     # etr_miu function
     mkdir /config/usb_gadget/g1/functions/etr_miu.gs11
 
+    # acm function for uwb
+    mkdir /config/usb_gadget/g1/functions/acm.uwb0
+
     setprop vendor.usb.functions.ready 1
 
 on boot
@@ -120,3 +123,6 @@
 
 on property:vendor.usb.contaminantdisable=true
     exec /vendor/bin/hw/disable_contaminant_detection.sh
+
+on property:ro.bootmode=usbuwb
+    setprop persist.vendor.usb.usbradio.config uwb_acm
diff --git a/device.mk b/device.mk
index 982ecb6..fee9ac0 100644
--- a/device.mk
+++ b/device.mk
@@ -251,10 +251,13 @@
 	device/google/gs101/conf/init.recovery.device.rc:$(TARGET_COPY_OUT_RECOVERY)/root/init.recovery.gs101.rc
 
 # Fstab files
+PRODUCT_PACKAGES += \
+	fstab.gs101 \
+	fstab.gs101.vendor_ramdisk \
+	fstab.gs101-fips \
+	fstab.gs101-fips.vendor_ramdisk
 PRODUCT_COPY_FILES += \
-	device/google/gs101/conf/fstab.gs101:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.gs101 \
-	device/google/gs101/conf/fstab.persist:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.persist \
-	device/google/gs101/conf/fstab.gs101:$(TARGET_COPY_OUT_VENDOR_RAMDISK)/first_stage_ramdisk/fstab.gs101
+	device/google/gs101/conf/fstab.persist:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.persist
 
 # Shell scripts
 PRODUCT_COPY_FILES += \
diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp
index 620df1a..2bd36df 100644
--- a/dumpstate/DumpstateDevice.cpp
+++ b/dumpstate/DumpstateDevice.cpp
@@ -378,10 +378,8 @@
                         " for f in `ls bd_*` ; do echo \"$f: `cat $f`\" ; done"});
     if (!PropertiesHelper::IsUserBuild()) {
 
-        RunCommandToFd(fd, "DC_registers dump", {"/vendor/bin/sh", "-c",
-                        "for f in /d/regmap/*-0057-pca9468-mains ; do "
-                        "regs=`cat $f/registers`; echo $f: ;"
-                        "echo \"$regs\"; done"});
+        DumpFileToFd(fd, "DC_registers dump", "/sys/class/power_supply/pca9468-mains/device/registers_dump");
+
 
         RunCommandToFd(fd, "fg_model", {"/vendor/bin/sh", "-c",
                         "for f in /d/maxfg* ; do "
@@ -401,7 +399,7 @@
 
         /* FG Registers */
         RunCommandToFd(fd, "fg registers", {"/vendor/bin/sh", "-c",
-                        "for f in /d/regmap/*-0036 ; do "
+                        "for f in /d/maxfg* ; do "
                         "regs=`cat $f/registers`; echo $f: ;"
                         "echo \"$regs\"; done"});
     }
diff --git a/interfaces/boot/1.2/BootControl.cpp b/interfaces/boot/1.2/BootControl.cpp
index 70b9594..a28be05 100644
--- a/interfaces/boot/1.2/BootControl.cpp
+++ b/interfaces/boot/1.2/BootControl.cpp
@@ -162,7 +162,7 @@
         return false;
     }
 
-    android::base::unique_fd fd(open(DEVINFO_PATH, O_WRONLY));
+    android::base::unique_fd fd(open(DEVINFO_PATH, O_WRONLY | O_DSYNC));
     return android::base::WriteFully(fd, &devinfo, sizeof devinfo);
 }
 
@@ -270,13 +270,13 @@
 
     std::string boot_lun_path =
             std::string("/sys/devices/platform/") + boot_dev + "/pixel/boot_lun_enabled";
-    int fd = open(boot_lun_path.c_str(), O_RDWR);
+    int fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC);
     if (fd < 0) {
         // Try old path for kernels < 5.4
         // TODO: remove once kernel 4.19 support is deprecated
         std::string boot_lun_path =
                 std::string("/sys/devices/platform/") + boot_dev + "/attributes/boot_lun_enabled";
-        fd = open(boot_lun_path.c_str(), O_RDWR);
+        fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC);
         if (fd < 0) {
             _hidl_cb({false, "failed to open ufs attr boot_lun_enabled"});
             return Void();
diff --git a/usb/UsbGadget.cpp b/usb/UsbGadget.cpp
index 909fb48..0a6cea3 100644
--- a/usb/UsbGadget.cpp
+++ b/usb/UsbGadget.cpp
@@ -165,6 +165,8 @@
                 ret = setVidPid("0x04e8", "0x6862");
             } else if (vendorFunctions == "etr_miu") {
                 ret = setVidPid("0x18d1", "0x4ee2");
+            } else if (vendorFunctions == "uwb_acm"){
+                ret = setVidPid("0x18d1", "0x4ee2");
             } else {
                 if (!(vendorFunctions == "user" || vendorFunctions == "")) {
                     ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
@@ -284,6 +286,10 @@
         ALOGI("enable etr_miu functions");
         if (linkFunction("etr_miu.gs11", i++))
             return Status::ERROR;
+    } else if (vendorFunctions == "uwb_acm") {
+        ALOGI("enable uwb acm function");
+        if (linkFunction("acm.uwb0", i++))
+            return Status::ERROR;
     }
 
     if ((functions & GadgetFunction::ADB) != 0) {
diff --git a/usb/android.hardware.usb@1.3-service.gs101.rc b/usb/android.hardware.usb@1.3-service.gs101.rc
index 966726b..4112b4e 100644
--- a/usb/android.hardware.usb@1.3-service.gs101.rc
+++ b/usb/android.hardware.usb@1.3-service.gs101.rc
@@ -39,6 +39,8 @@
     chown system system /config/usb_gadget/g1/functions/accessory.gs2
     chown system system /config/usb_gadget/g1/functions/acm.gs6
     chown system system /config/usb_gadget/g1/functions/acm.gs6/port_num
+    chown system system /config/usb_gadget/g1/functions/acm.uwb0
+    chown system system /config/usb_gadget/g1/functions/acm.uwb0/port_num
     chown system system /config/usb_gadget/g1/functions/audio_source.gs3
     chown system system /config/usb_gadget/g1/functions/dm.gs7
     chown system system /config/usb_gadget/g1/functions/ffs.adb
diff --git a/uwb/uwb.mk b/uwb/uwb.mk
index 4a28fe8..be2f6d2 100644
--- a/uwb/uwb.mk
+++ b/uwb/uwb.mk
@@ -16,3 +16,5 @@
 # UWB - ultra wide band
 $(call inherit-product-if-exists, vendor/qorvo/uwb/uwb.mk)
 
+PRODUCT_COPY_FILES += \
+    frameworks/native/data/etc/android.hardware.uwb.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.uwb.xml