diff --git a/OWNERS b/OWNERS index 73ac18d..b807c00 100644 --- a/OWNERS +++ b/OWNERS @@ -13,10 +13,4 @@ pattjin@google.com bkhalife@google.com lokeshgoel@google.com jainne@google.com -pscovanner@google.com - -per-file *.te=file://sepolicy/OWNERS -per-file *_contexts=file://sepolicy/OWNERS -per-file te_macros=file://sepolicy/OWNERS -per-file global_macros=file://sepolicy/OWNERS - +pscovanner@google.com \ No newline at end of file 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 +#include + +// 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..fbee004 --- /dev/null +++ b/aoc/sepolicy/device.te @@ -0,0 +1,3 @@ +# AOC device +type aoc_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..602c5fe --- /dev/null +++ b/aoc/sepolicy/file.te @@ -0,0 +1,12 @@ +# 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; + +# vendor +type aoc_audio_file, file_type, vendor_file_type; diff --git a/aoc/sepolicy/file_contexts b/aoc/sepolicy/file_contexts new file mode 100644 index 0000000..fef8d73 --- /dev/null +++ b/aoc/sepolicy/file_contexts @@ -0,0 +1,37 @@ +# 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-audio_rtp_tx u:object_r:aoc_device:s0 +/dev/acd-audio_rtp_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.umfw_stat 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/acd-mel_processor u:object_r:aoc_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 + +# 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 + diff --git a/aoc/sepolicy/property.te b/aoc/sepolicy/property.te new file mode 100644 index 0000000..e6f9ddb --- /dev/null +++ b/aoc/sepolicy/property.te @@ -0,0 +1,2 @@ +# AoC +vendor_internal_prop(vendor_aoc_prop) diff --git a/aoc/sepolicy/property_contexts b/aoc/sepolicy/property_contexts new file mode 100644 index 0000000..0838873 --- /dev/null +++ b/aoc/sepolicy/property_contexts @@ -0,0 +1,2 @@ +# AoC +vendor.aoc.firmware.version u:object_r:vendor_aoc_prop:s0 diff --git a/audio/aidl.mk b/audio/aidl.mk new file mode 100644 index 0000000..172b63d --- /dev/null +++ b/audio/aidl.mk @@ -0,0 +1,25 @@ +DEVICE_MANIFEST_FILE += device/google/gs-common/audio/aidl/manifest.xml + +# Audio HALs +PRODUCT_PACKAGES += \ + android.hardware.audio.service-aidl.aoc + +# AIDL software effects. These are the effects supporting in all projects. +# For the project-specific effects, such as haptic generator, please add them +# to makefile in the project's device folder. +PRODUCT_PACKAGES += \ + libvisualizeraidl \ + libbundleaidl \ + libreverbaidl \ + libdynamicsprocessingaidl \ + libloudnessenhanceraidl \ + libdownmixaidl \ + +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/audio/sepolicy/aidl + +include device/google/gs-common/audio/common.mk + +DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs-common/audio/aidl/device_framework_matrix_product.xml + +PRODUCT_PROPERTY_OVERRIDES += \ + vendor.audio_hal.aidl.enable=true diff --git a/audio/aidl/device_framework_matrix_product.xml b/audio/aidl/device_framework_matrix_product.xml new file mode 100644 index 0000000..48b8889 --- /dev/null +++ b/audio/aidl/device_framework_matrix_product.xml @@ -0,0 +1,10 @@ + + + vendor.google.audiometricext + 1.0 + + IAudioMetricExt + default + + + diff --git a/audio/aidl/manifest.xml b/audio/aidl/manifest.xml new file mode 100644 index 0000000..8d957cc --- /dev/null +++ b/audio/aidl/manifest.xml @@ -0,0 +1,11 @@ + + + vendor.google.audiometricext + hwbinder + 1.0 + + IAudioMetricExt + default + + + diff --git a/audio/common.mk b/audio/common.mk new file mode 100644 index 0000000..7f3375b --- /dev/null +++ b/audio/common.mk @@ -0,0 +1,25 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/audio/sepolicy/common + +#Audio Vendor libraries +PRODUCT_PACKAGES += \ + libfvsam_prm_parser \ + libmahalcontroller \ + libAlgFx_HiFi3z + +## AudioHAL Configurations +PRODUCT_COPY_FILES += \ + frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration_7_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration_7_0.xml \ + frameworks/av/services/audiopolicy/config/a2dp_in_audio_policy_configuration_7_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_in_audio_policy_configuration_7_0.xml \ + frameworks/av/services/audiopolicy/config/hearing_aid_audio_policy_configuration_7_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/hearing_aid_audio_policy_configuration_7_0.xml \ + frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml \ + frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/usb_audio_policy_configuration.xml \ + frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml \ + frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml \ + frameworks/av/services/audiopolicy/config/bluetooth_audio_policy_configuration_7_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/bluetooth_audio_policy_configuration_7_0.xml + +## TODO(b/271958194): separate for hidl and aidl. +PRODUCT_SOONG_NAMESPACES += \ + vendor/google/whitechapel/audio/hal \ + vendor/google/whitechapel/audio/interfaces + +$(call soong_config_set,aoc_audio_board,platform,$(TARGET_BOARD_PLATFORM)) diff --git a/audio/hidl/device_framework_matrix_product.xml b/audio/hidl/device_framework_matrix_product.xml new file mode 100644 index 0000000..4c0a3c1 --- /dev/null +++ b/audio/hidl/device_framework_matrix_product.xml @@ -0,0 +1,18 @@ + + + vendor.google.whitechapel.audio.audioext + 4.0 + + IAudioExt + default + + + + vendor.google.audiometricext + 1.0 + + IAudioMetricExt + default + + + diff --git a/audio/hidl/device_framework_matrix_product_gs101.xml b/audio/hidl/device_framework_matrix_product_gs101.xml new file mode 100644 index 0000000..e1bd62a --- /dev/null +++ b/audio/hidl/device_framework_matrix_product_gs101.xml @@ -0,0 +1,18 @@ + + + vendor.google.whitechapel.audio.audioext + 4.0 + + IAudioExt + default + + + + vendor.google.audiometricext + 1.0 + + IAudioMetricExt + default + + + diff --git a/audio/hidl/manifest.xml b/audio/hidl/manifest.xml new file mode 100644 index 0000000..80eec22 --- /dev/null +++ b/audio/hidl/manifest.xml @@ -0,0 +1,47 @@ + + + android.hardware.audio + hwbinder + 7.1 + + IDevicesFactory + default + + + + android.hardware.audio.effect + hwbinder + 7.0 + + IEffectsFactory + default + + + + android.hardware.soundtrigger + hwbinder + 2.3 + + ISoundTriggerHw + default + + + + vendor.google.whitechapel.audio.audioext + hwbinder + 4.0 + + IAudioExt + default + + + + vendor.google.audiometricext + hwbinder + 1.0 + + IAudioMetricExt + default + + + diff --git a/audio/hidl/manifest_gs101.xml b/audio/hidl/manifest_gs101.xml new file mode 100644 index 0000000..c2fba61 --- /dev/null +++ b/audio/hidl/manifest_gs101.xml @@ -0,0 +1,47 @@ + + + android.hardware.audio + hwbinder + 7.1 + + IDevicesFactory + default + + + + android.hardware.audio.effect + hwbinder + 7.0 + + IEffectsFactory + default + + + + android.hardware.soundtrigger + hwbinder + 2.3 + + ISoundTriggerHw + default + + + + vendor.google.whitechapel.audio.audioext + hwbinder + 4.0 + + IAudioExt + default + + + + vendor.google.audiometricext + hwbinder + 1.0 + + IAudioMetricExt + default + + + diff --git a/audio/hidl/manifest_gs101_64.xml b/audio/hidl/manifest_gs101_64.xml new file mode 100644 index 0000000..0022cea --- /dev/null +++ b/audio/hidl/manifest_gs101_64.xml @@ -0,0 +1,47 @@ + + + android.hardware.audio + hwbinder + 7.1 + + IDevicesFactory + default + + + + android.hardware.audio.effect + hwbinder + 7.0 + + IEffectsFactory + default + + + + android.hardware.soundtrigger + hwbinder + 2.3 + + ISoundTriggerHw + default + + + + vendor.google.whitechapel.audio.audioext + hwbinder + 4.0 + + IAudioExt + default + + + + vendor.google.audiometricext + hwbinder + 1.0 + + IAudioMetricExt + default + + + diff --git a/audio/hidl_gs101.mk b/audio/hidl_gs101.mk new file mode 100644 index 0000000..f764e7a --- /dev/null +++ b/audio/hidl_gs101.mk @@ -0,0 +1,39 @@ +DEVICE_MANIFEST_FILE += device/google/gs-common/audio/hidl/manifest_gs101$(LOCAL_64ONLY).xml + +# Audio HAL Server & Default Implementations +PRODUCT_PACKAGES += \ + android.hardware.audio.service \ + android.hardware.audio@7.1-impl \ + android.hardware.audio.effect@7.0-impl \ + android.hardware.bluetooth.audio-impl \ + android.hardware.soundtrigger@2.3-impl \ + vendor.google.whitechapel.audio.audioext@4.0-impl + +#Audio HAL libraries +PRODUCT_PACKAGES += \ + audio.primary.$(TARGET_BOARD_PLATFORM) \ + audio.platform.aoc \ + sound_trigger.primary.$(TARGET_BOARD_PLATFORM) \ + audio_bt_aoc \ + audio_tunnel_aoc \ + aoc_aud_ext \ + libaoctuningdecoder \ + libaoc_waves \ + liboffloadeffect \ + audio_waves_aoc \ + audio_fortemedia_aoc \ + audio_bluenote_aoc \ + audio_usb_aoc \ + audio_spk_35l41 \ + audio.usb.default \ + audio.usbv2.default \ + audio.bluetooth.default \ + audio.r_submix.default \ + libamcsextfile \ + audio_amcs_ext \ + +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/audio/sepolicy/hidl + +include device/google/gs-common/audio/common.mk + +DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs-common/audio/hidl/device_framework_matrix_product_gs101.xml diff --git a/audio/hidl_gs201.mk b/audio/hidl_gs201.mk new file mode 100644 index 0000000..1438b27 --- /dev/null +++ b/audio/hidl_gs201.mk @@ -0,0 +1,39 @@ +DEVICE_MANIFEST_FILE += device/google/gs-common/audio/hidl/manifest.xml + +# Audio HAL Server & Default Implementations +PRODUCT_PACKAGES += \ + android.hardware.audio.service \ + android.hardware.audio@7.1-impl \ + android.hardware.audio.effect@7.0-impl \ + android.hardware.soundtrigger@2.3-impl \ + vendor.google.whitechapel.audio.audioext@4.0-impl \ + android.hardware.bluetooth.audio-impl \ + +#Audio HAL libraries +PRODUCT_PACKAGES += \ + audio.primary.$(TARGET_BOARD_PLATFORM) \ + audio.platform.aoc \ + audio_tunnel_aoc \ + aoc_aud_ext \ + libaoctuningdecoder \ + liboffloadeffect \ + audio_bt_aoc \ + audio_waves_aoc \ + audio_fortemedia_aoc \ + audio_bluenote_aoc \ + audio_usb_aoc \ + audio_cca_aoc \ + libamcsextfile \ + audio_amcs_ext \ + audio.usb.default \ + audio.usbv2.default \ + audio.bluetooth.default \ + audio.r_submix.default \ + audio_spk_35l41 \ + sound_trigger.primary.$(TARGET_BOARD_PLATFORM) + +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/audio/sepolicy/hidl + +include device/google/gs-common/audio/common.mk + +DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs-common/audio/hidl/device_framework_matrix_product.xml diff --git a/audio/hidl_zuma.mk b/audio/hidl_zuma.mk new file mode 100644 index 0000000..980d5fb --- /dev/null +++ b/audio/hidl_zuma.mk @@ -0,0 +1,38 @@ +DEVICE_MANIFEST_FILE += device/google/gs-common/audio/hidl/manifest.xml + +# Audio HAL Server & Default Implementations +PRODUCT_PACKAGES += \ + android.hardware.audio.service \ + android.hardware.audio@7.1-impl \ + android.hardware.audio.effect@7.0-impl \ + android.hardware.soundtrigger@2.3-impl \ + vendor.google.whitechapel.audio.audioext@4.0-impl \ + android.hardware.bluetooth.audio-impl \ + +#Audio HAL libraries +PRODUCT_PACKAGES += \ + audio.primary.$(TARGET_BOARD_PLATFORM) \ + audio.platform.aoc \ + audio_tunnel_aoc \ + aoc_aud_ext \ + libaoctuningdecoder \ + liboffloadeffect \ + audio_bt_aoc \ + audio_waves_aoc \ + audio_fortemedia_aoc \ + audio_bluenote_aoc \ + audio_usb_aoc \ + libamcsextfile \ + audio_amcs_ext \ + audio.usb.default \ + audio.usbv2.default \ + audio.bluetooth.default \ + audio.r_submix.default \ + audio_spk_35l41 \ + sound_trigger.primary.$(TARGET_BOARD_PLATFORM) + +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/audio/sepolicy/hidl + +include device/google/gs-common/audio/common.mk + +DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs-common/audio/hidl/device_framework_matrix_product.xml diff --git a/audio/sepolicy/aidl/file_contexts b/audio/sepolicy/aidl/file_contexts new file mode 100644 index 0000000..9e07893 --- /dev/null +++ b/audio/sepolicy/aidl/file_contexts @@ -0,0 +1,2 @@ +# Audio Hal AIDL Service for Aoc +/vendor/bin/hw/android\.hardware\.audio\.service-aidl\.aoc u:object_r:hal_audio_default_exec:s0 diff --git a/audio/sepolicy/aidl/hal_audio_default.te b/audio/sepolicy/aidl/hal_audio_default.te new file mode 100644 index 0000000..2512a17 --- /dev/null +++ b/audio/sepolicy/aidl/hal_audio_default.te @@ -0,0 +1 @@ +add_service(hal_audio_default, hal_audio_ext_service) diff --git a/audio/sepolicy/aidl/rild.te b/audio/sepolicy/aidl/rild.te new file mode 100644 index 0000000..218a69d --- /dev/null +++ b/audio/sepolicy/aidl/rild.te @@ -0,0 +1 @@ +allow rild hal_audio_ext_service:service_manager find; diff --git a/audio/sepolicy/aidl/service.te b/audio/sepolicy/aidl/service.te new file mode 100644 index 0000000..052558c --- /dev/null +++ b/audio/sepolicy/aidl/service.te @@ -0,0 +1,2 @@ +# Audio +type hal_audio_ext_service, service_manager_type; diff --git a/audio/sepolicy/aidl/service_contexts b/audio/sepolicy/aidl/service_contexts new file mode 100644 index 0000000..1b5f301 --- /dev/null +++ b/audio/sepolicy/aidl/service_contexts @@ -0,0 +1,2 @@ +# Audio +vendor.google.whitechapel.audio.extension.IAudioExtension/default u:object_r:hal_audio_ext_service:s0 diff --git a/audio/sepolicy/common/device.te b/audio/sepolicy/common/device.te new file mode 100644 index 0000000..b4e77e5 --- /dev/null +++ b/audio/sepolicy/common/device.te @@ -0,0 +1,2 @@ +# AMCS device +type amcs_device, dev_type; diff --git a/audio/sepolicy/common/file.te b/audio/sepolicy/common/file.te new file mode 100644 index 0000000..353ab9f --- /dev/null +++ b/audio/sepolicy/common/file.te @@ -0,0 +1,5 @@ +# persist +type persist_audio_file, file_type, vendor_persist_type; + +# data +type audio_vendor_data_file, file_type, data_file_type; diff --git a/audio/sepolicy/common/file_contexts b/audio/sepolicy/common/file_contexts new file mode 100644 index 0000000..1480861 --- /dev/null +++ b/audio/sepolicy/common/file_contexts @@ -0,0 +1,11 @@ +# AMCS devices +/dev/amcs u:object_r:amcs_device:s0 + +# AMCS vendor service +/vendor/bin/hw/vendor\.google\.audiometricext@1\.0-service-vendor u:object_r:hal_audiometricext_default_exec:s0 + +# Audio data files +/data/vendor/audio(/.*)? u:object_r:audio_vendor_data_file:s0 + +# Audio presist file +/mnt/vendor/persist/audio(/.*)? u:object_r:persist_audio_file:s0 diff --git a/audio/sepolicy/common/genfs_contexts b/audio/sepolicy/common/genfs_contexts new file mode 100644 index 0000000..1df3116 --- /dev/null +++ b/audio/sepolicy/common/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/audio/sepolicy/common/hal_audio_default.te b/audio/sepolicy/common/hal_audio_default.te new file mode 100644 index 0000000..7465532 --- /dev/null +++ b/audio/sepolicy/common/hal_audio_default.te @@ -0,0 +1,30 @@ +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 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/audio/sepolicy/common/hal_audiometricext_default.te b/audio/sepolicy/common/hal_audiometricext_default.te new file mode 100644 index 0000000..5358eac --- /dev/null +++ b/audio/sepolicy/common/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/audio/sepolicy/common/hwservice.te b/audio/sepolicy/common/hwservice.te new file mode 100644 index 0000000..0809453 --- /dev/null +++ b/audio/sepolicy/common/hwservice.te @@ -0,0 +1,2 @@ +# AudioMetric +type hal_audiometricext_hwservice, hwservice_manager_type; diff --git a/audio/sepolicy/common/hwservice_contexts b/audio/sepolicy/common/hwservice_contexts new file mode 100644 index 0000000..85c05e5 --- /dev/null +++ b/audio/sepolicy/common/hwservice_contexts @@ -0,0 +1,3 @@ +# Audio +vendor.google.audiometricext::IAudioMetricExt u:object_r:hal_audiometricext_hwservice:s0 + diff --git a/audio/sepolicy/common/property.te b/audio/sepolicy/common/property.te new file mode 100644 index 0000000..e2ffcd1 --- /dev/null +++ b/audio/sepolicy/common/property.te @@ -0,0 +1,2 @@ +# Audio +vendor_internal_prop(vendor_audio_prop) diff --git a/audio/sepolicy/common/property_contexts b/audio/sepolicy/common/property_contexts new file mode 100644 index 0000000..1749ac8 --- /dev/null +++ b/audio/sepolicy/common/property_contexts @@ -0,0 +1,11 @@ +# 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 +vendor.audio_hal.aidl.enable u:object_r:vendor_audio_prop:s0 diff --git a/audio/sepolicy/common/rild.te b/audio/sepolicy/common/rild.te new file mode 100644 index 0000000..fe86848 --- /dev/null +++ b/audio/sepolicy/common/rild.te @@ -0,0 +1 @@ +get_prop(rild, vendor_audio_prop); diff --git a/audio/sepolicy/common/vendor_init.te b/audio/sepolicy/common/vendor_init.te new file mode 100644 index 0000000..26f3fa8 --- /dev/null +++ b/audio/sepolicy/common/vendor_init.te @@ -0,0 +1,2 @@ +# Audio property +set_prop(vendor_init, vendor_audio_prop) diff --git a/audio/sepolicy/hidl/hal_audio_default.te b/audio/sepolicy/hidl/hal_audio_default.te new file mode 100644 index 0000000..bdc3bf9 --- /dev/null +++ b/audio/sepolicy/hidl/hal_audio_default.te @@ -0,0 +1,3 @@ +hwbinder_use(hal_audio_default) + +add_hwservice(hal_audio_default, hal_audio_ext_hwservice) diff --git a/audio/sepolicy/hidl/hwservice.te b/audio/sepolicy/hidl/hwservice.te new file mode 100644 index 0000000..15aaaf7 --- /dev/null +++ b/audio/sepolicy/hidl/hwservice.te @@ -0,0 +1,2 @@ +# Audio +type hal_audio_ext_hwservice, hwservice_manager_type; diff --git a/audio/sepolicy/hidl/hwservice_contexts b/audio/sepolicy/hidl/hwservice_contexts new file mode 100644 index 0000000..8eadd21 --- /dev/null +++ b/audio/sepolicy/hidl/hwservice_contexts @@ -0,0 +1,2 @@ +# Audio +vendor.google.whitechapel.audio.audioext::IAudioExt u:object_r:hal_audio_ext_hwservice:s0 diff --git a/audio/sepolicy/hidl/rild.te b/audio/sepolicy/hidl/rild.te new file mode 100644 index 0000000..378d26c --- /dev/null +++ b/audio/sepolicy/hidl/rild.te @@ -0,0 +1 @@ +allow rild hal_audio_ext_hwservice:hwservice_manager find; diff --git a/battery_mitigation/Android.bp b/battery_mitigation/Android.bp new file mode 100644 index 0000000..c919de5 --- /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", + "liblog", + "libutils", + "android.hardware.thermal@2.0", + "android.hardware.thermal-V1-ndk" + ], + 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..230f297 --- /dev/null +++ b/battery_mitigation/battery_mitigation.cpp @@ -0,0 +1,114 @@ +/* + * 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 +#include + +using android::hardware::google::pixel::BatteryMitigation; +using android::hardware::google::pixel::MitigationConfig; + +android::sp 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 char kLastMealProperty[] = "vendor.brownout.br.feasible"; +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(); + ABinderProcess_setThreadPoolMaxThreadCount(1); + ABinderProcess_startThreadPool(); + 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(); + android::base::SetProperty(kLastMealProperty, "1"); + } + 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..6c8f5cc --- /dev/null +++ b/battery_mitigation/battery_mitigation.rc @@ -0,0 +1,96 @@ +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:vendor.thermal.link_ready=1 && 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:vendor.thermal.link_ready=1 && 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:vendor.thermal.link_ready=1 && 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:vendor.thermal.link_ready=1 && 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:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK1M && property:sys.boot.reason=reboot,ocp,buck1m + setprop vendor.brownout_reason "ocp,buck1m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK2M && property:sys.boot.reason=reboot,ocp,buck2m + setprop vendor.brownout_reason "ocp,buck2m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK3M && property:sys.boot.reason=reboot,ocp,buck3m + setprop vendor.brownout_reason "ocp,buck3m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK4M && property:sys.boot.reason=reboot,ocp,buck4m + setprop vendor.brownout_reason "ocp,buck4m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK5M && property:sys.boot.reason=reboot,ocp,buck5m + setprop vendor.brownout_reason "ocp,buck5m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK6M && property:sys.boot.reason=reboot,ocp,buck6m + setprop vendor.brownout_reason "ocp,buck6m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK7M && property:sys.boot.reason=reboot,ocp,buck7m + setprop vendor.brownout_reason "ocp,buck7m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK8M && property:sys.boot.reason=reboot,ocp,buck8m + setprop vendor.brownout_reason "ocp,buck8m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK9M && property:sys.boot.reason=reboot,ocp,buck9m + setprop vendor.brownout_reason "ocp,buck9m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK10M && property:sys.boot.reason=reboot,ocp,buck10m + setprop vendor.brownout_reason "ocp,buck10m" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK1S && property:sys.boot.reason=reboot,ocp,buck1s + setprop vendor.brownout_reason "ocp,buck1s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK2S && property:sys.boot.reason=reboot,ocp,buck2s + setprop vendor.brownout_reason "ocp,buck2s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK3S && property:sys.boot.reason=reboot,ocp,buck3s + setprop vendor.brownout_reason "ocp,buck3s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK4S && property:sys.boot.reason=reboot,ocp,buck4s + setprop vendor.brownout_reason "ocp,buck4s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK5S && property:sys.boot.reason=reboot,ocp,buck5s + setprop vendor.brownout_reason "ocp,buck5s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK6S && property:sys.boot.reason=reboot,ocp,buck6s + setprop vendor.brownout_reason "ocp,buck6s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK7S && property:sys.boot.reason=reboot,ocp,buck7s + setprop vendor.brownout_reason "ocp,buck7s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK8S && property:sys.boot.reason=reboot,ocp,buck8s + setprop vendor.brownout_reason "ocp,buck8s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK9S && property:sys.boot.reason=reboot,ocp,buck9s + setprop vendor.brownout_reason "ocp,buck9s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCK10S && property:sys.boot.reason=reboot,ocp,buck10s + setprop vendor.brownout_reason "ocp,buck10s" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCKDS && property:sys.boot.reason=reboot,ocp,buckds + setprop vendor.brownout_reason "ocp,buckds" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCKAS && property:sys.boot.reason=reboot,ocp,buckas + setprop vendor.brownout_reason "ocp,buckas" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCKCS && property:sys.boot.reason=reboot,ocp,buckcs + setprop vendor.brownout_reason "ocp,buckcs" + +on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,ocp,BUCKBS && property:sys.boot.reason=reboot,ocp,buckbs + setprop vendor.brownout_reason "ocp,buckbs" + +on property:vendor.brownout.br.feasible=1 + chown system system data/vendor/mitigation/lastmeal.txt + +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..4b83c28 --- /dev/null +++ b/battery_mitigation/sepolicy/battery_mitigation.te @@ -0,0 +1,26 @@ +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) +set_prop(battery_mitigation, vendor_brownout_br_feasible_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; + +# Allow battery_mitigation to use Binder IPC so that service manager can notify it for callbacks +binder_use(battery_mitigation) 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..66d63dd --- /dev/null +++ b/battery_mitigation/sepolicy/genfs_contexts @@ -0,0 +1 @@ +genfscon sysfs /devices/virtual/pmic/mitigation 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..3dfa12e --- /dev/null +++ b/battery_mitigation/sepolicy/property.te @@ -0,0 +1,4 @@ +# Battery Mitigation +vendor_internal_prop(vendor_mitigation_ready_prop) +vendor_public_prop(vendor_brownout_reason_prop) +vendor_internal_prop(vendor_brownout_br_feasible_prop) diff --git a/battery_mitigation/sepolicy/property_contexts b/battery_mitigation/sepolicy/property_contexts new file mode 100644 index 0000000..d5d538a --- /dev/null +++ b/battery_mitigation/sepolicy/property_contexts @@ -0,0 +1,4 @@ +# 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 +vendor.brownout.br.feasible u:object_r:vendor_brownout_br_feasible_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..d53053f --- /dev/null +++ b/battery_mitigation/sepolicy/vendor_init.te @@ -0,0 +1,5 @@ +# Battery Mitigation +set_prop(vendor_init, vendor_brownout_reason_prop) +get_prop(vendor_init, vendor_brownout_br_feasible_prop) +get_prop(vendor_init, system_boot_reason_prop) +get_prop(vendor_init, vendor_thermal_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 @@ + + + hardware.google.bluetooth.ccc + 1.1 + + IBluetoothCcc + default + + + + hardware.google.bluetooth.bt_channel_avoidance + 1.0 + + IBTChannelAvoidance + default + + + + hardware.google.bluetooth.sar + 1.1 + + IBluetoothSar + default + + + + hardware.google.bluetooth.ext + 1.0 + + IBluetoothExt + default + + + + hardware.google.bluetooth.ewp + 1.0 + + IBluetoothEwp + default + + + 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 @@ + + + android.hardware.bluetooth + hwbinder + 1.1 + + IBluetoothHci + default + + + + hardware.google.bluetooth.bt_channel_avoidance + hwbinder + 1.0 + + IBTChannelAvoidance + default + + + + hardware.google.bluetooth.sar + hwbinder + 1.1 + + IBluetoothSar + default + + + + hardware.google.bluetooth.ext + hwbinder + 1.0 + + IBluetoothExt + default + + + + hardware.google.bluetooth.ccc + hwbinder + 1.1 + + IBluetoothCcc + default + + + + hardware.google.bluetooth.ewp + hwbinder + 1.0 + + IBluetoothEwp + default + + + 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/camera/Android.bp b/camera/Android.bp new file mode 100644 index 0000000..9d647c9 --- /dev/null +++ b/camera/Android.bp @@ -0,0 +1,20 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "dump_camera", + srcs: ["dump_camera.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libbase", + "libdump", + "liblog", + ], + vendor: true, + relative_install_path: "dump", +} diff --git a/camera/dump.mk b/camera/dump.mk new file mode 100644 index 0000000..a3a5c7a --- /dev/null +++ b/camera/dump.mk @@ -0,0 +1,4 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/camera/sepolicy/ + +PRODUCT_PACKAGES_DEBUG += dump_camera + diff --git a/camera/dump_camera.cpp b/camera/dump_camera.cpp new file mode 100644 index 0000000..548a866 --- /dev/null +++ b/camera/dump_camera.cpp @@ -0,0 +1,52 @@ +/* + * 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 +#include +#include + +namespace { + +constexpr std::string_view kCameraLogDir = "/data/vendor/camera/profiler"; +constexpr std::string_view kGraphStateDumpDir = "/data/vendor/camera"; + +} // namespace + +int main() { + if (!::android::base::GetBoolProperty( + "vendor.camera.debug.camera_performance_analyzer.attach_to_bugreport", + true)) { + return 0; + } + + const std::string cameraDestDir = + concatenatePath(BUGREPORT_PACKING_DIR, "camera"); + + if (mkdir(cameraDestDir.c_str(), 0777) == -1) { + printf("Unable to create folder: %s\n", cameraDestDir.c_str()); + return 0; + } + + // Attach multiple latest sessions (in case the user is running concurrent + // sessions or starts a new session after the one with performance issues). + dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 10, "session-ended-"); + dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "high-drop-rate-"); + dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "watchdog-"); + dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "camera-ended-"); + dumpLogs(kGraphStateDumpDir.data(), cameraDestDir.c_str(), 5, + "hal_graph_state_"); + + return 0; +} diff --git a/camera/sepolicy/dump_camera.te b/camera/sepolicy/dump_camera.te new file mode 100644 index 0000000..c431184 --- /dev/null +++ b/camera/sepolicy/dump_camera.te @@ -0,0 +1,9 @@ +pixel_bugreport(dump_camera) + +userdebug_or_eng(` + allow dump_camera vendor_camera_data_file:dir r_dir_perms; + allow dump_camera vendor_camera_data_file:file create_file_perms; + allow dump_camera radio_vendor_data_file:dir create_dir_perms; + allow dump_camera radio_vendor_data_file:file create_file_perms; + get_prop(dump_camera, vendor_camera_debug_prop) +') diff --git a/camera/sepolicy/file.te b/camera/sepolicy/file.te new file mode 100644 index 0000000..5f4a142 --- /dev/null +++ b/camera/sepolicy/file.te @@ -0,0 +1,2 @@ +type vendor_camera_data_file, file_type, data_file_type; + diff --git a/camera/sepolicy/file_contexts b/camera/sepolicy/file_contexts new file mode 100644 index 0000000..4bb5308 --- /dev/null +++ b/camera/sepolicy/file_contexts @@ -0,0 +1,5 @@ +/vendor/bin/dump/dump_camera u:object_r:dump_camera_exec:s0 + +# Data +/data/vendor/camera(/.*)? u:object_r:vendor_camera_data_file:s0 + diff --git a/camera/sepolicy/property.te b/camera/sepolicy/property.te new file mode 100644 index 0000000..19d6a2f --- /dev/null +++ b/camera/sepolicy/property.te @@ -0,0 +1,2 @@ +vendor_internal_prop(vendor_camera_debug_prop) + diff --git a/camera/sepolicy/property_contexts b/camera/sepolicy/property_contexts new file mode 100644 index 0000000..5e2c815 --- /dev/null +++ b/camera/sepolicy/property_contexts @@ -0,0 +1,2 @@ +vendor.camera.debug. u:object_r:vendor_camera_debug_prop: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..892f71a --- /dev/null +++ b/dauntless/gsc.mk @@ -0,0 +1,23 @@ +# Dauntless +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/dauntless/sepolicy +ifneq ($(wildcard vendor),) +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 +endif \ No newline at end of file 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/fastbootd.te b/dauntless/sepolicy/fastbootd.te new file mode 100644 index 0000000..c8c0e29 --- /dev/null +++ b/dauntless/sepolicy/fastbootd.te @@ -0,0 +1,3 @@ +recovery_only(` + allow fastbootd citadel_device:chr_file rw_file_perms; +') 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/recovery.te b/dauntless/sepolicy/recovery.te new file mode 100644 index 0000000..c68244f --- /dev/null +++ b/dauntless/sepolicy/recovery.te @@ -0,0 +1,3 @@ +recovery_only(` + allow recovery citadel_device:chr_file rw_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/dauntless/sepolicy/vndservicemanager.te b/dauntless/sepolicy/vndservicemanager.te new file mode 100644 index 0000000..335cd2b --- /dev/null +++ b/dauntless/sepolicy/vndservicemanager.te @@ -0,0 +1 @@ +binder_call(vndservicemanager, hal_keymint_citadel) diff --git a/device.mk b/device.mk index 2813186..f686621 100644 --- a/device.mk +++ b/device.mk @@ -23,3 +23,6 @@ PRODUCT_PROPERTY_OVERRIDES += \ # Installs gsi keys into ramdisk, to boot a developer GSI with verified boot. $(call inherit-product, $(SRC_TARGET_DIR)/product/developer_gsi_keys.mk) + +PRODUCT_COPY_FILES += \ + frameworks/native/data/etc/android.software.ipsec_tunnel_migration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.ipsec_tunnel_migration.xml diff --git a/display/Android.bp b/display/Android.bp new file mode 100644 index 0000000..63dd76e --- /dev/null +++ b/display/Android.bp @@ -0,0 +1,42 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "dump_display_userdebug.sh", + src: "dump_display_userdebug.sh", + vendor: true, + sub_dir: "dump", +} + +cc_binary { + name: "dump_display", + srcs: ["dump_display.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libbase", + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} + +cc_binary { + name: "dump_second_display", + srcs: ["dump_second_display.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} + diff --git a/display/dump.mk b/display/dump.mk new file mode 100644 index 0000000..2af14da --- /dev/null +++ b/display/dump.mk @@ -0,0 +1,4 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/display/sepolicy + +PRODUCT_PACKAGES_DEBUG += dump_display_userdebug.sh +PRODUCT_PACKAGES += dump_display diff --git a/display/dump_display.cpp b/display/dump_display.cpp new file mode 100644 index 0000000..d78a91a --- /dev/null +++ b/display/dump_display.cpp @@ -0,0 +1,29 @@ +/* + * 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 +#include + + +int main() { + setbuf(stdout, NULL); + dumpFileContent("DECON-0 counters /sys/class/drm/card0/device/decon0/counters", "/sys/class/drm/card0/device/decon0/counters"); + dumpFileContent("CRTC-0 event log", "/sys/kernel/debug/dri/0/crtc-0/event"); + runCommand("libdisplaycolor", "/vendor/bin/dumpsys displaycolor -v"); + dumpFileContent("Primary panel name", "/sys/devices/platform/exynos-drm/primary-panel/panel_name"); + dumpFileContent("Primary panel extra info", "/sys/devices/platform/exynos-drm/primary-panel/panel_extinfo"); + return 0; +} + diff --git a/display/dump_display_userdebug.sh b/display/dump_display_userdebug.sh new file mode 100644 index 0000000..b66a4fe --- /dev/null +++ b/display/dump_display_userdebug.sh @@ -0,0 +1,22 @@ +#!/vendor/bin/sh +echo "------ HWC Fence States ------" +for f in $(ls /data/vendor/log/hwc/*_hwc_fence_state*.txt) +do + echo $f + cat $f +done + +echo "------ HWC Error Logs ------" +for f in $(ls /data/vendor/log/hwc/*_hwc_error_log*.txt) +do + echo $f + cat $f +done + +echo "------ HWC Debug Dumps ------" +for f in $(ls /data/vendor/log/hwc/*_hwc_debug*.dump) +do + echo $f + cat $f +done + diff --git a/display/dump_second_display.cpp b/display/dump_second_display.cpp new file mode 100644 index 0000000..a6f2665 --- /dev/null +++ b/display/dump_second_display.cpp @@ -0,0 +1,25 @@ +/* + * 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 + +int main() { + dumpFileContent("DECON-1 counters /sys/class/drm/card0/device/decon1/counters", "/sys/class/drm/card0/device/decon1/counters"); + dumpFileContent("CRTC-1 event log", "/sys/kernel/debug/dri/0/crtc-1/event"); + dumpFileContent("Secondary panel name", "/sys/devices/platform/exynos-drm/secondary-panel/panel_name"); + dumpFileContent("Secondary panel extra info", "/sys/devices/platform/exynos-drm/secondary-panel/panel_extinfo"); + return 0; +} + diff --git a/display/dump_second_display.mk b/display/dump_second_display.mk new file mode 100644 index 0000000..dfab73e --- /dev/null +++ b/display/dump_second_display.mk @@ -0,0 +1,3 @@ +PRODUCT_PACKAGES += dump_second_display +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/display/sepolicy_second_display + diff --git a/display/sepolicy/dump_display.te b/display/sepolicy/dump_display.te new file mode 100644 index 0000000..b8fd1b8 --- /dev/null +++ b/display/sepolicy/dump_display.te @@ -0,0 +1,14 @@ +pixel_bugreport(dump_display) + +allow dump_display sysfs_display:file r_file_perms; +allow dump_display vendor_displaycolor_service:service_manager find; +binder_call(dump_display, hal_graphics_composer_default) +allow dump_display vendor_dumpsys:file execute_no_trans; +allow dump_display vendor_shell_exec:file execute_no_trans; + +userdebug_or_eng(` + allow dump_display vendor_dri_debugfs:dir r_dir_perms; + allow dump_display vendor_dri_debugfs:file r_file_perms; +') +vndbinder_use(dump_display) + diff --git a/display/sepolicy/dump_display_userdebug.te b/display/sepolicy/dump_display_userdebug.te new file mode 100644 index 0000000..a3f83bb --- /dev/null +++ b/display/sepolicy/dump_display_userdebug.te @@ -0,0 +1,8 @@ +pixel_bugreport(dump_display_userdebug) + +userdebug_or_eng(` + allow dump_display_userdebug vendor_toolbox_exec:file execute_no_trans; + allow dump_display_userdebug vendor_log_file:dir search; + allow dump_display_userdebug vendor_hwc_log_file:dir r_dir_perms; + allow dump_display_userdebug vendor_hwc_log_file:file r_file_perms; +') diff --git a/display/sepolicy/file.te b/display/sepolicy/file.te new file mode 100644 index 0000000..e3f2382 --- /dev/null +++ b/display/sepolicy/file.te @@ -0,0 +1,3 @@ +type vendor_hwc_log_file, file_type, data_file_type; +type vendor_dri_debugfs, fs_type, debugfs_type; + diff --git a/display/sepolicy/file_contexts b/display/sepolicy/file_contexts new file mode 100644 index 0000000..66118d0 --- /dev/null +++ b/display/sepolicy/file_contexts @@ -0,0 +1,5 @@ +/vendor/bin/dump/dump_display_userdebug\.sh u:object_r:dump_display_userdebug_exec:s0 +/vendor/bin/dump/dump_display u:object_r:dump_display_exec:s0 + +/data/vendor/log/hwc(/.*)? u:object_r:vendor_hwc_log_file:s0 + diff --git a/display/sepolicy/genfs_contexts b/display/sepolicy/genfs_contexts new file mode 100644 index 0000000..9eaf5fb --- /dev/null +++ b/display/sepolicy/genfs_contexts @@ -0,0 +1,3 @@ + +genfscon debugfs /dri/0/crtc- u:object_r:vendor_dri_debugfs:s0 + diff --git a/display/sepolicy/hal_graphics_composer_default.te b/display/sepolicy/hal_graphics_composer_default.te new file mode 100644 index 0000000..c644559 --- /dev/null +++ b/display/sepolicy/hal_graphics_composer_default.te @@ -0,0 +1,3 @@ +allow hal_graphics_composer_default dump_display:fifo_file { append write }; +allow hal_graphics_composer_default dump_display:fd use; + diff --git a/display/sepolicy/vndservice.te b/display/sepolicy/vndservice.te new file mode 100644 index 0000000..5c3693b --- /dev/null +++ b/display/sepolicy/vndservice.te @@ -0,0 +1,2 @@ +type vendor_displaycolor_service, vndservice_manager_type; + diff --git a/display/sepolicy/vndservice_contexts b/display/sepolicy/vndservice_contexts new file mode 100644 index 0000000..9276f97 --- /dev/null +++ b/display/sepolicy/vndservice_contexts @@ -0,0 +1,2 @@ +displaycolor u:object_r:vendor_displaycolor_service:s0 + diff --git a/display/sepolicy_second_display/dump_second_display.te b/display/sepolicy_second_display/dump_second_display.te new file mode 100644 index 0000000..62d9c2d --- /dev/null +++ b/display/sepolicy_second_display/dump_second_display.te @@ -0,0 +1,9 @@ +pixel_bugreport(dump_second_display) + +allow dump_second_display sysfs_display:file r_file_perms; + +userdebug_or_eng(` + allow dump_second_display vendor_dri_debugfs:dir r_dir_perms; + allow dump_second_display vendor_dri_debugfs:file r_file_perms; +') + diff --git a/display/sepolicy_second_display/file_contexts b/display/sepolicy_second_display/file_contexts new file mode 100644 index 0000000..d9bb31c --- /dev/null +++ b/display/sepolicy_second_display/file_contexts @@ -0,0 +1,2 @@ +/vendor/bin/dump/dump_second_display u:object_r:dump_second_display_exec:s0 + diff --git a/edgetpu/edgetpu.mk b/edgetpu/edgetpu.mk new file mode 100644 index 0000000..5ad2711 --- /dev/null +++ b/edgetpu/edgetpu.mk @@ -0,0 +1,35 @@ +# 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 +# TPU DBA AIDL HAL service +PRODUCT_PACKAGES += com.google.edgetpu.dba-service +# TPU DBA C API library +PRODUCT_PACKAGES += libedgetpu_dba.google + +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/edgetpu/sepolicy + +# Tflite Darwinn delegate property +PRODUCT_VENDOR_PROPERTIES += vendor.edgetpu.tflite_delegate.force_disable_io_coherency=0 + +# Edgetpu CPU scheduler property +PRODUCT_VENDOR_PROPERTIES += vendor.edgetpu.cpu_scheduler.policy=FIFO +PRODUCT_VENDOR_PROPERTIES += vendor.edgetpu.cpu_scheduler.priority=99 + diff --git a/edgetpu/sepolicy/appdomain.te b/edgetpu/sepolicy/appdomain.te new file mode 100644 index 0000000..804a202 --- /dev/null +++ b/edgetpu/sepolicy/appdomain.te @@ -0,0 +1,5 @@ +# Allow apps to read tflite Darwinn delegate properties +get_prop(appdomain, vendor_tflite_delegate_prop) + +# Allow apps to read hetero runtime properties +get_prop(appdomain, vendor_hetero_runtime_prop) 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..271805e --- /dev/null +++ b/edgetpu/sepolicy/edgetpu_app_service.te @@ -0,0 +1,40 @@ +# 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 read device_configs that are set by the cloud server. +get_prop(edgetpu_app_server, device_config_edgetpu_native_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_dba_service.te b/edgetpu/sepolicy/edgetpu_dba_service.te new file mode 100644 index 0000000..da210da --- /dev/null +++ b/edgetpu/sepolicy/edgetpu_dba_service.te @@ -0,0 +1,49 @@ +# EdgeTPU DBA service. +type edgetpu_dba_server, domain; +type edgetpu_dba_server_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(edgetpu_dba_server) + +# The vendor service will use binder calls. +binder_use(edgetpu_dba_server); + +# The vendor service will serve a binder service. +binder_service(edgetpu_dba_server); + +# EdgeTPU DBA service to register the service to service_manager. +add_service(edgetpu_dba_server, edgetpu_dba_service); + +# Allow EdgeTPU DBA service to access the edgetpu_app_service. +allow edgetpu_dba_server edgetpu_app_service:service_manager find; +binder_call(edgetpu_dba_server, edgetpu_app_server); + +# Allow EdgeTPU DBA service to look for TPU instance in /dev/edgetpu or /dev/edgetpu-soc. +allow edgetpu_dba_server edgetpu_device:chr_file rw_file_perms; + +# Allow EdgeTPU DBA service to request power hints from the Power Service. +hal_client_domain(edgetpu_dba_server, hal_power) + +# Allow EdgeTPU DBA service to access hardware buffers and ION memory. +allow edgetpu_dba_server hal_allocator:fd use; +allow edgetpu_dba_server hal_graphics_mapper_hwservice:hwservice_manager find; +allow edgetpu_dba_server hal_graphics_allocator:fd use; +allow edgetpu_dba_server gpu_device:chr_file rw_file_perms; +allow edgetpu_dba_server gpu_device:dir r_dir_perms; +allow edgetpu_dba_server ion_device:chr_file r_file_perms; + +# Allow EdgeTPU DBA service to read the overcommit_memory info. +allow edgetpu_dba_server proc_overcommit_memory:file r_file_perms; + +# Allow EdgeTPU DBA service to read the kernel version. +# This is done inside the InitGoogle. +allow edgetpu_dba_server proc_version:file r_file_perms; + +# Allow EdgeTPU DBA service to send trace packets to Perfetto with SELinux enabled +# under userdebug builds. +userdebug_or_eng(`perfetto_producer(edgetpu_dba_server)') + +# Allow EdgeTPU DBA service to read tflite Darwinn delegate properties +get_prop(edgetpu_dba_server, vendor_tflite_delegate_prop) +# Allow EdgeTPU DBA service to read hetero runtime properties +get_prop(edgetpu_dba_server, vendor_hetero_runtime_prop) +# Allow EdgeTPU DBA service to read EdgeTPU CPU scheduler properties +get_prop(edgetpu_dba_server, vendor_edgetpu_cpu_scheduler_prop) 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/ +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..4c03744 --- /dev/null +++ b/edgetpu/sepolicy/edgetpu_vendor_server.te @@ -0,0 +1,34 @@ +# 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; + +# Allow EdgeTPU vendor service to read hetero runtime properties +get_prop(edgetpu_vendor_server, vendor_hetero_runtime_prop) 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..8f6481c --- /dev/null +++ b/edgetpu/sepolicy/file_contexts @@ -0,0 +1,26 @@ +# 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 + +# EdgeTPU DBA service +/vendor/bin/hw/com\.google\.edgetpu.dba-service u:object_r:edgetpu_dba_server_exec:s0 diff --git a/edgetpu/sepolicy/hal_camera_default.te b/edgetpu/sepolicy/hal_camera_default.te new file mode 100644 index 0000000..3c09f2f --- /dev/null +++ b/edgetpu/sepolicy/hal_camera_default.te @@ -0,0 +1,5 @@ +# Allow camera HAL to read tflite Darwinn delegate properties +get_prop(hal_camera_default, vendor_tflite_delegate_prop) + +# Allow camera HAL to read hetero runtime properties +get_prop(hal_camera_default, vendor_hetero_runtime_prop) diff --git a/edgetpu/sepolicy/hal_neuralnetworks_darwinn.te b/edgetpu/sepolicy/hal_neuralnetworks_darwinn.te new file mode 100644 index 0000000..7d50bfc --- /dev/null +++ b/edgetpu/sepolicy/hal_neuralnetworks_darwinn.te @@ -0,0 +1,58 @@ +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)') + +# Allow NNAPI HAL to read tflite DarwiNN delegate properties +get_prop(hal_neuralnetworks_darwinn, vendor_tflite_delegate_prop) +# Allow NNAPI HAL to read hetero runtime properties +get_prop(hal_neuralnetworks_darwinn, vendor_hetero_runtime_prop) diff --git a/edgetpu/sepolicy/priv_app.te b/edgetpu/sepolicy/priv_app.te new file mode 100644 index 0000000..a9b49c3 --- /dev/null +++ b/edgetpu/sepolicy/priv_app.te @@ -0,0 +1,9 @@ +# 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..625ed0a --- /dev/null +++ b/edgetpu/sepolicy/property.te @@ -0,0 +1,14 @@ +# EdgeTPU service requires system public properties +# since it lives under /system_ext/. +system_public_prop(vendor_edgetpu_service_prop) + +# Tflite Darwinn delegate properties are written once by vendor_init, +# and then read by apps, camera hal, and some Darwinn vendor services. +system_vendor_config_prop(vendor_tflite_delegate_prop) + +# The EdgeTPU CPU scheduler properties are written once by vendor_init, +# and then read by HAL service. +system_vendor_config_prop(vendor_edgetpu_cpu_scheduler_prop) + +# Hetero runtime properties, including tracing levels. +system_vendor_config_prop(vendor_hetero_runtime_prop) diff --git a/edgetpu/sepolicy/property_contexts b/edgetpu/sepolicy/property_contexts new file mode 100644 index 0000000..dabbd20 --- /dev/null +++ b/edgetpu/sepolicy/property_contexts @@ -0,0 +1,9 @@ +# for EdgeTPU +vendor.edgetpu.service. u:object_r:vendor_edgetpu_service_prop:s0 +vendor.edgetpu.cpu_scheduler. u:object_r:vendor_edgetpu_cpu_scheduler_prop:s0 + +# for DarwinnDelegate +vendor.edgetpu.tflite_delegate. u:object_r:vendor_tflite_delegate_prop:s0 + +# for hetero runtime +vendor.google.silicon. u:object_r:vendor_hetero_runtime_prop:s0 diff --git a/edgetpu/sepolicy/service.te b/edgetpu/sepolicy/service.te new file mode 100644 index 0000000..a61c8f8 --- /dev/null +++ b/edgetpu/sepolicy/service.te @@ -0,0 +1,6 @@ +type edgetpu_nnapi_service, app_api_service, service_manager_type, isolated_compute_allowed_service; +type edgetpu_vendor_service, service_manager_type, hal_service_type; +type edgetpu_dba_service, app_api_service, service_manager_type, isolated_compute_allowed_service; + +# 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..83967f7 --- /dev/null +++ b/edgetpu/sepolicy/service_contexts @@ -0,0 +1,10 @@ + +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 + +# EdgeTPU DBA Service +com.google.edgetpu.dba.IDevice/default u:object_r:edgetpu_dba_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/edgetpu/sepolicy/vendor_init.te b/edgetpu/sepolicy/vendor_init.te new file mode 100644 index 0000000..d0ee1f9 --- /dev/null +++ b/edgetpu/sepolicy/vendor_init.te @@ -0,0 +1,4 @@ +# Allow vendor_init to set tflite Darwinn delegate properties +set_prop(vendor_init, vendor_tflite_delegate_prop) +# Allow vendor_init to set the EdgeTPU CPU scheduler properties. +set_prop(vendor_init, vendor_edgetpu_cpu_scheduler_prop) diff --git a/gear/dumpstate/Android.bp b/gear/dumpstate/Android.bp new file mode 100644 index 0000000..590ba10 --- /dev/null +++ b/gear/dumpstate/Android.bp @@ -0,0 +1,29 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "android.hardware.dumpstate-service", + srcs: [ + "Dumpstate.cpp", + "service.cpp", + ], + init_rc: ["android.hardware.dumpstate-service.rc"], + vintf_fragments: ["android.hardware.dumpstate-service.xml"], + cflags: [ + "-Wall", + "-Werror", + ], + shared_libs: [ + "libbase", + "libbinder_ndk", + "libcutils", + "libdumpstateutil", + "liblog", + "libutils", + "libdump", + "android.hardware.dumpstate-V1-ndk", + ], + vendor: true, + relative_install_path: "hw", +} diff --git a/gear/dumpstate/Dumpstate.cpp b/gear/dumpstate/Dumpstate.cpp new file mode 100644 index 0000000..9fe7c1a --- /dev/null +++ b/gear/dumpstate/Dumpstate.cpp @@ -0,0 +1,226 @@ +/* + * Copyright 2016 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 "dumpstate_device" +#define ATRACE_TAG ATRACE_TAG_ALWAYS + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "Dumpstate.h" + +#include "DumpstateUtil.h" + +#define HW_REVISION "ro.boot.hardware.revision" + +using android::os::dumpstate::CommandOptions; +using android::os::dumpstate::DumpFileToFd; +using android::os::dumpstate::PropertiesHelper; +using android::os::dumpstate::RunCommandToFd; + +namespace aidl { +namespace android { +namespace hardware { +namespace dumpstate { + +typedef std::chrono::time_point timepoint_t; + +const char kVerboseLoggingProperty[] = "persist.vendor.verbose_logging_enabled"; + +timepoint_t startSection(int fd, const std::string §ionName) { + ATRACE_BEGIN(sectionName.c_str()); + ::android::base::WriteStringToFd( + "\n" + "------ Section start: " + sectionName + " ------\n" + "\n", fd); + return std::chrono::steady_clock::now(); +} + +void endSection(int fd, const std::string §ionName, timepoint_t startTime) { + ATRACE_END(); + auto endTime = std::chrono::steady_clock::now(); + auto elapsedMsec = std::chrono::duration_cast + (endTime - startTime).count(); + + ::android::base::WriteStringToFd( + "\n" + "------ Section end: " + sectionName + " ------\n" + "Elapsed msec: " + std::to_string(elapsedMsec) + "\n" + "\n", fd); +} + +// Dump data requested by an argument to the "dump" interface, or help info +// if the specified section is not supported. +void Dumpstate::dumpTextSection(int fd, const std::string §ionName) { + bool dumpAll = (sectionName == kAllSections); + std::string dumpFiles; + + // Execute all or designated programs under vendor/bin/dump/ + std::unique_ptr dir(opendir("/vendor/bin/dump"), closedir); + if (!dir) { + ALOGE("Fail To Open Dir vendor/bin/dump/"); + ::android::base::WriteStringToFd("Fail To Open Dir vendor/bin/dump/\n", fd); + return; + } + dirent *entry; + while ((entry = readdir(dir.get())) != nullptr) { + // Skip '.', '..' + if (entry->d_name[0] == '.') { + continue; + } + std::string bin(entry->d_name); + dumpFiles = dumpFiles + " " + bin; + if (dumpAll || sectionName == bin) { + auto startTime = startSection(fd, bin); + RunCommandToFd(fd, "/vendor/bin/dump/"+bin, {"/vendor/bin/dump/"+bin}, CommandOptions::WithTimeout(15).Build()); + endSection(fd, bin, startTime); + if (!dumpAll) { + return; + } + } + } + + if (dumpAll) { + RunCommandToFd(fd, "VENDOR PROPERTIES", {"/vendor/bin/getprop"}); + return; + } + + // An unsupported section was requested on the command line + ::android::base::WriteStringToFd("Unrecognized text section: " + sectionName + "\n", fd); + ::android::base::WriteStringToFd("Try \"" + kAllSections + "\" or one of the following:", fd); + ::android::base::WriteStringToFd(dumpFiles, fd); + ::android::base::WriteStringToFd("\nNote: sections with attachments (e.g. dump_soc) are" + "not available from the command line.\n", fd); +} + +void Dumpstate::dumpLogSection(int fd, int fd_bin) +{ + std::string logDir = MODEM_LOG_DIRECTORY; + const std::string logCombined = logDir + "/combined_logs.tar"; + const std::string logAllDir = logDir + "/all_logs"; + + RunCommandToFd(fd, "MKDIR LOG", {"/vendor/bin/mkdir", "-p", logAllDir.c_str()}, CommandOptions::WithTimeout(2).Build()); + + dumpTextSection(fd, kAllSections); + + RunCommandToFd(fd, "TAR LOG", {"/vendor/bin/tar", "cvf", logCombined.c_str(), "-C", logAllDir.c_str(), "."}, CommandOptions::WithTimeout(20).Build()); + RunCommandToFd(fd, "CHG PERM", {"/vendor/bin/chmod", "a+w", logCombined.c_str()}, CommandOptions::WithTimeout(2).Build()); + + std::vector buffer(65536); + ::android::base::unique_fd fdLog(TEMP_FAILURE_RETRY(open(logCombined.c_str(), O_RDONLY | O_CLOEXEC | O_NONBLOCK))); + + if (fdLog >= 0) { + while (1) { + ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fdLog, buffer.data(), buffer.size())); + + if (bytes_read == 0) { + break; + } else if (bytes_read < 0) { + ALOGD("read(%s): %s\n", logCombined.c_str(), strerror(errno)); + break; + } + + ssize_t result = TEMP_FAILURE_RETRY(write(fd_bin, buffer.data(), bytes_read)); + + if (result != bytes_read) { + ALOGD("Failed to write %zd bytes, actually written: %zd", bytes_read, result); + break; + } + } + } + + RunCommandToFd(fd, "RM LOG DIR", { "/vendor/bin/rm", "-r", logAllDir.c_str()}, CommandOptions::WithTimeout(2).Build()); + RunCommandToFd(fd, "RM LOG", { "/vendor/bin/rm", logCombined.c_str()}, CommandOptions::WithTimeout(2).Build()); +} + +ndk::ScopedAStatus Dumpstate::dumpstateBoard(const std::vector<::ndk::ScopedFileDescriptor>& in_fds, + IDumpstateDevice::DumpstateMode in_mode, + int64_t in_timeoutMillis) { + ATRACE_BEGIN("dumpstateBoard"); + // Unused arguments. + (void) in_timeoutMillis; + + if (in_mode < IDumpstateDevice::DumpstateMode::FULL || in_mode > IDumpstateDevice::DumpstateMode::PROTO) { + ALOGE("Invalid mode: %d\n", in_mode); + return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT, "Invalid mode"); + } + + if (in_fds.size() < 1) { + ALOGE("no FDs\n"); + return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT, + "No file descriptor"); + } + + int fd = in_fds[0].get(); + if (fd < 0) { + ALOGE("invalid FD: %d\n", fd); + return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT, + "Invalid file descriptor"); + } + + if (in_fds.size() < 2) { + ALOGE("no FD for dumpstate_board binary\n"); + dumpTextSection(fd, ""); + } else { + int fd_bin = in_fds[1].get(); + dumpLogSection(fd, fd_bin); + } + + ATRACE_END(); + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Dumpstate::setVerboseLoggingEnabled(bool in_enable) { + ::android::base::SetProperty(kVerboseLoggingProperty, in_enable ? "true" : "false"); + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Dumpstate::getVerboseLoggingEnabled(bool* _aidl_return) { + *_aidl_return = ::android::base::GetBoolProperty(kVerboseLoggingProperty, false); + return ndk::ScopedAStatus::ok(); +} + +// Since AIDLs that support the dump() interface are automatically invoked during +// bugreport generation and we don't want to generate a second copy of the same +// data that will go into dumpstate_board.txt, this function will only do +// something if it is called with an option, e.g. +// dumpsys android.hardware.dumpstate.IDumpstateDevice/default all +// +// Also, note that sections which generate attachments and/or binary data when +// included in a bugreport are not available through the dump() interface. +binder_status_t Dumpstate::dump(int fd, const char** args, uint32_t numArgs) { + + if (numArgs != 1) { + return STATUS_OK; + } + + dumpTextSection(fd, static_cast(args[0])); + + fsync(fd); + return STATUS_OK; +} + +} // namespace dumpstate +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/gear/dumpstate/Dumpstate.h b/gear/dumpstate/Dumpstate.h new file mode 100644 index 0000000..787b774 --- /dev/null +++ b/gear/dumpstate/Dumpstate.h @@ -0,0 +1,53 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include + +namespace aidl { +namespace android { +namespace hardware { +namespace dumpstate { + +class Dumpstate : public BnDumpstateDevice { + public: + ::ndk::ScopedAStatus dumpstateBoard(const std::vector<::ndk::ScopedFileDescriptor>& in_fds, + IDumpstateDevice::DumpstateMode in_mode, + int64_t in_timeoutMillis) override; + + ::ndk::ScopedAStatus getVerboseLoggingEnabled(bool* _aidl_return) override; + + ::ndk::ScopedAStatus setVerboseLoggingEnabled(bool in_enable) override; + + binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; + + private: + const std::string kAllSections = "all"; + + void dumpTextSection(int fd, std::string const& sectionName); + void dumpLogSection(int fd, int fdModem); + + //bool getVerboseLoggingEnabledImpl(); + //::ndk::ScopedAStatus dumpstateBoardImpl(const int fd, const bool full); +}; + +} // namespace dumpstate +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/gear/dumpstate/aidl.mk b/gear/dumpstate/aidl.mk new file mode 100644 index 0000000..0df64e9 --- /dev/null +++ b/gear/dumpstate/aidl.mk @@ -0,0 +1,3 @@ +PRODUCT_PACKAGES += android.hardware.dumpstate-service +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/gear/dumpstate/sepolicy + diff --git a/gear/dumpstate/android.hardware.dumpstate-service.rc b/gear/dumpstate/android.hardware.dumpstate-service.rc new file mode 100644 index 0000000..ee69a68 --- /dev/null +++ b/gear/dumpstate/android.hardware.dumpstate-service.rc @@ -0,0 +1,5 @@ +service vendor.dumpstate-default /vendor/bin/hw/android.hardware.dumpstate-service + class hal + user system + group system shell + interface aidl android.hardware.dumpstate.IDumpstateDevice/default diff --git a/gear/dumpstate/android.hardware.dumpstate-service.xml b/gear/dumpstate/android.hardware.dumpstate-service.xml new file mode 100644 index 0000000..5e51b28 --- /dev/null +++ b/gear/dumpstate/android.hardware.dumpstate-service.xml @@ -0,0 +1,9 @@ + + + android.hardware.dumpstate + + IDumpstateDevice + default + + + diff --git a/gear/dumpstate/sepolicy/file.te b/gear/dumpstate/sepolicy/file.te new file mode 100644 index 0000000..1777353 --- /dev/null +++ b/gear/dumpstate/sepolicy/file.te @@ -0,0 +1,6 @@ +# dumpstate packing directory +type radio_vendor_data_file, file_type, data_file_type; +userdebug_or_eng(` + typeattribute radio_vendor_data_file mlstrustedobject; +') + diff --git a/gear/dumpstate/sepolicy/file_contexts b/gear/dumpstate/sepolicy/file_contexts new file mode 100644 index 0000000..086b481 --- /dev/null +++ b/gear/dumpstate/sepolicy/file_contexts @@ -0,0 +1,5 @@ +# generic dumpstate for pixel +/vendor/bin/hw/android\.hardware\.dumpstate-service u:object_r:hal_dumpstate_default_exec:s0 + +/data/vendor/radio(/.*)? u:object_r:radio_vendor_data_file:s0 + diff --git a/gear/dumpstate/sepolicy/hal_dumpstate_default.te b/gear/dumpstate/sepolicy/hal_dumpstate_default.te new file mode 100644 index 0000000..06ebb75 --- /dev/null +++ b/gear/dumpstate/sepolicy/hal_dumpstate_default.te @@ -0,0 +1,7 @@ +# required permission to use tar to pack dumpsate_board.bin +allow hal_dumpstate_default vendor_toolbox_exec:file execute_no_trans; +allow hal_dumpstate_default radio_vendor_data_file:dir create_dir_perms; +allow hal_dumpstate_default radio_vendor_data_file:file create_file_perms; +allow hal_dumpstate_default shell_data_file:file getattr; +set_prop(hal_dumpstate_default, vendor_logger_prop) + diff --git a/gear/dumpstate/sepolicy/property.te b/gear/dumpstate/sepolicy/property.te new file mode 100644 index 0000000..c6f5a4f --- /dev/null +++ b/gear/dumpstate/sepolicy/property.te @@ -0,0 +1,3 @@ +# verbose property +vendor_internal_prop(vendor_logger_prop) + diff --git a/gear/dumpstate/sepolicy/property_contexts b/gear/dumpstate/sepolicy/property_contexts new file mode 100644 index 0000000..5ead16f --- /dev/null +++ b/gear/dumpstate/sepolicy/property_contexts @@ -0,0 +1,3 @@ +# verbose property name +persist.vendor.verbose_logging_enabled u:object_r:vendor_logger_prop:s0 + diff --git a/gear/dumpstate/service.cpp b/gear/dumpstate/service.cpp new file mode 100644 index 0000000..848bddd --- /dev/null +++ b/gear/dumpstate/service.cpp @@ -0,0 +1,37 @@ +/* + * 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 "android.hardware.dumpstate-service" + +#include "Dumpstate.h" + +#include +#include +#include + +using aidl::android::hardware::dumpstate::Dumpstate; + +int main() { + ABinderProcess_setThreadPoolMaxThreadCount(0); + std::shared_ptr dumpstate = ndk::SharedRefBase::make(); + + const std::string instance = std::string() + Dumpstate::descriptor + "/default"; + binder_status_t status = + AServiceManager_addService(dumpstate->asBinder().get(), instance.c_str()); + CHECK_EQ(status, STATUS_OK); + + ABinderProcess_joinThreadPool(); + return EXIT_FAILURE; // Unreachable +} diff --git a/gps/brcm/cbd_gps.mk b/gps/brcm/cbd_gps.mk new file mode 100644 index 0000000..74d1a3b --- /dev/null +++ b/gps/brcm/cbd_gps.mk @@ -0,0 +1,3 @@ +# Copy the cbd control gps state init rc file +PRODUCT_PACKAGES += \ + cbd_gps.rc diff --git a/gps/brcm/conf/Android.bp b/gps/brcm/conf/Android.bp new file mode 100644 index 0000000..97e0af9 --- /dev/null +++ b/gps/brcm/conf/Android.bp @@ -0,0 +1,10 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +prebuilt_etc { + name: "cbd_gps.rc", + src: "cbd_gps.rc", + relative_install_path: "init", + vendor: true, +} \ No newline at end of file diff --git a/gps/brcm/conf/cbd_gps.rc b/gps/brcm/conf/cbd_gps.rc new file mode 100644 index 0000000..b315fe3 --- /dev/null +++ b/gps/brcm/conf/cbd_gps.rc @@ -0,0 +1,5 @@ +# disable gps service if cbd state is invalid +on property:vendor.ril.cbd.svc=0 + stop gpsd + stop lhd + stop scd diff --git a/gps/brcm/device.mk b/gps/brcm/device.mk new file mode 100644 index 0000000..73d0492 --- /dev/null +++ b/gps/brcm/device.mk @@ -0,0 +1,14 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/gps/brcm/sepolicy + +PRODUCT_SOONG_NAMESPACES += device/google/gs-common/gps/brcm/prebuilt + +ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) + $(call soong_config_set, SensorHub_debug, assertion, true) +endif + +PRODUCT_PACKAGES += \ + bcm47765_gps_package \ + android.hardware.location.gps.prebuilt.xml + +PRODUCT_PACKAGES_DEBUG += \ + init.gps_log.rc diff --git a/gps/brcm/device_v2.mk b/gps/brcm/device_v2.mk new file mode 100644 index 0000000..5de9b61 --- /dev/null +++ b/gps/brcm/device_v2.mk @@ -0,0 +1,14 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/gps/brcm/sepolicy + +PRODUCT_SOONG_NAMESPACES += vendor/broadcom/gps/bcm47765 + +ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) + $(call soong_config_set, gpsv2, assertion, true) +endif + +PRODUCT_PACKAGES += \ + bcm47765_gps_package_v2 \ + android.hardware.location.gps.prebuilt.xml + +PRODUCT_PACKAGES_DEBUG += \ + init.gps_log.rc diff --git a/gps/brcm/prebuilt/Android.bp b/gps/brcm/prebuilt/Android.bp new file mode 100644 index 0000000..d12f897 --- /dev/null +++ b/gps/brcm/prebuilt/Android.bp @@ -0,0 +1,240 @@ +soong_namespace { + imports: [ + "hardware/google/pixel", + ], +} + +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_prebuilt_library_shared { + name: "android.hardware.gnss@2.1-impl-google", + arch: { + arm64: { + srcs: ["android.hardware.gnss@2.1-impl-google.so"], + shared_libs: [ + "liblog", + "libutils", + "libbinder_ndk", + "android.hardware.gnss-V3-ndk", + "libhardware", + "libc++", + "libc", + "libm", + "libdl", + ], + }, + }, + compile_multilib: "64", + vendor: true, + relative_install_path: "hw", + strip: { + none: true, + }, + // Bypass because libhidltransport is deprecated + check_elf_files: false, +} + +cc_prebuilt_binary { + name: "android.hardware.gnss@2.1-service-brcm", + init_rc: ["init.gps.rc"], + arch: { + arm64: { + srcs: ["android.hardware.gnss@2.1-service-brcm"], + shared_libs: [ + "liblog", + "libutils", + "libhardware", + "libbinder_ndk", + "android.hardware.gnss-V3-ndk", + "libc++", + "libc", + "libm", + "libdl", + ], + }, + }, + compile_multilib: "64", + vendor: true, + relative_install_path: "hw", + strip: { + none: true, + }, + // Bypass because libhidltransport is deprecated + // Bypass because libhwbinder is deprecated + check_elf_files: false, + vintf_fragments: ["android.hardware.gnss@2.1-service-brcm.xml"] +} + +cc_prebuilt_library_shared { + name: "flp.default", + arch: { + arm64: { + srcs: ["flp.default.so"], + shared_libs: [ + "liblog", + "libcutils", + "libutils", + "libc++", + "libc", + "libm", + "libdl", + ], + }, + }, + compile_multilib: "64", + vendor: true, + relative_install_path: "hw", + strip: { + none: true, + }, + // Bypass because soname mismatch + check_elf_files: false, +} + +cc_prebuilt_binary { + name: "gpsd", + arch: { + arm64: { + srcs: ["gpsd"], + shared_libs: [ + "liblog", + "libutils", + "libhardware_legacy", + "libcutils", + "libssl", + "libcrypto", + // "libsitril-gps", + "android.frameworks.sensorservice@1.0", + "libhidlbase", + "libandroid_net", + "libc++", + "libc", + "libm", + "libdl", + ], + }, + }, + compile_multilib: "64", + vendor: true, + relative_install_path: "hw", + strip: { + none: true, + }, + // Bypass because libsitril-gps is Android.mk module + check_elf_files: false, +} + +cc_prebuilt_library_shared { + name: "gps.default", + arch: { + arm64: { + srcs: ["gps.default.so"], + shared_libs: [ + "liblog", + "libcutils", + "libutils", + "libc++", + "libc", + "libm", + "libdl", + ], + }, + }, + compile_multilib: "64", + vendor: true, + relative_install_path: "hw", + strip: { + none: true, + }, + // Bypass because soname mismatch + check_elf_files: false, +} + +cc_prebuilt_binary { + name: "lhd", + arch: { + arm64: { + srcs: ["lhd"], + shared_libs: [ + "liblog", + "libutils", + "libhardware_legacy", + "libc++", + "libc", + "libm", + "libz", + "libdl", + ], + }, + }, + compile_multilib: "64", + vendor: true, + relative_install_path: "hw", + strip: { + none: true, + }, +} + +cc_prebuilt_binary { + name: "scd", + arch: { + arm64: { + srcs: ["scd"], + shared_libs: [ + "liblog", + "libutils", + "libssl", + "libcrypto", + "libandroid_net", + ], + }, + }, + compile_multilib: "64", + vendor: true, + relative_install_path: "hw", + strip: { + none: true, + }, +} + +soong_config_module_type { + name: "gps_prebuilt_firmware", + module_type: "prebuilt_firmware", + config_namespace: "SensorHub_debug", + bool_variables: [ + "assertion", + ], + properties: [ + "src" + ], +} + +gps_prebuilt_firmware { + name: "SensorHub.patch", + soong_config_variables: { + assertion: { + src: "SensorHub_DebugBuild_A0.patch", + conditions_default: { + src: "SensorHub_A0.patch" + }, + }, + }, + vendor: true, + filename: "SensorHub.patch" +} + +phony { + name: "bcm47765_gps_package", + required: [ + "android.hardware.gnss@2.1-impl-google", + "android.hardware.gnss@2.1-service-brcm", + "flp.default", + "gpsd", + "lhd", + "gps.default", + "scd", + "SensorHub.patch" + ], +} diff --git a/gps/brcm/prebuilt/SensorHub_A0.patch b/gps/brcm/prebuilt/SensorHub_A0.patch new file mode 100644 index 0000000..f9e6598 --- /dev/null +++ b/gps/brcm/prebuilt/SensorHub_A0.patch @@ -0,0 +1,7027 @@ + + + + + + + + + + + + + + diff --git a/gps/brcm/prebuilt/SensorHub_DebugBuild_A0.patch b/gps/brcm/prebuilt/SensorHub_DebugBuild_A0.patch new file mode 100644 index 0000000..92b15bc --- /dev/null +++ b/gps/brcm/prebuilt/SensorHub_DebugBuild_A0.patch @@ -0,0 +1,7050 @@ + + + + + + + + + + + + + + diff --git a/gps/brcm/prebuilt/android.hardware.gnss@2.1-impl-google.so b/gps/brcm/prebuilt/android.hardware.gnss@2.1-impl-google.so new file mode 100755 index 0000000..e42bf07 Binary files /dev/null and b/gps/brcm/prebuilt/android.hardware.gnss@2.1-impl-google.so differ diff --git a/gps/brcm/prebuilt/android.hardware.gnss@2.1-service-brcm b/gps/brcm/prebuilt/android.hardware.gnss@2.1-service-brcm new file mode 100755 index 0000000..46c3502 Binary files /dev/null and b/gps/brcm/prebuilt/android.hardware.gnss@2.1-service-brcm differ diff --git a/gps/brcm/prebuilt/android.hardware.gnss@2.1-service-brcm.xml b/gps/brcm/prebuilt/android.hardware.gnss@2.1-service-brcm.xml new file mode 100644 index 0000000..8d06407 --- /dev/null +++ b/gps/brcm/prebuilt/android.hardware.gnss@2.1-service-brcm.xml @@ -0,0 +1,7 @@ + + + android.hardware.gnss + 3 + IGnss/default + + diff --git a/gps/brcm/prebuilt/flp.default.so b/gps/brcm/prebuilt/flp.default.so new file mode 100755 index 0000000..ae82480 Binary files /dev/null and b/gps/brcm/prebuilt/flp.default.so differ diff --git a/gps/brcm/prebuilt/gps.default.so b/gps/brcm/prebuilt/gps.default.so new file mode 100755 index 0000000..616d840 Binary files /dev/null and b/gps/brcm/prebuilt/gps.default.so differ diff --git a/gps/brcm/prebuilt/gpsd b/gps/brcm/prebuilt/gpsd new file mode 100755 index 0000000..8a7f911 Binary files /dev/null and b/gps/brcm/prebuilt/gpsd differ diff --git a/gps/brcm/prebuilt/init.gps.rc b/gps/brcm/prebuilt/init.gps.rc new file mode 100644 index 0000000..a9823ef --- /dev/null +++ b/gps/brcm/prebuilt/init.gps.rc @@ -0,0 +1,26 @@ +service lhd /vendor/bin/hw/lhd /vendor/etc/gnss/lhd.conf + class main + user gps + group system inet net_raw sdcard_rw + ioprio be 0 + +service gpsd /vendor/bin/hw/gpsd -c /vendor/etc/gnss/gps.xml + class main + user gps + group system gps radio inet wakelock sdcard_rw net_raw + ioprio be 0 + +service scd /vendor/bin/hw/scd /vendor/etc/gnss/scd.conf + class main + user gps + group system inet net_raw wakelock + ioprio be 0 + priority -1 + +service gnss_service /vendor/bin/hw/android.hardware.gnss@2.1-service-brcm + class hal + user gps + group system gps radio + ioprio be 0 + priority -1 + diff --git a/gps/brcm/prebuilt/lhd b/gps/brcm/prebuilt/lhd new file mode 100755 index 0000000..258bf23 Binary files /dev/null and b/gps/brcm/prebuilt/lhd differ diff --git a/gps/brcm/prebuilt/scd b/gps/brcm/prebuilt/scd new file mode 100755 index 0000000..cccca1f Binary files /dev/null and b/gps/brcm/prebuilt/scd differ 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..7b566f9 --- /dev/null +++ b/gps/brcm/sepolicy/gpsd.te @@ -0,0 +1,23 @@ +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; + +# android.frameworks.sensorservice through libsensorndkbridge +allow gpsd fwk_sensor_service:service_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/gps/dump/Android.bp b/gps/dump/Android.bp new file mode 100644 index 0000000..1f66882 --- /dev/null +++ b/gps/dump/Android.bp @@ -0,0 +1,20 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "dump_gps", + srcs: ["dump_gps.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libbase", + "libdump", + "liblog", + ], + vendor: true, + relative_install_path: "dump", +} diff --git a/gps/dump/dump_gps.cpp b/gps/dump/dump_gps.cpp new file mode 100644 index 0000000..d569f9b --- /dev/null +++ b/gps/dump/dump_gps.cpp @@ -0,0 +1,46 @@ +/* + * 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 +#include +#include + +#define GPS_LOG_NUMBER_PROPERTY "persist.vendor.gps.aol.log_num" +#define GPS_LOG_DIRECTORY "/data/vendor/gps/logs" +#define GPS_TMP_LOG_DIRECTORY "/data/vendor/gps/logs/.tmp" +#define GPS_LOG_PREFIX "gl-" +#define GPS_MCU_LOG_PREFIX "esw-" +#define GPS_MALLOC_LOG_DIRECTORY "/data/vendor/gps" +#define GPS_MALLOC_LOG_PREFIX "malloc_" + +int main() { + if(!::android::base::GetBoolProperty("vendor.gps.aol.enabled", false)) { + printf("vendor.gps.aol.enabled is false. gps logging is not running.\n"); + return 0; + } + int maxFileNum = ::android::base::GetIntProperty(GPS_LOG_NUMBER_PROPERTY, 20); + std::string outputDir = concatenatePath(BUGREPORT_PACKING_DIR, "gps"); + if (mkdir(outputDir.c_str(), 0777) == -1) { + printf("Unable to create folder: %s\n", outputDir.c_str()); + return 0; + } + + dumpLogs(GPS_TMP_LOG_DIRECTORY, outputDir.c_str(), 1, GPS_LOG_PREFIX); + dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), 3, GPS_MCU_LOG_PREFIX); + dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), maxFileNum, GPS_LOG_PREFIX); + dumpLogs(GPS_MALLOC_LOG_DIRECTORY, outputDir.c_str(), 1, GPS_MALLOC_LOG_PREFIX); + return 0; +} + diff --git a/gps/dump/log.mk b/gps/dump/log.mk new file mode 100644 index 0000000..d977cb2 --- /dev/null +++ b/gps/dump/log.mk @@ -0,0 +1,4 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/gps/dump/sepolicy/ + +PRODUCT_PACKAGES_DEBUG += dump_gps + diff --git a/gps/dump/sepolicy/dump_gps.te b/gps/dump/sepolicy/dump_gps.te new file mode 100644 index 0000000..b60a251 --- /dev/null +++ b/gps/dump/sepolicy/dump_gps.te @@ -0,0 +1,10 @@ +pixel_bugreport(dump_gps) + +userdebug_or_eng(` + allow dump_gps radio_vendor_data_file:dir create_dir_perms; + allow dump_gps radio_vendor_data_file:file create_file_perms; + allow dump_gps vendor_gps_file:dir r_dir_perms; + allow dump_gps vendor_gps_file:file r_file_perms; + + get_prop(dump_gps, vendor_gps_prop) +') diff --git a/gps/dump/sepolicy/file_contexts b/gps/dump/sepolicy/file_contexts new file mode 100644 index 0000000..a35e59c --- /dev/null +++ b/gps/dump/sepolicy/file_contexts @@ -0,0 +1,2 @@ +/vendor/bin/dump/dump_gps u:object_r:dump_gps_exec:s0 + 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#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..f58ce50 --- /dev/null +++ b/gs_watchdogd/init.gs_watchdogd.rc @@ -0,0 +1,9 @@ +# 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 + shutdown critical + +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..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/gxp/Android.bp b/gxp/Android.bp new file mode 100644 index 0000000..f3683fc --- /dev/null +++ b/gxp/Android.bp @@ -0,0 +1,19 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "dump_gxp", + srcs: ["dump_gxp.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libbase", + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} diff --git a/gxp/dump.mk b/gxp/dump.mk new file mode 100644 index 0000000..c1f6300 --- /dev/null +++ b/gxp/dump.mk @@ -0,0 +1,4 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/gxp/sepolicy/ + +PRODUCT_PACKAGES_DEBUG += dump_gxp + diff --git a/gxp/dump_gxp.cpp b/gxp/dump_gxp.cpp new file mode 100644 index 0000000..5a0bb3b --- /dev/null +++ b/gxp/dump_gxp.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 +#include +#include + +#define maxGxpDebugDumps 3 + +int main() { + /* TODO(b/277094681): Set default value to false around device beta milestone. */ + if(::android::base::GetBoolProperty("vendor.gxp.attach_to_bugreport", true)) { + std::string outputDir = concatenatePath(BUGREPORT_PACKING_DIR, "gxp_ssrdump"); + printf("Creating %s", outputDir.c_str()); + if (mkdir(outputDir.c_str(), 0777) == -1) { + printf("Unable to create folder: %s\n", outputDir.c_str()); + return 0; + } + + dumpLogs("/data/vendor/ssrdump/coredump", outputDir.c_str(), maxGxpDebugDumps, "coredump_gxp_"); + dumpLogs("/data/vendor/ssrdump", outputDir.c_str(), maxGxpDebugDumps, "crashinfo_gxp_"); + } + return 0; +} + diff --git a/gxp/sepolicy/dump_gxp.te b/gxp/sepolicy/dump_gxp.te new file mode 100644 index 0000000..61a0482 --- /dev/null +++ b/gxp/sepolicy/dump_gxp.te @@ -0,0 +1,11 @@ +pixel_bugreport(dump_gxp) + +userdebug_or_eng(` + allow dump_gxp radio_vendor_data_file:dir create_dir_perms; + allow dump_gxp radio_vendor_data_file:file create_file_perms; + allow dump_gxp sscoredump_vendor_data_coredump_file:dir r_dir_perms; + allow dump_gxp sscoredump_vendor_data_coredump_file:file r_file_perms; + allow dump_gxp sscoredump_vendor_data_crashinfo_file:dir r_dir_perms; + allow dump_gxp sscoredump_vendor_data_crashinfo_file:file r_file_perms; +') + diff --git a/gxp/sepolicy/file_contexts b/gxp/sepolicy/file_contexts new file mode 100644 index 0000000..80420f4 --- /dev/null +++ b/gxp/sepolicy/file_contexts @@ -0,0 +1,2 @@ +/vendor/bin/dump/dump_gxp u:object_r:dump_gxp_exec:s0 + 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..4d67d15 --- /dev/null +++ b/insmod/include/dump/pixel_dump.h @@ -0,0 +1,15 @@ +#ifndef DEVICE_GOOGLE_GS_COMMON_INSMOD_INCLUDE_DUMP_PIXEL_DUMP_H_ +#define DEVICE_GOOGLE_GS_COMMON_INSMOD_INCLUDE_DUMP_PIXEL_DUMP_H_ + +#include + +#define BUGREPORT_PACKING_DIR "/data/vendor/radio/logs/always-on/all_logs" +#define MODEM_LOG_DIRECTORY "/data/vendor/radio/logs/always-on" + +void dumpFileContent(const char* title, const char* file_path); +void runCommand(const char* title, const char* cmd); +std::string concatenatePath(const char* folder, const char* file); +void dumpLogs(const char* SrcDir, const char* DestDir, int limit, const char* prefix); +void copyFile(const char* SrcDir, const char* DestDir); + +#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..aaaae01 --- /dev/null +++ b/insmod/pixel_dump.cpp @@ -0,0 +1,105 @@ +/* + * 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 +#include +#include +#include +#include + +// 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; +} + +std::string concatenatePath(const char* folder, const char* file){ + std::string path = folder; + if(folder[strlen(folder)-1] == '/'){ + path = path + file; + } else { + path = path + "/" + file; + } + + printf("folder:%s, result:%s\n", folder, path.c_str()); + return path; +} + +// Copy stored log from individual folder to our dumpstate folder for +// compressing. +void dumpLogs(const char* SrcDir, const char* DestDir, int limit, const char* prefix) { + + struct dirent **dirent_list = NULL; + int num_entries = scandir(SrcDir, &dirent_list, 0, (int (*)(const struct dirent **, const struct dirent **)) alphasort); + if (!dirent_list) { + printf("Unable to scan dir: %s.\n", SrcDir); + return; + } else if (num_entries <= 0) { + printf("No file is found.\n"); + return; + } + + if (access(DestDir, R_OK)) { + printf("Unable to find folder: %s\n", DestDir); + return; + } + + int copiedFiles = 0; + + for (int i = num_entries - 1; i >= 0; i--) { + + if (0 != strncmp(dirent_list[i]->d_name, prefix, strlen(prefix))) { + continue; + } + + if ((copiedFiles >= limit) && (limit != -1)) { + printf("Skipped %s\n", dirent_list[i]->d_name); + continue; + } + + copiedFiles++; + copyFile(concatenatePath(SrcDir, dirent_list[i]->d_name).c_str(), concatenatePath(DestDir, dirent_list[i]->d_name).c_str()); + } + + while (num_entries--) { + free(dirent_list[num_entries]); + } + + free(dirent_list); + return; +} + +void copyFile(const char* SrcDir, const char* DestDir) { + std::ifstream src(SrcDir, std::ios::binary); + std::ofstream dst(DestDir, std::ios::binary); + dst << src.rdbuf(); + src.close(); + dst.close(); + 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/led/Android.bp b/led/Android.bp new file mode 100644 index 0000000..6e15ac5 --- /dev/null +++ b/led/Android.bp @@ -0,0 +1,18 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "dump_led", + srcs: ["dump_led.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} diff --git a/led/dump_led.cpp b/led/dump_led.cpp new file mode 100644 index 0000000..7ce4846 --- /dev/null +++ b/led/dump_led.cpp @@ -0,0 +1,24 @@ +/* + * 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 + +int main() { + dumpFileContent("Green LED Brightness", "/sys/class/leds/green/brightness"); + dumpFileContent("Green LED Max Brightness", "/sys/class/leds/green/max_brightness"); + dumpFileContent("LED Calibration Data", "/mnt/vendor/persist/led/led_calibration_LUT.txt"); + return 0; +} diff --git a/led/led.mk b/led/led.mk new file mode 100644 index 0000000..81d0f33 --- /dev/null +++ b/led/led.mk @@ -0,0 +1,3 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/led/sepolicy + +PRODUCT_PACKAGES_DEBUG += dump_led diff --git a/led/sepolicy/dump_led.te b/led/sepolicy/dump_led.te new file mode 100644 index 0000000..b1ba1ef --- /dev/null +++ b/led/sepolicy/dump_led.te @@ -0,0 +1,9 @@ +pixel_bugreport(dump_led) + +allow dump_led mnt_vendor_file:dir search; +allow dump_led persist_file:dir search; +allow dump_led persist_leds_file:dir search; +allow dump_led persist_leds_file:file r_file_perms; +allow dump_led sysfs_leds:dir search; +allow dump_led sysfs_leds:file r_file_perms; + diff --git a/led/sepolicy/file.te b/led/sepolicy/file.te new file mode 100644 index 0000000..7fda883 --- /dev/null +++ b/led/sepolicy/file.te @@ -0,0 +1,2 @@ +type persist_leds_file, file_type, vendor_persist_type; + diff --git a/led/sepolicy/file_contexts b/led/sepolicy/file_contexts new file mode 100644 index 0000000..1b006cf --- /dev/null +++ b/led/sepolicy/file_contexts @@ -0,0 +1,4 @@ +/vendor/bin/dump/dump_led u:object_r:dump_led_exec:s0 + +/mnt/vendor/persist/led(/.*)? u:object_r:persist_leds_file:s0 + diff --git a/mediacodec/common/mediacodec_common.mk b/mediacodec/common/mediacodec_common.mk new file mode 100644 index 0000000..7f57785 --- /dev/null +++ b/mediacodec/common/mediacodec_common.mk @@ -0,0 +1,4 @@ +# mediacodec_common for all build configs and sepolicy shared among different Codec HAL +# example 1: shared among multiple HALs on the same device +# example 2: shared among different Hals on different devices +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/mediacodec/common/sepolicy diff --git a/mediacodec/common/sepolicy/file.te b/mediacodec/common/sepolicy/file.te new file mode 100644 index 0000000..921cc69 --- /dev/null +++ b/mediacodec/common/sepolicy/file.te @@ -0,0 +1 @@ +type vendor_media_data_file, file_type, data_file_type; diff --git a/mediacodec/common/sepolicy/file_contexts b/mediacodec/common/sepolicy/file_contexts new file mode 100644 index 0000000..e92274f --- /dev/null +++ b/mediacodec/common/sepolicy/file_contexts @@ -0,0 +1 @@ +/data/vendor/media(/.*)? u:object_r:vendor_media_data_file:s0 diff --git a/mediacodec/common/sepolicy/vndservice.te b/mediacodec/common/sepolicy/vndservice.te new file mode 100644 index 0000000..0784fe3 --- /dev/null +++ b/mediacodec/common/sepolicy/vndservice.te @@ -0,0 +1 @@ +type eco_service, vndservice_manager_type; diff --git a/mediacodec/common/sepolicy/vndservice_contexts b/mediacodec/common/sepolicy/vndservice_contexts new file mode 100644 index 0000000..87800a3 --- /dev/null +++ b/mediacodec/common/sepolicy/vndservice_contexts @@ -0,0 +1 @@ +media.ecoservice u:object_r:eco_service:s0 diff --git a/mediacodec/samsung/mediacodec_samsung.mk b/mediacodec/samsung/mediacodec_samsung.mk new file mode 100644 index 0000000..96ffac4 --- /dev/null +++ b/mediacodec/samsung/mediacodec_samsung.mk @@ -0,0 +1,21 @@ +PRODUCT_SOONG_NAMESPACES += vendor/samsung_slsi/codec2 + +PRODUCT_PACKAGES += \ + samsung.hardware.media.c2@1.2-service \ + codec2.vendor.base.policy \ + codec2.vendor.ext.policy \ + libExynosC2ComponentStore \ + libExynosC2H264Dec \ + libExynosC2H264Enc \ + libExynosC2HevcDec \ + libExynosC2HevcEnc \ + libExynosC2Mpeg4Dec \ + libExynosC2Mpeg4Enc \ + libExynosC2H263Dec \ + libExynosC2H263Enc \ + libExynosC2Vp8Dec \ + libExynosC2Vp8Enc \ + libExynosC2Vp9Dec \ + libExynosC2Vp9Enc + +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/mediacodec/samsung/sepolicy diff --git a/mediacodec/samsung/sepolicy/file.te b/mediacodec/samsung/sepolicy/file.te new file mode 100644 index 0000000..99c3b66 --- /dev/null +++ b/mediacodec/samsung/sepolicy/file.te @@ -0,0 +1 @@ +type sysfs_mfc, sysfs_type, fs_type; diff --git a/mediacodec/samsung/sepolicy/file_contexts b/mediacodec/samsung/sepolicy/file_contexts new file mode 100644 index 0000000..6f4f29b --- /dev/null +++ b/mediacodec/samsung/sepolicy/file_contexts @@ -0,0 +1,2 @@ +# MFC +/vendor/bin/hw/samsung\.hardware\.media\.c2@1\.2-service u:object_r:mediacodec_samsung_exec:s0 diff --git a/mediacodec/samsung/sepolicy/genfs_contexts b/mediacodec/samsung/sepolicy/genfs_contexts new file mode 100644 index 0000000..d44d760 --- /dev/null +++ b/mediacodec/samsung/sepolicy/genfs_contexts @@ -0,0 +1 @@ +genfscon sysfs /devices/platform/mfc/video4linux/video u:object_r:sysfs_mfc:s0 diff --git a/mediacodec/samsung/sepolicy/mediacodec_samsung.te b/mediacodec/samsung/sepolicy/mediacodec_samsung.te new file mode 100644 index 0000000..efc83d7 --- /dev/null +++ b/mediacodec/samsung/sepolicy/mediacodec_samsung.te @@ -0,0 +1,37 @@ +type mediacodec_samsung, domain; +type mediacodec_samsung_exec, vendor_file_type, exec_type, file_type; +init_daemon_domain(mediacodec_samsung) + +hal_server_domain(mediacodec_samsung, hal_codec2) +add_service(mediacodec_samsung, eco_service) + +vndbinder_use(mediacodec_samsung) + +allow mediacodec_samsung video_device:chr_file rw_file_perms; +allow mediacodec_samsung dmabuf_system_heap_device:chr_file r_file_perms; +allow mediacodec_samsung gpu_device:chr_file rw_file_perms; + +allow mediacodec_samsung sysfs_mfc:file r_file_perms; +allow mediacodec_samsung sysfs_mfc:dir r_dir_perms; + +# can use graphics allocator +hal_client_domain(mediacodec_samsung, hal_graphics_allocator) + +binder_call(mediacodec_samsung, hal_camera_default) + +crash_dump_fallback(mediacodec_samsung) + +# mediacodec_samsung should never execute any executable without a domain transition +neverallow mediacodec_samsung { file_type fs_type }:file execute_no_trans; + +# Media processing code is inherently risky and thus should have limited +# permissions and be isolated from the rest of the system and network. +# Lengthier explanation here: +# https://android-developers.googleblog.com/2016/05/hardening-media-stack.html +neverallow mediacodec_samsung domain:{ udp_socket rawip_socket } *; +neverallow mediacodec_samsung { domain userdebug_or_eng(`-su') }:tcp_socket *; + +userdebug_or_eng(` + allow mediacodec_samsung vendor_media_data_file:dir rw_dir_perms; + allow mediacodec_samsung vendor_media_data_file:file create_file_perms; +') diff --git a/modem/Android.bp b/modem/Android.bp new file mode 100644 index 0000000..84bdd61 --- /dev/null +++ b/modem/Android.bp @@ -0,0 +1,28 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "dump_modem.sh", + src: "dump_modem.sh", + vendor: true, + sub_dir: "dump", +} + +cc_binary { + name: "dump_modemlog", + srcs: ["dump_modemlog.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libbase", + "libdump", + "liblog", + ], + vendor: true, + relative_install_path: "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/dump_modemlog.cpp b/modem/dump_modemlog.cpp new file mode 100644 index 0000000..f7ef834 --- /dev/null +++ b/modem/dump_modemlog.cpp @@ -0,0 +1,64 @@ +/* + * 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 +#include +#include + +#define MODEM_LOGGING_PERSIST_PROPERTY "persist.vendor.sys.modem.logging.enable" +#define MODEM_LOGGING_PROPERTY "vendor.sys.modem.logging.enable" +#define MODEM_LOGGING_STATUS_PROPERTY "vendor.sys.modem.logging.status" +#define MODEM_LOGGING_NUMBER_BUGREPORT_PROPERTY "persist.vendor.sys.modem.logging.br_num" +#define MODEM_LOGGING_PATH_PROPERTY "vendor.sys.modem.logging.log_path" +#define MODEM_SIM_DIRECTORY "/data/vendor/radio/sim/" +#define MODEM_LOG_PREFIX "sbuff_" +#define SIM_POWERON_LOG_PREFIX "sim_poweron_log_" + +int main() { + bool modemLogEnabled = ::android::base::GetBoolProperty(MODEM_LOGGING_PERSIST_PROPERTY, false); + if (modemLogEnabled && ::android::base::GetProperty(MODEM_LOGGING_PATH_PROPERTY, "") == MODEM_LOG_DIRECTORY) { + bool modemLogStarted = ::android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false); + int maxFileNum = ::android::base::GetIntProperty(MODEM_LOGGING_NUMBER_BUGREPORT_PROPERTY, 100); + + if (modemLogStarted) { + ::android::base::SetProperty(MODEM_LOGGING_PROPERTY, "false"); + ALOGD("Stopping modem logging...\n"); + } else { + ALOGD("modem logging is not running\n"); + } + + for (int i = 0; i < 15; i++) { + if (!::android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false)) { + ALOGD("modem logging stopped\n"); + sleep(1); + break; + } + sleep(1); + } + + dumpLogs(MODEM_LOG_DIRECTORY, BUGREPORT_PACKING_DIR, maxFileNum, MODEM_LOG_PREFIX); + + if (modemLogStarted) { + ALOGD("Restarting modem logging...\n"); + ::android::base::SetProperty(MODEM_LOGGING_PROPERTY, "true"); + } + } + + dumpLogs("/data/vendor/radio/extended_logs", BUGREPORT_PACKING_DIR, 20, "extended_log_"); + dumpLogs(MODEM_SIM_DIRECTORY, BUGREPORT_PACKING_DIR, 1, SIM_POWERON_LOG_PREFIX); + copyFile("/mnt/vendor/efs/nv_normal.bin", "/data/vendor/radio/logs/always-on/all_logs/nv_normal.bin"); + copyFile("/mnt/vendor/efs/nv_protected.bin", "/data/vendor/radio/logs/always-on/all_logs/nv_protected.bin"); + return 0; +} diff --git a/modem/modem.mk b/modem/modem.mk new file mode 100644 index 0000000..10df7d4 --- /dev/null +++ b/modem/modem.mk @@ -0,0 +1,5 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/modem/sepolicy + +PRODUCT_PACKAGES += dump_modem.sh +PRODUCT_PACKAGES += dump_modemlog + 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/dump_modemlog.te b/modem/sepolicy/dump_modemlog.te new file mode 100644 index 0000000..b7082c9 --- /dev/null +++ b/modem/sepolicy/dump_modemlog.te @@ -0,0 +1,10 @@ +pixel_bugreport(dump_modemlog) + +allow dump_modemlog mnt_vendor_file:dir search; +allow dump_modemlog modem_efs_file:dir search; +allow dump_modemlog modem_efs_file:file r_file_perms; +allow dump_modemlog vendor_slog_file:dir r_dir_perms; +allow dump_modemlog vendor_slog_file:file r_file_perms; +allow dump_modemlog radio_vendor_data_file:dir create_dir_perms; +allow dump_modemlog radio_vendor_data_file:file create_file_perms; +set_prop(dump_modemlog, vendor_modem_prop) diff --git a/modem/sepolicy/file_contexts b/modem/sepolicy/file_contexts new file mode 100644 index 0000000..29315e9 --- /dev/null +++ b/modem/sepolicy/file_contexts @@ -0,0 +1,3 @@ +/vendor/bin/dump/dump_modem\.sh u:object_r:dump_modem_exec:s0 +/vendor/bin/dump/dump_modemlog u:object_r:dump_modemlog_exec:s0 + diff --git a/pcie/Android.bp b/pcie/Android.bp new file mode 100644 index 0000000..ae6a94e --- /dev/null +++ b/pcie/Android.bp @@ -0,0 +1,10 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "dump_pcie.sh", + src: "dump_pcie.sh", + vendor: true, + sub_dir: "dump", +} diff --git a/pcie/dump_pcie.sh b/pcie/dump_pcie.sh new file mode 100644 index 0000000..4546207 --- /dev/null +++ b/pcie/dump_pcie.sh @@ -0,0 +1,11 @@ +#!/vendor/bin/sh +echo "--- pcie0 dump ---" +cat /dev/logbuffer_pcie0 +echo "--- pcie1 dump ---" +cat /dev/logbuffer_pcie1 + +echo "--- pcie link statistics ---" +for f in /sys/devices/platform/*.pcie/link_stats/* +do + echo "$f: `cat $f`" +done diff --git a/pcie/pcie.mk b/pcie/pcie.mk new file mode 100644 index 0000000..f9ab327 --- /dev/null +++ b/pcie/pcie.mk @@ -0,0 +1,2 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/pcie/sepolicy +PRODUCT_PACKAGES += dump_pcie.sh diff --git a/pcie/sepolicy/device.te b/pcie/sepolicy/device.te new file mode 100644 index 0000000..934cdb4 --- /dev/null +++ b/pcie/sepolicy/device.te @@ -0,0 +1,2 @@ +type pcie_log_device, dev_type; +type sysfs_pcie, sysfs_type, fs_type; diff --git a/pcie/sepolicy/dump_pcie.te b/pcie/sepolicy/dump_pcie.te new file mode 100644 index 0000000..30b2241 --- /dev/null +++ b/pcie/sepolicy/dump_pcie.te @@ -0,0 +1,7 @@ +pixel_bugreport(dump_pcie) + +allow dump_pcie pcie_log_device:chr_file r_file_perms; +allow dump_pcie vendor_toolbox_exec:file execute_no_trans; + +allow dump_pcie sysfs:dir r_dir_perms; +allow dump_pcie sysfs_pcie:file r_file_perms; diff --git a/pcie/sepolicy/file_contexts b/pcie/sepolicy/file_contexts new file mode 100644 index 0000000..e06f754 --- /dev/null +++ b/pcie/sepolicy/file_contexts @@ -0,0 +1,4 @@ +/vendor/bin/dump/dump_pcie\.sh u:object_r:dump_pcie_exec:s0 + +/dev/logbuffer_pcie0 u:object_r:pcie_log_device:s0 +/dev/logbuffer_pcie1 u:object_r:pcie_log_device:s0 diff --git a/performance/Android.bp b/performance/Android.bp new file mode 100644 index 0000000..6eee7c4 --- /dev/null +++ b/performance/Android.bp @@ -0,0 +1,18 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "dump_perf", + srcs: ["dump_perf.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} diff --git a/performance/dump_perf.cpp b/performance/dump_perf.cpp new file mode 100644 index 0000000..aa742f1 --- /dev/null +++ b/performance/dump_perf.cpp @@ -0,0 +1,22 @@ +/* + * 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 + +int main() { + dumpFileContent("VENDOR PROC DUMP", "/proc/vendor_sched/dump_task"); + return 0; +} diff --git a/performance/perf.mk b/performance/perf.mk new file mode 100644 index 0000000..dfbdb5b --- /dev/null +++ b/performance/perf.mk @@ -0,0 +1,3 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/performance/sepolicy + +PRODUCT_PACKAGES += dump_perf diff --git a/performance/sepolicy/dump_perf.te b/performance/sepolicy/dump_perf.te new file mode 100644 index 0000000..15c4f6e --- /dev/null +++ b/performance/sepolicy/dump_perf.te @@ -0,0 +1,3 @@ +pixel_bugreport(dump_perf) + +allow dump_perf proc_vendor_sched:file r_file_perms; diff --git a/performance/sepolicy/file_contexts b/performance/sepolicy/file_contexts new file mode 100644 index 0000000..171529e --- /dev/null +++ b/performance/sepolicy/file_contexts @@ -0,0 +1,2 @@ +/vendor/bin/dump/dump_perf u:object_r:dump_perf_exec:s0 + diff --git a/pixel_metrics/Android.bp b/pixel_metrics/Android.bp new file mode 100644 index 0000000..04d83f3 --- /dev/null +++ b/pixel_metrics/Android.bp @@ -0,0 +1,20 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "dump_pixel_metrics", + srcs: ["dump_pixel_metrics.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libbase", + "libdump", + "liblog", + ], + vendor: true, + relative_install_path: "dump", +} diff --git a/pixel_metrics/dump_pixel_metrics.cpp b/pixel_metrics/dump_pixel_metrics.cpp new file mode 100644 index 0000000..2dd5553 --- /dev/null +++ b/pixel_metrics/dump_pixel_metrics.cpp @@ -0,0 +1,27 @@ +/* + * 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 +#include + + +int main() { + setbuf(stdout, NULL); + dumpFileContent("Long running IRQ metrics", "/sys/kernel/metrics/irq/long_irq_metrics"); + dumpFileContent("Storm IRQ metrics", "/sys/kernel/metrics/irq/storm_irq_metrics"); + dumpFileContent("Resume latency metrics", "/sys/kernel/metrics/resume_latency/resume_latency_metrics"); + return 0; +} + diff --git a/pixel_metrics/pixel_metrics.mk b/pixel_metrics/pixel_metrics.mk new file mode 100644 index 0000000..736ddf3 --- /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 diff --git a/pixel_metrics/sepolicy/dump_pixel_metrics.te b/pixel_metrics/sepolicy/dump_pixel_metrics.te new file mode 100644 index 0000000..903a8e3 --- /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_dumpsys:file execute_no_trans; diff --git a/pixel_metrics/sepolicy/file.te b/pixel_metrics/sepolicy/file.te new file mode 100644 index 0000000..63640e3 --- /dev/null +++ b/pixel_metrics/sepolicy/file.te @@ -0,0 +1,2 @@ +#vendor-metrics +type sysfs_vendor_metrics, fs_type, sysfs_type; diff --git a/pixel_metrics/sepolicy/file_contexts b/pixel_metrics/sepolicy/file_contexts new file mode 100644 index 0000000..966055f --- /dev/null +++ b/pixel_metrics/sepolicy/file_contexts @@ -0,0 +1 @@ +/vendor/bin/dump/dump_pixel_metrics 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..3be226a --- /dev/null +++ b/pixel_metrics/sepolicy/genfs_contexts @@ -0,0 +1,6 @@ +#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/irq/storm_irq_metrics u:object_r:sysfs_vendor_metrics:s0 +genfscon sysfs /kernel/metrics/thermal/tr_by_group/tmu/stats u:object_r:sysfs_vendor_metrics:s0 +genfscon sysfs /kernel/metrics/thermal/tr_by_group/spmic/stats u:object_r:sysfs_vendor_metrics:s0 diff --git a/pixel_ril/compatibility_matrix.xml b/pixel_ril/compatibility_matrix.xml new file mode 100644 index 0000000..edd9ecd --- /dev/null +++ b/pixel_ril/compatibility_matrix.xml @@ -0,0 +1,11 @@ + + + hardware.google.ril_ext + 1 + + IRilExt + slot1 + slot2 + + + diff --git a/pixel_ril/manifest_ril.xml b/pixel_ril/manifest_ril.xml new file mode 100644 index 0000000..a292d3f --- /dev/null +++ b/pixel_ril/manifest_ril.xml @@ -0,0 +1,6 @@ + + + hardware.google.ril_ext + IRilExt/slot1 + + diff --git a/pixel_ril/manifest_ril_ds.xml b/pixel_ril/manifest_ril_ds.xml new file mode 100644 index 0000000..ade8b26 --- /dev/null +++ b/pixel_ril/manifest_ril_ds.xml @@ -0,0 +1,7 @@ + + + hardware.google.ril_ext + IRilExt/slot1 + IRilExt/slot2 + + diff --git a/pixel_ril/ril.mk b/pixel_ril/ril.mk new file mode 100644 index 0000000..37274aa --- /dev/null +++ b/pixel_ril/ril.mk @@ -0,0 +1,18 @@ +BOARD_SEPOLICY_DIRS += device/google/gs-common/pixel_ril/sepolicy + +ifeq ($(SIM_COUNT), 2) + DEVICE_MANIFEST_FILE += device/google/gs-common/pixel_ril/manifest_ril_ds.xml +else + DEVICE_MANIFEST_FILE += device/google/gs-common/pixel_ril/manifest_ril.xml +endif +DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs-common/pixel_ril/compatibility_matrix.xml + +PRODUCT_PACKAGES += ril-extension + +PRODUCT_PACKAGES_DEBUG += libgooglerilmemmonitor + +PRODUCT_SOONG_NAMESPACES += \ + vendor/google/tools/ril-extension-service \ + vendor/google/tools/ril-mem-monitor + +USE_GOOGLE_RIL_EXT := true diff --git a/pixel_ril/sepolicy/rild.te b/pixel_ril/sepolicy/rild.te new file mode 100644 index 0000000..55bffee --- /dev/null +++ b/pixel_ril/sepolicy/rild.te @@ -0,0 +1,7 @@ +add_service(rild, hal_ril_ext_service) +binder_call(rild, rilextensionservice_app) + +# Allow rild to ptrace for memory leak detection +userdebug_or_eng(` +allow rild self:process ptrace; +') diff --git a/pixel_ril/sepolicy/rilextensionservice_app.te b/pixel_ril/sepolicy/rilextensionservice_app.te new file mode 100644 index 0000000..d315367 --- /dev/null +++ b/pixel_ril/sepolicy/rilextensionservice_app.te @@ -0,0 +1,11 @@ +type rilextensionservice_app, domain; +app_domain(rilextensionservice_app) + +allow rilextensionservice_app app_api_service:service_manager find; +allow rilextensionservice_app hal_ril_ext_service:service_manager find; +allow rilextensionservice_app radio_service:service_manager find; + +binder_call(rilextensionservice_app, rild) + +set_prop(rilextensionservice_app, vendor_rild_prop) +set_prop(rilextensionservice_app, radio_prop) diff --git a/pixel_ril/sepolicy/seapp_contexts b/pixel_ril/sepolicy/seapp_contexts new file mode 100644 index 0000000..295f5c9 --- /dev/null +++ b/pixel_ril/sepolicy/seapp_contexts @@ -0,0 +1,2 @@ +# RIL extension service +user=_app isPrivApp=true name=com.google.android.rilextension domain=rilextensionservice_app levelFrom=all diff --git a/pixel_ril/sepolicy/service.te b/pixel_ril/sepolicy/service.te new file mode 100644 index 0000000..1908206 --- /dev/null +++ b/pixel_ril/sepolicy/service.te @@ -0,0 +1 @@ +type hal_ril_ext_service, hal_service_type, service_manager_type; diff --git a/pixel_ril/sepolicy/service_contexts b/pixel_ril/sepolicy/service_contexts new file mode 100644 index 0000000..be5a8d2 --- /dev/null +++ b/pixel_ril/sepolicy/service_contexts @@ -0,0 +1,3 @@ +hardware.google.ril_ext.IRilExt/slot1 u:object_r:hal_ril_ext_service:s0 +hardware.google.ril_ext.IRilExt/slot2 u:object_r:hal_ril_ext_service:s0 +hardware.google.ril_ext.IRilExt/slot3 u:object_r:hal_ril_ext_service:s0 diff --git a/powerstats/AdaptiveDvfsStateResidencyDataProvider.cpp b/powerstats/AdaptiveDvfsStateResidencyDataProvider.cpp new file mode 100644 index 0000000..6e377aa --- /dev/null +++ b/powerstats/AdaptiveDvfsStateResidencyDataProvider.cpp @@ -0,0 +1,85 @@ +/* + * 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 "AdaptiveDvfsStateResidencyDataProvider.h" + +#include +#include +#include + +#include +#include + +using android::base::Split; +using android::base::Trim; + +static const std::string pathSuffix = "/time_in_state"; +static const std::string stateSuffix = "MHz"; + +namespace aidl { +namespace android { +namespace hardware { +namespace power { +namespace stats { + +AdaptiveDvfsStateResidencyDataProvider::AdaptiveDvfsStateResidencyDataProvider( + std::string path, + uint64_t clockRate, + std::vector> powerEntities) + : DvfsStateResidencyDataProvider(path, clockRate, {}) { + size_t len = 0; + char *line = nullptr; + std::vector> states = {}; + std::vector parts; + + for (int32_t i = 0; i < powerEntities.size(); i++) { + std::string freqPath = powerEntities[i].second + pathSuffix; + std::unique_ptr fp(fopen(freqPath.c_str(), "r"), fclose); + if (!fp) { + PLOG(ERROR) << __func__ << ":Failed to open file " << freqPath; + continue; + } + + while (getline(&line, &len, fp.get()) != -1) { + parts = Split(Trim(std::string(line)), " "); + if (parts.size() > 0) { + std::string freqStr = Trim(parts[0]); + states.push_back(std::make_pair( + freqStr.substr(0, freqStr.length() - 3) + stateSuffix, + freqStr)); + } + } + + mPowerEntities.push_back({powerEntities[i].first, std::move(states)}); + } + + free(line); +} + +bool AdaptiveDvfsStateResidencyDataProvider::getStateResidencies( + std::unordered_map> *residencies) { + return DvfsStateResidencyDataProvider::getStateResidencies(residencies); +} + +std::unordered_map> + AdaptiveDvfsStateResidencyDataProvider::getInfo() { + return DvfsStateResidencyDataProvider::getInfo(); +} + +} // namespace stats +} // namespace power +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/powerstats/CpupmStateResidencyDataProvider.cpp b/powerstats/CpupmStateResidencyDataProvider.cpp new file mode 100644 index 0000000..2adae54 --- /dev/null +++ b/powerstats/CpupmStateResidencyDataProvider.cpp @@ -0,0 +1,180 @@ +/* + * 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 +#include +#include + +#include +#include + +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, + const std::string &sleepPath, + const SleepConfig &sleepConfig) + : mPath(std::move(path)), + mConfig(std::move(config)), + mSleepPath(std::move(sleepPath)), + mSleepConfig(std::move(sleepConfig)) {} + +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 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> *residencies) { + std::unique_ptr fp(fopen(mPath.c_str(), "r"), fclose); + if (!fp) { + PLOG(ERROR) << __func__ << ":Failed to open file " << mPath; + return false; + } + + std::unique_ptr sleepFp(fopen(mSleepPath.c_str(), "r"), fclose); + if (!sleepFp) { + PLOG(ERROR) << __func__ << ":Failed to open file " << mSleepPath; + return false; + } + + for (int32_t i = 0; i < mConfig.entities.size(); i++) { + std::vector 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, sleepDurationMs = 0; + auto it = residencies->end(); + int32_t sleepIndex = 0; + + // Parse state for sleep duration + while (getline(&line, &len, sleepFp.get()) != -1) { + std::string trimedLine = Trim(std::string(line)); + if (StartsWith(trimedLine, mSleepConfig[sleepIndex])) { + if (sleepIndex < mSleepConfig.size() - 1) { + sleepIndex++; + continue; + } else { + std::vector parts = Split(trimedLine, " "); + if (parts.size() == 2) { + ParseUint(parts[1], &sleepDurationMs); + sleepDurationMs /= NS_TO_MS; + } + break; + } + } + } + + // Parse state for CPUPM entities + 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) continue; + + entityIndex = matchEntity(line); + + if (entityIndex < 0) continue; + + it = residencies->find(mConfig.entities[entityIndex].first); + if (it != residencies->end()) { + if (parseState(line, &duration, &count)) { + it->second[stateId].totalTimeInStateMs = duration / US_TO_MS + sleepDurationMs; + 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> CpupmStateResidencyDataProvider::getInfo() { + std::unordered_map> info; + for (auto const &entity : mConfig.entities) { + std::vector 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/DvfsStateResidencyDataProvider.cpp b/powerstats/DvfsStateResidencyDataProvider.cpp index 511159e..ba8bd5e 100644 --- a/powerstats/DvfsStateResidencyDataProvider.cpp +++ b/powerstats/DvfsStateResidencyDataProvider.cpp @@ -37,7 +37,7 @@ namespace stats { DvfsStateResidencyDataProvider::DvfsStateResidencyDataProvider(std::string path, uint64_t clockRate, std::vector cfgs) - : mPath(std::move(path)), mClockRate(clockRate), mPowerEntities(std::move(cfgs)) {} + : mPowerEntities(std::move(cfgs)), mPath(std::move(path)), mClockRate(clockRate) {} int32_t DvfsStateResidencyDataProvider::matchEntity(char const *line) { for (int32_t i = 0; i < mPowerEntities.size(); i++) { @@ -103,6 +103,10 @@ bool DvfsStateResidencyDataProvider::getStateResidencies( it = residencies->find(mPowerEntities[powerEntityIndex].powerEntityName + nameSuffix); } + // The given string is last state for each entity. + if (StartsWith(Trim(std::string(line)), "last_freq_change_time_ns:")) + it = residencies->end(); + if (it != residencies->end()) { stateId = matchState(line, mPowerEntities[powerEntityIndex]); diff --git a/powerstats/include/AdaptiveDvfsStateResidencyDataProvider.h b/powerstats/include/AdaptiveDvfsStateResidencyDataProvider.h new file mode 100644 index 0000000..5983f0b --- /dev/null +++ b/powerstats/include/AdaptiveDvfsStateResidencyDataProvider.h @@ -0,0 +1,55 @@ +/* + * 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 "DvfsStateResidencyDataProvider.h" + +namespace aidl { +namespace android { +namespace hardware { +namespace power { +namespace stats { + +class AdaptiveDvfsStateResidencyDataProvider : public DvfsStateResidencyDataProvider { + public: + /* + * path - path to dvfs sysfs node. + * clockRate - clock rate in KHz. + * powerEntities - list of power entity pairs (name to power entity, path to frequency table) + */ + AdaptiveDvfsStateResidencyDataProvider( + std::string path, + uint64_t clockRate, + std::vector> powerEntities); + ~AdaptiveDvfsStateResidencyDataProvider() = default; + + /* + * See IStateResidencyDataProvider::getStateResidencies + */ + bool getStateResidencies( + std::unordered_map> *residencies) override; + + /* + * See IStateResidencyDataProvider::getInfo + */ + std::unordered_map> getInfo() override; +}; + +} // 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..be8ee46 --- /dev/null +++ b/powerstats/include/CpupmStateResidencyDataProvider.h @@ -0,0 +1,80 @@ +/* + * 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 + +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> entities; + + // List of state pairs (state to display, state to parse). + std::vector> states; + }; + + typedef std::vector SleepConfig; + + /* + * path - path to cpupm sysfs node. + */ + CpupmStateResidencyDataProvider( + const std::string &path, + const Config &config, + const std::string &sleepPath, + const SleepConfig &sleepConfig); + ~CpupmStateResidencyDataProvider() = default; + + /* + * See IStateResidencyDataProvider::getStateResidencies + */ + bool getStateResidencies( + std::unordered_map> *residencies) override; + + /* + * See IStateResidencyDataProvider::getInfo + */ + std::unordered_map> 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; + // A constant to represent the number of nanoseconds in one millisecond. + const uint64_t NS_TO_MS = 1000000; + + const std::string mPath; + const Config mConfig; + const std::string mSleepPath; + const SleepConfig mSleepConfig; +}; + +} // namespace stats +} // namespace power +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/powerstats/include/DvfsStateResidencyDataProvider.h b/powerstats/include/DvfsStateResidencyDataProvider.h index ca8ab22..0aeafb7 100644 --- a/powerstats/include/DvfsStateResidencyDataProvider.h +++ b/powerstats/include/DvfsStateResidencyDataProvider.h @@ -51,6 +51,9 @@ class DvfsStateResidencyDataProvider : public PowerStats::IStateResidencyDataPro */ std::unordered_map> getInfo() override; + protected: + std::vector mPowerEntities; + private: int32_t matchEntity(char const *line); int32_t matchState(char const *line, const Config& powerEntity); @@ -58,7 +61,6 @@ class DvfsStateResidencyDataProvider : public PowerStats::IStateResidencyDataPro const std::string mPath; const uint64_t mClockRate; - std::vector mPowerEntities; }; } // namespace stats diff --git a/radio/Android.bp b/radio/Android.bp new file mode 100644 index 0000000..29b0f16 --- /dev/null +++ b/radio/Android.bp @@ -0,0 +1,20 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "dump_radio", + srcs: ["dump_radio.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libbase", + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} + diff --git a/radio/dump.mk b/radio/dump.mk new file mode 100644 index 0000000..0c4d09d --- /dev/null +++ b/radio/dump.mk @@ -0,0 +1,4 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/radio/sepolicy/ + +PRODUCT_PACKAGES_DEBUG += dump_radio + diff --git a/radio/dump_radio.cpp b/radio/dump_radio.cpp new file mode 100644 index 0000000..8d6743c --- /dev/null +++ b/radio/dump_radio.cpp @@ -0,0 +1,62 @@ +/* + * 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 +#include +#include + +#define RIL_LOG_DIRECTORY "/data/vendor/radio" +#define RIL_LOG_DIRECTORY_PROPERTY "persist.vendor.ril.log.base_dir" +#define RIL_LOG_NUMBER_PROPERTY "persist.vendor.ril.log.num_file" +#define RIL_LOG_PREFIX "rild.log." + +#define TCPDUMP_LOG_DIRECTORY "/data/vendor/tcpdump_logger/logs" +#define TCPDUMP_NUMBER_BUGREPORT "persist.vendor.tcpdump.log.br_num" +#define TCPDUMP_PERSIST_PROPERTY "persist.vendor.tcpdump.log.alwayson" +#define TCPDUMP_LOG_PREFIX "tcpdump" + +int main() { + // netmgr + bool tcpdumpEnabled = ::android::base::GetBoolProperty(TCPDUMP_PERSIST_PROPERTY, false); + + if (tcpdumpEnabled) { + dumpLogs(TCPDUMP_LOG_DIRECTORY, BUGREPORT_PACKING_DIR, ::android::base::GetIntProperty(TCPDUMP_NUMBER_BUGREPORT, 5), TCPDUMP_LOG_PREFIX); + } + copyFile("/data/vendor/radio/metrics_data", "/data/vendor/radio/logs/always-on/all_logs/metrics_data"); + copyFile("/data/vendor/radio/omadm_logs.txt", "/data/vendor/radio/logs/always-on/all_logs/omadm_logs.txt"); + copyFile("/data/vendor/radio/power_anomaly_data.txt", "/data/vendor/radio/logs/always-on/all_logs/power_anomaly_data.txt"); + + // RIL dump + std::string rilLogDir = ::android::base::GetProperty(RIL_LOG_DIRECTORY_PROPERTY, RIL_LOG_DIRECTORY); + + int maxFileNum = ::android::base::GetIntProperty(RIL_LOG_NUMBER_PROPERTY, 50); + + const std::string currentLogDir = concatenatePath(rilLogDir.c_str(), "/cur"); + const std::string previousLogDir = concatenatePath(rilLogDir.c_str(), "/prev"); + const std::string currentDestDir = concatenatePath(BUGREPORT_PACKING_DIR, "cur"); + const std::string previousDestDir = concatenatePath(BUGREPORT_PACKING_DIR, "prev"); + if (mkdir(currentDestDir.c_str(), 0777) == -1) { + printf("Unable to create folder: %s\n", currentDestDir.c_str()); + return 0; + } + if (mkdir(previousDestDir.c_str(), 0777) == -1) { + printf("Unable to create folder: %s\n", previousDestDir.c_str()); + return 0; + } + + dumpLogs(currentLogDir.c_str(), currentDestDir.c_str(), maxFileNum, RIL_LOG_PREFIX); + dumpLogs(previousLogDir.c_str(), previousDestDir.c_str(), maxFileNum, RIL_LOG_PREFIX); + return 0; +} diff --git a/radio/sepolicy/dump_radio.te b/radio/sepolicy/dump_radio.te new file mode 100644 index 0000000..7970f08 --- /dev/null +++ b/radio/sepolicy/dump_radio.te @@ -0,0 +1,10 @@ +pixel_bugreport(dump_radio) + +userdebug_or_eng(` + allow dump_radio radio_vendor_data_file:dir create_dir_perms; + allow dump_radio radio_vendor_data_file:file create_file_perms; + allow dump_radio tcpdump_vendor_data_file:dir r_dir_perms; + allow dump_radio tcpdump_vendor_data_file:file r_file_perms; + get_prop(dump_radio, vendor_rild_prop) + get_prop(dump_radio vendor_tcpdump_log_prop) +') diff --git a/radio/sepolicy/file.te b/radio/sepolicy/file.te new file mode 100644 index 0000000..02d0209 --- /dev/null +++ b/radio/sepolicy/file.te @@ -0,0 +1,6 @@ +# Data +type tcpdump_vendor_data_file, file_type, data_file_type; + +userdebug_or_eng(` + typeattribute tcpdump_vendor_data_file mlstrustedobject; +') diff --git a/radio/sepolicy/file_contexts b/radio/sepolicy/file_contexts new file mode 100644 index 0000000..20d786c --- /dev/null +++ b/radio/sepolicy/file_contexts @@ -0,0 +1,2 @@ +/vendor/bin/dump/dump_radio u:object_r:dump_radio_exec:s0 +/data/vendor/tcpdump_logger(/.*)? u:object_r:tcpdump_vendor_data_file:s0 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 +#include +#include +#include +#include + +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 <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 +#include +#include +#include +#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..e913154 --- /dev/null +++ b/soc/Android.bp @@ -0,0 +1,42 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "dump_memory.sh", + src: "dump_memory.sh", + vendor: true, + sub_dir: "dump", +} + +cc_binary { + name: "dump_devfreq", + srcs: ["dump_devfreq.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} + +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_devfreq.cpp b/soc/dump_devfreq.cpp new file mode 100644 index 0000000..5cbbb94 --- /dev/null +++ b/soc/dump_devfreq.cpp @@ -0,0 +1,29 @@ +/* + * 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 + +int main() { + dumpFileContent("MIF DVFS", "/sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/time_in_state"); + dumpFileContent("INT DVFS", "/sys/devices/platform/17000020.devfreq_int/devfreq/17000020.devfreq_int/time_in_state"); + dumpFileContent("INTCAM DVFS", "/sys/devices/platform/17000030.devfreq_intcam/devfreq/17000030.devfreq_intcam/time_in_state"); + dumpFileContent("DISP DVFS", "/sys/devices/platform/17000040.devfreq_disp/devfreq/17000040.devfreq_disp/time_in_state"); + dumpFileContent("CAM DVFS", "/sys/devices/platform/17000050.devfreq_cam/devfreq/17000050.devfreq_cam/time_in_state"); + dumpFileContent("TNR DVFS", "/sys/devices/platform/17000060.devfreq_tnr/devfreq/17000060.devfreq_tnr/time_in_state"); + dumpFileContent("MFC DVFS", "/sys/devices/platform/17000070.devfreq_mfc/devfreq/17000070.devfreq_mfc/time_in_state"); + dumpFileContent("BO DVFS", "/sys/devices/platform/17000080.devfreq_bo/devfreq/17000080.devfreq_bo/time_in_state"); + dumpFileContent("BTS stats", "/sys/devices/platform/exynos-bts/bts_stats"); + return 0; +} diff --git a/soc/dump_memory.sh b/soc/dump_memory.sh new file mode 100644 index 0000000..6135dea --- /dev/null +++ b/soc/dump_memory.sh @@ -0,0 +1,46 @@ +#!/vendor/bin/sh +echo "------ ION HEAPS ------" +for d in $(ls -d /d/ion/*) +do + if [ -f $d ]; then + echo --- $d + cat $d + else + for f in $(ls $d) + do + echo --- $d/$f + cat $d/$f + done + fi +done + +echo "------ dmabuf info ------" +cat "/d/dma_buf/bufinfo" + +echo "------ Page Pinner - longterm pin ------" +cat "/sys/kernel/debug/page_pinner/buffer" + +echo "------ CMA info ------" +for d in $(ls -d /sys/kernel/debug/cma/*) +do + echo --- $d + echo --- count; cat $d/count; + echo --- used; cat $d/used; + echo --- bitmap; cat $d/bitmap; +done + +echo "------ Pixel CMA stat ------" +for d in $(ls -d /sys/kernel/pixel_stat/mm/cma/*); do + if [ -f $d ]; then + echo --- $d + cat $d + else + for f in $(ls $d); do + echo --- $d/$f + cat $d/$f + done + fi +done + +echo "------ Pixel Trace ------" +cat "/sys/kernel/tracing/instances/pixel/trace" 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 +#include +#include +#include +#include +#include + +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 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 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/freq.mk b/soc/freq.mk new file mode 100644 index 0000000..bd79977 --- /dev/null +++ b/soc/freq.mk @@ -0,0 +1,4 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/soc/sepolicy/freq + +PRODUCT_PACKAGES += dump_devfreq + diff --git a/soc/sepolicy/freq/dump_devfreq.te b/soc/sepolicy/freq/dump_devfreq.te new file mode 100644 index 0000000..75aa325 --- /dev/null +++ b/soc/sepolicy/freq/dump_devfreq.te @@ -0,0 +1,5 @@ +pixel_bugreport(dump_devfreq) +allow dump_devfreq sysfs_cpu:file r_file_perms; +allow dump_devfreq sysfs_exynos_bts:dir r_dir_perms; +allow dump_devfreq sysfs_exynos_bts_stats:file r_file_perms; + diff --git a/soc/sepolicy/freq/file.te b/soc/sepolicy/freq/file.te new file mode 100644 index 0000000..1201d5a --- /dev/null +++ b/soc/sepolicy/freq/file.te @@ -0,0 +1,4 @@ +type sysfs_cpu, sysfs_type, fs_type; +type sysfs_exynos_bts, sysfs_type, fs_type; +type sysfs_exynos_bts_stats, sysfs_type, fs_type; + diff --git a/soc/sepolicy/freq/file_contexts b/soc/sepolicy/freq/file_contexts new file mode 100644 index 0000000..b1f5b4f --- /dev/null +++ b/soc/sepolicy/freq/file_contexts @@ -0,0 +1,2 @@ +/vendor/bin/dump/dump_devfreq u:object_r:dump_devfreq_exec:s0 + diff --git a/soc/sepolicy/freq/genfs_contexts b/soc/sepolicy/freq/genfs_contexts new file mode 100644 index 0000000..76a783d --- /dev/null +++ b/soc/sepolicy/freq/genfs_contexts @@ -0,0 +1,20 @@ +# CPU +genfscon sysfs /devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/17000020.devfreq_int/devfreq/17000020.devfreq_int/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/17000030.devfreq_intcam/devfreq/17000030.devfreq_intcam/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/17000040.devfreq_disp/devfreq/17000040.devfreq_disp/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/17000050.devfreq_cam/devfreq/17000050.devfreq_cam/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/17000060.devfreq_tnr/devfreq/17000060.devfreq_tnr/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/17000070.devfreq_mfc/devfreq/17000070.devfreq_mfc/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/17000080.devfreq_bw/devfreq/17000080.devfreq_bw/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/17000080.devfreq_bo/devfreq/17000080.devfreq_bo/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/17000090.devfreq_dsu/devfreq/17000090.devfreq_dsu/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/170000a0.devfreq_bci/devfreq/170000a0.devfreq_bci/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/1f000000.mali/time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/1f000000.mali/uid_time_in_state u:object_r:sysfs_cpu:s0 +genfscon sysfs /devices/platform/cpupm/cpupm/time_in_state u:object_r:sysfs_cpu:s0 + +# Exynos +genfscon sysfs /devices/platform/exynos-bts u:object_r:sysfs_exynos_bts:s0 +genfscon sysfs /devices/platform/exynos-bts/bts_stats u:object_r:sysfs_exynos_bts_stats:s0 + diff --git a/soc/sepolicy/soc/dump_memory.te b/soc/sepolicy/soc/dump_memory.te new file mode 100644 index 0000000..7502f3a --- /dev/null +++ b/soc/sepolicy/soc/dump_memory.te @@ -0,0 +1,14 @@ +pixel_bugreport(dump_memory) +allow dump_memory vendor_toolbox_exec:file execute_no_trans; +userdebug_or_eng(` + allow dump_memory vendor_dmabuf_debugfs:file r_file_perms; + allow dump_memory vendor_page_pinner_debugfs:dir r_dir_perms; + allow dump_memory vendor_page_pinner_debugfs:file r_file_perms; + allow dump_memory vendor_cma_debugfs:dir r_dir_perms; + allow dump_memory vendor_cma_debugfs:file r_file_perms; + allow dump_memory debugfs_tracing_instances:dir search; + allow dump_memory debugfs_tracing_instances:file r_file_perms; + allow dump_memory sysfs_pixel_stat:dir r_dir_perms; + allow dump_memory sysfs_pixel_stat:file r_file_perms; +') + diff --git a/soc/sepolicy/soc/dump_soc.te b/soc/sepolicy/soc/dump_soc.te new file mode 100644 index 0000000..b103de4 --- /dev/null +++ b/soc/sepolicy/soc/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/soc/dumpstate.te b/soc/sepolicy/soc/dumpstate.te new file mode 100644 index 0000000..1d23bb4 --- /dev/null +++ b/soc/sepolicy/soc/dumpstate.te @@ -0,0 +1,2 @@ +dontaudit dumpstate vendor_dmabuf_debugfs:file r_file_perms; + diff --git a/soc/sepolicy/soc/file.te b/soc/sepolicy/soc/file.te new file mode 100644 index 0000000..63b579d --- /dev/null +++ b/soc/sepolicy/soc/file.te @@ -0,0 +1,3 @@ +type vendor_dmabuf_debugfs, fs_type, debugfs_type; +type vendor_page_pinner_debugfs, fs_type, debugfs_type; +type vendor_cma_debugfs, fs_type, debugfs_type; diff --git a/soc/sepolicy/soc/file_contexts b/soc/sepolicy/soc/file_contexts new file mode 100644 index 0000000..23a91e5 --- /dev/null +++ b/soc/sepolicy/soc/file_contexts @@ -0,0 +1,3 @@ +/vendor/bin/dump/dump_soc u:object_r:dump_soc_exec:s0 +/vendor/bin/dump/dump_memory\.sh u:object_r:dump_memory_exec:s0 + diff --git a/soc/sepolicy/soc/genfs_contexts b/soc/sepolicy/soc/genfs_contexts new file mode 100644 index 0000000..e718bd1 --- /dev/null +++ b/soc/sepolicy/soc/genfs_contexts @@ -0,0 +1,10 @@ +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 + +genfscon debugfs /dma_buf/bufinfo u:object_r:vendor_dmabuf_debugfs:s0 +genfscon debugfs /page_pinner u:object_r:vendor_page_pinner_debugfs:s0 +genfscon debugfs /cma u:object_r:vendor_cma_debugfs:s0 diff --git a/soc/soc.mk b/soc/soc.mk new file mode 100644 index 0000000..d08d99d --- /dev/null +++ b/soc/soc.mk @@ -0,0 +1,5 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/soc/sepolicy/soc + +PRODUCT_PACKAGES += dump_soc +PRODUCT_PACKAGES_DEBUG += dump_memory.sh + 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/dumpstate.te b/storage/sepolicy/dumpstate.te new file mode 100644 index 0000000..2c01193 --- /dev/null +++ b/storage/sepolicy/dumpstate.te @@ -0,0 +1 @@ +allow dumpstate sysfs_scsi_devices_0000:file r_file_perms; \ No newline at end of file diff --git a/storage/sepolicy/fastbootd.te b/storage/sepolicy/fastbootd.te new file mode 100644 index 0000000..35bac15 --- /dev/null +++ b/storage/sepolicy/fastbootd.te @@ -0,0 +1 @@ +allow fastbootd devpts:chr_file rw_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/sepolicy/hal_health_storage_default.te b/storage/sepolicy/hal_health_storage_default.te new file mode 100644 index 0000000..af6593a --- /dev/null +++ b/storage/sepolicy/hal_health_storage_default.te @@ -0,0 +1,3 @@ +# Access to /sys/devices/platform/*ufs/* +allow hal_health_storage_default sysfs_scsi_devices_0000:dir r_dir_perms; +allow hal_health_storage_default sysfs_scsi_devices_0000:file rw_file_perms; diff --git a/storage/sepolicy/init.te b/storage/sepolicy/init.te new file mode 100644 index 0000000..7070318 --- /dev/null +++ b/storage/sepolicy/init.te @@ -0,0 +1 @@ +allow init sysfs_scsi_devices_0000:file w_file_perms; diff --git a/storage/sepolicy/vold.te b/storage/sepolicy/vold.te new file mode 100644 index 0000000..1d743b5 --- /dev/null +++ b/storage/sepolicy/vold.te @@ -0,0 +1,4 @@ +allow vold sysfs_scsi_devices_0000:file rw_file_perms; + +dontaudit vold dumpstate:fifo_file rw_file_perms; +dontaudit vold dumpstate:fd use ; diff --git a/storage/storage.mk b/storage/storage.mk new file mode 100644 index 0000000..cd0556d --- /dev/null +++ b/storage/storage.mk @@ -0,0 +1,8 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/storage/sepolicy + +PRODUCT_PACKAGES += dump_storage.sh + +# Pixel storage tool +PRODUCT_PACKAGES_DEBUG += \ + sg_write_buffer \ + sg_read_buffer 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..c066d0d --- /dev/null +++ b/touch/gti/Android.bp @@ -0,0 +1,19 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "dump_gti0.sh", + src: "dump_gti0.sh", + init_rc: ["init.touch.gti0.rc"], + vendor: true, + sub_dir: "dump", +} + +sh_binary { + name: "dump_gti1.sh", + src: "dump_gti1.sh", + init_rc: ["init.touch.gti1.rc"], + vendor: true, + sub_dir: "dump", +} diff --git a/touch/gti/dump_gti0.sh b/touch/gti/dump_gti0.sh new file mode 100644 index 0000000..40886e0 --- /dev/null +++ b/touch/gti/dump_gti0.sh @@ -0,0 +1,45 @@ +#!/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 "------ Panel ID ------" +cat $path/panel_id + +echo "------ Offload ID ------" +cat $path/offload_id + +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/dump_gti1.sh b/touch/gti/dump_gti1.sh new file mode 100644 index 0000000..79aa5fb --- /dev/null +++ b/touch/gti/dump_gti1.sh @@ -0,0 +1,45 @@ +#!/vendor/bin/sh +path="/sys/devices/virtual/goog_touch_interface/gti.1" +procfs_path="/proc/goog_touch_interface/gti.1" + +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 "------ Panel ID ------" +cat $path/panel_id + +echo "------ Offload ID ------" +cat $path/offload_id + +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..171534f --- /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_gti0.sh diff --git a/touch/gti/gti_dual.mk b/touch/gti/gti_dual.mk new file mode 100644 index 0000000..f56645d --- /dev/null +++ b/touch/gti/gti_dual.mk @@ -0,0 +1,5 @@ +include device/google/gs-common/touch/gti/gti.mk + +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/gti/sepolicy_gti_dual + +PRODUCT_PACKAGES += dump_gti1.sh diff --git a/touch/gti/init.touch.gti0.rc b/touch/gti/init.touch.gti0.rc new file mode 100644 index 0000000..5489ff8 --- /dev/null +++ b/touch/gti/init.touch.gti0.rc @@ -0,0 +1,23 @@ +on property:vendor.device.modules.ready=1 + # Sysfs + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/force_active + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/fw_ver + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/panel_id + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/offload_id + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ms_base + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ms_diff + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ms_raw + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/self_test + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ss_base + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ss_diff + chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ss_raw + + # Procfs + 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/init.touch.gti1.rc b/touch/gti/init.touch.gti1.rc new file mode 100644 index 0000000..28c8204 --- /dev/null +++ b/touch/gti/init.touch.gti1.rc @@ -0,0 +1,23 @@ +on property:vendor.device.modules.ready=1 + # Sysfs + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/force_active + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/fw_ver + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/panel_id + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/offload_id + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/ms_base + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/ms_diff + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/ms_raw + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/self_test + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/ss_base + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/ss_diff + chown system system /sys/devices/virtual/goog_touch_interface/gti.1/ss_raw + + # Procfs + chown system system /proc/goog_touch_interface + chown system system /proc/goog_touch_interface/gti.1 + chown system system /proc/goog_touch_interface/gti.1/ms_base + chown system system /proc/goog_touch_interface/gti.1/ms_diff + chown system system /proc/goog_touch_interface/gti.1/ms_raw + chown system system /proc/goog_touch_interface/gti.1/ss_base + chown system system /proc/goog_touch_interface/gti.1/ss_diff + chown system system /proc/goog_touch_interface/gti.1/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..5c429b7 --- /dev/null +++ b/touch/gti/sepolicy/file_contexts @@ -0,0 +1,2 @@ +/vendor/bin/dump/dump_gti0\.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/gti/sepolicy_gti_dual/file_contexts b/touch/gti/sepolicy_gti_dual/file_contexts new file mode 100644 index 0000000..21c4064 --- /dev/null +++ b/touch/gti/sepolicy_gti_dual/file_contexts @@ -0,0 +1,2 @@ +/vendor/bin/dump/dump_gti1\.sh u:object_r:dump_gti_exec: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/sepolicy/vendor_init.te b/touch/stm/sepolicy/vendor_init.te new file mode 100644 index 0000000..74a6666 --- /dev/null +++ b/touch/stm/sepolicy/vendor_init.te @@ -0,0 +1 @@ +set_prop(vendor_init, vendor_touch_dump_path_prop) 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/umfw_stat/Android.bp b/umfw_stat/Android.bp new file mode 100644 index 0000000..765c4be --- /dev/null +++ b/umfw_stat/Android.bp @@ -0,0 +1,36 @@ +// +// 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. +// + +// Package defs. +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +// UmfwStat dump tool binary. +cc_binary { + name: "dump_umfw_stat", + srcs: ["dump_umfw_stat.cpp"], + cflags: [ + "-Wall", + "-Werror", + "-Wextra", + ], + shared_libs: [ + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} diff --git a/umfw_stat/dump_umfw_stat.cpp b/umfw_stat/dump_umfw_stat.cpp new file mode 100644 index 0000000..63478cd --- /dev/null +++ b/umfw_stat/dump_umfw_stat.cpp @@ -0,0 +1,33 @@ +// +// 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. +// + +// +// UmfwStat dump tool. +// + +#include + +int main() { + // Set stdout to be unbuffered. + setbuf(stdout, NULL); + + // Dump AoC statistics. + // TODO(b/272300997): Add timeouts for requests. + runCommand("AoC statistics", "timeout 5 /vendor/bin/umfw_stat_tool get_all"); + + return 0; +} + diff --git a/umfw_stat/sepolicy/dump_umfw_stat.te b/umfw_stat/sepolicy/dump_umfw_stat.te new file mode 100644 index 0000000..dac2d25 --- /dev/null +++ b/umfw_stat/sepolicy/dump_umfw_stat.te @@ -0,0 +1,27 @@ +# +# 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. +# + +# +# UmfwStat dump tool type enforcing file. +# + +pixel_bugreport(dump_umfw_stat) +allow dump_umfw_stat aoc_device:chr_file rw_file_perms; +allow dump_umfw_stat device:dir r_dir_perms; +allow dump_umfw_stat vendor_shell_exec:file execute_no_trans; +allow dump_umfw_stat vendor_umfw_stat_tool:file execute_no_trans; +allow dump_umfw_stat vendor_toolbox_exec:file execute_no_trans; + diff --git a/umfw_stat/sepolicy/file.te b/umfw_stat/sepolicy/file.te new file mode 100644 index 0000000..239ce5a --- /dev/null +++ b/umfw_stat/sepolicy/file.te @@ -0,0 +1,21 @@ +# +# 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. +# + +# +# UmfwStat type enforcing file. +# + +type vendor_umfw_stat_tool, vendor_file_type, file_type; diff --git a/umfw_stat/sepolicy/file_contexts b/umfw_stat/sepolicy/file_contexts new file mode 100644 index 0000000..876ba67 --- /dev/null +++ b/umfw_stat/sepolicy/file_contexts @@ -0,0 +1,22 @@ +# +# 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. +# + +# +# UmfwStat security contexts. +# + +/vendor/bin/dump/dump_umfw_stat u:object_r:dump_umfw_stat_exec:s0 +/vendor/bin/umfw_stat_tool u:object_r:vendor_umfw_stat_tool:s0 diff --git a/umfw_stat/umfw_stat.mk b/umfw_stat/umfw_stat.mk new file mode 100644 index 0000000..102e63f --- /dev/null +++ b/umfw_stat/umfw_stat.mk @@ -0,0 +1,27 @@ +# +# 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. +# + +# +# UmfwStat product makefile. +# + +# Add UmfwStat product packages. +PRODUCT_PACKAGES += dump_umfw_stat +PRODUCT_PACKAGES += umfw_stat_tool + +# Add UmfwStat SELinx policy. +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/umfw_stat/sepolicy + diff --git a/widevine/widevine.mk b/widevine/widevine.mk new file mode 100644 index 0000000..c59c7b9 --- /dev/null +++ b/widevine/widevine.mk @@ -0,0 +1,4 @@ +PRODUCT_PACKAGES += \ + android.hardware.drm-service.clearkey \ + +-include vendor/widevine/libwvdrmengine/apex/device/device.mk \ No newline at end of file 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 @@ + + + vendor.google.wireless_charger + 1 + + IWirelessCharger + default + + + 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 diff --git a/wlan/Android.bp b/wlan/Android.bp new file mode 100644 index 0000000..d8103e5 --- /dev/null +++ b/wlan/Android.bp @@ -0,0 +1,18 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "dump_wlan", + srcs: ["dump_wlan.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} diff --git a/wlan/dump.mk b/wlan/dump.mk new file mode 100644 index 0000000..1d90d22 --- /dev/null +++ b/wlan/dump.mk @@ -0,0 +1,4 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/wlan/sepolicy/ + +PRODUCT_PACKAGES_DEBUG += dump_wlan + diff --git a/wlan/dump_wlan.cpp b/wlan/dump_wlan.cpp new file mode 100644 index 0000000..86d3fc7 --- /dev/null +++ b/wlan/dump_wlan.cpp @@ -0,0 +1,27 @@ +/* + * Copyright 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 +#include + +int main() { + //This line is required to avoid output out of order + //setbuf(stdout, NULL); + dumpFileContent("WLAN FW Log Symbol Table", "/vendor/firmware/Data.msc"); + //runCommand("WLAN TWT Dump", "cat /sys/wlan_ptracker/twt/*"); + return 0; +} + diff --git a/wlan/sepolicy/dump_wlan.te b/wlan/sepolicy/dump_wlan.te new file mode 100644 index 0000000..983d71c --- /dev/null +++ b/wlan/sepolicy/dump_wlan.te @@ -0,0 +1,4 @@ + +pixel_bugreport(dump_wlan) + + diff --git a/wlan/sepolicy/file_contexts b/wlan/sepolicy/file_contexts new file mode 100644 index 0000000..318a610 --- /dev/null +++ b/wlan/sepolicy/file_contexts @@ -0,0 +1,3 @@ + +/vendor/bin/dump/dump_wlan u:object_r:dump_wlan_exec:s0 +