[automerger skipped] Merge tm-qpr-dev-plus-aosp-without-vendor@9467136 am: 0725b4c5fd -s ours am: c71ebeb4bc -s ours

am skip reason: Merged-In Ia4041e10156eadb37799ebdc12b33fbb3de4c54d with SHA-1 c010e721ea is already in history

Original change: https://googleplex-android-review.googlesource.com/c/device/google/gs-common/+/20947041

Change-Id: Ibb77bbb5378cadce13cd2fc884e205182f2f3cae
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/aoc/Android.bp b/aoc/Android.bp
new file mode 100644
index 0000000..7af2424
--- /dev/null
+++ b/aoc/Android.bp
@@ -0,0 +1,19 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+    name: "dump_aoc",
+    srcs: ["dump_aoc.cpp"],
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+    ],
+    shared_libs: [
+        "libbase",
+	"libdump",
+    ],
+    vendor: true,
+    relative_install_path: "dump",
+}
diff --git a/aoc/aoc.mk b/aoc/aoc.mk
new file mode 100644
index 0000000..2eadb08
--- /dev/null
+++ b/aoc/aoc.mk
@@ -0,0 +1,26 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/aoc/sepolicy
+
+PRODUCT_PACKAGES += dump_aoc \
+		    aocd
+
+ifeq (,$(filter aosp_%,$(TARGET_PRODUCT)))
+# IAudioMetricExt HIDL
+PRODUCT_PACKAGES += \
+    vendor.google.audiometricext@1.0-service-vendor
+endif
+
+# If AoC Daemon is not present on this build, load firmware at boot via rc
+ifeq ($(wildcard vendor/google/whitechapel/aoc/aocd),)
+PRODUCT_COPY_FILES += \
+	device/google/gs-common/aoc/conf/init.aoc.nodaemon.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.aoc.rc
+else
+PRODUCT_COPY_FILES += \
+	device/google/gs-common/aoc/conf/init.aoc.daemon.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.aoc.rc
+endif
+
+# AoC debug support
+PRODUCT_PACKAGES_DEBUG += \
+	aocdump \
+	aocutil \
+	aoc_audio_cfg \
+	vp_util
diff --git a/aoc/conf/init.aoc.daemon.rc b/aoc/conf/init.aoc.daemon.rc
new file mode 100644
index 0000000..1cf204e
--- /dev/null
+++ b/aoc/conf/init.aoc.daemon.rc
@@ -0,0 +1 @@
+# AoC firmware will be loaded by Daemon
\ No newline at end of file
diff --git a/aoc/conf/init.aoc.nodaemon.rc b/aoc/conf/init.aoc.nodaemon.rc
new file mode 100644
index 0000000..329d7d3
--- /dev/null
+++ b/aoc/conf/init.aoc.nodaemon.rc
@@ -0,0 +1,3 @@
+# Load AoC firmware and boot
+on property:vendor.all.modules.ready=1
+    write /sys/devices/platform/19000000.aoc/firmware aoc.bin
\ No newline at end of file
diff --git a/aoc/dump_aoc.cpp b/aoc/dump_aoc.cpp
new file mode 100644
index 0000000..97da3b5
--- /dev/null
+++ b/aoc/dump_aoc.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2022 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 <stdio.h>
+#include <dump/pixel_dump.h>
+
+// Dump Aoc.
+int main() {
+    setbuf(stdout, NULL);
+    dumpFileContent("AoC Service Status", "/sys/devices/platform/19000000.aoc/services");
+    dumpFileContent("AoC Restarts", "/sys/devices/platform/19000000.aoc/restart_count");
+    dumpFileContent("AoC Coredumps", "/sys/devices/platform/19000000.aoc/coredump_count");
+    dumpFileContent("AoC ring buf wake", "/sys/devices/platform/19000000.aoc/control/ring_buffer_wakeup");
+    dumpFileContent("AoC host ipc wake", "/sys/devices/platform/19000000.aoc/control/host_ipc_wakeup");
+    dumpFileContent("AoC usf wake", "/sys/devices/platform/19000000.aoc/control/usf_wakeup");
+    dumpFileContent("AoC audio wake", "/sys/devices/platform/19000000.aoc/control/audio_wakeup");
+    dumpFileContent("AoC logging wake", "/sys/devices/platform/19000000.aoc/control/logging_wakeup");
+    dumpFileContent("AoC hotword wake", "/sys/devices/platform/19000000.aoc/control/hotword_wakeup");
+    dumpFileContent("AoC memory exception wake", "/sys/devices/platform/19000000.aoc/control/memory_exception");
+    dumpFileContent("AoC memory votes", "/sys/devices/platform/19000000.aoc/control/memory_votes_a32");
+    dumpFileContent("AoC memory votes", "/sys/devices/platform/19000000.aoc/control/memory_votes_ff1");
+    runCommand("clean AoC buffer","echo ' ' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
+    runCommand("AoC Heap Stats (A32)", "echo 'dbg heap -c 1' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
+    runCommand("AoC Heap Stats (F1)", "echo 'dbg heap -c 2' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
+    runCommand("AoC Heap Stats (HF0)", "echo 'dbg heap -c 3' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
+    runCommand("AoC Heap Stats (HF1)", "echo 'dbg heap -c 4' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
+    return 0;
+}
diff --git a/aoc/sepolicy/aocd.te b/aoc/sepolicy/aocd.te
new file mode 100644
index 0000000..69b0af0
--- /dev/null
+++ b/aoc/sepolicy/aocd.te
@@ -0,0 +1,21 @@
+type aocd, domain;
+type aocd_exec, vendor_file_type, exec_type, file_type;
+init_daemon_domain(aocd)
+
+# access persist files
+allow aocd mnt_vendor_file:dir search;
+allow aocd persist_file:dir search;
+r_dir_file(aocd, persist_aoc_file);
+
+# sysfs operations
+allow aocd sysfs_aoc:dir search;
+allow aocd sysfs_aoc_firmware:file w_file_perms;
+
+# dev operations
+allow aocd aoc_device:chr_file rw_file_perms;
+
+# allow inotify to watch for additions/removals from /dev
+allow aocd device:dir r_dir_perms;
+
+# set properties
+set_prop(aocd, vendor_aoc_prop)
diff --git a/aoc/sepolicy/aocdump.te b/aoc/sepolicy/aocdump.te
new file mode 100644
index 0000000..0801ec0
--- /dev/null
+++ b/aoc/sepolicy/aocdump.te
@@ -0,0 +1,18 @@
+type aocdump, domain;
+type aocdump_exec, vendor_file_type, exec_type, file_type;
+init_daemon_domain(aocdump)
+
+userdebug_or_eng(`
+    # Permit communication with AoC
+    allow aocdump aoc_device:chr_file rw_file_perms;
+
+    allow aocdump radio_vendor_data_file:dir rw_dir_perms;
+    allow aocdump radio_vendor_data_file:file create_file_perms;
+    allow aocdump wifi_logging_data_file:dir create_dir_perms;
+    allow aocdump wifi_logging_data_file:file create_file_perms;
+    set_prop(aocdump, vendor_audio_prop);
+    r_dir_file(aocdump, proc_asound)
+
+    allow aocdump self:unix_stream_socket create_stream_socket_perms;
+    allow aocdump audio_vendor_data_file:sock_file { create unlink };
+')
diff --git a/aoc/sepolicy/device.te b/aoc/sepolicy/device.te
new file mode 100644
index 0000000..fbd2b32
--- /dev/null
+++ b/aoc/sepolicy/device.te
@@ -0,0 +1,5 @@
+# AOC device
+type aoc_device, dev_type;
+
+# AMCS device
+type amcs_device, dev_type;
diff --git a/aoc/sepolicy/dump_aoc.te b/aoc/sepolicy/dump_aoc.te
new file mode 100644
index 0000000..f5f085c
--- /dev/null
+++ b/aoc/sepolicy/dump_aoc.te
@@ -0,0 +1,7 @@
+pixel_bugreport(dump_aoc)
+allow dump_aoc sysfs_aoc:dir search;
+allow dump_aoc sysfs_aoc_dumpstate:file r_file_perms;
+allow dump_aoc aoc_device:chr_file rw_file_perms;
+allow dump_aoc vendor_shell_exec:file execute_no_trans;
+allow dump_aoc vendor_toolbox_exec:file execute_no_trans;
+
diff --git a/aoc/sepolicy/file.te b/aoc/sepolicy/file.te
new file mode 100644
index 0000000..649e161
--- /dev/null
+++ b/aoc/sepolicy/file.te
@@ -0,0 +1,16 @@
+# sysfs
+type sysfs_aoc_dumpstate, sysfs_type, fs_type;
+type sysfs_aoc_boottime, sysfs_type, fs_type;
+type sysfs_aoc_firmware, sysfs_type, fs_type;
+type sysfs_aoc, sysfs_type, fs_type;
+type sysfs_aoc_reset, sysfs_type, fs_type;
+
+# persist
+type persist_aoc_file, file_type, vendor_persist_type;
+type persist_audio_file, file_type, vendor_persist_type;
+
+# vendor
+type aoc_audio_file, file_type, vendor_file_type;
+
+# data
+type audio_vendor_data_file, file_type, data_file_type;
diff --git a/aoc/sepolicy/file_contexts b/aoc/sepolicy/file_contexts
new file mode 100644
index 0000000..399a6dc
--- /dev/null
+++ b/aoc/sepolicy/file_contexts
@@ -0,0 +1,38 @@
+# AoC devices
+/dev/acd-audio_output_tuning        u:object_r:aoc_device:s0
+/dev/acd-audio_bulk_tx              u:object_r:aoc_device:s0
+/dev/acd-audio_bulk_rx              u:object_r:aoc_device:s0
+/dev/acd-audio_input_tuning         u:object_r:aoc_device:s0
+/dev/acd-audio_input_bulk_tx        u:object_r:aoc_device:s0
+/dev/acd-audio_input_bulk_rx        u:object_r:aoc_device:s0
+/dev/acd-sound_trigger              u:object_r:aoc_device:s0
+/dev/acd-hotword_notification       u:object_r:aoc_device:s0
+/dev/acd-hotword_pcm                u:object_r:aoc_device:s0
+/dev/acd-ambient_pcm                u:object_r:aoc_device:s0
+/dev/acd-model_data                 u:object_r:aoc_device:s0
+/dev/acd-debug                      u:object_r:aoc_device:s0
+/dev/acd-audio_tap[0-9]*            u:object_r:aoc_device:s0
+/dev/acd-audio_dcdoff_ref           u:object_r:aoc_device:s0
+/dev/acd-com.google.usf             u:object_r:aoc_device:s0
+/dev/acd-com.google.usf.non_wake_up u:object_r:aoc_device:s0
+/dev/acd-logging                    u:object_r:aoc_device:s0
+/dev/aoc                            u:object_r:aoc_device:s0
+/dev/acd-audio_ap_offload_rx        u:object_r:aoc_device:s0
+/dev/acd-audio_ap_offload_tx        u:object_r:aoc_device:s0
+/dev/amcs                           u:object_r:amcs_device:s0
+
+# AoC vendor binaries
+/vendor/bin/aocd                    u:object_r:aocd_exec:s0
+/vendor/bin/aocdump                 u:object_r:aocdump_exec:s0
+/vendor/bin/dump/dump_aoc           u:object_r:dump_aoc_exec:s0
+/vendor/bin/hw/vendor\.google\.audiometricext@1\.0-service-vendor           u:object_r:hal_audiometricext_default_exec:s0
+
+# AoC audio files
+/vendor/etc/aoc(/.*)?               u:object_r:aoc_audio_file:s0
+
+# Aoc persist files
+/mnt/vendor/persist/aoc(/.*)?       u:object_r:persist_aoc_file:s0
+/mnt/vendor/persist/audio(/.*)?     u:object_r:persist_audio_file:s0
+
+# Audio data files
+/data/vendor/audio(/.*)?            u:object_r:audio_vendor_data_file:s0
diff --git a/aoc/sepolicy/genfs_contexts b/aoc/sepolicy/genfs_contexts
new file mode 100644
index 0000000..1df3116
--- /dev/null
+++ b/aoc/sepolicy/genfs_contexts
@@ -0,0 +1,13 @@
+# pixelstat_vendor
+genfscon sysfs /devices/platform/audiometrics/codec_state                   u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/hs_codec_state                u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/speaker_impedance             u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/speaker_excursion             u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/speaker_heartbeat             u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/speaker_temp                  u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/mic_broken_degrade            u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/codec_crashed_counter         u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/hwinfo_part_number            u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/ams_rate_read_once            u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/cca_rate_read_once            u:object_r:sysfs_pixelstats:s0
+
diff --git a/aoc/sepolicy/hal_audio_default.te b/aoc/sepolicy/hal_audio_default.te
new file mode 100644
index 0000000..aa462bf
--- /dev/null
+++ b/aoc/sepolicy/hal_audio_default.te
@@ -0,0 +1,35 @@
+vndbinder_use(hal_audio_default)
+hwbinder_use(hal_audio_default)
+
+allow hal_audio_default audio_vendor_data_file:dir rw_dir_perms;
+allow hal_audio_default audio_vendor_data_file:file create_file_perms;
+
+r_dir_file(hal_audio_default, aoc_audio_file);
+r_dir_file(hal_audio_default, mnt_vendor_file);
+r_dir_file(hal_audio_default, persist_audio_file);
+
+allow hal_audio_default persist_file:dir search;
+allow hal_audio_default aoc_device:file rw_file_perms;
+allow hal_audio_default aoc_device:chr_file rw_file_perms;
+
+allow hal_audio_default hal_audio_ext_hwservice:hwservice_manager { find add };
+
+allow hal_audio_default amcs_device:file rw_file_perms;
+allow hal_audio_default amcs_device:chr_file rw_file_perms;
+allow hal_audio_default sysfs_pixelstats:file rw_file_perms;
+
+#allow access to DMABUF Heaps for AAudio API
+allow hal_audio_default dmabuf_heap_device:chr_file r_file_perms;
+
+set_prop(hal_audio_default, vendor_audio_prop);
+
+hal_client_domain(hal_audio_default, hal_health);
+hal_client_domain(hal_audio_default, hal_thermal);
+allow hal_audio_default fwk_sensor_hwservice:hwservice_manager find;
+
+userdebug_or_eng(`
+    allow hal_audio_default self:unix_stream_socket create_stream_socket_perms;
+    allow hal_audio_default audio_vendor_data_file:sock_file { create unlink };
+')
+
+wakelock_use(hal_audio_default);
diff --git a/aoc/sepolicy/hal_audiometricext_default.te b/aoc/sepolicy/hal_audiometricext_default.te
new file mode 100644
index 0000000..5358eac
--- /dev/null
+++ b/aoc/sepolicy/hal_audiometricext_default.te
@@ -0,0 +1,12 @@
+type hal_audiometricext_default, domain;
+type hal_audiometricext_default_exec, vendor_file_type, exec_type, file_type;
+init_daemon_domain(hal_audiometricext_default)
+
+allow hal_audiometricext_default amcs_device:chr_file rw_file_perms;
+allow hal_audiometricext_default sysfs_pixelstats:file rw_file_perms;
+
+get_prop(hal_audiometricext_default, vendor_audio_prop);
+get_prop(hal_audiometricext_default, hwservicemanager_prop);
+
+hwbinder_use(hal_audiometricext_default);
+add_hwservice(hal_audiometricext_default, hal_audiometricext_hwservice);
diff --git a/aoc/sepolicy/hwservice.te b/aoc/sepolicy/hwservice.te
new file mode 100644
index 0000000..b7bf5d9
--- /dev/null
+++ b/aoc/sepolicy/hwservice.te
@@ -0,0 +1,6 @@
+# Audio
+type hal_audio_ext_hwservice, hwservice_manager_type;
+
+# AudioMetric
+type hal_audiometricext_hwservice, hwservice_manager_type;
+
diff --git a/aoc/sepolicy/hwservice_contexts b/aoc/sepolicy/hwservice_contexts
new file mode 100644
index 0000000..f06c846
--- /dev/null
+++ b/aoc/sepolicy/hwservice_contexts
@@ -0,0 +1,4 @@
+# Audio
+vendor.google.whitechapel.audio.audioext::IAudioExt             u:object_r:hal_audio_ext_hwservice:s0
+vendor.google.audiometricext::IAudioMetricExt                   u:object_r:hal_audiometricext_hwservice:s0
+
diff --git a/aoc/sepolicy/property.te b/aoc/sepolicy/property.te
new file mode 100644
index 0000000..d38e3ec
--- /dev/null
+++ b/aoc/sepolicy/property.te
@@ -0,0 +1,4 @@
+# AoC
+vendor_internal_prop(vendor_aoc_prop)
+# Audio
+vendor_internal_prop(vendor_audio_prop)
diff --git a/aoc/sepolicy/property_contexts b/aoc/sepolicy/property_contexts
new file mode 100644
index 0000000..e957de6
--- /dev/null
+++ b/aoc/sepolicy/property_contexts
@@ -0,0 +1,13 @@
+# AoC
+vendor.aoc.firmware.version                     u:object_r:vendor_aoc_prop:s0
+
+# for audio
+vendor.audio_hal.period_multiplier              u:object_r:vendor_audio_prop:s0
+vendor.audiodump.enable                         u:object_r:vendor_audio_prop:s0
+persist.vendor.audio.                           u:object_r:vendor_audio_prop:s0
+vendor.audiodump.log.ondemand                   u:object_r:vendor_audio_prop:s0
+vendor.audiodump.log.config                     u:object_r:vendor_audio_prop:s0
+vendor.audiodump.output.dir                     u:object_r:vendor_audio_prop:s0
+vendor.audiodump.encode.disable                 u:object_r:vendor_audio_prop:s0
+vendor.audiodump.log.cca.updated                u:object_r:vendor_audio_prop:s0
+vendor.audiodump.cca.config                     u:object_r:vendor_audio_prop:s0
diff --git a/battery_mitigation/Android.bp b/battery_mitigation/Android.bp
new file mode 100644
index 0000000..3c0b882
--- /dev/null
+++ b/battery_mitigation/Android.bp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+soong_namespace {
+    imports: [
+        "hardware/google/pixel",
+    ],
+}
+
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+    vendor: true,
+    name: "battery_mitigation",
+    relative_install_path: "hw",
+    proprietary: true,
+    init_rc: ["battery_mitigation.rc"],
+    shared_libs: [
+        "libpixelmitigation",
+        "libbase",
+        "libbinder_ndk",
+        "libcutils",
+        "libhardware",
+        "libhidlbase",
+        "liblog",
+        "libutils",
+        "android.hardware.thermal@2.0"
+    ],
+    srcs: [
+        "battery_mitigation.cpp",
+    ],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+}
diff --git a/battery_mitigation/battery_mitigation.cpp b/battery_mitigation/battery_mitigation.cpp
new file mode 100644
index 0000000..70e8188
--- /dev/null
+++ b/battery_mitigation/battery_mitigation.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2022 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 "battery-mitigation"
+
+#include <battery_mitigation/BatteryMitigation.h>
+
+using android::hardware::google::pixel::BatteryMitigation;
+using android::hardware::google::pixel::MitigationConfig;
+
+android::sp<BatteryMitigation> bmSp;
+
+const struct MitigationConfig::Config cfg = {
+    .SystemPath = {
+        "/dev/thermal/tz-by-name/batoilo/temp",
+        "/dev/thermal/tz-by-name/smpl_gm/temp",
+        "/dev/thermal/tz-by-name/soc/temp",
+        "/dev/thermal/tz-by-name/vdroop1/temp",
+        "/dev/thermal/tz-by-name/vdroop2/temp",
+        "/dev/thermal/tz-by-name/ocp_gpu/temp",
+        "/dev/thermal/tz-by-name/ocp_tpu/temp",
+        "/dev/thermal/tz-by-name/soft_ocp_cpu2/temp",
+        "/dev/thermal/tz-by-name/soft_ocp_cpu1/temp",
+        "/dev/thermal/tz-by-name/battery/temp",
+        "/dev/thermal/tz-by-name/battery_cycle/temp",
+        "/sys/bus/iio/devices/iio:device0/lpf_power",
+        "/sys/bus/iio/devices/iio:device1/lpf_power",
+        "/dev/thermal/cdev-by-name/thermal-cpufreq-2/cur_state",
+        "/dev/thermal/cdev-by-name/thermal-cpufreq-1/cur_state",
+        "/dev/thermal/cdev-by-name/thermal-gpufreq-0/cur_state",
+        "/dev/thermal/cdev-by-name/tpu_cooling/cur_state",
+        "/dev/thermal/cdev-by-name/CAM/cur_state",
+        "/dev/thermal/cdev-by-name/DISP/cur_state",
+        "/dev/thermal/cdev-by-name/gxp-cooling/cur_state",
+        "/sys/class/power_supply/battery/voltage_now",
+        "/sys/class/power_supply/battery/current_now",
+    },
+    .FilteredZones = {
+        "batoilo",
+        "vdroop1",
+        "vdroop2",
+        "smpl_gm",
+    },
+    .SystemName = {
+        "batoilo", "smpl_gm", "soc", "vdroop1", "vdroop2", "ocp_gpu",
+        "ocp_tpu", "soft_ocp_cpu2", "soft_ocp_cpu1", "battery", "battery_cycle",
+        "main", "sub", "CPU2", "CPU1", "GPU", "TPU", "CAM", "DISP", "NPU",
+        "voltage_now", "current_now",
+    },
+    .LogFilePath = "/data/vendor/mitigation/thismeal.txt",
+    .TimestampFormat = "%Y-%m-%d %H:%M:%S",
+};
+
+const char kReadyFilePath[] = "/sys/devices/virtual/pmic/mitigation/instruction/ready";
+const char kReadyProperty[] = "vendor.brownout.mitigation.ready";
+const char kLastMealPath[] = "/data/vendor/mitigation/lastmeal.txt";
+const char kBRRequestedProperty[] = "vendor.brownout_reason";
+const std::regex kTimestampRegex("^\\S+\\s[0-9]+:[0-9]+:[0-9]+\\S+$");
+
+int main(int /*argc*/, char ** /*argv*/) {
+    auto batteryMitigationStartTime = std::chrono::system_clock::now();
+    bmSp = new BatteryMitigation(cfg);
+    if (!bmSp) {
+        return 0;
+    }
+    bool mitigationLogTimeValid = bmSp->isMitigationLogTimeValid(batteryMitigationStartTime,
+                                                                 cfg.LogFilePath,
+                                                                 cfg.TimestampFormat,
+                                                                 kTimestampRegex);
+    std::string reason = android::base::GetProperty(kBRRequestedProperty, "");
+    if (!reason.empty() && mitigationLogTimeValid) {
+        std::ifstream src(cfg.LogFilePath, std::ios::in);
+        std::ofstream dst(kLastMealPath, std::ios::out);
+        dst << src.rdbuf();
+    }
+    bool isBatteryMitigationReady = false;
+    std::string ready_str;
+    int val = 0;
+    while (!isBatteryMitigationReady) {
+        if (!android::base::ReadFileToString(kReadyFilePath, &ready_str)) {
+            continue;
+        }
+        ready_str = android::base::Trim(ready_str);
+        if (!android::base::ParseInt(ready_str, &val)) {
+            continue;
+        }
+        if (val == 1) {
+            isBatteryMitigationReady = true;
+        }
+    }
+    android::base::SetProperty(kReadyProperty, "1");
+    while (true) {
+        pause();
+    }
+    return 0;
+}
diff --git a/battery_mitigation/battery_mitigation.rc b/battery_mitigation/battery_mitigation.rc
new file mode 100644
index 0000000..fcc9a4f
--- /dev/null
+++ b/battery_mitigation/battery_mitigation.rc
@@ -0,0 +1,93 @@
+on property:vendor.thermal.link_ready=1
+    mkdir /data/vendor/mitigation 0755 system system
+    chown system system /data/vendor/mitigation
+    start vendor.battery_mitigation
+
+on property:ro.boot.bootreason=reboot,uvlo,pmic,if && property:sys.boot.reason=reboot,uvlo,pmic,if
+    setprop vendor.brownout_reason "uvlo,pmic,if"
+
+on property:ro.boot.bootreason=reboot,ocp,pmic,if && property:sys.boot.reason=reboot,ocp,pmic,if
+    setprop vendor.brownout_reason "ocp,pmic,if"
+
+on property:ro.boot.bootreason=reboot,uvlo,pmic,main && property:sys.boot.reason=reboot,uvlo,pmic,main
+    setprop vendor.brownout_reason "uvlo,pmic,main"
+
+on property:ro.boot.bootreason=reboot,uvlo,pmic,sub && property:sys.boot.reason=reboot,uvlo,pmic,sub
+    setprop vendor.brownout_reason "uvlo,pmic,sub"
+
+on property:ro.boot.bootreason=reboot,ocp,buck1m && property:sys.boot.reason=reboot,ocp,buck1m
+    setprop vendor.brownout_reason "ocp,buck1m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck2m && property:sys.boot.reason=reboot,ocp,buck2m
+    setprop vendor.brownout_reason "ocp,buck2m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck3m && property:sys.boot.reason=reboot,ocp,buck3m
+    setprop vendor.brownout_reason "ocp,buck3m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck4m && property:sys.boot.reason=reboot,ocp,buck4m
+    setprop vendor.brownout_reason "ocp,buck4m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck5m && property:sys.boot.reason=reboot,ocp,buck5m
+    setprop vendor.brownout_reason "ocp,buck5m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck6m && property:sys.boot.reason=reboot,ocp,buck6m
+    setprop vendor.brownout_reason "ocp,buck6m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck7m && property:sys.boot.reason=reboot,ocp,buck7m
+    setprop vendor.brownout_reason "ocp,buck7m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck8m && property:sys.boot.reason=reboot,ocp,buck8m
+    setprop vendor.brownout_reason "ocp,buck8m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck9m && property:sys.boot.reason=reboot,ocp,buck9m
+    setprop vendor.brownout_reason "ocp,buck9m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck10m && property:sys.boot.reason=reboot,ocp,buck10m
+    setprop vendor.brownout_reason "ocp,buck10m"
+
+on property:ro.boot.bootreason=reboot,ocp,buck1s && property:sys.boot.reason=reboot,ocp,buck1s
+    setprop vendor.brownout_reason "ocp,buck1s"
+
+on property:ro.boot.bootreason=reboot,ocp,buck2s && property:sys.boot.reason=reboot,ocp,buck2s
+    setprop vendor.brownout_reason "ocp,buck2s"
+
+on property:ro.boot.bootreason=reboot,ocp,buck3s && property:sys.boot.reason=reboot,ocp,buck3s
+    setprop vendor.brownout_reason "ocp,buck3s"
+
+on property:ro.boot.bootreason=reboot,ocp,buck4s && property:sys.boot.reason=reboot,ocp,buck4s
+    setprop vendor.brownout_reason "ocp,buck4s"
+
+on property:ro.boot.bootreason=reboot,ocp,buck5s && property:sys.boot.reason=reboot,ocp,buck5s
+    setprop vendor.brownout_reason "ocp,buck5s"
+
+on property:ro.boot.bootreason=reboot,ocp,buck6s && property:sys.boot.reason=reboot,ocp,buck6s
+    setprop vendor.brownout_reason "ocp,buck6s"
+
+on property:ro.boot.bootreason=reboot,ocp,buck7s && property:sys.boot.reason=reboot,ocp,buck7s
+    setprop vendor.brownout_reason "ocp,buck7s"
+
+on property:ro.boot.bootreason=reboot,ocp,buck8s && property:sys.boot.reason=reboot,ocp,buck8s
+    setprop vendor.brownout_reason "ocp,buck8s"
+
+on property:ro.boot.bootreason=reboot,ocp,buck9s && property:sys.boot.reason=reboot,ocp,buck9s
+    setprop vendor.brownout_reason "ocp,buck9s"
+
+on property:ro.boot.bootreason=reboot,ocp,buck10s && property:sys.boot.reason=reboot,ocp,buck10s
+    setprop vendor.brownout_reason "ocp,buck10s"
+
+on property:ro.boot.bootreason=reboot,ocp,buckds && property:sys.boot.reason=reboot,ocp,buckds
+    setprop vendor.brownout_reason "ocp,buckds"
+
+on property:ro.boot.bootreason=reboot,ocp,buckas && property:sys.boot.reason=reboot,ocp,buckas
+    setprop vendor.brownout_reason "ocp,buckas"
+
+on property:ro.boot.bootreason=reboot,ocp,buckcs && property:sys.boot.reason=reboot,ocp,buckcs
+    setprop vendor.brownout_reason "ocp,buckcs"
+
+on property:ro.boot.bootreason=reboot,ocp,buckbs && property:sys.boot.reason=reboot,ocp,buckbs
+    setprop vendor.brownout_reason "ocp,buckbs"
+
+service vendor.battery_mitigation /vendor/bin/hw/battery_mitigation
+    user system
+    group system
+    capabilities WAKE_ALARM BLOCK_SUSPEND
diff --git a/battery_mitigation/bcl.mk b/battery_mitigation/bcl.mk
new file mode 100644
index 0000000..87e0f95
--- /dev/null
+++ b/battery_mitigation/bcl.mk
@@ -0,0 +1,7 @@
+PRODUCT_PACKAGES += battery_mitigation
+ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
+PRODUCT_PACKAGES += BrownoutDetection
+endif
+
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/battery_mitigation/sepolicy
+PRODUCT_SOONG_NAMESPACES += device/google/gs-common/battery_mitigation
diff --git a/battery_mitigation/sepolicy/battery_mitigation.te b/battery_mitigation/sepolicy/battery_mitigation.te
new file mode 100644
index 0000000..ff34c43
--- /dev/null
+++ b/battery_mitigation/sepolicy/battery_mitigation.te
@@ -0,0 +1,22 @@
+type battery_mitigation, domain;
+type battery_mitigation_exec, exec_type, vendor_file_type, file_type;
+init_daemon_domain(battery_mitigation)
+get_prop(battery_mitigation, boot_status_prop)
+get_prop(battery_mitigation, vendor_brownout_reason_prop)
+get_prop(battery_mitigation, system_boot_reason_prop)
+set_prop(battery_mitigation, vendor_mitigation_ready_prop)
+
+hal_client_domain(battery_mitigation, hal_thermal);
+hal_client_domain(battery_mitigation, hal_health);
+
+r_dir_file(battery_mitigation, sysfs_batteryinfo)
+r_dir_file(battery_mitigation, sysfs_iio_devices)
+r_dir_file(battery_mitigation, sysfs_thermal)
+r_dir_file(battery_mitigation, thermal_link_device)
+r_dir_file(battery_mitigation, sysfs_odpm)
+allow battery_mitigation sysfs_bcl:dir r_dir_perms;
+allow battery_mitigation sysfs_bcl:file r_file_perms;
+allow battery_mitigation sysfs_bcl:lnk_file r_file_perms;
+allow battery_mitigation sysfs_thermal:lnk_file r_file_perms;
+allow battery_mitigation mitigation_vendor_data_file:dir rw_dir_perms;
+allow battery_mitigation mitigation_vendor_data_file:file create_file_perms;
diff --git a/battery_mitigation/sepolicy/brownout_detection_app.te b/battery_mitigation/sepolicy/brownout_detection_app.te
new file mode 100644
index 0000000..6146a74
--- /dev/null
+++ b/battery_mitigation/sepolicy/brownout_detection_app.te
@@ -0,0 +1,9 @@
+type brownout_detection_app, domain, coredomain;
+
+userdebug_or_eng(`
+  app_domain(brownout_detection_app)
+  net_domain(brownout_detection_app)
+  allow brownout_detection_app app_api_service:service_manager find;
+  allow brownout_detection_app system_api_service:service_manager find;
+  get_prop(brownout_detection_app, vendor_brownout_reason_prop)
+')
diff --git a/battery_mitigation/sepolicy/file.te b/battery_mitigation/sepolicy/file.te
new file mode 100644
index 0000000..06bedad
--- /dev/null
+++ b/battery_mitigation/sepolicy/file.te
@@ -0,0 +1,3 @@
+type mitigation_vendor_data_file, file_type, data_file_type;
+type sysfs_bcl, sysfs_type, fs_type;
+type sysfs_odpm, sysfs_type, fs_type;
diff --git a/battery_mitigation/sepolicy/file_contexts b/battery_mitigation/sepolicy/file_contexts
new file mode 100644
index 0000000..2e88ba0
--- /dev/null
+++ b/battery_mitigation/sepolicy/file_contexts
@@ -0,0 +1,2 @@
+/vendor/bin/hw/battery_mitigation                                           u:object_r:battery_mitigation_exec:s0
+/data/vendor/mitigation(/.*)?                                               u:object_r:mitigation_vendor_data_file:s0
diff --git a/battery_mitigation/sepolicy/genfs_contexts b/battery_mitigation/sepolicy/genfs_contexts
new file mode 100644
index 0000000..84c6e21
--- /dev/null
+++ b/battery_mitigation/sepolicy/genfs_contexts
@@ -0,0 +1,3 @@
+genfscon sysfs /devices/virtual/pmic/mitigation                                u:object_r:sysfs_bcl:s0
+genfscon sysfs /bus/iio/devices/iio:device0/lpf_power                          u:object_r:sysfs_bcl:s0
+genfscon sysfs /bus/iio/devices/iio:device1/lpf_power                          u:object_r:sysfs_bcl:s0
diff --git a/battery_mitigation/sepolicy/property.te b/battery_mitigation/sepolicy/property.te
new file mode 100644
index 0000000..d750f09
--- /dev/null
+++ b/battery_mitigation/sepolicy/property.te
@@ -0,0 +1,3 @@
+# Battery Mitigation
+vendor_internal_prop(vendor_mitigation_ready_prop)
+vendor_public_prop(vendor_brownout_reason_prop)
diff --git a/battery_mitigation/sepolicy/property_contexts b/battery_mitigation/sepolicy/property_contexts
new file mode 100644
index 0000000..014cb14
--- /dev/null
+++ b/battery_mitigation/sepolicy/property_contexts
@@ -0,0 +1,3 @@
+# Battery Mitigation
+vendor.brownout.mitigation.ready           u:object_r:vendor_mitigation_ready_prop:s0
+vendor.brownout_reason                     u:object_r:vendor_brownout_reason_prop:s0
diff --git a/battery_mitigation/sepolicy/seapp_contexts b/battery_mitigation/sepolicy/seapp_contexts
new file mode 100644
index 0000000..7e5d883
--- /dev/null
+++ b/battery_mitigation/sepolicy/seapp_contexts
@@ -0,0 +1,2 @@
+# BrownoutDetection
+user=_app isPrivApp=true name=com.google.android.brownoutdetection domain=brownout_detection_app type=app_data_file levelFrom=all
diff --git a/battery_mitigation/sepolicy/vendor_init.te b/battery_mitigation/sepolicy/vendor_init.te
new file mode 100644
index 0000000..275f377
--- /dev/null
+++ b/battery_mitigation/sepolicy/vendor_init.te
@@ -0,0 +1,3 @@
+# Battery Mitigation
+set_prop(vendor_init, vendor_brownout_reason_prop)
+get_prop(vendor_init, system_boot_reason_prop)
diff --git a/bcmbt/bluetooth.mk b/bcmbt/bluetooth.mk
new file mode 100644
index 0000000..6615878
--- /dev/null
+++ b/bcmbt/bluetooth.mk
@@ -0,0 +1,12 @@
+PRODUCT_SOONG_NAMESPACES += vendor/broadcom/bluetooth
+PRODUCT_PACKAGES += \
+       android.hardware.bluetooth@1.1-service.bcmbtlinux \
+       bt_vendor.conf \
+       android.hardware.bluetooth.prebuilt.xml \
+       android.hardware.bluetooth_le.prebuilt.xml
+
+
+BOARD_SEPOLICY_DIRS += device/google/gs-common/bcmbt/sepolicy
+
+DEVICE_MANIFEST_FILE += device/google/gs-common/bcmbt/manifest_bluetooth.xml
+DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs-common/bcmbt/compatibility_matrix.xml
diff --git a/bcmbt/compatibility_matrix.xml b/bcmbt/compatibility_matrix.xml
new file mode 100644
index 0000000..ec47e35
--- /dev/null
+++ b/bcmbt/compatibility_matrix.xml
@@ -0,0 +1,42 @@
+<compatibility-matrix version="1.0" type="framework" level="7">
+    <hal format="hidl">
+        <name>hardware.google.bluetooth.ccc</name>
+        <version>1.1</version>
+        <interface>
+            <name>IBluetoothCcc</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>hardware.google.bluetooth.bt_channel_avoidance</name>
+        <version>1.0</version>
+        <interface>
+            <name>IBTChannelAvoidance</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>hardware.google.bluetooth.sar</name>
+        <version>1.1</version>
+        <interface>
+            <name>IBluetoothSar</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl" optional="true">
+        <name>hardware.google.bluetooth.ext</name>
+        <version>1.0</version>
+        <interface>
+            <name>IBluetoothExt</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl" optional="true">
+        <name>hardware.google.bluetooth.ewp</name>
+        <version>1.0</version>
+        <interface>
+            <name>IBluetoothEwp</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</compatibility-matrix>
diff --git a/bcmbt/manifest_bluetooth.xml b/bcmbt/manifest_bluetooth.xml
new file mode 100644
index 0000000..64238c7
--- /dev/null
+++ b/bcmbt/manifest_bluetooth.xml
@@ -0,0 +1,56 @@
+<manifest version="1.0" type="device">
+    <hal format="hidl">
+        <name>android.hardware.bluetooth</name>
+        <transport>hwbinder</transport>
+        <version>1.1</version>
+        <interface>
+            <name>IBluetoothHci</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>hardware.google.bluetooth.bt_channel_avoidance</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IBTChannelAvoidance</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>hardware.google.bluetooth.sar</name>
+        <transport>hwbinder</transport>
+        <version>1.1</version>
+        <interface>
+            <name>IBluetoothSar</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>hardware.google.bluetooth.ext</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IBluetoothExt</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>hardware.google.bluetooth.ccc</name>
+        <transport>hwbinder</transport>
+        <version>1.1</version>
+        <interface>
+            <name>IBluetoothCcc</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>hardware.google.bluetooth.ewp</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IBluetoothEwp</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</manifest>
diff --git a/bcmbt/sepolicy/device.te b/bcmbt/sepolicy/device.te
new file mode 100644
index 0000000..a256332
--- /dev/null
+++ b/bcmbt/sepolicy/device.te
@@ -0,0 +1,3 @@
+# Bt Wifi Coexistence device
+type wb_coexistence_dev, dev_type;
+
diff --git a/bcmbt/sepolicy/file_contexts b/bcmbt/sepolicy/file_contexts
new file mode 100644
index 0000000..d4681db
--- /dev/null
+++ b/bcmbt/sepolicy/file_contexts
@@ -0,0 +1,6 @@
+# Bluetooth
+/(vendor|system/vendor)/bin/hw/android\.hardware\.bluetooth@1\.1-service\.bcmbtlinux    u:object_r:hal_bluetooth_btlinux_exec:s0
+
+/dev/wbrc                           u:object_r:wb_coexistence_dev:s0
+/dev/ttySAC16                       u:object_r:hci_attach_dev:s0
+
diff --git a/bcmbt/sepolicy/genfs_contexts b/bcmbt/sepolicy/genfs_contexts
new file mode 100644
index 0000000..607e146
--- /dev/null
+++ b/bcmbt/sepolicy/genfs_contexts
@@ -0,0 +1,7 @@
+genfscon sysfs /devices/platform/odm/odm:btbcm/rfkill/rfkill0/state                             u:object_r:sysfs_bluetooth_writable:s0
+genfscon sysfs /devices/platform/odm/odm:btbcm/rfkill/rfkill2/state                             u:object_r:sysfs_bluetooth_writable:s0
+genfscon proc /bluetooth/sleep/lpm                                                              u:object_r:proc_bluetooth_writable:s0
+genfscon proc /bluetooth/sleep/btwrite                                                          u:object_r:proc_bluetooth_writable:s0
+genfscon proc /bluetooth/sleep/btwake                                                           u:object_r:proc_bluetooth_writable:s0
+genfscon proc /bluetooth/timesync                                                               u:object_r:proc_bluetooth_writable:s0
+
diff --git a/bcmbt/sepolicy/hal_bluetooth_btlinux.te b/bcmbt/sepolicy/hal_bluetooth_btlinux.te
new file mode 100644
index 0000000..f348099
--- /dev/null
+++ b/bcmbt/sepolicy/hal_bluetooth_btlinux.te
@@ -0,0 +1,22 @@
+add_hwservice(hal_bluetooth_btlinux, hal_bluetooth_coexistence_hwservice);
+get_prop(hal_bluetooth_btlinux, boot_status_prop)
+
+allow hal_bluetooth_btlinux sysfs_bluetooth_writable:file rw_file_perms;
+allow hal_bluetooth_btlinux proc_bluetooth_writable:file rw_file_perms;
+allow hal_bluetooth_btlinux hci_attach_dev:chr_file rw_file_perms;
+allow hal_bluetooth_btlinux wb_coexistence_dev:chr_file rw_file_perms;
+binder_call(hal_bluetooth_btlinux, servicemanager)
+
+# power stats
+vndbinder_use(hal_bluetooth_btlinux)
+allow hal_bluetooth_btlinux hal_power_stats_vendor_service:service_manager find;
+binder_call(hal_bluetooth_btlinux, hal_power_stats_default)
+
+allow hal_bluetooth_btlinux sscoredump_vendor_data_crashinfo_file:dir create_dir_perms;
+allow hal_bluetooth_btlinux sscoredump_vendor_data_crashinfo_file:file create_file_perms;
+
+userdebug_or_eng(`
+  allow hal_bluetooth_btlinux sscoredump_vendor_data_coredump_file:dir create_dir_perms;
+  allow hal_bluetooth_btlinux sscoredump_vendor_data_coredump_file:file create_file_perms;
+  allow hal_bluetooth_btlinux logbuffer_device:chr_file r_file_perms;
+')
diff --git a/bcmbt/sepolicy/hwservice.te b/bcmbt/sepolicy/hwservice.te
new file mode 100644
index 0000000..5e36cd0
--- /dev/null
+++ b/bcmbt/sepolicy/hwservice.te
@@ -0,0 +1,3 @@
+# Bluetooth HAL extension
+type hal_bluetooth_coexistence_hwservice, hwservice_manager_type, vendor_hwservice_type;
+
diff --git a/bcmbt/sepolicy/hwservice_contexts b/bcmbt/sepolicy/hwservice_contexts
new file mode 100644
index 0000000..8480b4e
--- /dev/null
+++ b/bcmbt/sepolicy/hwservice_contexts
@@ -0,0 +1,6 @@
+# Bluetooth HAL extension
+hardware.google.bluetooth.bt_channel_avoidance::IBTChannelAvoidance   u:object_r:hal_bluetooth_coexistence_hwservice:s0
+hardware.google.bluetooth.sar::IBluetoothSar                          u:object_r:hal_bluetooth_coexistence_hwservice:s0
+hardware.google.bluetooth.ccc::IBluetoothCcc                          u:object_r:hal_bluetooth_coexistence_hwservice:s0
+hardware.google.bluetooth.ewp::IBluetoothEwp                          u:object_r:hal_bluetooth_coexistence_hwservice:s0
+hardware.google.bluetooth.ext::IBluetoothExt                          u:object_r:hal_bluetooth_coexistence_hwservice:s0
diff --git a/dauntless/Android.bp b/dauntless/Android.bp
new file mode 100644
index 0000000..bd365a7
--- /dev/null
+++ b/dauntless/Android.bp
@@ -0,0 +1,10 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_gsc.sh",
+    src: "dump_gsc.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/dauntless/dump_gsc.sh b/dauntless/dump_gsc.sh
new file mode 100644
index 0000000..7966d1b
--- /dev/null
+++ b/dauntless/dump_gsc.sh
@@ -0,0 +1,7 @@
+#!/vendor/bin/sh
+echo "Citadel VERSION\n"
+vendor/bin/hw/citadel_updater -lv
+echo "Citadel STATS\n"
+vendor/bin/hw/citadel_updater --stats
+echo "GSC DEBUG DUMP\n"
+vendor/bin/hw/citadel_updater -D
diff --git a/dauntless/gsc.mk b/dauntless/gsc.mk
new file mode 100644
index 0000000..326fc6d
--- /dev/null
+++ b/dauntless/gsc.mk
@@ -0,0 +1,21 @@
+# Dauntless
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/dauntless/sepolicy
+PRODUCT_SOONG_NAMESPACES += vendor/google_nos/init/dauntless
+
+PRODUCT_PACKAGES += \
+    citadeld \
+    citadel_updater \
+    android.hardware.weaver-service.citadel \
+    android.hardware.authsecret-service.citadel \
+    android.hardware.oemlock-service.citadel \
+    android.hardware.identity@1.0-service.citadel \
+    init_citadel \
+    android.hardware.strongbox_keystore.xml \
+    android.hardware.security.keymint-service.citadel \
+    dump_gsc.sh
+
+# USERDEBUG ONLY: Install test packages
+PRODUCT_PACKAGES_DEBUG += citadel_integration_tests \
+                          pwntest \
+                          nugget_targeted_tests \
+                          CitadelProvision
diff --git a/dauntless/sepolicy/citadel_provision.te b/dauntless/sepolicy/citadel_provision.te
new file mode 100644
index 0000000..5605085
--- /dev/null
+++ b/dauntless/sepolicy/citadel_provision.te
@@ -0,0 +1,6 @@
+type citadel_provision, domain;
+type citadel_provision_exec, exec_type, vendor_file_type, file_type;
+
+userdebug_or_eng(`
+  init_daemon_domain(citadel_provision)
+')
diff --git a/dauntless/sepolicy/citadeld.te b/dauntless/sepolicy/citadeld.te
new file mode 100644
index 0000000..86cb61c
--- /dev/null
+++ b/dauntless/sepolicy/citadeld.te
@@ -0,0 +1,13 @@
+type citadeld, domain;
+type citadeld_exec, exec_type, vendor_file_type, file_type;
+
+init_daemon_domain(citadeld)
+
+add_service(citadeld, citadeld_service)
+binder_use(citadeld)
+vndbinder_use(citadeld)
+binder_call(citadeld, system_server)
+
+allow citadeld citadel_device:chr_file rw_file_perms;
+allow citadeld fwk_stats_service:service_manager find;
+allow citadeld hal_power_stats_vendor_service:service_manager find;
diff --git a/dauntless/sepolicy/device.te b/dauntless/sepolicy/device.te
new file mode 100644
index 0000000..f63186f
--- /dev/null
+++ b/dauntless/sepolicy/device.te
@@ -0,0 +1 @@
+type citadel_device, dev_type;
diff --git a/dauntless/sepolicy/dump_gsc.te b/dauntless/sepolicy/dump_gsc.te
new file mode 100644
index 0000000..8a3580b
--- /dev/null
+++ b/dauntless/sepolicy/dump_gsc.te
@@ -0,0 +1,12 @@
+type dump_gsc, domain;
+type dump_gsc_exec, exec_type, vendor_file_type, file_type;
+domain_auto_trans(hal_dumpstate_default, dump_gsc_exec, dump_gsc)
+hal_client_domain(dump_gsc, hal_dumpstate)
+
+allow dump_gsc dumpstate:fd use;
+allow dump_gsc dumpstate:fifo_file { write getattr };
+allow dump_gsc shell_data_file:file { write getattr };
+allow dump_gsc citadel_updater:file execute_no_trans;
+allow dump_gsc citadeld_service:service_manager find;
+binder_call(dump_gsc, citadeld)
+vndbinder_use(dump_gsc)
diff --git a/dauntless/sepolicy/file.te b/dauntless/sepolicy/file.te
new file mode 100644
index 0000000..cfc0dea
--- /dev/null
+++ b/dauntless/sepolicy/file.te
@@ -0,0 +1 @@
+type citadel_updater, vendor_file_type, file_type;
diff --git a/dauntless/sepolicy/file_contexts b/dauntless/sepolicy/file_contexts
new file mode 100644
index 0000000..0fba0da
--- /dev/null
+++ b/dauntless/sepolicy/file_contexts
@@ -0,0 +1,13 @@
+/vendor/bin/dump/dump_gsc\.sh                                               u:object_r:dump_gsc_exec:s0
+/vendor/bin/CitadelProvision                                                u:object_r:citadel_provision_exec:s0
+/vendor/bin/hw/init_citadel                                                 u:object_r:init_citadel_exec:s0
+/vendor/bin/hw/android\.hardware\.security\.keymint-service\.citadel        u:object_r:hal_keymint_citadel_exec:s0
+/vendor/bin/hw/android\.hardware\.weaver@1\.0-service\.citadel              u:object_r:hal_weaver_citadel_exec:s0
+/vendor/bin/hw/android\.hardware\.weaver-service\.citadel                   u:object_r:hal_weaver_citadel_exec:s0
+/vendor/bin/hw/android\.hardware\.identity@1\.0-service\.citadel            u:object_r:hal_identity_citadel_exec:s0
+/vendor/bin/hw/android\.hardware\.authsecret-service\.citadel               u:object_r:hal_authsecret_citadel_exec:s0
+/vendor/bin/hw/android\.hardware\.oemlock-service\.citadel                  u:object_r:hal_oemlock_citadel_exec:s0
+/vendor/bin/hw/citadel_updater                                              u:object_r:citadel_updater:s0
+/vendor/bin/hw/citadeld                                                     u:object_r:citadeld_exec:s0
+
+/dev/gsc0                                                                   u:object_r:citadel_device:s0
diff --git a/dauntless/sepolicy/hal_authsecret_citadel.te b/dauntless/sepolicy/hal_authsecret_citadel.te
new file mode 100644
index 0000000..029d957
--- /dev/null
+++ b/dauntless/sepolicy/hal_authsecret_citadel.te
@@ -0,0 +1,9 @@
+type hal_authsecret_citadel, domain;
+type hal_authsecret_citadel_exec, exec_type, vendor_file_type, file_type;
+
+vndbinder_use(hal_authsecret_citadel)
+binder_call(hal_authsecret_citadel, citadeld)
+allow hal_authsecret_citadel citadeld_service:service_manager find;
+
+hal_server_domain(hal_authsecret_citadel, hal_authsecret)
+init_daemon_domain(hal_authsecret_citadel)
diff --git a/dauntless/sepolicy/hal_identity_citadel.te b/dauntless/sepolicy/hal_identity_citadel.te
new file mode 100644
index 0000000..c181e27
--- /dev/null
+++ b/dauntless/sepolicy/hal_identity_citadel.te
@@ -0,0 +1,11 @@
+type hal_identity_citadel, domain;
+type hal_identity_citadel_exec, exec_type, vendor_file_type, file_type;
+
+vndbinder_use(hal_identity_citadel)
+binder_call(hal_identity_citadel, citadeld)
+allow hal_identity_citadel citadeld_service:service_manager find;
+allow hal_identity_citadel hal_keymint_citadel:binder call;
+
+hal_server_domain(hal_identity_citadel, hal_identity)
+hal_server_domain(hal_identity_citadel, hal_keymint)
+init_daemon_domain(hal_identity_citadel)
diff --git a/dauntless/sepolicy/hal_keymint_citadel.te b/dauntless/sepolicy/hal_keymint_citadel.te
new file mode 100644
index 0000000..e1a6177
--- /dev/null
+++ b/dauntless/sepolicy/hal_keymint_citadel.te
@@ -0,0 +1,9 @@
+type hal_keymint_citadel, domain;
+type hal_keymint_citadel_exec, exec_type, vendor_file_type, file_type;
+
+hal_server_domain(hal_keymint_citadel, hal_keymint)
+init_daemon_domain(hal_keymint_citadel)
+vndbinder_use(hal_keymint_citadel)
+get_prop(hal_keymint_citadel, vendor_security_patch_level_prop)
+allow hal_keymint_citadel citadeld_service:service_manager find;
+binder_call(hal_keymint_citadel, citadeld)
diff --git a/dauntless/sepolicy/hal_oemlock_citadel.te b/dauntless/sepolicy/hal_oemlock_citadel.te
new file mode 100644
index 0000000..d3ff719
--- /dev/null
+++ b/dauntless/sepolicy/hal_oemlock_citadel.te
@@ -0,0 +1,9 @@
+type hal_oemlock_citadel, domain;
+type hal_oemlock_citadel_exec, exec_type, vendor_file_type, file_type;
+
+vndbinder_use(hal_oemlock_citadel)
+binder_call(hal_oemlock_citadel, citadeld)
+allow hal_oemlock_citadel citadeld_service:service_manager find;
+
+hal_server_domain(hal_oemlock_citadel, hal_oemlock)
+init_daemon_domain(hal_oemlock_citadel)
diff --git a/dauntless/sepolicy/hal_weaver_citadel.te b/dauntless/sepolicy/hal_weaver_citadel.te
new file mode 100644
index 0000000..c47287b
--- /dev/null
+++ b/dauntless/sepolicy/hal_weaver_citadel.te
@@ -0,0 +1,11 @@
+type hal_weaver_citadel, domain;
+type hal_weaver_citadel_exec, exec_type, vendor_file_type, file_type;
+
+init_daemon_domain(hal_weaver_citadel)
+hal_server_domain(hal_weaver_citadel, hal_weaver)
+hal_server_domain(hal_weaver_citadel, hal_oemlock)
+hal_server_domain(hal_weaver_citadel, hal_authsecret)
+vndbinder_use(hal_weaver_citadel)
+binder_call(hal_weaver_citadel, citadeld)
+
+allow hal_weaver_citadel citadeld_service:service_manager find;
diff --git a/dauntless/sepolicy/init_citadel.te b/dauntless/sepolicy/init_citadel.te
new file mode 100644
index 0000000..2e986d0
--- /dev/null
+++ b/dauntless/sepolicy/init_citadel.te
@@ -0,0 +1,15 @@
+type init_citadel, domain;
+type init_citadel_exec, exec_type, vendor_file_type, file_type;
+
+init_daemon_domain(init_citadel)
+
+# Citadel communication must be via citadeld
+vndbinder_use(init_citadel)
+binder_call(init_citadel, citadeld)
+allow init_citadel citadeld_service:service_manager find;
+
+# Many standard utils are actually vendor_toolbox (like xxd)
+allow init_citadel vendor_toolbox_exec:file rx_file_perms;
+
+# init_citadel needs to invoke citadel_updater
+allow init_citadel citadel_updater:file rx_file_perms;
diff --git a/dauntless/sepolicy/service_contexts b/dauntless/sepolicy/service_contexts
new file mode 100644
index 0000000..ac6a186
--- /dev/null
+++ b/dauntless/sepolicy/service_contexts
@@ -0,0 +1,3 @@
+android.hardware.security.keymint.IKeyMintDevice/strongbox      u:object_r:hal_keymint_service:s0
+android.hardware.security.sharedsecret.ISharedSecret/strongbox  u:object_r:hal_sharedsecret_service:s0
+android.hardware.security.keymint.IRemotelyProvisionedComponent/strongbox  u:object_r:hal_remotelyprovisionedcomponent_service:s0
diff --git a/dauntless/sepolicy/vndservice.te b/dauntless/sepolicy/vndservice.te
new file mode 100644
index 0000000..880c09c
--- /dev/null
+++ b/dauntless/sepolicy/vndservice.te
@@ -0,0 +1 @@
+type citadeld_service, vndservice_manager_type;
diff --git a/dauntless/sepolicy/vndservice_contexts b/dauntless/sepolicy/vndservice_contexts
new file mode 100644
index 0000000..b4df996
--- /dev/null
+++ b/dauntless/sepolicy/vndservice_contexts
@@ -0,0 +1 @@
+android.hardware.citadel.ICitadeld  u:object_r:citadeld_service:s0
diff --git a/edgetpu/edgetpu.mk b/edgetpu/edgetpu.mk
new file mode 100644
index 0000000..3f79438
--- /dev/null
+++ b/edgetpu/edgetpu.mk
@@ -0,0 +1,23 @@
+# TPU logging service
+PRODUCT_PACKAGES += \
+	android.hardware.edgetpu.logging@service-edgetpu-logging
+# TPU NN AIDL HAL
+PRODUCT_PACKAGES += \
+	android.hardware.neuralnetworks@service-darwinn-aidl
+# TPU application service
+PRODUCT_PACKAGES += \
+	vendor.google.edgetpu_app_service@1.0-service
+# TPU vendor service
+PRODUCT_PACKAGES += \
+	vendor.google.edgetpu_vendor_service@1.0-service
+# TPU HAL client library
+PRODUCT_PACKAGES += \
+	libedgetpu_client.google
+# TPU metrics logger library
+PRODUCT_PACKAGES += \
+	libmetrics_logger
+# TPU TFlite Delegate
+PRODUCT_PACKAGES += \
+        libedgetpu_util
+
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/edgetpu/sepolicy
diff --git a/edgetpu/sepolicy/device.te b/edgetpu/sepolicy/device.te
new file mode 100644
index 0000000..9296ba5
--- /dev/null
+++ b/edgetpu/sepolicy/device.te
@@ -0,0 +1,2 @@
+# EdgeTPU device (DarwiNN)
+type edgetpu_device, dev_type, mlstrustedobject;
diff --git a/edgetpu/sepolicy/edgetpu_app_service.te b/edgetpu/sepolicy/edgetpu_app_service.te
new file mode 100644
index 0000000..58ce246
--- /dev/null
+++ b/edgetpu/sepolicy/edgetpu_app_service.te
@@ -0,0 +1,38 @@
+# EdgeTPU app server process which runs the EdgeTPU binder service.
+type edgetpu_app_server, coredomain, domain;
+type edgetpu_app_server_exec, exec_type, system_file_type, file_type;
+init_daemon_domain(edgetpu_app_server)
+
+# The server will use binder calls.
+binder_use(edgetpu_app_server);
+
+# The server will serve a binder service.
+binder_service(edgetpu_app_server);
+
+# EdgeTPU server to register the service to service_manager.
+add_service(edgetpu_app_server, edgetpu_app_service);
+
+# EdgeTPU service needs to access /dev/abrolhos.
+allow edgetpu_app_server edgetpu_device:chr_file rw_file_perms;
+allow edgetpu_app_server sysfs_edgetpu:dir r_dir_perms;
+allow edgetpu_app_server sysfs_edgetpu:file rw_file_perms;
+
+# Applications are not allowed to open the EdgeTPU device directly.
+neverallow appdomain edgetpu_device:chr_file { open };
+
+# Allow EdgeTPU service to access the Package Manager service.
+allow edgetpu_app_server package_native_service:service_manager find;
+binder_call(edgetpu_app_server, system_server);
+
+# Allow EdgeTPU service to read EdgeTPU service related system properties.
+get_prop(edgetpu_app_server, vendor_edgetpu_service_prop);
+
+# Allow EdgeTPU service to generate Perfetto traces.
+perfetto_producer(edgetpu_app_server);
+
+# Allow EdgeTPU service to connect to the EdgeTPU vendor version of the service.
+allow edgetpu_app_server edgetpu_vendor_service:service_manager find;
+binder_call(edgetpu_app_server, edgetpu_vendor_server);
+
+# Allow EdgeTPU service to log to stats service. (metrics)
+allow edgetpu_app_server fwk_stats_service:service_manager find;
diff --git a/edgetpu/sepolicy/edgetpu_logging.te b/edgetpu/sepolicy/edgetpu_logging.te
new file mode 100644
index 0000000..2cd9ea4
--- /dev/null
+++ b/edgetpu/sepolicy/edgetpu_logging.te
@@ -0,0 +1,15 @@
+type edgetpu_logging, domain;
+type edgetpu_logging_exec, exec_type, vendor_file_type, file_type;
+init_daemon_domain(edgetpu_logging)
+
+# The logging service accesses /dev/<edgetpu device>
+allow edgetpu_logging edgetpu_device:chr_file rw_file_perms;
+
+# Allows the logging service to access /sys/class/edgetpu
+allow edgetpu_logging sysfs_edgetpu:dir search;
+allow edgetpu_logging sysfs_edgetpu:file rw_file_perms;
+
+# Allow TPU logging service to log to stats service. (metrics)
+allow edgetpu_logging fwk_stats_service:service_manager find;
+binder_call(edgetpu_logging, system_server);
+binder_use(edgetpu_logging)
diff --git a/edgetpu/sepolicy/edgetpu_vendor_server.te b/edgetpu/sepolicy/edgetpu_vendor_server.te
new file mode 100644
index 0000000..1060510
--- /dev/null
+++ b/edgetpu/sepolicy/edgetpu_vendor_server.te
@@ -0,0 +1,31 @@
+# EdgeTPU vendor service.
+type edgetpu_vendor_server, domain;
+type edgetpu_vendor_server_exec, exec_type, vendor_file_type, file_type;
+init_daemon_domain(edgetpu_vendor_server)
+
+# The vendor service will use binder calls.
+binder_use(edgetpu_vendor_server);
+
+# The vendor service will serve a binder service.
+binder_service(edgetpu_vendor_server);
+
+# EdgeTPU vendor service to register the service to service_manager.
+add_service(edgetpu_vendor_server, edgetpu_vendor_service);
+
+# Allow communications between other vendor services.
+allow edgetpu_vendor_server vndbinder_device:chr_file { read write open ioctl map };
+
+# Allow EdgeTPU vendor service to access its data files.
+allow edgetpu_vendor_server edgetpu_vendor_service_data_file:file create_file_perms;
+allow edgetpu_vendor_server edgetpu_vendor_service_data_file:dir create_dir_perms;
+
+# Allow EdgeTPU vendor service to access Android shared memory allocated
+# by the camera hal for on-device compilation.
+allow edgetpu_vendor_server hal_camera_default:fd use;
+
+# Allow EdgeTPU vendor service to read the kernel version.
+# This is done inside the InitGoogle.
+allow edgetpu_vendor_server proc_version:file r_file_perms;
+
+# Allow EdgeTPU vendor service to read the overcommit_memory info.
+allow edgetpu_vendor_server proc_overcommit_memory:file r_file_perms;
diff --git a/edgetpu/sepolicy/file.te b/edgetpu/sepolicy/file.te
new file mode 100644
index 0000000..5b3c8b5
--- /dev/null
+++ b/edgetpu/sepolicy/file.te
@@ -0,0 +1,8 @@
+# EdgeTPU sysfs
+type sysfs_edgetpu, sysfs_type, fs_type;
+
+# EdgeTPU hal data file
+type hal_neuralnetworks_darwinn_data_file, file_type, data_file_type;
+
+# EdgeTPU vendor service data file
+type edgetpu_vendor_service_data_file, file_type, data_file_type;
diff --git a/edgetpu/sepolicy/file_contexts b/edgetpu/sepolicy/file_contexts
new file mode 100644
index 0000000..e8fb9ac
--- /dev/null
+++ b/edgetpu/sepolicy/file_contexts
@@ -0,0 +1,24 @@
+# EdgeTPU logging service
+/vendor/bin/hw/android\.hardware\.edgetpu\.logging@service-edgetpu-logging u:object_r:edgetpu_logging_exec:s0
+
+# NeuralNetworks file contexts
+/vendor/bin/hw/android\.hardware\.neuralnetworks@service-darwinn-aidl      u:object_r:hal_neuralnetworks_darwinn_exec:s0
+
+# EdgeTPU service binaries and libraries
+/system_ext/bin/hw/vendor\.google\.edgetpu_app_service@1\.0-service        u:object_r:edgetpu_app_server_exec:s0
+
+# EdgeTPU vendor service
+/vendor/bin/hw/vendor\.google\.edgetpu_vendor_service@1\.0-service         u:object_r:edgetpu_vendor_server_exec:s0
+
+# EdgeTPU metrics logging service.
+/vendor/lib64/libedgetpu_client\.google\.so                                u:object_r:same_process_hal_file:s0
+/vendor/lib64/libmetrics_logger\.so                                        u:object_r:same_process_hal_file:s0
+/vendor/lib64/libedgetpu_util\.so                                          u:object_r:same_process_hal_file:s0
+# EdgeTPU runtime libraries
+/vendor/lib64/com\.google\.edgetpu_app_service-V[1-2]-ndk\.so              u:object_r:same_process_hal_file:s0
+/vendor/lib64/com\.google\.edgetpu_vendor_service-V[1-2]-ndk\.so           u:object_r:same_process_hal_file:s0
+
+# EdgeTPU data files
+/data/vendor/hal_neuralnetworks_darwinn(/.*)?                              u:object_r:hal_neuralnetworks_darwinn_data_file:s0
+/data/vendor/edgetpu(/.*)?                                                 u:object_r:edgetpu_vendor_service_data_file:s0
+
diff --git a/edgetpu/sepolicy/hal_neuralnetworks_darwinn.te b/edgetpu/sepolicy/hal_neuralnetworks_darwinn.te
new file mode 100644
index 0000000..f301a72
--- /dev/null
+++ b/edgetpu/sepolicy/hal_neuralnetworks_darwinn.te
@@ -0,0 +1,53 @@
+type hal_neuralnetworks_darwinn, domain;
+hal_server_domain(hal_neuralnetworks_darwinn, hal_neuralnetworks)
+
+type hal_neuralnetworks_darwinn_exec, exec_type, vendor_file_type, file_type;
+init_daemon_domain(hal_neuralnetworks_darwinn)
+
+# The TPU HAL looks for TPU instance in /dev/abrolhos
+allow hal_neuralnetworks_darwinn edgetpu_device:chr_file rw_file_perms;
+
+# Allow DawriNN service to use a client-provided fd residing in /vendor/etc/.
+allow hal_neuralnetworks_darwinn vendor_configs_file:file r_file_perms;
+
+# Allow DarwiNN service to access data files.
+allow hal_neuralnetworks_darwinn hal_neuralnetworks_darwinn_data_file:file create_file_perms;
+allow hal_neuralnetworks_darwinn hal_neuralnetworks_darwinn_data_file:dir rw_dir_perms;
+
+# Allow DarwiNN service to access unix sockets for IPC.
+allow hal_neuralnetworks_darwinn hal_neuralnetworks_darwinn_data_file:sock_file { create unlink rw_file_perms };
+
+# Register to hwbinder service.
+# add_hwservice() is granted by hal_server_domain + hal_neuralnetworks.te
+hwbinder_use(hal_neuralnetworks_darwinn)
+get_prop(hal_neuralnetworks_darwinn, hwservicemanager_prop)
+
+# Allow TPU HAL to read the kernel version.
+# This is done inside the InitGoogle.
+allow hal_neuralnetworks_darwinn proc_version:file r_file_perms;
+
+# Allow TPU NNAPI HAL to log to stats service. (metrics)
+allow hal_neuralnetworks_darwinn fwk_stats_service:service_manager find;
+binder_call(hal_neuralnetworks_darwinn, system_server);
+binder_use(hal_neuralnetworks_darwinn)
+
+# Allow TPU NNAPI HAL to request power hints from the Power Service
+hal_client_domain(hal_neuralnetworks_darwinn, hal_power)
+
+# TPU NNAPI to register the service to service_manager.
+add_service(hal_neuralnetworks_darwinn, edgetpu_nnapi_service);
+
+# Allow TPU NNAPI HAL to read the overcommit_memory info.
+allow hal_neuralnetworks_darwinn proc_overcommit_memory:file r_file_perms;
+
+# Allows the logging service to access /sys/class/edgetpu
+allow hal_neuralnetworks_darwinn sysfs_edgetpu:dir r_dir_perms;
+allow hal_neuralnetworks_darwinn sysfs_edgetpu:file r_file_perms;
+
+# Allows the NNAPI HAL to access the edgetpu_app_service
+allow hal_neuralnetworks_darwinn edgetpu_app_service:service_manager find;
+binder_call(hal_neuralnetworks_darwinn, edgetpu_app_server);
+
+# Allow NNAPI HAL to send trace packets to Perfetto with SELinux enabled
+# under userdebug builds.
+userdebug_or_eng(`perfetto_producer(hal_neuralnetworks_darwinn)')
diff --git a/edgetpu/sepolicy/priv_app.te b/edgetpu/sepolicy/priv_app.te
new file mode 100644
index 0000000..22021a8
--- /dev/null
+++ b/edgetpu/sepolicy/priv_app.te
@@ -0,0 +1,10 @@
+# Allows privileged applications to discover the EdgeTPU service.
+allow priv_app edgetpu_app_service:service_manager find;
+
+# Allows privileged applications to discover the NNAPI TPU service.
+allow priv_app edgetpu_nnapi_service:service_manager find;
+
+# Allows privileged applications to access the EdgeTPU device, except open,
+# which is guarded by the EdgeTPU service.
+allow priv_app edgetpu_device:chr_file { getattr read write ioctl map };
+
diff --git a/edgetpu/sepolicy/property.te b/edgetpu/sepolicy/property.te
new file mode 100644
index 0000000..ed93d44
--- /dev/null
+++ b/edgetpu/sepolicy/property.te
@@ -0,0 +1,4 @@
+# EdgeTPU service requires system public properties
+# since it lives under /system_ext/.
+system_public_prop(vendor_edgetpu_service_prop)
+
diff --git a/edgetpu/sepolicy/property_contexts b/edgetpu/sepolicy/property_contexts
new file mode 100644
index 0000000..130cfef
--- /dev/null
+++ b/edgetpu/sepolicy/property_contexts
@@ -0,0 +1,3 @@
+# for EdgeTPU
+vendor.edgetpu.service.                         u:object_r:vendor_edgetpu_service_prop:s0
+
diff --git a/edgetpu/sepolicy/service.te b/edgetpu/sepolicy/service.te
new file mode 100644
index 0000000..3cb81dd
--- /dev/null
+++ b/edgetpu/sepolicy/service.te
@@ -0,0 +1,5 @@
+type edgetpu_nnapi_service, app_api_service, service_manager_type;
+type edgetpu_vendor_service, service_manager_type, hal_service_type;
+
+# EdgeTPU binder service type declaration.
+type edgetpu_app_service, service_manager_type;
diff --git a/edgetpu/sepolicy/service_contexts b/edgetpu/sepolicy/service_contexts
new file mode 100644
index 0000000..9972eae
--- /dev/null
+++ b/edgetpu/sepolicy/service_contexts
@@ -0,0 +1,7 @@
+
+com.google.edgetpu.IEdgeTpuVendorService/default           u:object_r:edgetpu_vendor_service:s0
+# TPU NNAPI Service
+android.hardware.neuralnetworks.IDevice/google-edgetpu	   u:object_r:edgetpu_nnapi_service:s0
+
+# EdgeTPU service
+com.google.edgetpu.IEdgeTpuAppService/default              u:object_r:edgetpu_app_service:s0
diff --git a/edgetpu/sepolicy/untrusted_app_all.te b/edgetpu/sepolicy/untrusted_app_all.te
new file mode 100644
index 0000000..9abec61
--- /dev/null
+++ b/edgetpu/sepolicy/untrusted_app_all.te
@@ -0,0 +1,7 @@
+# Allows applications to discover the EdgeTPU service.
+allow untrusted_app_all edgetpu_app_service:service_manager find;
+
+# Allows applications to access the EdgeTPU device, except open, which is guarded
+# by the EdgeTPU service.
+allow untrusted_app_all edgetpu_device:chr_file { getattr read write ioctl map };
+
diff --git a/gps/brcm/device.mk b/gps/brcm/device.mk
new file mode 100644
index 0000000..e9dcf3d
--- /dev/null
+++ b/gps/brcm/device.mk
@@ -0,0 +1,10 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/gps/brcm/sepolicy
+
+PRODUCT_SOONG_NAMESPACES += vendor/broadcom/gps/bcm47765
+
+PRODUCT_PACKAGES += \
+	bcm47765_gps_package \
+	android.hardware.location.gps.prebuilt.xml
+
+PRODUCT_PACKAGES_DEBUG += \
+	init.gps_log.rc
diff --git a/gps/brcm/sepolicy/file.te b/gps/brcm/sepolicy/file.te
new file mode 100644
index 0000000..5d9dd83
--- /dev/null
+++ b/gps/brcm/sepolicy/file.te
@@ -0,0 +1,2 @@
+type sysfs_gps, sysfs_type, fs_type;
+type sysfs_gps_assert, sysfs_type, fs_type;
diff --git a/gps/brcm/sepolicy/file_contexts b/gps/brcm/sepolicy/file_contexts
new file mode 100644
index 0000000..8ae128e
--- /dev/null
+++ b/gps/brcm/sepolicy/file_contexts
@@ -0,0 +1,12 @@
+# gnss/gps data/log files
+/data/vendor/gps(/.*)?                                            u:object_r:vendor_gps_file:s0
+
+# devices
+/dev/bbd_control                                                  u:object_r:vendor_gnss_device:s0
+/dev/ttyBCM                                                       u:object_r:vendor_gnss_device:s0
+
+# vendor binaries
+/vendor/bin/hw/scd                                                u:object_r:scd_exec:s0
+/vendor/bin/hw/lhd                                                u:object_r:lhd_exec:s0
+/vendor/bin/hw/gpsd                                               u:object_r:gpsd_exec:s0
+/vendor/bin/hw/android\.hardware\.gnss@[0-9]\.[0-9]-service-brcm  u:object_r:hal_gnss_default_exec:s0
diff --git a/gps/brcm/sepolicy/genfs_contexts b/gps/brcm/sepolicy/genfs_contexts
new file mode 100644
index 0000000..446fc45
--- /dev/null
+++ b/gps/brcm/sepolicy/genfs_contexts
@@ -0,0 +1,3 @@
+# GPS
+genfscon sysfs /devices/virtual/pps/pps0/assert_elapsed                         u:object_r:sysfs_gps_assert:s0
+
diff --git a/gps/brcm/sepolicy/gpsd.te b/gps/brcm/sepolicy/gpsd.te
new file mode 100644
index 0000000..2e5a497
--- /dev/null
+++ b/gps/brcm/sepolicy/gpsd.te
@@ -0,0 +1,20 @@
+init_daemon_domain(gpsd)
+
+# Allow gpsd to obtain wakelock
+wakelock_use(gpsd)
+
+# Allow gpsd access data vendor gps files
+allow gpsd vendor_gps_file:dir create_dir_perms;
+allow gpsd vendor_gps_file:file create_file_perms;
+allow gpsd vendor_gps_file:fifo_file create_file_perms;
+
+# Allow gpsd to access rild
+binder_call(gpsd, rild);
+allow gpsd hal_exynos_rild_hwservice:hwservice_manager find;
+
+# Allow gpsd to access sensor service
+binder_call(gpsd, system_server);
+allow gpsd fwk_sensor_hwservice:hwservice_manager find;
+
+# Allow gpsd to access pps gpio
+allow gpsd sysfs_gps_assert:file r_file_perms;
diff --git a/gps/brcm/sepolicy/hal_gnss_default.te b/gps/brcm/sepolicy/hal_gnss_default.te
new file mode 100644
index 0000000..e300423
--- /dev/null
+++ b/gps/brcm/sepolicy/hal_gnss_default.te
@@ -0,0 +1,4 @@
+# Allow hal_gnss_default access data vendor gps files
+allow hal_gnss_default vendor_gps_file:dir create_dir_perms;
+allow hal_gnss_default vendor_gps_file:file create_file_perms;
+allow hal_gnss_default vendor_gps_file:fifo_file create_file_perms;
diff --git a/gps/brcm/sepolicy/lhd.te b/gps/brcm/sepolicy/lhd.te
new file mode 100644
index 0000000..e980897
--- /dev/null
+++ b/gps/brcm/sepolicy/lhd.te
@@ -0,0 +1,23 @@
+type lhd, domain;
+type lhd_exec, vendor_file_type, exec_type, file_type;
+init_daemon_domain(lhd)
+
+# Allow lhd access PixelLogger unix socket in debug build only
+userdebug_or_eng(`
+    typeattribute lhd mlstrustedsubject;
+    allow lhd logger_app:unix_stream_socket connectto;
+')
+
+# Allow lhd access data vendor gps files
+allow lhd vendor_gps_file:dir create_dir_perms;
+allow lhd vendor_gps_file:file create_file_perms;
+allow lhd vendor_gps_file:fifo_file create_file_perms;
+
+# Allow lhd to obtain wakelock
+wakelock_use(lhd)
+
+# Allow lhd access /dev/bbd_control file
+allow lhd vendor_gnss_device:chr_file rw_file_perms;
+
+# Allow lhd access nstandby gpio
+allow lhd sysfs_gps:file rw_file_perms;
diff --git a/gps/brcm/sepolicy/scd.te b/gps/brcm/sepolicy/scd.te
new file mode 100644
index 0000000..28aaee0
--- /dev/null
+++ b/gps/brcm/sepolicy/scd.te
@@ -0,0 +1,17 @@
+type scd, domain;
+type scd_exec, vendor_file_type, exec_type, file_type;
+init_daemon_domain(scd)
+
+# Allow scd access PixelLogger unix socket in debug build only
+userdebug_or_eng(`
+    typeattribute scd mlstrustedsubject;
+    allow scd logger_app:unix_stream_socket connectto;
+')
+
+# Allow a base set of permissions required for network access.
+net_domain(scd);
+
+# Allow scd access data vendor gps files
+allow scd vendor_gps_file:dir create_dir_perms;
+allow scd vendor_gps_file:file create_file_perms;
+allow scd vendor_gps_file:fifo_file create_file_perms;
diff --git a/gs_watchdogd/Android.bp b/gs_watchdogd/Android.bp
new file mode 100644
index 0000000..708f2d9
--- /dev/null
+++ b/gs_watchdogd/Android.bp
@@ -0,0 +1,20 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+    name: "gs_watchdogd",
+    recovery_available: true,
+    system_ext_specific: true,
+    init_rc: ["init.gs_watchdogd.rc"],
+    srcs: ["gs_watchdogd.cpp"],
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+    ],
+    shared_libs: ["libbase"],
+    sanitize: {
+        misc_undefined: ["signed-integer-overflow"],
+    },
+}
diff --git a/gs_watchdogd/gs_watchdogd.cpp b/gs_watchdogd/gs_watchdogd.cpp
new file mode 100644
index 0000000..59b089c
--- /dev/null
+++ b/gs_watchdogd/gs_watchdogd.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2022 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-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/stringprintf.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <glob.h>
+#include <linux/watchdog.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define DEV_GLOB "/sys/devices/platform/*.watchdog_cl0/watchdog/watchdog*"
+
+using android::base::Basename;
+using android::base::StringPrintf;
+
+int main(int argc, char** argv) {
+    android::base::InitLogging(argv, &android::base::KernelLogger);
+
+    int interval = 10;
+    if (argc >= 2) interval = atoi(argv[1]);
+
+    int margin = 10;
+    if (argc >= 3) margin = atoi(argv[2]);
+
+    LOG(INFO) << "gs_watchdogd started (interval " << interval << ", margin " << margin << ")!";
+
+    glob_t globbuf;
+    int ret = glob(DEV_GLOB, GLOB_MARK, nullptr, &globbuf);
+    if (ret) {
+        PLOG(ERROR) << "Failed to lookup glob " << DEV_GLOB << ": " << ret;
+        return 1;
+    }
+
+    if (globbuf.gl_pathc > 1) {
+        PLOG(WARNING) << "Multiple watchdog dev path found by " << DEV_GLOB;
+    }
+
+    std::string dev_path = StringPrintf("/dev/%s", Basename(globbuf.gl_pathv[0]).c_str());
+    globfree(&globbuf);
+
+    int fd = open(dev_path.c_str(), O_RDWR | O_CLOEXEC);
+    if (fd == -1) {
+        PLOG(ERROR) << "Failed to open " << dev_path;
+        return 1;
+    }
+
+    int timeout = interval + margin;
+    ret = ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
+    if (ret) {
+        PLOG(ERROR) << "Failed to set timeout to " << timeout;
+        ret = ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
+        if (ret) {
+            PLOG(ERROR) << "Failed to get timeout";
+        } else {
+            if (timeout > margin) {
+                interval = timeout - margin;
+            } else {
+                interval = 1;
+            }
+            LOG(WARNING) << "Adjusted interval to timeout returned by driver: "
+                         << "timeout " << timeout << ", interval " << interval << ", margin "
+                         << margin;
+        }
+    }
+
+    while (true) {
+        write(fd, "", 1);
+        sleep(interval);
+    }
+}
diff --git a/gs_watchdogd/init.gs_watchdogd.rc b/gs_watchdogd/init.gs_watchdogd.rc
new file mode 100644
index 0000000..450daa1
--- /dev/null
+++ b/gs_watchdogd/init.gs_watchdogd.rc
@@ -0,0 +1,8 @@
+# Set watchdog timer to 30 seconds and pet it every 10 seconds to get a 20 second margin
+service gs_watchdogd /system_ext/bin/gs_watchdogd 10 20
+    class core
+    oneshot
+    seclabel u:r:gs_watchdogd:s0
+
+on property:vendor.all.devices.ready=1
+    start gs_watchdogd
diff --git a/gs_watchdogd/sepolicy/file_contexts b/gs_watchdogd/sepolicy/file_contexts
new file mode 100644
index 0000000..22dd02b
--- /dev/null
+++ b/gs_watchdogd/sepolicy/file_contexts
@@ -0,0 +1,5 @@
+# Platform watchdogd
+/system_ext/bin/gs_watchdogd            u:object_r:gs_watchdogd_exec:s0
+
+# Devices
+/dev/watchdog[0-9]                      u:object_r:watchdog_device:s0
diff --git a/gs_watchdogd/sepolicy/gs_watchdogd.te b/gs_watchdogd/sepolicy/gs_watchdogd.te
new file mode 100644
index 0000000..538f870
--- /dev/null
+++ b/gs_watchdogd/sepolicy/gs_watchdogd.te
@@ -0,0 +1,9 @@
+# gs_watchdogd seclabel is specified in init.<board>.rc
+type gs_watchdogd, domain, coredomain;
+type gs_watchdogd_exec, system_file_type, exec_type, file_type;
+
+init_daemon_domain(gs_watchdogd)
+
+allow gs_watchdogd watchdog_device:chr_file rw_file_perms;
+allow gs_watchdogd kmsg_device:chr_file rw_file_perms;
+allow gs_watchdogd sysfs:dir r_dir_perms;
diff --git a/gs_watchdogd/watchdog.mk b/gs_watchdogd/watchdog.mk
new file mode 100644
index 0000000..69cbbbd
--- /dev/null
+++ b/gs_watchdogd/watchdog.mk
@@ -0,0 +1,6 @@
+# Platform watchdogd
+PRODUCT_PACKAGES += gs_watchdogd
+PRODUCT_SOONG_NAMESPACES += \
+	device/google/gs-common/gs_watchdogd
+SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += \
+	device/google/gs-common/gs_watchdogd/sepolicy
diff --git a/insmod/Android.bp b/insmod/Android.bp
new file mode 100644
index 0000000..3b956e7
--- /dev/null
+++ b/insmod/Android.bp
@@ -0,0 +1,36 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "insmod.sh",
+    src: "insmod.sh",
+    init_rc: ["init.module.rc"],
+    vendor: true,
+}
+
+prebuilt_etc {
+    name: "init.common.cfg",
+    src: "init.common.cfg",
+    vendor: true,
+}
+
+cc_library {
+    name: "libdump",
+    srcs: ["pixel_dump.cpp"],
+    vendor_available: true,
+    vendor_ramdisk_available: true,
+    shared_libs: [
+        "libbase",
+        "liblog",
+    ],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+
+    export_include_dirs: [
+        "include",
+    ],
+}
+
diff --git a/insmod/include/dump/pixel_dump.h b/insmod/include/dump/pixel_dump.h
new file mode 100644
index 0000000..1d661be
--- /dev/null
+++ b/insmod/include/dump/pixel_dump.h
@@ -0,0 +1,7 @@
+#ifndef DEVICE_GOOGLE_GS_COMMON_INSMOD_INCLUDE_DUMP_PIXEL_DUMP_H_
+#define DEVICE_GOOGLE_GS_COMMON_INSMOD_INCLUDE_DUMP_PIXEL_DUMP_H_
+
+void dumpFileContent(const char* title, const char* file_path);
+void runCommand(const char* title, const char* cmd);
+
+#endif  // DEVICE_GOOGLE_GS_COMMON_INSMOD_INCLUDE_DUMP_PIXEL_DUMP_H_
diff --git a/insmod/init.common.cfg b/insmod/init.common.cfg
new file mode 100644
index 0000000..3a81fd2
--- /dev/null
+++ b/insmod/init.common.cfg
@@ -0,0 +1,11 @@
+####################################################
+#           init.insmod.common.cfg                 #
+# This file contains common kernel modules to load #
+# at init time by init.insmod.sh script            #
+####################################################
+
+# Load common kernel modules
+# Modules here will be loaded *before* device specific modules
+modprobe|-b *
+# All common modules loaded
+setprop|vendor.common.modules.ready
diff --git a/insmod/init.module.rc b/insmod/init.module.rc
new file mode 100644
index 0000000..de23b5b
--- /dev/null
+++ b/insmod/init.module.rc
@@ -0,0 +1,10 @@
+on init
+    # Loading common kernel modules in background
+    start insmod_sh
+
+service insmod_sh /vendor/bin/insmod.sh /vendor/etc/init.common.cfg
+    class main
+    user root
+    group root system
+    disabled
+    oneshot
diff --git a/insmod/insmod.mk b/insmod/insmod.mk
new file mode 100644
index 0000000..aa2261a
--- /dev/null
+++ b/insmod/insmod.mk
@@ -0,0 +1,4 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/insmod/sepolicy
+PRODUCT_PACKAGES += \
+        insmod.sh \
+        init.common.cfg
diff --git a/insmod/insmod.sh b/insmod/insmod.sh
new file mode 100755
index 0000000..2c434ef
--- /dev/null
+++ b/insmod/insmod.sh
@@ -0,0 +1,67 @@
+#!/vendor/bin/sh
+
+#############################################################
+### init.insmod.cfg format:                               ###
+### ----------------------------------------------------- ###
+### [insmod|setprop|enable/moprobe|wait] [path|prop name] ###
+### ...                                                   ###
+#############################################################
+
+modules_dir=
+
+for f in /vendor/lib/modules/*/modules.dep /vendor/lib/modules/modules.dep; do
+  if [[ -f "$f" ]]; then
+    modules_dir="$(dirname "$f")"
+    break
+  fi
+done
+
+if [[ -z "${modules_dir}" ]]; then
+  echo "Unable to locate kernel modules directory" 2>&1
+  exit 1
+fi
+
+# imitates wait_for_file() in init
+wait_for_file()
+{
+    filename="${1}"
+    timeout="${2:-5}"
+
+    expiry=$(($(date "+%s")+timeout))
+    while [[ ! -e "${filename}" ]] && [[ "$(date "+%s")" -le "${expiry}" ]]
+    do
+        sleep 0.01
+    done
+}
+
+if [ $# -eq 1 ]; then
+  cfg_file=$1
+else
+  # Set property even if there is no insmod config
+  # to unblock early-boot trigger
+  setprop vendor.common.modules.ready
+  setprop vendor.device.modules.ready
+  setprop vendor.all.modules.ready
+  setprop vendor.all.devices.ready
+  exit 1
+fi
+
+if [ -f $cfg_file ]; then
+  while IFS="|" read -r action arg
+  do
+    case $action in
+      "insmod") insmod $arg ;;
+      "setprop") setprop $arg 1 ;;
+      "enable") echo 1 > $arg ;;
+      "modprobe")
+        case ${arg} in
+          "-b *" | "-b")
+            arg="-b --all=${modules_dir}/modules.load" ;;
+          "*" | "")
+            arg="--all=${modules_dir}/modules.load" ;;
+        esac
+        modprobe -a -d "${modules_dir}" $arg ;;
+      "wait") wait_for_file $arg ;;
+    esac
+  done < $cfg_file
+fi
diff --git a/insmod/pixel_dump.cpp b/insmod/pixel_dump.cpp
new file mode 100644
index 0000000..5926dfc
--- /dev/null
+++ b/insmod/pixel_dump.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2022 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 <stdio.h>
+#include <string>
+#include <android-base/file.h>
+
+// Format title and content output.
+void dumpFileContent(const char* title, const char* file_path) {
+    std::string content;
+    printf("------ %s (%s) ------\n", title, file_path);
+    if (android::base::ReadFileToString(file_path, &content)) {
+        printf("%s\n", content.c_str());
+    } else {
+        printf("Unable to read %s\n", file_path);
+    }
+    return;
+}
+
+// Format title and command output.
+void runCommand(const char* title, const char* cmd) {
+    printf("------ %s (%s)------\n", title, cmd);
+    system(cmd);
+    return;
+}
diff --git a/insmod/sepolicy/file_contexts b/insmod/sepolicy/file_contexts
new file mode 100644
index 0000000..e048641
--- /dev/null
+++ b/insmod/sepolicy/file_contexts
@@ -0,0 +1,5 @@
+# Vendor_kernel_modules
+/vendor_dlkm/lib/modules/.*\.ko u:object_r:vendor_kernel_modules:s0
+
+/vendor/bin/insmod\.sh          u:object_r:insmod-sh_exec:s0
+
diff --git a/insmod/sepolicy/insmod-sh.te b/insmod/sepolicy/insmod-sh.te
new file mode 100644
index 0000000..d7b4f72
--- /dev/null
+++ b/insmod/sepolicy/insmod-sh.te
@@ -0,0 +1,11 @@
+type insmod-sh, domain;
+type insmod-sh_exec, vendor_file_type, exec_type, file_type;
+init_daemon_domain(insmod-sh)
+
+allow insmod-sh self:capability sys_module;
+allow insmod-sh vendor_kernel_modules:system module_load;
+allow insmod-sh vendor_toolbox_exec:file execute_no_trans;
+
+set_prop(insmod-sh, vendor_device_prop)
+
+dontaudit insmod-sh proc_cmdline:file r_file_perms;
diff --git a/insmod/sepolicy/property.te b/insmod/sepolicy/property.te
new file mode 100644
index 0000000..50f7b34
--- /dev/null
+++ b/insmod/sepolicy/property.te
@@ -0,0 +1 @@
+vendor_internal_prop(vendor_device_prop)
diff --git a/insmod/sepolicy/property_contexts b/insmod/sepolicy/property_contexts
new file mode 100644
index 0000000..1e871b6
--- /dev/null
+++ b/insmod/sepolicy/property_contexts
@@ -0,0 +1,5 @@
+# Kernel modules related
+vendor.common.modules.ready     u:object_r:vendor_device_prop:s0
+vendor.device.modules.ready     u:object_r:vendor_device_prop:s0
+vendor.all.modules.ready        u:object_r:vendor_device_prop:s0
+vendor.all.devices.ready        u:object_r:vendor_device_prop:s0
diff --git a/modem/Android.bp b/modem/Android.bp
new file mode 100644
index 0000000..0376ca6
--- /dev/null
+++ b/modem/Android.bp
@@ -0,0 +1,10 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_modem.sh",
+    src: "dump_modem.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/modem/dump_modem.sh b/modem/dump_modem.sh
new file mode 100644
index 0000000..f9f7cf2
--- /dev/null
+++ b/modem/dump_modem.sh
@@ -0,0 +1,17 @@
+#!/vendor/bin/sh
+
+echo "------ Modem Stat ------"
+cat /data/vendor/modem_stat/debug.txt
+
+echo "\n------ Modem SSR history ------"
+for f in $(ls /data/vendor/ssrdump/crashinfo_modem*); do
+  echo $f
+  cat $f
+done
+
+echo "\n------ RFSD error log ------"
+for f in $(ls /data/vendor/log/rfsd/rfslog_*); do
+  echo $f
+  cat $f
+done
+
diff --git a/modem/modem.mk b/modem/modem.mk
new file mode 100644
index 0000000..fe4633d
--- /dev/null
+++ b/modem/modem.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/modem/sepolicy
+
+PRODUCT_PACKAGES += dump_modem.sh
diff --git a/modem/sepolicy/dump_modem.te b/modem/sepolicy/dump_modem.te
new file mode 100644
index 0000000..dc9b38d
--- /dev/null
+++ b/modem/sepolicy/dump_modem.te
@@ -0,0 +1,10 @@
+pixel_bugreport(dump_modem)
+
+allow dump_modem modem_stat_data_file:dir search;
+allow dump_modem modem_stat_data_file:file r_file_perms;
+allow dump_modem sscoredump_vendor_data_crashinfo_file:dir r_dir_perms;
+allow dump_modem sscoredump_vendor_data_crashinfo_file:file r_file_perms;
+allow dump_modem vendor_log_file:dir search;
+allow dump_modem vendor_rfsd_log_file:dir r_dir_perms;
+allow dump_modem vendor_rfsd_log_file:file r_file_perms;
+allow dump_modem vendor_toolbox_exec:file execute_no_trans;
diff --git a/modem/sepolicy/file_contexts b/modem/sepolicy/file_contexts
new file mode 100644
index 0000000..d7f6be5
--- /dev/null
+++ b/modem/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/dump/dump_modem\.sh      u:object_r:dump_modem_exec:s0
diff --git a/pixel_metrics/Android.bp b/pixel_metrics/Android.bp
new file mode 100644
index 0000000..3ad3ff4
--- /dev/null
+++ b/pixel_metrics/Android.bp
@@ -0,0 +1,10 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_pixel_metrics.sh",
+    src: "dump_pixel_metrics.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/pixel_metrics/dump_pixel_metrics.sh b/pixel_metrics/dump_pixel_metrics.sh
new file mode 100644
index 0000000..0c6e2c2
--- /dev/null
+++ b/pixel_metrics/dump_pixel_metrics.sh
@@ -0,0 +1,7 @@
+#!/vendor/bin/sh
+echo "Long running IRQ metrics"
+cat /sys/kernel/metrics/irq/long_irq_metrics
+echo "Resume latency metrics"
+cat /sys/kernel/metrics/resume_latency/resume_latency_metrics
+echo "Temperature Residency Metrics:"
+cat /sys/kernel/metrics/temp_residency/temp_residency_all/stats
diff --git a/pixel_metrics/pixel_metrics.mk b/pixel_metrics/pixel_metrics.mk
new file mode 100644
index 0000000..41e027d
--- /dev/null
+++ b/pixel_metrics/pixel_metrics.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/pixel_metrics/sepolicy
+
+PRODUCT_PACKAGES += dump_pixel_metrics.sh
diff --git a/pixel_metrics/sepolicy/device.te b/pixel_metrics/sepolicy/device.te
new file mode 100644
index 0000000..63640e3
--- /dev/null
+++ b/pixel_metrics/sepolicy/device.te
@@ -0,0 +1,2 @@
+#vendor-metrics
+type sysfs_vendor_metrics, fs_type, sysfs_type;
diff --git a/pixel_metrics/sepolicy/dump_pixel_metrics.te b/pixel_metrics/sepolicy/dump_pixel_metrics.te
new file mode 100644
index 0000000..681670e
--- /dev/null
+++ b/pixel_metrics/sepolicy/dump_pixel_metrics.te
@@ -0,0 +1,5 @@
+pixel_bugreport(dump_pixel_metrics)
+
+#vendor-metrics
+r_dir_file(dump_pixel_metrics, sysfs_vendor_metrics)
+allow dump_pixel_metrics vendor_toolbox_exec:file execute_no_trans;
diff --git a/pixel_metrics/sepolicy/file_contexts b/pixel_metrics/sepolicy/file_contexts
new file mode 100644
index 0000000..1b5b11f
--- /dev/null
+++ b/pixel_metrics/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/dump/dump_pixel_metrics\.sh      u:object_r:dump_pixel_metrics_exec:s0
diff --git a/pixel_metrics/sepolicy/genfs_contexts b/pixel_metrics/sepolicy/genfs_contexts
new file mode 100644
index 0000000..b914014
--- /dev/null
+++ b/pixel_metrics/sepolicy/genfs_contexts
@@ -0,0 +1,4 @@
+#vendor-metrics
+genfscon sysfs /kernel/metrics/resume_latency/resume_latency_metrics      u:object_r:sysfs_vendor_metrics:s0
+genfscon sysfs /kernel/metrics/irq/long_irq_metrics                       u:object_r:sysfs_vendor_metrics:s0
+genfscon sysfs /kernel/metrics/temp_residency/temp_residency_all/stats    u:object_r:sysfs_vendor_metrics:s0
diff --git a/powerstats/CpupmStateResidencyDataProvider.cpp b/powerstats/CpupmStateResidencyDataProvider.cpp
new file mode 100644
index 0000000..bb0e61f
--- /dev/null
+++ b/powerstats/CpupmStateResidencyDataProvider.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2023 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 "CpupmStateResidencyDataProvider.h"
+
+#include <android-base/logging.h>
+#include <android-base/parseint.h>
+#include <android-base/strings.h>
+
+#include <string>
+#include <utility>
+
+using android::base::ParseUint;
+using android::base::Split;
+using android::base::StartsWith;
+using android::base::Trim;
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace power {
+namespace stats {
+
+CpupmStateResidencyDataProvider::CpupmStateResidencyDataProvider(
+        const std::string &path, const Config &config)
+    : mPath(std::move(path)), mConfig(std::move(config)) {}
+
+int32_t CpupmStateResidencyDataProvider::matchState(char const *line) {
+    for (int32_t i = 0; i < mConfig.states.size(); i++) {
+        if (mConfig.states[i].second == Trim(std::string(line))) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+int32_t CpupmStateResidencyDataProvider::matchEntity(char const *line) {
+    for (int32_t i = 0; i < mConfig.entities.size(); i++) {
+        if (StartsWith(Trim(std::string(line)), mConfig.entities[i].second)) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+bool CpupmStateResidencyDataProvider::parseState(
+        char const *line, uint64_t *duration, uint64_t *count) {
+    std::vector<std::string> parts = Split(line, " ");
+    if (parts.size() != 5) {
+        return false;
+    }
+    if (!ParseUint(Trim(parts[1]), count)) {
+        return false;
+    }
+    if (!ParseUint(Trim(parts[3]), duration)) {
+        return false;
+    }
+    return true;
+}
+
+bool CpupmStateResidencyDataProvider::getStateResidencies(
+        std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
+    std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(mPath.c_str(), "r"), fclose);
+    if (!fp) {
+        PLOG(ERROR) << __func__ << ":Failed to open file " << mPath;
+        return false;
+    }
+
+    for (int32_t i = 0; i < mConfig.entities.size(); i++) {
+        std::vector<StateResidency> stateResidencies(mConfig.states.size());
+        for (int32_t j = 0; j < stateResidencies.size(); j++) {
+            stateResidencies[j].id = j;
+        }
+        residencies->emplace(mConfig.entities[i].first, stateResidencies);
+    }
+
+    size_t len = 0;
+    char *line = nullptr;
+
+    int32_t temp, entityIndex, stateId = -1;
+    uint64_t duration, count;
+    auto it = residencies->end();
+
+    while (getline(&line, &len, fp.get()) != -1) {
+        temp = matchState(line);
+        // Assign new id only when a new valid state is encountered.
+        if (temp >= 0) {
+            stateId = temp;
+        }
+
+        if (stateId >= 0) {
+            entityIndex = matchEntity(line);
+            it = residencies->find(mConfig.entities[entityIndex].first);
+
+            if (it != residencies->end()) {
+                if (parseState(line, &duration, &count)) {
+                    it->second[stateId].totalTimeInStateMs = duration / US_TO_MS;
+                    it->second[stateId].totalStateEntryCount = count;
+                } else {
+                    LOG(ERROR) << "Failed to parse duration and count from [" << std::string(line)
+                               << "]";
+                    return false;
+                }
+            }
+        }
+    }
+
+    free(line);
+
+    return true;
+}
+
+std::unordered_map<std::string, std::vector<State>> CpupmStateResidencyDataProvider::getInfo() {
+    std::unordered_map<std::string, std::vector<State>> info;
+    for (auto const &entity : mConfig.entities) {
+        std::vector<State> stateInfo(mConfig.states.size());
+        int32_t stateId = 0;
+        for (auto const &state : mConfig.states) {
+            stateInfo[stateId] = State{
+                .id = stateId,
+                .name = state.first
+            };
+            stateId++;
+        }
+        info.emplace(entity.first, stateInfo);
+    }
+    return info;
+}
+
+}  // namespace stats
+}  // namespace power
+}  // namespace hardware
+}  // namespace android
+}  // namespace aidl
diff --git a/powerstats/include/CpupmStateResidencyDataProvider.h b/powerstats/include/CpupmStateResidencyDataProvider.h
new file mode 100644
index 0000000..c04e11e
--- /dev/null
+++ b/powerstats/include/CpupmStateResidencyDataProvider.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+#pragma once
+
+#include <PowerStatsAidl.h>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace power {
+namespace stats {
+
+class CpupmStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
+  public:
+    class Config {
+      public:
+        // List of power entity name pairs (name to display, name to parse)
+        std::vector<std::pair<std::string, std::string>> entities;
+
+        // List of state pairs (state to display, state to parse).
+        std::vector<std::pair<std::string, std::string>> states;
+    };
+
+    /*
+     * path - path to cpupm sysfs node.
+     */
+    CpupmStateResidencyDataProvider(const std::string &path, const Config &config);
+    ~CpupmStateResidencyDataProvider() = default;
+
+    /*
+     * See IStateResidencyDataProvider::getStateResidencies
+     */
+    bool getStateResidencies(
+        std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
+
+    /*
+     * See IStateResidencyDataProvider::getInfo
+     */
+    std::unordered_map<std::string, std::vector<State>> getInfo() override;
+
+  private:
+    int32_t matchEntity(char const *line);
+    int32_t matchState(char const *line);
+    bool parseState(char const *line, uint64_t *duration, uint64_t *count);
+
+    // A constant to represent the number of microseconds in one millisecond.
+    const uint64_t US_TO_MS = 1000;
+
+    const std::string mPath;
+    const Config mConfig;
+};
+
+}  // namespace stats
+}  // namespace power
+}  // namespace hardware
+}  // namespace android
+}  // namespace aidl
diff --git a/ramdump/Android.bp b/ramdump/Android.bp
new file mode 100644
index 0000000..928a677
--- /dev/null
+++ b/ramdump/Android.bp
@@ -0,0 +1,16 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+    name: "dump_ramdump",
+    srcs: ["dump_ramdump.cpp"],
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+    ],
+    shared_libs: ["libbase"],
+    vendor: true,
+    relative_install_path: "dump",
+}
diff --git a/ramdump/dump_ramdump.cpp b/ramdump/dump_ramdump.cpp
new file mode 100644
index 0000000..4be0c0c
--- /dev/null
+++ b/ramdump/dump_ramdump.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2022 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 <inttypes.h>
+#include <stdio.h>
+#include <string>
+#include <android-base/file.h>
+#include <android-base/stringprintf.h>
+
+struct abl_log_header {
+    uint64_t i;
+    uint64_t size;
+    char buf[];
+} __attribute__((packed));
+
+// Gzip binary data and dump in base64 format. Cmd to decode is also attached.
+void dumpGzippedFileInBase64(const char* title, const char* file_path) {
+    auto cmd = android::base::StringPrintf("gzip < %s | base64", file_path);
+    printf("------ %s, %s\n", title, cmd.c_str());
+    printf("base64 -d <<EOF | gunzip\n");
+    system(cmd.c_str());
+    printf("EOF\n");
+    return;
+}
+
+// Dump items related to ramdump.
+int main() {
+    setbuf(stdout, NULL);
+    std::string abl_log;
+    if (android::base::ReadFileToString("/mnt/vendor/ramdump/abl.log", &abl_log)) {
+        const struct abl_log_header *header = (const struct abl_log_header*) abl_log.c_str();
+        printf("------ Ramdump misc file: abl.log (i:0x%" PRIx64 " size:0x%" PRIx64 ") ------\n%s\n",
+               header->i, header->size, std::string(header->buf, header->i).c_str());
+    } else {
+        printf("*** Ramdump misc file: abl.log: File not found\n");
+    }
+
+    dumpGzippedFileInBase64("Ramdump misc file: acpm.lst (gzipped in base64)", "/mnt/vendor/ramdump/acpm.lst");
+    dumpGzippedFileInBase64("Ramdump misc file: s2d.lst (gzipped in base64)", "/mnt/vendor/ramdump/s2d.lst");
+    return 0;
+}
diff --git a/ramdump/ramdump.mk b/ramdump/ramdump.mk
new file mode 100644
index 0000000..5b34a67
--- /dev/null
+++ b/ramdump/ramdump.mk
@@ -0,0 +1,3 @@
+PRODUCT_PACKAGES_DEBUG += dump_ramdump
+
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/ramdump/sepolicy
diff --git a/ramdump/sepolicy/dump_ramdump.te b/ramdump/sepolicy/dump_ramdump.te
new file mode 100644
index 0000000..8bf6ccc
--- /dev/null
+++ b/ramdump/sepolicy/dump_ramdump.te
@@ -0,0 +1,10 @@
+pixel_bugreport(dump_ramdump)
+
+userdebug_or_eng(`
+  allow dump_ramdump mnt_vendor_file:dir search;
+  allow dump_ramdump vendor_shell_exec:file execute_no_trans;
+  allow dump_ramdump vendor_toolbox_exec:file execute_no_trans;
+
+  allow dump_ramdump ramdump_vendor_mnt_file:dir search;
+  allow dump_ramdump ramdump_vendor_mnt_file:file r_file_perms;
+')
diff --git a/ramdump/sepolicy/file_contexts b/ramdump/sepolicy/file_contexts
new file mode 100644
index 0000000..726f69d
--- /dev/null
+++ b/ramdump/sepolicy/file_contexts
@@ -0,0 +1,2 @@
+# dumpstate
+/vendor/bin/dump/dump_ramdump           u:object_r:dump_ramdump_exec:s0
diff --git a/sensors/Android.bp b/sensors/Android.bp
new file mode 100644
index 0000000..dec4991
--- /dev/null
+++ b/sensors/Android.bp
@@ -0,0 +1,20 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+    name: "dump_sensors",
+    srcs: ["dump_sensors.cpp"],
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+    ],
+    shared_libs: [
+    	"libbase",
+	"libdumpstateutil",
+	"libdump",
+    ],
+    vendor: true,
+    relative_install_path: "dump",
+}
diff --git a/sensors/dump_sensors.cpp b/sensors/dump_sensors.cpp
new file mode 100644
index 0000000..58d63e9
--- /dev/null
+++ b/sensors/dump_sensors.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2022 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 <stdio.h>
+#include <string>
+#include <android-base/properties.h>
+#include <dump/pixel_dump.h>
+#include "DumpstateUtil.h"
+
+int main() {
+    setbuf(stdout, NULL);
+
+    runCommand("USF statistics", "/vendor/bin/usf_stats get --all");
+    if (!::android::os::dumpstate::PropertiesHelper::IsUserBuild()) {
+        // Not a user build, if this is also not a production device dump the USF registry.
+        std::string hwRev = ::android::base::GetProperty("ro.boot.hardware.revision", "");
+        if (hwRev.find("PROTO") != std::string::npos ||
+            hwRev.find("EVT") != std::string::npos ||
+            hwRev.find("DVT") != std::string::npos ||
+            hwRev.find("PVT") != std::string::npos) {
+            runCommand("USF Registry", "/vendor/bin/usf_reg_edit save -");
+            dumpFileContent("USF Last Stat Buffer", "/data/vendor/sensors/debug/stats.history");
+        }
+    }
+    return 0;
+}
diff --git a/sensors/sensors.mk b/sensors/sensors.mk
new file mode 100644
index 0000000..54ee2f8
--- /dev/null
+++ b/sensors/sensors.mk
@@ -0,0 +1,5 @@
+$(call inherit-product-if-exists, vendor/google/sensors/usf/android/usf_efw_product.mk)
+
+PRODUCT_PACKAGES += dump_sensors
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/sensors/sepolicy
+
diff --git a/sensors/sepolicy/dump_sensors.te b/sensors/sepolicy/dump_sensors.te
new file mode 100644
index 0000000..7d37a63
--- /dev/null
+++ b/sensors/sepolicy/dump_sensors.te
@@ -0,0 +1,11 @@
+pixel_bugreport(dump_sensors)
+allow dump_sensors aoc_device:chr_file rw_file_perms;
+allow dump_sensors device:dir r_dir_perms;
+allow dump_sensors vendor_shell_exec:file execute_no_trans;
+allow dump_sensors vendor_usf_stats:file execute_no_trans;
+
+userdebug_or_eng(`
+  allow dump_sensors vendor_usf_reg_edit:file execute_no_trans;
+  allow dump_sensors sensor_debug_data_file:dir r_dir_perms;
+  allow dump_sensors sensor_debug_data_file:file r_file_perms;
+')
diff --git a/sensors/sepolicy/file.te b/sensors/sepolicy/file.te
new file mode 100644
index 0000000..97084b6
--- /dev/null
+++ b/sensors/sepolicy/file.te
@@ -0,0 +1,2 @@
+type vendor_usf_stats, vendor_file_type, file_type;
+type vendor_usf_reg_edit, vendor_file_type, file_type;
diff --git a/sensors/sepolicy/file_contexts b/sensors/sepolicy/file_contexts
new file mode 100644
index 0000000..0fbbdf2
--- /dev/null
+++ b/sensors/sepolicy/file_contexts
@@ -0,0 +1,3 @@
+/vendor/bin/dump/dump_sensors      u:object_r:dump_sensors_exec:s0
+/vendor/bin/usf_stats              u:object_r:vendor_usf_stats:s0
+/vendor/bin/usf_reg_edit           u:object_r:vendor_usf_reg_edit:s0
diff --git a/soc/Android.bp b/soc/Android.bp
new file mode 100644
index 0000000..9600855
--- /dev/null
+++ b/soc/Android.bp
@@ -0,0 +1,20 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+    name: "dump_soc",
+    srcs: ["dump_soc.cpp"],
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+    ],
+    shared_libs: [
+        "libbase",
+	"libdump",
+	"liblog",
+    ],
+    vendor: true,
+    relative_install_path: "dump",
+}
diff --git a/soc/dump_soc.cpp b/soc/dump_soc.cpp
new file mode 100644
index 0000000..4c34349
--- /dev/null
+++ b/soc/dump_soc.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2022 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 <dump/pixel_dump.h>
+#include <android-base/file.h>
+#include <string.h>
+#include <stdio.h>
+#include <log/log.h>
+#include <regex>
+
+std::string readFile(const std::string& file_path) {
+    std::string content;
+    if(android::base::ReadFileToString(file_path.c_str(), &content)) {
+        return std::regex_replace(content, std::regex("\\r\\n|\\r|\\n"),"");
+    }
+    return content;
+}
+
+// Dump chip ID.
+int main() {
+    dumpFileContent("AP HW TUNE", "/sys/devices/system/chip-id/ap_hw_tune_str");
+    dumpFileContent("EVT VERSION", "/sys/devices/system/chip-id/evt_ver");
+    dumpFileContent("LOT ID", "/sys/devices/system/chip-id/lot_id");
+    dumpFileContent("PRODUCT ID", "/sys/devices/system/chip-id/product_id");
+    dumpFileContent("REVISION", "/sys/devices/system/chip-id/revision");
+    dumpFileContent("RAW STR", "/sys/devices/system/chip-id/raw_str");
+    dumpFileContent("CPU present", "/sys/devices/system/cpu/present");
+    dumpFileContent("CPU online", "/sys/devices/system/cpu/online");
+
+    printf("------ CPU time-in-state ------\n");
+    std::string states;
+    std::unique_ptr<DIR, decltype(&closedir)> cpudir(opendir("/sys/devices/system/cpu/"), closedir);
+    if (!cpudir) {
+        ALOGE("Fail To Open Dir /sys/devices/system/cpu/");
+        return 0;
+    }
+    dirent *entry;
+    while ((entry = readdir(cpudir.get())) != nullptr) {
+        std::string core(entry->d_name);
+        if (core.find("cpu") != std::string::npos) {
+            std::string path("/sys/devices/system/cpu/" + core + "/cpufreq/stats/time_in_state");
+            if(!access(path.c_str(), R_OK)){
+                dumpFileContent(path.c_str(), path.c_str());
+            }
+        }
+        std::string cpu_idle_path("/sys/devices/system/cpu/" + core + "/cpuidle");
+        std::unique_ptr<DIR, decltype(&closedir)> statedir(opendir(cpu_idle_path.c_str()), closedir);
+        if (!statedir) {
+            continue;
+        }
+        dirent *state_entry;
+        while ((state_entry = readdir(statedir.get())) != nullptr) {
+            std::string cpu_idle_state_path(state_entry->d_name);
+            std::string full_state_path;
+            full_state_path += cpu_idle_path;
+            full_state_path += "/";
+            full_state_path += cpu_idle_state_path;
+            if (cpu_idle_state_path.find("state") != std::string::npos) {
+                std::string name(full_state_path + "/name");
+                std::string desc(full_state_path + "/desc");
+                std::string time(full_state_path + "/time");
+                std::string usage(full_state_path + "/usage");
+                states += full_state_path+": "+readFile(name)+" "+readFile(desc)+" "+readFile(time)+" "+readFile(usage)+"\n";
+            }
+        }
+    }
+    printf("------ CPU cpuidle ------\n%s\n", states.c_str());
+
+    dumpFileContent("INTERRUPTS", "/proc/interrupts");
+    return 0;
+}
diff --git a/soc/sepolicy/dump_soc.te b/soc/sepolicy/dump_soc.te
new file mode 100644
index 0000000..b103de4
--- /dev/null
+++ b/soc/sepolicy/dump_soc.te
@@ -0,0 +1,2 @@
+pixel_bugreport(dump_soc)
+allow dump_soc sysfs_chip_id:file r_file_perms;
diff --git a/soc/sepolicy/file_contexts b/soc/sepolicy/file_contexts
new file mode 100644
index 0000000..81b1e68
--- /dev/null
+++ b/soc/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/dump/dump_soc      u:object_r:dump_soc_exec:s0
diff --git a/soc/sepolicy/genfs_contexts b/soc/sepolicy/genfs_contexts
new file mode 100644
index 0000000..07ae4b8
--- /dev/null
+++ b/soc/sepolicy/genfs_contexts
@@ -0,0 +1,7 @@
+genfscon sysfs /devices/system/chip-id/ap_hw_tune_str  u:object_r:sysfs_chip_id:s0
+genfscon sysfs /devices/system/chip-id/evt_ver         u:object_r:sysfs_chip_id:s0
+genfscon sysfs /devices/system/chip-id/lot_id          u:object_r:sysfs_chip_id:s0
+genfscon sysfs /devices/system/chip-id/product_id      u:object_r:sysfs_chip_id:s0
+genfscon sysfs /devices/system/chip-id/revision        u:object_r:sysfs_chip_id:s0
+genfscon sysfs /devices/system/chip-id/raw_str         u:object_r:sysfs_chip_id:s0
+
diff --git a/soc/soc.mk b/soc/soc.mk
new file mode 100644
index 0000000..75b134e
--- /dev/null
+++ b/soc/soc.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/soc/sepolicy
+
+PRODUCT_PACKAGES += dump_soc
diff --git a/storage/Android.bp b/storage/Android.bp
new file mode 100644
index 0000000..54e097e
--- /dev/null
+++ b/storage/Android.bp
@@ -0,0 +1,10 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_storage.sh",
+    src: "dump_storage.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/storage/dump_storage.sh b/storage/dump_storage.sh
new file mode 100644
index 0000000..5f08fc1
--- /dev/null
+++ b/storage/dump_storage.sh
@@ -0,0 +1,68 @@
+#!/vendor/bin/sh
+# F2FS
+echo "--- F2FS status---"
+cat "/sys/kernel/debug/f2fs/status"
+echo "\n--- F2FS fsck ---"
+cat "/dev/fscklogs/fsck"
+echo "\n--- F2FS - fsck time (ms) ---"
+getprop ro.boottime.init.fsck.data
+echo "\n--- F2FS - checkpoint=disable time (ms) ---"
+getprop ro.boottime.init.mount.data
+
+# UFS
+echo "\n------ UFS model (/sys/block/sda/device/model) ------"
+cat "/sys/block/sda/device/model"
+echo "\n------ UFS rev (/sys/block/sda/device/rev) ------"
+cat "/sys/block/sda/device/rev"
+echo "\n------ UFS size (/sys/block/sda/size) ------"
+cat "/sys/block/sda/size"
+
+echo "\n------ UFS Slow IO Read (/dev/sys/block/bootdevice/slowio_read_cnt) ------"
+cat "/dev/sys/block/bootdevice/slowio_read_cnt"
+echo "\n------ UFS Slow IO Write (/dev/sys/block/bootdevice/slowio_write_cnt) ------"
+cat "/dev/sys/block/bootdevice/slowio_write_cnt"
+echo "\n------ UFS Slow IO Unmap (/dev/sys/block/bootdevice/slowio_unmap_cnt) ------"
+cat "/dev/sys/block/bootdevice/slowio_unmap_cnt"
+echo "\n------ UFS Slow IO Sync (/dev/sys/block/bootdevice/slowio_sync_cnt) ------"
+cat "/dev/sys/block/bootdevice/slowio_sync_cnt"
+
+echo "\n------ UFS err_stats ------"
+path="/dev/sys/block/bootdevice/err_stats";
+for node in `ls $path/* | grep -v reset_err_status`
+do
+  printf "%s:%d\n" $(basename $node) $(cat $node)
+done
+
+
+echo "\n------ UFS io_stats ------"
+path="/dev/sys/block/bootdevice/io_stats"
+printf "\t\t%-12s %-12s %-12s %-12s %-12s %-12s\n" ReadCnt ReadBytes WriteCnt WriteBytes RWCnt RWBytes
+str=$(cat $path/*_start); arr=($str);
+printf "Started: \t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[1]} ${arr[0]} ${arr[5]} ${arr[4]} ${arr[3]} ${arr[2]}
+str=$(cat $path/*_complete); arr=($str);
+printf "Completed: \t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[1]} ${arr[0]} ${arr[5]} ${arr[4]} ${arr[3]} ${arr[2]}
+str=$(cat $path/*_maxdiff); arr=($str);
+printf "MaxDiff: \t%-12s %-12s %-12s %-12s %-12s %-12s\n\n" ${arr[1]} ${arr[0]} ${arr[5]} ${arr[4]} ${arr[3]} ${arr[2]}
+
+echo "\n------ UFS req_stats ------"
+path="/dev/sys/block/bootdevice/req_stats"
+printf "\t%-12s %-12s %-12s %-12s %-12s %-12s\n" All Write Read Security Flush Discard
+str=$(cat $path/*_min); arr=($str);
+printf "Min:\t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[0]} ${arr[5]} ${arr[3]} ${arr[4]} ${arr[2]} ${arr[1]}
+str=$(cat $path/*_max); arr=($str);
+printf "Max:\t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[0]} ${arr[5]} ${arr[3]} ${arr[4]} ${arr[2]} ${arr[1]}
+str=$(cat $path/*_avg); arr=($str);
+printf "Avg.:\t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[0]} ${arr[5]} ${arr[3]} ${arr[4]} ${arr[2]} ${arr[1]}
+str=$(cat $path/*_sum); arr=($str);
+printf "Count:\t%-12s %-12s %-12s %-12s %-12s %-12s\n\n" ${arr[0]} ${arr[5]} ${arr[3]} ${arr[4]} ${arr[2]} ${arr[1]}
+
+echo "\n------ UFS health ------"
+for f in $(find /dev/sys/block/bootdevice/health_descriptor -type f)
+do
+  if [[ -r $f && -f $f ]]; then
+    echo --- $f
+    cat $f
+    echo ''
+  fi
+done
+
diff --git a/storage/sepolicy/dump_storage.te b/storage/sepolicy/dump_storage.te
new file mode 100644
index 0000000..9411f8e
--- /dev/null
+++ b/storage/sepolicy/dump_storage.te
@@ -0,0 +1,15 @@
+pixel_bugreport(dump_storage)
+
+allow dump_storage vendor_toolbox_exec:file execute_no_trans;
+allow dump_storage sysfs_scsi_devices_0000:dir r_dir_perms;
+allow dump_storage sysfs_scsi_devices_0000:file r_file_perms;
+
+userdebug_or_eng(`
+  allow dump_storage debugfs_f2fs:dir r_dir_perms;
+  allow dump_storage debugfs_f2fs:file r_file_perms;
+')
+
+get_prop(dump_storage, boottime_public_prop)
+
+dontaudit dump_storage debugfs_f2fs:dir r_dir_perms;
+dontaudit dump_storage debugfs_f2fs:file r_file_perms;
diff --git a/storage/sepolicy/file.te b/storage/sepolicy/file.te
new file mode 100644
index 0000000..64b6b4e
--- /dev/null
+++ b/storage/sepolicy/file.te
@@ -0,0 +1 @@
+type debugfs_f2fs, debugfs_type, fs_type;
diff --git a/storage/sepolicy/file_contexts b/storage/sepolicy/file_contexts
new file mode 100644
index 0000000..eda4cf7
--- /dev/null
+++ b/storage/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/dump/dump_storage\.sh      u:object_r:dump_storage_exec:s0
diff --git a/storage/sepolicy/genfs_contexts b/storage/sepolicy/genfs_contexts
new file mode 100644
index 0000000..1a27ec4
--- /dev/null
+++ b/storage/sepolicy/genfs_contexts
@@ -0,0 +1 @@
+genfscon debugfs /f2fs     u:object_r:debugfs_f2fs:s0
diff --git a/storage/storage.mk b/storage/storage.mk
new file mode 100644
index 0000000..5542ac8
--- /dev/null
+++ b/storage/storage.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/storage/sepolicy
+
+PRODUCT_PACKAGES += dump_storage.sh
diff --git a/thermal/Android.bp b/thermal/Android.bp
new file mode 100644
index 0000000..70fef5c
--- /dev/null
+++ b/thermal/Android.bp
@@ -0,0 +1,10 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_thermal.sh",
+    src: "dump_thermal.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/thermal/dump_thermal.sh b/thermal/dump_thermal.sh
new file mode 100644
index 0000000..2b87da9
--- /dev/null
+++ b/thermal/dump_thermal.sh
@@ -0,0 +1,46 @@
+#!/vendor/bin/sh
+
+echo "Temperatures"
+for f in /sys/class/thermal/thermal* ; do
+  printf "%s: %s\n" `cat $f/type` `cat $f/temp`
+done
+
+echo "Cooling Device Current State"
+for f in /sys/class/thermal/cooling* ; do
+  printf "%s: %s\n" `cat $f/type` `cat $f/cur_state`
+done
+
+echo "Cooling Device User Vote State"
+for f in /sys/class/thermal/cooling* ; do
+  if [ ! -f $f/user_vote ]; then continue; fi;
+  printf "%s: %s\n" `cat $f/type` `cat $f/user_vote`
+done
+
+echo "Cooling Device Time in State"
+for f in /sys/class/thermal/cooling* ; do
+  printf "%s: %s\n" `cat $f/type` `cat $f/stats/time_in_state_ms`
+done
+
+echo "Cooling Device Trans Table"
+for f in /sys/class/thermal/cooling* ; do
+  printf "%s: %s\n" `cat $f/type` `cat $f/stats/trans_table`
+done
+
+echo "Cooling Device State2Power Table"
+for f in /sys/class/thermal/cooling* ; do
+  if [ ! -f $f/state2power_table ]; then continue; fi;
+  printf "%s: %s\n" `cat $f/type` `cat $f/state2power_table`
+done
+
+echo "TMU state:"
+cat /sys/module/gs_thermal/parameters/tmu_reg_dump_state
+echo "TMU current temperature:"
+cat /sys/module/gs_thermal/parameters/tmu_reg_dump_current_temp
+echo "TMU_TOP rise thresholds:"
+cat /sys/module/gs_thermal/parameters/tmu_top_reg_dump_rise_thres
+echo "TMU_TOP fall thresholds:"
+cat /sys/module/gs_thermal/parameters/tmu_top_reg_dump_fall_thres
+echo "TMU_SUB rise thresholds:"
+cat /sys/module/gs_thermal/parameters/tmu_sub_reg_dump_rise_thres
+echo "TMU_SUB fall thresholds:"
+cat /sys/module/gs_thermal/parameters/tmu_sub_reg_dump_fall_thres
diff --git a/thermal/sepolicy/dump_thermal.te b/thermal/sepolicy/dump_thermal.te
new file mode 100644
index 0000000..c36f7cd
--- /dev/null
+++ b/thermal/sepolicy/dump_thermal.te
@@ -0,0 +1,7 @@
+pixel_bugreport(dump_thermal)
+
+allow dump_thermal sysfs_thermal:dir r_dir_perms;
+allow dump_thermal sysfs_thermal:file r_file_perms;
+allow dump_thermal sysfs_thermal:lnk_file r_file_perms;
+allow dump_thermal vendor_toolbox_exec:file execute_no_trans;
+
diff --git a/thermal/sepolicy/file_contexts b/thermal/sepolicy/file_contexts
new file mode 100644
index 0000000..461a07b
--- /dev/null
+++ b/thermal/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/dump/dump_thermal\.sh      u:object_r:dump_thermal_exec:s0
diff --git a/thermal/sepolicy/genfs_contexts b/thermal/sepolicy/genfs_contexts
new file mode 100644
index 0000000..1422e63
--- /dev/null
+++ b/thermal/sepolicy/genfs_contexts
@@ -0,0 +1,3 @@
+# thermal sysfs files
+genfscon sysfs /module/gs_thermal/parameters            u:object_r:sysfs_thermal:s0
+
diff --git a/thermal/thermal.mk b/thermal/thermal.mk
new file mode 100644
index 0000000..3b3dede
--- /dev/null
+++ b/thermal/thermal.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/thermal/sepolicy
+
+PRODUCT_PACKAGES += dump_thermal.sh
diff --git a/touch/focaltech/Android.bp b/touch/focaltech/Android.bp
new file mode 100644
index 0000000..ebaa308
--- /dev/null
+++ b/touch/focaltech/Android.bp
@@ -0,0 +1,11 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_focaltech.sh",
+    src: "dump_focaltech.sh",
+    init_rc: ["init.touch.rc"],
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/touch/focaltech/dump_focaltech.sh b/touch/focaltech/dump_focaltech.sh
new file mode 100644
index 0000000..82bd2cd
--- /dev/null
+++ b/touch/focaltech/dump_focaltech.sh
@@ -0,0 +1,42 @@
+#!/vendor/bin/sh
+path="/proc/focaltech_touch"
+
+echo "------ Enable Force Touch Active ------"
+echo 21 > $path/force_active
+
+echo "------ Touch Firmware Version ------"
+cat $path/FW_Version
+
+echo "------ Touch INT PIN Test ------"
+cat $path/INT_PIN
+
+echo "------ Get Raw Data - Panel_Differ ------"
+cat $path/selftest/Panel_Differ
+
+echo "------ Get Raw Data - Raw ------"
+cat $path/selftest/Rawdata
+
+echo "------ Get Raw Data - Baseline ------"
+cat $path/selftest/Baseline
+
+echo "------ Get Raw Data - Noise ------"
+cat $path/selftest/Noise
+
+echo "------ Get Raw Data - Uniformity ------"
+cat $path/selftest/Rawdata_Uniformity
+
+echo "------ Get Scap_CB ------"
+cat $path/selftest/Scap_CB
+
+echo "------ Get Scap_Rawdata ------"
+cat $path/selftest/Scap_Rawdata
+
+echo "------ Get Short Test ------"
+cat $path/selftest/Short
+
+echo "------ Get HeatMap(ms,ss) ------"
+cat $path/selftest/Strength
+
+echo "------ Disable Force Touch Active ------"
+echo 20 > $path/force_active
+
diff --git a/touch/focaltech/focaltech.mk b/touch/focaltech/focaltech.mk
new file mode 100644
index 0000000..5236586
--- /dev/null
+++ b/touch/focaltech/focaltech.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/focaltech/sepolicy
+
+PRODUCT_PACKAGES += dump_focaltech.sh
diff --git a/touch/focaltech/init.touch.rc b/touch/focaltech/init.touch.rc
new file mode 100644
index 0000000..b517d9e
--- /dev/null
+++ b/touch/focaltech/init.touch.rc
@@ -0,0 +1,28 @@
+on property:vendor.device.modules.ready=1
+    chown system system /proc/focaltech_touch/Channel_Num
+    chown system system /proc/focaltech_touch/FW_Version
+    chown system system /proc/focaltech_touch/INT_PIN
+    chown system system /proc/focaltech_touch/force_active
+    chown system system /proc/focaltech_touch/Reset_Pin
+    chown system system /proc/focaltech_touch/fw_grip
+    chown system system /proc/focaltech_touch/fw_palm
+    chown system system /proc/focaltech_touch/heatmap_onoff
+    chown system system /proc/focaltech_touch/mf_mode
+    chown system system /proc/focaltech_touch/selftest/Baseline
+    chown system system /proc/focaltech_touch/selftest/Noise
+    chown system system /proc/focaltech_touch/selftest/Panel_Differ
+    chown system system /proc/focaltech_touch/selftest/Rawdata
+    chown system system /proc/focaltech_touch/selftest/Rawdata_Uniformity
+    chown system system /proc/focaltech_touch/selftest/Scap_CB
+    chown system system /proc/focaltech_touch/selftest/Scap_Rawdata
+    chown system system /proc/focaltech_touch/selftest/Short
+    chown system system /proc/focaltech_touch/selftest/Strength
+
+# Toggle glove_mode according to touch_sensitivity_mode
+on property:persist.vendor.touch_sensitivity_mode=0 && property:sys.boot_completed=1
+    write /proc/focaltech_touch/high_sensitivity 0
+
+on property:persist.vendor.touch_sensitivity_mode=1 && property:sys.boot_completed=1
+    write /proc/focaltech_touch/high_sensitivity 1
+
+
diff --git a/touch/focaltech/sepolicy/dump_focaltech.te b/touch/focaltech/sepolicy/dump_focaltech.te
new file mode 100644
index 0000000..0b0fb9a
--- /dev/null
+++ b/touch/focaltech/sepolicy/dump_focaltech.te
@@ -0,0 +1,5 @@
+pixel_bugreport(dump_focaltech)
+
+allow dump_focaltech proc_touch:dir r_dir_perms;
+allow dump_focaltech proc_touch:file rw_file_perms;
+allow dump_focaltech vendor_toolbox_exec:file execute_no_trans;
diff --git a/touch/focaltech/sepolicy/file.te b/touch/focaltech/sepolicy/file.te
new file mode 100644
index 0000000..c9a0c1f
--- /dev/null
+++ b/touch/focaltech/sepolicy/file.te
@@ -0,0 +1,3 @@
+type proc_touch, proc_type, fs_type;
+type sysfs_touch, sysfs_type, fs_type;
+
diff --git a/touch/focaltech/sepolicy/file_contexts b/touch/focaltech/sepolicy/file_contexts
new file mode 100644
index 0000000..250aaf9
--- /dev/null
+++ b/touch/focaltech/sepolicy/file_contexts
@@ -0,0 +1,2 @@
+/vendor/bin/dump/dump_focaltech\.sh      u:object_r:dump_focaltech_exec:s0
+
diff --git a/touch/focaltech/sepolicy/genfs_contexts b/touch/focaltech/sepolicy/genfs_contexts
new file mode 100644
index 0000000..2ac9314
--- /dev/null
+++ b/touch/focaltech/sepolicy/genfs_contexts
@@ -0,0 +1,3 @@
+genfscon proc  /focaltech_touch                                                u:object_r:proc_touch:s0
+
+
diff --git a/touch/focaltech/sepolicy/vendor_init.te b/touch/focaltech/sepolicy/vendor_init.te
new file mode 100644
index 0000000..117288e
--- /dev/null
+++ b/touch/focaltech/sepolicy/vendor_init.te
@@ -0,0 +1,2 @@
+allow vendor_init proc_touch:file w_file_perms;
+
diff --git a/touch/gti/Android.bp b/touch/gti/Android.bp
new file mode 100644
index 0000000..d21314a
--- /dev/null
+++ b/touch/gti/Android.bp
@@ -0,0 +1,11 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_gti.sh",
+    src: "dump_gti.sh",
+    init_rc: ["init.touch.gti.rc"],
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/touch/gti/dump_gti.sh b/touch/gti/dump_gti.sh
new file mode 100644
index 0000000..a7d3a61
--- /dev/null
+++ b/touch/gti/dump_gti.sh
@@ -0,0 +1,39 @@
+#!/vendor/bin/sh
+path="/sys/devices/virtual/goog_touch_interface/gti.0"
+procfs_path="/proc/goog_touch_interface/gti.0"
+
+if [[ -d "$procfs_path" ]]; then
+heatmap_path=$procfs_path
+else
+heatmap_path=$path
+fi
+
+echo "------ Force Touch Active ------"
+echo 1 > $path/force_active
+
+echo "------ Touch Firmware Version ------"
+cat $path/fw_ver
+
+echo "------ Get Mutual Sensing Data - Baseline ------"
+cat $heatmap_path/ms_base
+
+echo "------ Get Mutual Sensing Data - Delta ------"
+cat $heatmap_path/ms_diff
+
+echo "------ Get Mutual Sensing Data - Raw ------"
+cat $heatmap_path/ms_raw
+
+echo "------ Get Self Sensing Data - Baseline ------"
+cat $heatmap_path/ss_base
+
+echo "------ Get Self Sensing Data - Delta ------"
+cat $heatmap_path/ss_diff
+
+echo "------ Get Self Sensing Data - Raw ------"
+cat $heatmap_path/ss_raw
+
+echo "------ Self Test ------"
+cat $path/self_test
+
+echo "------ Disable Force Touch Active ------"
+echo 0 > $path/force_active
diff --git a/touch/gti/gti.mk b/touch/gti/gti.mk
new file mode 100644
index 0000000..e2e42bd
--- /dev/null
+++ b/touch/gti/gti.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/gti/sepolicy
+
+PRODUCT_PACKAGES += dump_gti.sh
diff --git a/touch/gti/init.touch.gti.rc b/touch/gti/init.touch.gti.rc
new file mode 100644
index 0000000..d714a97
--- /dev/null
+++ b/touch/gti/init.touch.gti.rc
@@ -0,0 +1,9 @@
+on property:vendor.device.modules.ready=1
+    chown system system /proc/goog_touch_interface
+    chown system system /proc/goog_touch_interface/gti.0
+    chown system system /proc/goog_touch_interface/gti.0/ms_base
+    chown system system /proc/goog_touch_interface/gti.0/ms_diff
+    chown system system /proc/goog_touch_interface/gti.0/ms_raw
+    chown system system /proc/goog_touch_interface/gti.0/ss_base
+    chown system system /proc/goog_touch_interface/gti.0/ss_diff
+    chown system system /proc/goog_touch_interface/gti.0/ss_raw
diff --git a/touch/gti/sepolicy/dump_gti.te b/touch/gti/sepolicy/dump_gti.te
new file mode 100644
index 0000000..060fc29
--- /dev/null
+++ b/touch/gti/sepolicy/dump_gti.te
@@ -0,0 +1,8 @@
+pixel_bugreport(dump_gti)
+
+allow dump_gti proc_touch_gti:dir r_dir_perms;
+allow dump_gti proc_touch_gti:file rw_file_perms;
+allow dump_gti sysfs_touch_gti:dir r_dir_perms;
+allow dump_gti sysfs_touch_gti:file rw_file_perms;
+allow dump_gti vendor_toolbox_exec:file execute_no_trans;
+
diff --git a/touch/gti/sepolicy/file.te b/touch/gti/sepolicy/file.te
new file mode 100644
index 0000000..c3900f0
--- /dev/null
+++ b/touch/gti/sepolicy/file.te
@@ -0,0 +1,3 @@
+type proc_touch_gti, proc_type, fs_type;
+type sysfs_touch_gti, sysfs_type, fs_type;
+
diff --git a/touch/gti/sepolicy/file_contexts b/touch/gti/sepolicy/file_contexts
new file mode 100644
index 0000000..cbddadf
--- /dev/null
+++ b/touch/gti/sepolicy/file_contexts
@@ -0,0 +1,2 @@
+/vendor/bin/dump/dump_gti\.sh      u:object_r:dump_gti_exec:s0
+
diff --git a/touch/gti/sepolicy/genfs_contexts b/touch/gti/sepolicy/genfs_contexts
new file mode 100644
index 0000000..45d3b53
--- /dev/null
+++ b/touch/gti/sepolicy/genfs_contexts
@@ -0,0 +1,4 @@
+# Touch
+genfscon sysfs /devices/virtual/goog_touch_interface                            u:object_r:sysfs_touch_gti:s0
+genfscon proc  /goog_touch_interface                                            u:object_r:proc_touch_gti:s0
+
diff --git a/touch/lsi/Android.bp b/touch/lsi/Android.bp
new file mode 100644
index 0000000..b0cef6f
--- /dev/null
+++ b/touch/lsi/Android.bp
@@ -0,0 +1,10 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_lsi.sh",
+    src: "dump_lsi.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/touch/lsi/dump_lsi.sh b/touch/lsi/dump_lsi.sh
new file mode 100644
index 0000000..57c7f4d
--- /dev/null
+++ b/touch/lsi/dump_lsi.sh
@@ -0,0 +1,48 @@
+#!/vendor/bin/sh
+path="/sys/devices/virtual/sec/tsp"
+
+echo "--- Force Touch Active ---"
+echo "force_touch_active,2,1" > $path/cmd && cat $path/cmd_result
+
+echo "--- LSI firmware version ---"
+cat $path/fw_version
+
+echo "--- LSI touch status ---"
+cat $path/status
+
+echo "--- Calibration info ---"
+echo "get_mis_cal_info" > $path/cmd && cat $path/cmd_result
+
+echo "--- Mutual Strength ---"
+echo "run_delta_read_all" > $path/cmd && cat $path/cmd_result
+
+echo "--- Self Strength ---"
+echo "run_self_delta_read_all" > $path/cmd && cat $path/cmd_result
+
+echo "--- TYPE_AMBIENT_DATA ---"
+echo "run_rawdata_read_type,3" > $path/cmd && cat $path/cmd_result
+
+echo "--- TYPE_DECODED_DATA ---"
+echo "run_rawdata_read_type,5" > $path/cmd && cat $path/cmd_result
+
+echo "--- TYPE_OFFSET_DATA_SEC ---"
+echo "run_rawdata_read_type,19" > $path/cmd && cat $path/cmd_result
+
+echo "--- TYPE_NOI_P2P_MIN ---"
+echo "run_rawdata_read_type,30" > $path/cmd && cat $path/cmd_result
+
+echo "--- TYPE_NOI_P2P_MAX ---"
+echo "run_rawdata_read_type,31" > $path/cmd && cat $path/cmd_result
+
+echo "--- Mutual Raw Cap ---"
+echo "run_rawcap_read_all" > $path/cmd && cat $path/cmd_result
+
+echo "--- Self Raw Cap ---"
+echo "run_self_rawcap_read_all" > $path/cmd && cat $path/cmd_result
+
+echo "--- CM2 ---"
+echo "run_rawcap_high_freq_read_all" > $path/cmd && cat $path/cmd_result
+
+echo "--- Force Touch Active ---"
+echo force_touch_active,2,0 > $path/cmd && cat $path/cmd_result
+
diff --git a/touch/lsi/lsi.mk b/touch/lsi/lsi.mk
new file mode 100644
index 0000000..bcb69bb
--- /dev/null
+++ b/touch/lsi/lsi.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/lsi/sepolicy
+
+PRODUCT_PACKAGES += dump_lsi.sh
diff --git a/touch/lsi/sepolicy/dump_lsi.te b/touch/lsi/sepolicy/dump_lsi.te
new file mode 100644
index 0000000..a2e114d
--- /dev/null
+++ b/touch/lsi/sepolicy/dump_lsi.te
@@ -0,0 +1,5 @@
+pixel_bugreport(dump_lsi)
+
+allow dump_lsi sysfs_touch:dir r_dir_perms;
+allow dump_lsi sysfs_touch:file rw_file_perms;
+allow dump_lsi vendor_toolbox_exec:file execute_no_trans;
diff --git a/touch/lsi/sepolicy/file.te b/touch/lsi/sepolicy/file.te
new file mode 100644
index 0000000..3e53ec3
--- /dev/null
+++ b/touch/lsi/sepolicy/file.te
@@ -0,0 +1,2 @@
+type sysfs_touch, sysfs_type, fs_type;
+
diff --git a/touch/lsi/sepolicy/file_contexts b/touch/lsi/sepolicy/file_contexts
new file mode 100644
index 0000000..c1048fa
--- /dev/null
+++ b/touch/lsi/sepolicy/file_contexts
@@ -0,0 +1,2 @@
+/vendor/bin/dump/dump_lsi\.sh      u:object_r:dump_lsi_exec:s0
+
diff --git a/touch/lsi/sepolicy/genfs_contexts b/touch/lsi/sepolicy/genfs_contexts
new file mode 100644
index 0000000..6dce360
--- /dev/null
+++ b/touch/lsi/sepolicy/genfs_contexts
@@ -0,0 +1,2 @@
+genfscon sysfs /devices/virtual/sec/tsp        u:object_r:sysfs_touch:s0
+
diff --git a/touch/nvt/nvt.mk b/touch/nvt/nvt.mk
new file mode 100644
index 0000000..9655a75
--- /dev/null
+++ b/touch/nvt/nvt.mk
@@ -0,0 +1 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/nvt/sepolicy
diff --git a/touch/nvt/sepolicy/file.te b/touch/nvt/sepolicy/file.te
new file mode 100644
index 0000000..e310df7
--- /dev/null
+++ b/touch/nvt/sepolicy/file.te
@@ -0,0 +1 @@
+type sysfs_touch, sysfs_type, fs_type;
diff --git a/touch/nvt/sepolicy/system_server.te b/touch/nvt/sepolicy/system_server.te
new file mode 100644
index 0000000..d65d811
--- /dev/null
+++ b/touch/nvt/sepolicy/system_server.te
@@ -0,0 +1,2 @@
+allow system_server sysfs_touch:dir r_dir_perms;
+allow system_server sysfs_touch:file r_file_perms;
diff --git a/touch/stm/Android.bp b/touch/stm/Android.bp
new file mode 100644
index 0000000..1727f07
--- /dev/null
+++ b/touch/stm/Android.bp
@@ -0,0 +1,10 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_stm.sh",
+    src: "dump_stm.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/touch/stm/dump_stm.sh b/touch/stm/dump_stm.sh
new file mode 100644
index 0000000..8ef533d
--- /dev/null
+++ b/touch/stm/dump_stm.sh
@@ -0,0 +1,67 @@
+#!/vendor/bin/sh
+spi=`getprop ro.vendor.touch.dump.sys`
+proc=`getprop ro.vendor.touch.dump.proc`
+
+echo "------ Force Set AP as Bus Owner with Bugreport Flag ------"
+echo A0 01 01 > $proc
+
+echo "------ STM touch firmware version ------"
+cat $spi/appid
+
+echo "------ STM touch status ------"
+cat $spi/status
+
+echo "------ Mutual Raw ------"
+echo 13 00 01 > $spi/stm_fts_cmd && cat $spi/stm_fts_cmd
+
+echo "------ Mutual Strength ------"
+echo 17 01 > $spi/stm_fts_cmd && cat $spi/stm_fts_cmd
+
+echo "------ Self Raw ------"
+echo 15 00 01 > $spi/stm_fts_cmd && cat $spi/stm_fts_cmd
+
+echo "------ Mutual Raw Data ------"
+echo 23 00 > $proc && cat $proc
+
+echo "------ Mutual Baseline Data ------"
+echo 23 03 > $proc && cat $proc
+
+echo "------ Mutual Strength Data ------"
+echo 23 02 > $proc && cat $proc
+
+echo "------ Self Raw Data ------"
+echo 24 00 > $proc && cat $proc
+
+echo "------ Self Baseline Data ------"
+echo 24 03 > $proc && cat $proc
+
+echo "------ Self Strength Data ------"
+echo 24 02 > $proc && cat $proc
+
+echo "------ Mutual Compensation ------"
+echo 32 10 > $proc && cat $proc
+
+echo "------ Mutual Low Power Compensation ------"
+echo 32 11 > $proc && cat $proc
+
+echo "------ Self Compensation ------"
+echo 33 12 > $proc && cat $proc
+
+echo "------ Golden Mutual Raw Data ------"
+echo 34 > $proc && cat $proc
+
+echo "------ Packaging Plant - HW reset ------"
+echo 01 FA 20 00 00 24 80 > $proc
+
+echo "------ Packaging Plant - Hibernate Memory ------"
+echo 01 FA 20 00 00 68 08 > $proc
+
+echo "------ Packaging Plant - Read 16 bytes from Address 0x00041FD8 ------"
+echo 02 FB 00 04 3F D8 00 10 01 > $proc && cat $proc
+
+echo "------ ITO Raw ------"
+echo 01 > $spi/stm_fts_cmd && cat $spi/stm_fts_cmd
+
+echo "------ Restore Bus Owner ------"
+echo A0 00 01 > $proc
+
diff --git a/touch/stm/sepolicy/dump_stm.te b/touch/stm/sepolicy/dump_stm.te
new file mode 100644
index 0000000..f2da15f
--- /dev/null
+++ b/touch/stm/sepolicy/dump_stm.te
@@ -0,0 +1,8 @@
+pixel_bugreport(dump_stm)
+
+allow dump_stm proc_touch:file rw_file_perms;
+allow dump_stm sysfs_touch:dir search;
+allow dump_stm sysfs_touch:file rw_file_perms;
+allow dump_stm vendor_toolbox_exec:file execute_no_trans;
+
+get_prop(dump_stm vendor_touch_dump_path_prop)
diff --git a/touch/stm/sepolicy/file.te b/touch/stm/sepolicy/file.te
new file mode 100644
index 0000000..e197bb1
--- /dev/null
+++ b/touch/stm/sepolicy/file.te
@@ -0,0 +1,2 @@
+type proc_touch, proc_type, fs_type;
+type sysfs_touch, sysfs_type, fs_type;
diff --git a/touch/stm/sepolicy/file_contexts b/touch/stm/sepolicy/file_contexts
new file mode 100644
index 0000000..26576ef
--- /dev/null
+++ b/touch/stm/sepolicy/file_contexts
@@ -0,0 +1,2 @@
+/vendor/bin/dump/dump_stm\.sh      u:object_r:dump_stm_exec:s0
+
diff --git a/touch/stm/sepolicy/genfs_contexts b/touch/stm/sepolicy/genfs_contexts
new file mode 100644
index 0000000..2ed8978
--- /dev/null
+++ b/touch/stm/sepolicy/genfs_contexts
@@ -0,0 +1,7 @@
+genfscon sysfs /devices/platform/111d0000.spi/spi_master/spi20/spi20.0  u:object_r:sysfs_touch:s0
+genfscon sysfs /devices/platform/10d40000.spi/spi_master/spi11/spi11.0  u:object_r:sysfs_touch:s0
+genfscon sysfs /devices/platform/10950000.spi/spi_master/spi6/spi6.0    u:object_r:sysfs_touch:s0
+
+genfscon proc  /fts/driver_test                                         u:object_r:proc_touch:s0
+genfscon proc  /fts_ext/driver_test                                     u:object_r:proc_touch:s0
+
diff --git a/touch/stm/sepolicy/property.te b/touch/stm/sepolicy/property.te
new file mode 100644
index 0000000..adb5c0d
--- /dev/null
+++ b/touch/stm/sepolicy/property.te
@@ -0,0 +1,2 @@
+vendor_internal_prop(vendor_touch_dump_path_prop)
+
diff --git a/touch/stm/sepolicy/property_contexts b/touch/stm/sepolicy/property_contexts
new file mode 100644
index 0000000..db9fd5a
--- /dev/null
+++ b/touch/stm/sepolicy/property_contexts
@@ -0,0 +1,2 @@
+ro.vendor.touch.dump. u:object_r:vendor_touch_dump_path_prop:s0
+
diff --git a/touch/stm/stm11.mk b/touch/stm/stm11.mk
new file mode 100644
index 0000000..37d28de
--- /dev/null
+++ b/touch/stm/stm11.mk
@@ -0,0 +1,6 @@
+PRODUCT_VENDOR_PROPERTIES += ro.vendor.touch.dump.sys=/sys/class/spi_master/spi11/spi11.0
+PRODUCT_VENDOR_PROPERTIES += ro.vendor.touch.dump.proc=/proc/fts/driver_test
+
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/stm/sepolicy
+
+PRODUCT_PACKAGES += dump_stm.sh
diff --git a/touch/stm/stm20.mk b/touch/stm/stm20.mk
new file mode 100644
index 0000000..b1034e2
--- /dev/null
+++ b/touch/stm/stm20.mk
@@ -0,0 +1,6 @@
+PRODUCT_VENDOR_PROPERTIES += ro.vendor.touch.dump.sys=/sys/class/spi_master/spi20/spi20.0
+PRODUCT_VENDOR_PROPERTIES += ro.vendor.touch.dump.proc=/proc/fts/driver_test
+
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/stm/sepolicy
+
+PRODUCT_PACKAGES += dump_stm.sh
diff --git a/touch/stm/stm6.mk b/touch/stm/stm6.mk
new file mode 100644
index 0000000..bf6e420
--- /dev/null
+++ b/touch/stm/stm6.mk
@@ -0,0 +1,6 @@
+PRODUCT_VENDOR_PROPERTIES += ro.vendor.touch.dump.sys=/sys/class/spi_master/spi6/spi6.0
+PRODUCT_VENDOR_PROPERTIES += ro.vendor.touch.dump.proc=/proc/fts_ext/driver_test
+
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/stm/sepolicy
+
+PRODUCT_PACKAGES += dump_stm.sh
diff --git a/touch/syna/Android.bp b/touch/syna/Android.bp
new file mode 100644
index 0000000..faefb9b
--- /dev/null
+++ b/touch/syna/Android.bp
@@ -0,0 +1,10 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_syna.sh",
+    src: "dump_syna.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/touch/syna/dump_syna.sh b/touch/syna/dump_syna.sh
new file mode 100644
index 0000000..d30ff36
--- /dev/null
+++ b/touch/syna/dump_syna.sh
@@ -0,0 +1,21 @@
+#!/vendor/bin/sh
+path="/sys/devices/platform/10d10000.spi/spi_master/spi0/spi0.0/synaptics_tcm.0/sysfs"
+
+echo "Enable Force Touch Active"
+echo 21 > $path/force_active
+
+echo "Touch Firmware Information"
+cat $path/info
+
+echo "Get Raw Data - Delta"
+echo 12 > $path/get_raw_data && cat $path/get_raw_data
+
+echo "Get Raw Data - Raw"
+echo 13 > $path/get_raw_data && cat $path/get_raw_data
+
+echo "Get Raw Data - Baseline"
+echo 14 > $path/get_raw_data && cat $path/get_raw_data
+
+echo "Disable Force Touch Active"
+echo 20 > $path/force_active
+
diff --git a/touch/syna/sepolicy/dump_syna.te b/touch/syna/sepolicy/dump_syna.te
new file mode 100644
index 0000000..38655e7
--- /dev/null
+++ b/touch/syna/sepolicy/dump_syna.te
@@ -0,0 +1,5 @@
+pixel_bugreport(dump_syna)
+
+allow dump_syna sysfs_touch:dir r_dir_perms;
+allow dump_syna sysfs_touch:file rw_file_perms;
+allow dump_syna vendor_toolbox_exec:file execute_no_trans;
diff --git a/touch/syna/sepolicy/file.te b/touch/syna/sepolicy/file.te
new file mode 100644
index 0000000..3e53ec3
--- /dev/null
+++ b/touch/syna/sepolicy/file.te
@@ -0,0 +1,2 @@
+type sysfs_touch, sysfs_type, fs_type;
+
diff --git a/touch/syna/sepolicy/file_contexts b/touch/syna/sepolicy/file_contexts
new file mode 100644
index 0000000..40d5707
--- /dev/null
+++ b/touch/syna/sepolicy/file_contexts
@@ -0,0 +1,2 @@
+/vendor/bin/dump/dump_syna\.sh      u:object_r:dump_syna_exec:s0
+
diff --git a/touch/syna/sepolicy/genfs_contexts b/touch/syna/sepolicy/genfs_contexts
new file mode 100644
index 0000000..de55bf3
--- /dev/null
+++ b/touch/syna/sepolicy/genfs_contexts
@@ -0,0 +1,2 @@
+genfscon sysfs /devices/platform/10d10000.spi/spi_master/spi0/spi0.0/synaptics_tcm.0/sysfs   u:object_r:sysfs_touch:s0
+
diff --git a/touch/syna/syna.mk b/touch/syna/syna.mk
new file mode 100644
index 0000000..7f137a0
--- /dev/null
+++ b/touch/syna/syna.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/syna/sepolicy
+
+PRODUCT_PACKAGES += dump_syna.sh
diff --git a/trusty/Android.bp b/trusty/Android.bp
new file mode 100644
index 0000000..536fbd3
--- /dev/null
+++ b/trusty/Android.bp
@@ -0,0 +1,10 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+sh_binary {
+    name: "dump_trusty.sh",
+    src: "dump_trusty.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
diff --git a/trusty/dump_trusty.sh b/trusty/dump_trusty.sh
new file mode 100644
index 0000000..9592cd3
--- /dev/null
+++ b/trusty/dump_trusty.sh
@@ -0,0 +1,3 @@
+#!/vendor/bin/sh
+echo "--- Trusty TEE0 Logs ---"
+cat /dev/trusty-log0
diff --git a/trusty/sepolicy/device.te b/trusty/sepolicy/device.te
new file mode 100644
index 0000000..bb85670
--- /dev/null
+++ b/trusty/sepolicy/device.te
@@ -0,0 +1 @@
+type trusty_log_device, dev_type;
diff --git a/trusty/sepolicy/dump_trusty.te b/trusty/sepolicy/dump_trusty.te
new file mode 100644
index 0000000..d4e0d6e
--- /dev/null
+++ b/trusty/sepolicy/dump_trusty.te
@@ -0,0 +1,4 @@
+pixel_bugreport(dump_trusty)
+
+allow dump_trusty trusty_log_device:chr_file r_file_perms;
+allow dump_trusty vendor_toolbox_exec:file execute_no_trans;
diff --git a/trusty/sepolicy/file_contexts b/trusty/sepolicy/file_contexts
new file mode 100644
index 0000000..d961e84
--- /dev/null
+++ b/trusty/sepolicy/file_contexts
@@ -0,0 +1,3 @@
+/vendor/bin/dump/dump_trusty\.sh      u:object_r:dump_trusty_exec:s0
+
+/dev/trusty-log0                      u:object_r:trusty_log_device:s0
diff --git a/trusty/trusty.mk b/trusty/trusty.mk
new file mode 100644
index 0000000..1786817
--- /dev/null
+++ b/trusty/trusty.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/trusty/sepolicy
+
+PRODUCT_PACKAGES += dump_trusty.sh
diff --git a/wireless_charger/compatibility_matrix.xml b/wireless_charger/compatibility_matrix.xml
new file mode 100644
index 0000000..d0adcde
--- /dev/null
+++ b/wireless_charger/compatibility_matrix.xml
@@ -0,0 +1,10 @@
+<compatibility-matrix version="1.0" type="framework" level="7">
+    <hal format="aidl" optional="true">
+        <name>vendor.google.wireless_charger</name>
+        <version>1</version>
+        <interface>
+            <name>IWirelessCharger</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</compatibility-matrix>
diff --git a/wireless_charger/sepolicy/file_contexts b/wireless_charger/sepolicy/file_contexts
new file mode 100644
index 0000000..004c7a1
--- /dev/null
+++ b/wireless_charger/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/hw/vendor\.google\.wireless_charger-default                  u:object_r:hal_wireless_charger_exec:s0
diff --git a/wireless_charger/sepolicy/hal_dumpstate_default.te b/wireless_charger/sepolicy/hal_dumpstate_default.te
new file mode 100644
index 0000000..748345c
--- /dev/null
+++ b/wireless_charger/sepolicy/hal_dumpstate_default.te
@@ -0,0 +1,3 @@
+allow hal_dumpstate_default sysfs_wlc:dir search;
+allow hal_dumpstate_default sysfs_wlc:dir r_dir_perms;
+allow hal_dumpstate_default sysfs_wlc:file r_file_perms;
diff --git a/wireless_charger/sepolicy/hal_googlebattery.te b/wireless_charger/sepolicy/hal_googlebattery.te
new file mode 100644
index 0000000..6fda60f
--- /dev/null
+++ b/wireless_charger/sepolicy/hal_googlebattery.te
@@ -0,0 +1,2 @@
+r_dir_file(hal_googlebattery, sysfs_wlc)
+allow hal_googlebattery sysfs_wlc:file rw_file_perms;
diff --git a/wireless_charger/sepolicy/hal_health_default.te b/wireless_charger/sepolicy/hal_health_default.te
new file mode 100644
index 0000000..51ef352
--- /dev/null
+++ b/wireless_charger/sepolicy/hal_health_default.te
@@ -0,0 +1 @@
+allow hal_health_default sysfs_wlc:dir search;
diff --git a/wireless_charger/sepolicy/hal_sensors_default.te b/wireless_charger/sepolicy/hal_sensors_default.te
new file mode 100644
index 0000000..ed0efd0
--- /dev/null
+++ b/wireless_charger/sepolicy/hal_sensors_default.te
@@ -0,0 +1 @@
+allow hal_sensors_default sysfs_wlc:dir r_dir_perms;
diff --git a/wireless_charger/sepolicy/hal_wireless_charger.te b/wireless_charger/sepolicy/hal_wireless_charger.te
new file mode 100644
index 0000000..7ab8d83
--- /dev/null
+++ b/wireless_charger/sepolicy/hal_wireless_charger.te
@@ -0,0 +1,19 @@
+init_daemon_domain(hal_wireless_charger)
+
+r_dir_file(hal_wireless_charger, sysfs_batteryinfo)
+r_dir_file(hal_wireless_charger, sysfs_wlc)
+
+allow hal_wireless_charger sysfs_batteryinfo:file rw_file_perms;
+allow hal_wireless_charger self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
+allow hal_wireless_charger sysfs_wlc:file rw_file_perms;
+
+
+binder_call(hal_wireless_charger, servicemanager)
+add_service(hal_wireless_charger, hal_wireless_charger_service)
+
+userdebug_or_eng(`
+     domain_auto_trans(shell,  hal_wireless_charger_exec, hal_wireless_charger)
+')
+
+binder_call(hal_wireless_charger, platform_app)
+binder_call(hal_wireless_charger, system_app)
diff --git a/wireless_charger/sepolicy/pixelstats_vendor.te b/wireless_charger/sepolicy/pixelstats_vendor.te
new file mode 100644
index 0000000..cc2bd92
--- /dev/null
+++ b/wireless_charger/sepolicy/pixelstats_vendor.te
@@ -0,0 +1,3 @@
+# Wireless charge
+allow pixelstats_vendor sysfs_wlc:dir search;
+allow pixelstats_vendor sysfs_wlc:file rw_file_perms;
diff --git a/wireless_charger/sepolicy/service_contexts b/wireless_charger/sepolicy/service_contexts
new file mode 100644
index 0000000..5813e35
--- /dev/null
+++ b/wireless_charger/sepolicy/service_contexts
@@ -0,0 +1 @@
+vendor.google.wireless_charger.IWirelessCharger/default                      u:object_r:hal_wireless_charger_service:s0
diff --git a/wireless_charger/sepolicy/shell.te b/wireless_charger/sepolicy/shell.te
new file mode 100644
index 0000000..cd4fb18
--- /dev/null
+++ b/wireless_charger/sepolicy/shell.te
@@ -0,0 +1,2 @@
+# wlc
+dontaudit shell sysfs_wlc:dir search;
diff --git a/wireless_charger/wireless_charger.mk b/wireless_charger/wireless_charger.mk
new file mode 100644
index 0000000..acf5fc1
--- /dev/null
+++ b/wireless_charger/wireless_charger.mk
@@ -0,0 +1,5 @@
+PRODUCT_SOONG_NAMESPACES += vendor/google/interfaces
+PRODUCT_PACKAGES += vendor.google.wireless_charger-default
+DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs-common/wireless_charger/compatibility_matrix.xml
+
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/wireless_charger/sepolicy