diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-05-10 16:05:46 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-05-10 16:05:46 +0000 |
commit | b43ebdfa1baeca142807fdfd52efe3615deca8aa (patch) | |
tree | dbcb8cc4cc34f3dbb2a858552f3a337d550581ed | |
parent | c6796e0d865c0aff0fc0c34a7048704428b82dc5 (diff) | |
parent | 544960691a3a4b70e3d2ad69487ff8b3fd4dd251 (diff) | |
download | gs201-b43ebdfa1baeca142807fdfd52efe3615deca8aa.tar.gz |
Snap for 10103804 from 544960691a3a4b70e3d2ad69487ff8b3fd4dd251 to mainline-tzdata5-release
Change-Id: Iaf35868cccb192963ac95fb3fca8e34164b4e3d8
28 files changed, 682 insertions, 1280 deletions
diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk index 222b996..92dab88 100644 --- a/BoardConfig-common.mk +++ b/BoardConfig-common.mk @@ -124,9 +124,6 @@ BOARD_USES_GRALLOC_ION_SYNC := true # This should be the same value as USE_SWIFTSHADER in device.mk BOARD_USES_SWIFTSHADER := false -# This should be the same value as USE_ANGLE in device.mk -BOARD_USES_ANGLE := false - # Gralloc4 ifeq ($(BOARD_USES_SWIFTSHADER),true) $(call soong_config_set,arm_gralloc,gralloc_arm_no_external_afbc,true) @@ -154,6 +151,10 @@ BOARD_AVB_VBMETA_SYSTEM_ALGORITHM := SHA256_RSA2048 BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP) BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION := 1 +ifneq ($(PRODUCT_BUILD_PVMFW_IMAGE),false) +BOARD_AVB_VBMETA_SYSTEM += pvmfw +endif + # Enable chained vbmeta for boot images BOARD_AVB_BOOT_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem BOARD_AVB_BOOT_ALGORITHM := SHA256_RSA2048 @@ -251,8 +252,9 @@ endif # SoundTriggerHAL Configuration #BOARD_USE_SOUNDTRIGGER_HAL := false -# Vibrator HAL actuator model configuration +# Vibrator HAL actuator model and adaptive haptics configuration $(call soong_config_set,haptics,actuator_model,$(ACTUATOR_MODEL)) +$(call soong_config_set,haptics,adaptive_haptics_feature,$(ADAPTIVE_HAPTICS_FEATURE)) # HWComposer BOARD_HWC_VERSION := hwc3 @@ -0,0 +1,2 @@ +# per-file for Pixel device makefiles, see go/pixel-device-mk-owner-checklist for details. +per-file *.mk=file:device/google/gs-common:master:/OWNERS diff --git a/conf/init.debug.rc b/conf/init.debug.rc index 4d5e4c7..d609d7e 100644 --- a/conf/init.debug.rc +++ b/conf/init.debug.rc @@ -41,3 +41,8 @@ on property:ro.revision=PROTO1.1 setprop debug.hypervisor.metrics_tag "hwrev_a0" on property:ro.revision=EVT1.0 setprop debug.hypervisor.metrics_tag "hwrev_a0" + +# Enable etm/etm2dram when ramdump is enabled. +on property:ro.boot.ramdump=enabled + write /sys/devices/platform/exynos-etm/etm_on 1 + write /sys/devices/platform/etm2dram/arm 1 diff --git a/conf/init.gs201.rc b/conf/init.gs201.rc index f66ed07..828c699 100644 --- a/conf/init.gs201.rc +++ b/conf/init.gs201.rc @@ -132,7 +132,7 @@ on init symlink /data/app /factory # Apply network parameters for high data performance. - write /proc/sys/net/core/rmem_default 327680 + write /proc/sys/net/core/rmem_default 1310720 write /proc/sys/net/core/rmem_max 8388608 write /proc/sys/net/core/wmem_default 327680 write /proc/sys/net/core/wmem_max 8388608 @@ -283,6 +283,9 @@ on init # Charging policy chown system system /sys/class/power_supply/battery/charging_policy + # BatteryHealthData + chown system system /sys/class/power_supply/battery/first_usage_date + # Battery Defender chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_cnt chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_dry_run @@ -339,6 +342,9 @@ on init write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/mem_latency/ratio_ceil 3200 write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/mem_latency/ratio_ceil 3200 + # Set boost_adpf_prio, -1 by default + write /proc/vendor_sched/boost_adpf_prio ${persist.device_config.vendor_system_native_boot.boost_adpf_prio:--1} + on late-fs # Start bootanimation class before mount start bootanim @@ -713,7 +719,7 @@ on property:sys.boot_completed=1 # Setup final cpuset write /dev/cpuset/top-app/cpus ${persist.device_config.vendor_system_native.top-app_cpuset:-0-7} write /dev/cpuset/foreground/cpus ${persist.device_config.vendor_system_native.foreground_cpuset:-0-3,4-5} - write /dev/cpuset/background/cpus ${persist.device_config.vendor_system_native.background_cpuset:-0-1} + write /dev/cpuset/background/cpus ${persist.device_config.vendor_system_native.background_cpuset:-0-3} write /dev/cpuset/system-background/cpus ${persist.device_config.vendor_system_native.system-background_cpuset:-0-3} write /dev/cpuset/restricted/cpus ${persist.device_config.vendor_system_native.restricted_cpuset:-0-3} write /dev/cpuset/camera-daemon/cpus ${persist.device_config.vendor_system_native.camera-daemon_cpuset:-0-7} @@ -723,15 +729,17 @@ on property:sys.boot_completed=1 write /proc/vendor_sched/ta_uclamp_min 1 write /proc/vendor_sched/fg_uclamp_min 0 write /proc/vendor_sched/sys_prefer_idle 0 - # cfs_rq clamp is using tg->uclamp setting - # align it with the vendor_group setting - write /proc/vendor_sched/bg_uclamp_max 512 - write /dev/cpuctl/background/cpu.uclamp.max 50 - write /proc/vendor_sched/sysbg_uclamp_max 512 - write /dev/cpuctl/system-background/cpu.uclamp.max 50 - write /proc/vendor_sched/dex2oat_uclamp_max 615 - write /dev/cpuctl/dex2oat/cpu.uclamp.max 60 - write /proc/vendor_sched/ota_uclamp_max 410 + + # Set ug group + write /proc/vendor_sched/bg_ug 0 + write /proc/vendor_sched/sys_ug 0 + write /proc/vendor_sched/ota_ug 0 + write /proc/vendor_sched/dex2oat_ug 1 + + # Set bg group throttle + write /proc/vendor_sched/ug_bg_group_throttle 308 + # TODO: remove this one after all kernel prebuilts are merged + write /proc/vendor_sched/vug_bg_group_throttle 308 # Set PMU freq limit parameters write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/lcpi_threshold 2 @@ -1049,7 +1057,7 @@ on property:persist.device_config.vendor_system_native.top-app_cpuset=* on property:persist.device_config.vendor_system_native.foreground_cpuset=* write /dev/cpuset/foreground/cpus ${persist.device_config.vendor_system_native.foreground_cpuset:-0-3,4-5} on property:persist.device_config.vendor_system_native.background_cpuset=* - write /dev/cpuset/background/cpus ${persist.device_config.vendor_system_native.background_cpuset:-0-1} + write /dev/cpuset/background/cpus ${persist.device_config.vendor_system_native.background_cpuset:-0-3} on property:persist.device_config.vendor_system_native.system-background_cpuset=* write /dev/cpuset/system-background/cpus ${persist.device_config.vendor_system_native.system-background_cpuset:-0-3} on property:persist.device_config.vendor_system_native.restricted_cpuset=* diff --git a/conf/init.modem.rc b/conf/init.modem.rc index 96ed067..6c89e3b 100644 --- a/conf/init.modem.rc +++ b/conf/init.modem.rc @@ -16,6 +16,9 @@ on post-fs-data # Modem MDS log folder mkdir /data/vendor/radio/mds 0771 radio system + # Modem OTA UECap folder + mkdir /data/vendor/radio/ota_uecap 0773 radio system + # Unzipped modem images folder mkdir /data/vendor/radio/image 0771 radio system @@ -18,11 +18,21 @@ include device/google/gs-common/device.mk include device/google/gs-common/gs_watchdogd/watchdog.mk include device/google/gs-common/ramdump/ramdump.mk include device/google/gs-common/soc/soc.mk +include device/google/gs-common/soc/freq.mk include device/google/gs-common/modem/modem.mk include device/google/gs-common/aoc/aoc.mk include device/google/gs-common/thermal/thermal.mk include device/google/gs-common/pixel_metrics/pixel_metrics.mk include device/google/gs-common/performance/perf.mk +include device/google/gs-common/display/dump.mk +include device/google/gs-common/camera/dump.mk +include device/google/gs-common/gxp/dump.mk +include device/google/gs-common/gps/dump/log.mk +include device/google/gs-common/radio/dump.mk +include device/google/gs-common/umfw_stat/umfw_stat.mk +include device/google/gs-common/gear/dumpstate/aidl.mk +include device/google/gs-common/widevine/widevine.mk + TARGET_BOARD_PLATFORM := gs201 AB_OTA_POSTINSTALL_CONFIG += \ @@ -201,9 +211,6 @@ USES_GAUDIO := true # Must match BOARD_USES_SWIFTSHADER in BoardConfig.mk USE_SWIFTSHADER := false -# by default, USE_ANGLE is false -USE_ANGLE ?= false - # HWUI TARGET_USES_VULKAN = true @@ -224,6 +231,15 @@ PRODUCT_PACKAGES += \ PRODUCT_VENDOR_PROPERTIES += \ ro.hardware.vulkan=mali +# Mali Configuration Properties +# b/221255664 prevents setting PROTECTED_MAX_CORE_COUNT=2 +PRODUCT_VENDOR_PROPERTIES += \ + vendor.mali.platform.config=/vendor/etc/mali/platform.config \ + vendor.mali.debug.config=/vendor/etc/mali/debug.config \ + vendor.mali.base_protected_max_core_count=1 \ + vendor.mali.base_protected_tls_max=67108864 \ + vendor.mali.platform_agt_frequency_khz=24576 + ifeq ($(USE_SWIFTSHADER),true) PRODUCT_PACKAGES += \ libGLESv1_CM_swiftshader \ @@ -231,13 +247,6 @@ PRODUCT_PACKAGES += \ libGLESv2_swiftshader endif -ifeq ($(USE_ANGLE),true) -PRODUCT_PACKAGES += \ - libEGL_angle \ - libGLESv1_CM_angle \ - libGLESv2_angle -endif - PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.opengles.aep.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.opengles.aep.xml \ frameworks/native/data/etc/android.hardware.vulkan.version-1_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \ @@ -249,10 +258,6 @@ PRODUCT_COPY_FILES += \ ifeq ($(USE_SWIFTSHADER),true) PRODUCT_VENDOR_PROPERTIES += \ ro.hardware.egl = swiftshader -else ifeq ($(USE_ANGLE),true) -PRODUCT_VENDOR_PROPERTIES += \ - ro.hardware.egl = angle \ - ro.hardware.egl_legacy = mali else PRODUCT_VENDOR_PROPERTIES += \ ro.hardware.egl = mali @@ -266,7 +271,7 @@ PRODUCT_VENDOR_PROPERTIES += \ PRODUCT_VENDOR_PROPERTIES += \ ro.opengles.version=196610 \ graphics.gpu.profiler.support=true \ - debug.renderengine.backend=skiaglthreaded \ + debug.renderengine.backend=skiaglthreaded # GRAPHICS - GPU (end) # #################### @@ -456,9 +461,6 @@ include hardware/google/pixel/rebalance_interrupts/rebalance_interrupts.mk PRODUCT_PACKAGES += \ android.hardware.power.stats-service.pixel -# dumpstate HAL -PRODUCT_PACKAGES += \ - android.hardware.dumpstate-service.gs201 # # Audio HALs # @@ -811,8 +813,10 @@ $(call inherit-product, system/core/trusty/trusty-base.mk) include device/google/gs-common/trusty/trusty.mk # Trusty unit test tool -PRODUCT_PACKAGES_DEBUG += trusty-ut-ctrl \ - tipc-test +PRODUCT_PACKAGES_DEBUG += \ + trusty-ut-ctrl \ + tipc-test \ + trusty_stats_test \ include device/google/gs101/confirmationui/confirmationui.mk @@ -821,11 +825,11 @@ PRODUCT_PACKAGES += \ securedpud.slider # Trusty Metrics Daemon -#PRODUCT_SOONG_NAMESPACES += \ -# vendor/google/trusty/common -# -#PRODUCT_PACKAGES += \ -# trusty_metricsd +PRODUCT_SOONG_NAMESPACES += \ + vendor/google/trusty/common + +PRODUCT_PACKAGES += \ + trusty_metricsd $(call soong_config_set,google_displaycolor,displaycolor_platform,gs201) PRODUCT_PACKAGES += \ @@ -1015,63 +1019,7 @@ PRODUCT_PACKAGES += \ # Audio # 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) -# libaoc_waves \ -# - -##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 - -##Audio soong -PRODUCT_SOONG_NAMESPACES += \ - vendor/google/whitechapel/audio/hal \ - vendor/google/whitechapel/audio/interfaces - -$(call soong_config_set,aoc_audio_board,platform,$(TARGET_BOARD_PLATFORM)) +include device/google/gs-common/audio/hidl_gs201.mk ## AoC soong PRODUCT_SOONG_NAMESPACES += \ @@ -1193,6 +1141,7 @@ include hardware/google/pixel/wifi_ext/device.mk # Battery Stats Viewer PRODUCT_PACKAGES_DEBUG += BatteryStatsViewer +PRODUCT_PACKAGES += dump_power_gs201.sh # Install product specific framework compatibility matrix # (TODO: b/169535506) This includes the FCM for system_ext and product partition. @@ -1217,3 +1166,6 @@ PRODUCT_VENDOR_PROPERTIES += ro.crypto.metadata_init_delete_all_keys.enabled?=tr # Hardware Info include hardware/google/pixel/HardwareInfo/HardwareInfo.mk + +# UFS: the script is used to select the corresponding firmware to run FFU. +PRODUCT_PACKAGES += ufs_firmware_update.sh diff --git a/device_framework_matrix_product.xml b/device_framework_matrix_product.xml index d48ceba..70b2274 100644 --- a/device_framework_matrix_product.xml +++ b/device_framework_matrix_product.xml @@ -9,7 +9,7 @@ </hal> <hal format="aidl"> <name>android.hardware.graphics.composer3</name> - <version>1</version> + <version>2</version> <interface> <name>IComposer</name> <instance>default</instance> @@ -87,6 +87,10 @@ <name>IDebugHost</name> <instance>default</instance> </interface> + <interface> + <name>IDebugManager</name> + <instance>default</instance> + </interface> </hal> <hal format="aidl" optional="true"> <name>com.google.edgetpu</name> @@ -114,6 +118,7 @@ </hal> <hal format="aidl" optional="true"> <name>com.google.input</name> + <version>2</version> <interface> <name>ITouchContextService</name> <instance>default</instance> @@ -151,14 +156,6 @@ <instance>default</instance> </interface> </hal> - <hal format="hidl"> - <name>vendor.google.whitechapel.audio.audioext</name> - <version>4.0</version> - <interface> - <name>IAudioExt</name> - <instance>default</instance> - </interface> - </hal> <hal format="aidl" optional="true"> <name>vendor.google.wifi_ext</name> <version>1</version> @@ -185,12 +182,4 @@ <instance>rilExternal</instance> </interface> </hal> - <hal format="hidl"> - <name>vendor.google.audiometricext</name> - <version>1.0</version> - <interface> - <name>IAudioMetricExt</name> - <instance>default</instance> - </interface> - </hal> </compatibility-matrix> diff --git a/dumpstate/Android.bp b/dumpstate/Android.bp index 85cdc25..a325151 100644 --- a/dumpstate/Android.bp +++ b/dumpstate/Android.bp @@ -2,27 +2,9 @@ package { default_applicable_licenses: ["Android-Apache-2.0"], } -cc_binary { - name: "android.hardware.dumpstate-service.gs201", - srcs: [ - "Dumpstate.cpp", - "service.cpp", - ], - init_rc: ["android.hardware.dumpstate@1.1-service.gs201.rc"], - vintf_fragments: ["android.hardware.dumpstate-service.gs201.xml"], - cflags: [ - "-Wall", - "-Werror", - ], - shared_libs: [ - "libbase", - "libbinder_ndk", - "libcutils", - "libdumpstateutil", - "liblog", - "libutils", - "android.hardware.dumpstate-V1-ndk", - ], +sh_binary { + name: "dump_power_gs201.sh", + src: "dump_power_gs201.sh", vendor: true, - relative_install_path: "hw", + sub_dir: "dump", } diff --git a/dumpstate/Dumpstate.cpp b/dumpstate/Dumpstate.cpp deleted file mode 100644 index 58a2828..0000000 --- a/dumpstate/Dumpstate.cpp +++ /dev/null @@ -1,811 +0,0 @@ -/* - * 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 <inttypes.h> - -#include <android-base/file.h> -#include <android-base/stringprintf.h> -#include <android-base/properties.h> -#include <android-base/unique_fd.h> -#include <cutils/trace.h> -#include <log/log.h> -#include <sys/stat.h> - -#include "Dumpstate.h" - -#include "DumpstateUtil.h" - -#define MODEM_LOG_DIRECTORY "/data/vendor/radio/logs/always-on" -#define MODEM_LOG_HISTORY_DIRECTORY "data/vendor/radio/logs/history" -#define MODEM_EXTENDED_LOG_DIRECTORY "/data/vendor/radio/extended_logs" -#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 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 GPS_LOG_DIRECTORY "/data/vendor/gps/logs" -#define GPS_LOG_NUMBER_PROPERTY "persist.vendor.gps.aol.log_num" -#define GPS_LOGGING_STATUS_PROPERTY "vendor.gps.aol.enabled" - -#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" - -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 { - -#define GPS_LOG_PREFIX "gl-" -#define GPS_MCU_LOG_PREFIX "esw-" -#define MODEM_LOG_PREFIX "sbuff_" -#define EXTENDED_LOG_PREFIX "extended_log_" -#define RIL_LOG_PREFIX "rild.log." -#define BUFSIZE 65536 -#define TCPDUMP_LOG_PREFIX "tcpdump" - -typedef std::chrono::time_point<std::chrono::steady_clock> timepoint_t; - -const char kVerboseLoggingProperty[] = "persist.vendor.verbose_logging_enabled"; - -void Dumpstate::dumpLogs(int fd, std::string srcDir, std::string destDir, int maxFileNum, - const char *logPrefix) { - struct dirent **dirent_list = NULL; - int num_entries = scandir(srcDir.c_str(), - &dirent_list, - 0, - (int (*)(const struct dirent **, const struct dirent **)) alphasort); - if (!dirent_list) { - return; - } else if (num_entries <= 0) { - return; - } - - int copiedFiles = 0; - - for (int i = num_entries - 1; i >= 0; i--) { - ALOGD("Found %s\n", dirent_list[i]->d_name); - - if (0 != strncmp(dirent_list[i]->d_name, logPrefix, strlen(logPrefix))) { - continue; - } - - if ((copiedFiles >= maxFileNum) && (maxFileNum != -1)) { - ALOGD("Skipped %s\n", dirent_list[i]->d_name); - continue; - } - - copiedFiles++; - - CommandOptions options = CommandOptions::WithTimeout(120).Build(); - std::string srcLogFile = srcDir + "/" + dirent_list[i]->d_name; - std::string destLogFile = destDir + "/" + dirent_list[i]->d_name; - - std::string copyCmd = "/vendor/bin/cp " + srcLogFile + " " + destLogFile; - - ALOGD("Copying %s to %s\n", srcLogFile.c_str(), destLogFile.c_str()); - RunCommandToFd(fd, "CP LOGS", { "/vendor/bin/sh", "-c", copyCmd.c_str() }, options); - } - - while (num_entries--) { - free(dirent_list[num_entries]); - } - - free(dirent_list); -} - -void Dumpstate::dumpRilLogs(int fd, std::string destDir) { - 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 = rilLogDir + "/cur"; - const std::string previousLogDir = rilLogDir + "/prev"; - const std::string currentDestDir = destDir + "/cur"; - const std::string previousDestDir = destDir + "/prev"; - - RunCommandToFd(fd, "MKDIR RIL CUR LOG", {"/vendor/bin/mkdir", "-p", currentDestDir.c_str()}, - CommandOptions::WithTimeout(2).Build()); - RunCommandToFd(fd, "MKDIR RIL PREV LOG", {"/vendor/bin/mkdir", "-p", previousDestDir.c_str()}, - CommandOptions::WithTimeout(2).Build()); - - dumpLogs(fd, currentLogDir, currentDestDir, maxFileNum, RIL_LOG_PREFIX); - dumpLogs(fd, previousLogDir, previousDestDir, maxFileNum, RIL_LOG_PREFIX); -} - -void copyFile(std::string srcFile, std::string destFile) { - uint8_t buffer[BUFSIZE]; - ssize_t size; - - int fdSrc = open(srcFile.c_str(), O_RDONLY); - if (fdSrc < 0) { - ALOGD("Failed to open source file %s\n", srcFile.c_str()); - return; - } - - int fdDest = open(destFile.c_str(), O_WRONLY | O_CREAT, 0666); - if (fdDest < 0) { - ALOGD("Failed to open destination file %s\n", destFile.c_str()); - close(fdSrc); - return; - } - - ALOGD("Copying %s to %s\n", srcFile.c_str(), destFile.c_str()); - while ((size = TEMP_FAILURE_RETRY(read(fdSrc, buffer, BUFSIZE))) > 0) { - TEMP_FAILURE_RETRY(write(fdDest, buffer, size)); - } - - close(fdDest); - close(fdSrc); -} - -void dumpNetmgrLogs(std::string destDir) { - const std::vector <std::string> netmgrLogs - { - "/data/vendor/radio/metrics_data", - "/data/vendor/radio/omadm_logs.txt", - "/data/vendor/radio/power_anomaly_data.txt", - }; - for (const auto& logFile : netmgrLogs) { - copyFile(logFile, destDir + "/" + basename(logFile.c_str())); - } -} - -/** Dumps last synced NV data into bugreports */ -void dumpModemEFS(std::string destDir) { - const std::string EFS_DIRECTORY = "/mnt/vendor/efs/"; - const std::vector <std::string> nv_files - { - EFS_DIRECTORY+"nv_normal.bin", - EFS_DIRECTORY+"nv_protected.bin", - }; - for (const auto& logFile : nv_files) { - copyFile(logFile, destDir + "/" + basename(logFile.c_str())); - } -} - -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<std::chrono::milliseconds> - (endTime - startTime).count(); - - ::android::base::WriteStringToFd( - "\n" - "------ Section end: " + sectionName + " ------\n" - "Elapsed msec: " + std::to_string(elapsedMsec) + "\n" - "\n", fd); -} - -Dumpstate::Dumpstate() - : mTextSections{ - { "wlan", [this](int fd) { dumpWlanSection(fd); } }, - { "memory", [this](int fd) { dumpMemorySection(fd); } }, - { "Devfreq", [this](int fd) { dumpDevfreqSection(fd); } }, - { "power", [this](int fd) { dumpPowerSection(fd); } }, - { "display", [this](int fd) { dumpDisplaySection(fd); } }, - { "pixel-trace", [this](int fd) { dumpPixelTraceSection(fd); } }, - }, - mLogSections{ - { "modem", [this](int fd, const std::string &destDir) { dumpModemLogs(fd, destDir); } }, - { "radio", [this](int fd, const std::string &destDir) { dumpRadioLogs(fd, destDir); } }, - { "camera", [this](int fd, const std::string &destDir) { dumpCameraLogs(fd, destDir); } }, - { "gps", [this](int fd, const std::string &destDir) { dumpGpsLogs(fd, destDir); } }, - { "gxp", [this](int fd, const std::string &destDir) { dumpGxpLogs(fd, destDir); } }, - } { -} - -// 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; - - for (const auto §ion : mTextSections) { - if (dumpAll || sectionName == section.first) { - auto startTime = startSection(fd, section.first); - section.second(fd); - endSection(fd, section.first, startTime); - - if (!dumpAll) { - return; - } - } - } - - // Execute all or designated programs under vendor/bin/dump/ - std::unique_ptr<DIR, decltype(&closedir)> 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}); - 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); - for (const auto §ion : mTextSections) { - ::android::base::WriteStringToFd(" " + section.first, fd); - } - ::android::base::WriteStringToFd(dumpFiles, fd); - ::android::base::WriteStringToFd("\nNote: sections with attachments (e.g. modem) are" - "not avalable from the command line.\n", fd); -} - -// Dump items related to wlan -void Dumpstate::dumpWlanSection(int fd) { - // Dump firmware symbol table for firmware log decryption - DumpFileToFd(fd, "WLAN FW Log Symbol Table", "/vendor/firmware/Data.msc"); - RunCommandToFd(fd, "WLAN TWT Dump", {"/vendor/bin/sh", "-c", - "cat /sys/wlan_ptracker/twt/*"}); -} - -// Dump items related to power and battery -void Dumpstate::dumpPowerSection(int fd) { - struct stat buffer; - - RunCommandToFd(fd, "Power Stats Times", {"/vendor/bin/sh", "-c", - "echo -n \"Boot: \" && /vendor/bin/uptime -s && " - "echo -n \"Now: \" && date"}); - - RunCommandToFd(fd, "ACPM stats", {"/vendor/bin/sh", "-c", - "for f in /sys/devices/platform/acpm_stats/*_stats ; do " - "echo \"\\n\\n$f\" ; cat $f ; " - "done"}); - - DumpFileToFd(fd, "CPU PM stats", "/sys/devices/system/cpu/cpupm/cpupm/time_in_state"); - - DumpFileToFd(fd, "GENPD summary", "/d/pm_genpd/pm_genpd_summary"); - - DumpFileToFd(fd, "Power supply property battery", "/sys/class/power_supply/battery/uevent"); - DumpFileToFd(fd, "Power supply property dc", "/sys/class/power_supply/dc/uevent"); - DumpFileToFd(fd, "Power supply property gcpm", "/sys/class/power_supply/gcpm/uevent"); - DumpFileToFd(fd, "Power supply property gcpm_pps", "/sys/class/power_supply/gcpm_pps/uevent"); - DumpFileToFd(fd, "Power supply property main-charger", "/sys/class/power_supply/main-charger/uevent"); - if (!stat("/sys/class/power_supply/pca9468-mains/uevent", &buffer)) { - DumpFileToFd(fd, "Power supply property pca9468-mains", "/sys/class/power_supply/pca9468-mains/uevent"); - } else { - DumpFileToFd(fd, "Power supply property pca94xx-mains", "/sys/class/power_supply/pca94xx-mains/uevent"); - } - DumpFileToFd(fd, "Power supply property tcpm", "/sys/class/power_supply/tcpm-source-psy-i2c-max77759tcpc/uevent"); - DumpFileToFd(fd, "Power supply property usb", "/sys/class/power_supply/usb/uevent"); - DumpFileToFd(fd, "Power supply property wireless", "/sys/class/power_supply/wireless/uevent"); - if (!stat("/sys/class/power_supply/maxfg", &buffer)) { - DumpFileToFd(fd, "Power supply property maxfg", "/sys/class/power_supply/maxfg/uevent"); - DumpFileToFd(fd, "m5_state", "/sys/class/power_supply/maxfg/m5_model_state"); - DumpFileToFd(fd, "maxfg", "/dev/logbuffer_maxfg"); - DumpFileToFd(fd, "maxfg", "/dev/logbuffer_maxfg_monitor"); - } else { - DumpFileToFd(fd, "Power supply property maxfg_base", "/sys/class/power_supply/maxfg_base/uevent"); - DumpFileToFd(fd, "Power supply property maxfg_secondary", "/sys/class/power_supply/maxfg_secondary/uevent"); - DumpFileToFd(fd, "m5_state", "/sys/class/power_supply/maxfg_base/m5_model_state"); - DumpFileToFd(fd, "maxfg_base", "/dev/logbuffer_maxfg_base"); - DumpFileToFd(fd, "maxfg_secondary", "/dev/logbuffer_maxfg_secondary"); - DumpFileToFd(fd, "maxfg_base", "/dev/logbuffer_maxfg_base_monitor"); - DumpFileToFd(fd, "maxfg_secondary", "/dev/logbuffer_maxfg_secondary_monitor"); - DumpFileToFd(fd, "google_dual_batt", "/dev/logbuffer_dual_batt"); - } - - if (!stat("/dev/maxfg_history", &buffer)) { - DumpFileToFd(fd, "Maxim FG History", "/dev/maxfg_history"); - } - - if (!stat("/sys/class/power_supply/dock", &buffer)) { - DumpFileToFd(fd, "Power supply property dock", "/sys/class/power_supply/dock/uevent"); - } - - if (!stat("/dev/logbuffer_tcpm", &buffer)) { - DumpFileToFd(fd, "Logbuffer TCPM", "/dev/logbuffer_tcpm"); - } else if (!PropertiesHelper::IsUserBuild()) { - if (!stat("/sys/kernel/debug/tcpm", &buffer)) { - RunCommandToFd(fd, "TCPM logs", {"/vendor/bin/sh", "-c", "cat /sys/kernel/debug/tcpm/*"}); - } else { - RunCommandToFd(fd, "TCPM logs", {"/vendor/bin/sh", "-c", "cat /sys/kernel/debug/usb/tcpm*"}); - } - } - - RunCommandToFd(fd, "TCPC", {"/vendor/bin/sh", "-c", - "for f in /sys/devices/platform/10d60000.hsi2c/i2c-*/i2c-max77759tcpc;" - "do echo \"registers:\"; cat $f/registers;" - "echo \"frs:\"; cat $f/frs;" - "echo \"auto_discharge:\"; cat $f/auto_discharge;" - "echo \"bc12_enabled:\"; cat $f/bc12_enabled;" - "echo \"cc_toggle_enable:\"; cat $f/cc_toggle_enable;" - "echo \"contaminant_detection:\"; cat $f/contaminant_detection;" - "echo \"contaminant_detection_status:\"; cat $f/contaminant_detection_status; done"}); - - DumpFileToFd(fd, "PD Engine", "/dev/logbuffer_usbpd"); - DumpFileToFd(fd, "POGO Transport", "/dev/logbuffer_pogo_transport"); - DumpFileToFd(fd, "PPS-google_cpm", "/dev/logbuffer_cpm"); - DumpFileToFd(fd, "PPS-dc", "/dev/logbuffer_pca9468"); - - DumpFileToFd(fd, "Battery Health", "/sys/class/power_supply/battery/health_index_stats"); - DumpFileToFd(fd, "BMS", "/dev/logbuffer_ssoc"); - DumpFileToFd(fd, "TTF", "/dev/logbuffer_ttf"); - DumpFileToFd(fd, "TTF details", "/sys/class/power_supply/battery/ttf_details"); - DumpFileToFd(fd, "TTF stats", "/sys/class/power_supply/battery/ttf_stats"); - DumpFileToFd(fd, "aacr_state", "/sys/class/power_supply/battery/aacr_state"); - DumpFileToFd(fd, "maxq", "/dev/logbuffer_maxq"); - DumpFileToFd(fd, "TEMP/DOCK-DEFEND", "/dev/logbuffer_bd"); - - RunCommandToFd(fd, "TRICKLE-DEFEND Config", {"/vendor/bin/sh", "-c", - " cd /sys/devices/platform/google,battery/power_supply/battery/;" - " for f in `ls bd_*` ; do echo \"$f: `cat $f`\" ; done"}); - - RunCommandToFd(fd, "DWELL-DEFEND Config", {"/vendor/bin/sh", "-c", - " cd /sys/devices/platform/google,charger/;" - " for f in `ls charge_s*` ; do echo \"$f: `cat $f`\" ; done"}); - - RunCommandToFd(fd, "TEMP-DEFEND Config", {"/vendor/bin/sh", "-c", - " cd /sys/devices/platform/google,charger/;" - " for f in `ls bd_*` ; do echo \"$f: `cat $f`\" ; done"}); - - if (!PropertiesHelper::IsUserBuild()) { - DumpFileToFd(fd, "DC_registers dump", "/sys/class/power_supply/pca94xx-mains/device/registers_dump"); - DumpFileToFd(fd, "max77759_chg registers dump", "/d/max77759_chg/registers"); - DumpFileToFd(fd, "max77729_pmic registers dump", "/d/max77729_pmic/registers"); - DumpFileToFd(fd, "Charging table dump", "/d/google_battery/chg_raw_profile"); - - RunCommandToFd(fd, "fg_model", {"/vendor/bin/sh", "-c", - "for f in /d/maxfg* ; do " - "regs=`cat $f/fg_model`; echo $f: ;" - "echo \"$regs\"; done"}); - - RunCommandToFd(fd, "fg_alo_ver", {"/vendor/bin/sh", "-c", - "for f in /d/maxfg* ; do " - "regs=`cat $f/algo_ver`; echo $f: ;" - "echo \"$regs\"; done"}); - - RunCommandToFd(fd, "fg_model_ok", {"/vendor/bin/sh", "-c", - "for f in /d/maxfg* ; do " - "regs=`cat $f/model_ok`; echo $f: ;" - "echo \"$regs\"; done"}); - - /* FG Registers */ - RunCommandToFd(fd, "fg registers", {"/vendor/bin/sh", "-c", - "for f in /d/maxfg* ; do " - "regs=`cat $f/registers`; echo $f: ;" - "echo \"$regs\"; done"}); - - RunCommandToFd(fd, "Maxim FG NV RAM", {"/vendor/bin/sh", "-c", - "for f in /d/maxfg* ; do " - "regs=`cat $f/nv_registers`; echo $f: ;" - "echo \"$regs\"; done"}); - } - - /* EEPROM State */ - if (!stat("/sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom", &buffer)) { - RunCommandToFd(fd, "Battery EEPROM", {"/vendor/bin/sh", "-c", "xxd /sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom"}); - } else if (!stat("/sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom", &buffer)) { - RunCommandToFd(fd, "Battery EEPROM", {"/vendor/bin/sh", "-c", "xxd /sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom"}); - } else if (!stat("/sys/devices/platform/10da0000.hsi2c/i2c-5/5-0050/eeprom", &buffer)) { - RunCommandToFd(fd, "Battery EEPROM", {"/vendor/bin/sh", "-c", "xxd /sys/devices/platform/10da0000.hsi2c/i2c-5/5-0050/eeprom"}); - } else if (!stat("/sys/devices/platform/10da0000.hsi2c/i2c-6/6-0050/eeprom", &buffer)) { - RunCommandToFd(fd, "Battery EEPROM", {"/vendor/bin/sh", "-c", "xxd /sys/devices/platform/10da0000.hsi2c/i2c-6/6-0050/eeprom"}); - } else if (!stat("/sys/devices/platform/10da0000.hsi2c/i2c-7/7-0050/eeprom", &buffer)) { - RunCommandToFd(fd, "Battery EEPROM", {"/vendor/bin/sh", "-c", "xxd /sys/devices/platform/10da0000.hsi2c/i2c-7/7-0050/eeprom"}); - } - - DumpFileToFd(fd, "Charger Stats", "/sys/class/power_supply/battery/charge_details"); - if (!PropertiesHelper::IsUserBuild()) { - RunCommandToFd(fd, "Google Charger", {"/vendor/bin/sh", "-c", "cd /sys/kernel/debug/google_charger/; " - "for f in `ls pps_*` ; do echo \"$f: `cat $f`\" ; done"}); - RunCommandToFd(fd, "Google Battery", {"/vendor/bin/sh", "-c", "cd /sys/kernel/debug/google_battery/; " - "for f in `ls ssoc_*` ; do echo \"$f: `cat $f`\" ; done"}); - } - - DumpFileToFd(fd, "WLC logs", "/dev/logbuffer_wireless"); - DumpFileToFd(fd, "WLC VER", "/sys/class/power_supply/wireless/device/version"); - DumpFileToFd(fd, "WLC STATUS", "/sys/class/power_supply/wireless/device/status"); - DumpFileToFd(fd, "WLC FW Version", "/sys/class/power_supply/wireless/device/fw_rev"); - DumpFileToFd(fd, "RTX", "/dev/logbuffer_rtx"); - - if (!PropertiesHelper::IsUserBuild()) { - RunCommandToFd(fd, "gvotables", {"/vendor/bin/sh", "-c", "cat /sys/kernel/debug/gvotables/*/status"}); - } - DumpFileToFd(fd, "Lastmeal", "/data/vendor/mitigation/lastmeal.txt"); - DumpFileToFd(fd, "Thismeal", "/data/vendor/mitigation/thismeal.txt"); - RunCommandToFd(fd, "Mitigation Stats", {"/vendor/bin/sh", "-c", "echo \"Source\\t\\tCount\\tSOC\\tTime\\tVoltage\"; " - "for f in `ls /sys/devices/virtual/pmic/mitigation/last_triggered_count/*` ; " - "do count=`cat $f`; " - "a=${f/\\/sys\\/devices\\/virtual\\/pmic\\/mitigation\\/last_triggered_count\\//}; " - "b=${f/last_triggered_count/last_triggered_capacity}; " - "c=${f/last_triggered_count/last_triggered_timestamp/}; " - "d=${f/last_triggered_count/last_triggered_voltage/}; " - "cnt=`cat $f`; " - "cap=`cat ${b/count/cap}`; " - "ti=`cat ${c/count/time}`; " - "volt=`cat ${d/count/volt}`; " - "echo \"${a/_count/} " - "\\t$cnt\\t$cap\\t$ti\\t$volt\" ; done"}); - RunCommandToFd(fd, "Clock Divider Ratio", {"/vendor/bin/sh", "-c", "echo \"Source\\t\\tRatio\"; " - "for f in `ls /sys/devices/virtual/pmic/mitigation/clock_ratio/*` ; " - "do ratio=`cat $f`; " - "a=${f/\\/sys\\/devices\\/virtual\\/pmic\\/mitigation\\/clock_ratio\\//}; " - "echo \"${a/_ratio/} \\t$ratio\" ; done"}); - RunCommandToFd(fd, "Clock Stats", {"/vendor/bin/sh", "-c", "echo \"Source\\t\\tStats\"; " - "for f in `ls /sys/devices/virtual/pmic/mitigation/clock_stats/*` ; " - "do stats=`cat $f`; " - "a=${f/\\/sys\\/devices\\/virtual\\/pmic\\/mitigation\\/clock_stats\\//}; " - "echo \"${a/_stats/} \\t$stats\" ; done"}); - RunCommandToFd(fd, "Triggered Level", {"/vendor/bin/sh", "-c", "echo \"Source\\t\\tLevel\"; " - "for f in `ls /sys/devices/virtual/pmic/mitigation/triggered_lvl/*` ; " - "do lvl=`cat $f`; " - "a=${f/\\/sys\\/devices\\/virtual\\/pmic\\/mitigation\\/triggered_lvl\\//}; " - "echo \"${a/_lvl/} \\t$lvl\" ; done"}); - RunCommandToFd(fd, "Instruction", {"/vendor/bin/sh", "-c", - "for f in `ls /sys/devices/virtual/pmic/mitigation/instruction/*` ; " - "do val=`cat $f` ; " - "a=${f/\\/sys\\/devices\\/virtual\\/pmic\\/mitigation\\/instruction\\//}; " - "echo \"$a=$val\" ; done"}); - -} - -// Dump items related to Devfreq & BTS -void Dumpstate::dumpDevfreqSection(int fd) { - DumpFileToFd(fd, "MIF DVFS", - "/sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/time_in_state"); - DumpFileToFd(fd, "INT DVFS", - "/sys/devices/platform/17000020.devfreq_int/devfreq/17000020.devfreq_int/time_in_state"); - DumpFileToFd(fd, "INTCAM DVFS", - "/sys/devices/platform/17000030.devfreq_intcam/devfreq/17000030.devfreq_intcam/time_in_state"); - DumpFileToFd(fd, "DISP DVFS", - "/sys/devices/platform/17000040.devfreq_disp/devfreq/17000040.devfreq_disp/time_in_state"); - DumpFileToFd(fd, "CAM DVFS", - "/sys/devices/platform/17000050.devfreq_cam/devfreq/17000050.devfreq_cam/time_in_state"); - DumpFileToFd(fd, "TNR DVFS", - "/sys/devices/platform/17000060.devfreq_tnr/devfreq/17000060.devfreq_tnr/time_in_state"); - DumpFileToFd(fd, "MFC DVFS", - "/sys/devices/platform/17000070.devfreq_mfc/devfreq/17000070.devfreq_mfc/time_in_state"); - DumpFileToFd(fd, "BO DVFS", - "/sys/devices/platform/17000080.devfreq_bo/devfreq/17000080.devfreq_bo/time_in_state"); - DumpFileToFd(fd, "BTS stats", "/sys/devices/platform/exynos-bts/bts_stats"); -} - -// Dump items related to memory -void Dumpstate::dumpMemorySection(int fd) { - RunCommandToFd(fd, "CMA info", {"/vendor/bin/sh", "-c", - "for d in $(ls -d /d/cma/*); do " - "echo --- $d;" - "echo --- count; cat $d/count; " - "echo --- used; cat $d/used; " - "echo --- bitmap; cat $d/bitmap; " - "done"}); -} - -// Dump items related to display -void Dumpstate::dumpDisplaySection(int fd) { - // Dump counters for decon drivers - const std::string decon_device_sysfs_path("/sys/class/drm/card0/device/"); - for(int i = 0; i <= 2; ++i){ - const std::string decon_num_str = std::to_string(i); - const std::string decon_counter_path = decon_device_sysfs_path + - "decon" + decon_num_str + - "/counters"; - if (access(decon_counter_path.c_str(), R_OK) == 0){ - DumpFileToFd(fd, "DECON-" + decon_num_str + " counters", - decon_counter_path); - } - else{ - ::android::base::WriteStringToFd("No counters for DECON-" + - decon_num_str + " found at path (" + decon_counter_path + ")\n", - fd); - } - } - DumpFileToFd(fd, "CRTC-0 event log", "/sys/kernel/debug/dri/0/crtc-0/event"); - DumpFileToFd(fd, "CRTC-1 event log", "/sys/kernel/debug/dri/0/crtc-1/event"); - RunCommandToFd(fd, "libdisplaycolor", {"/vendor/bin/dumpsys", "displaycolor", "-v"}, - CommandOptions::WithTimeout(2).Build()); - DumpFileToFd(fd, "Primary panel name", "/sys/devices/platform/exynos-drm/primary-panel/panel_name"); - DumpFileToFd(fd, "Primary panel extra info", "/sys/devices/platform/exynos-drm/primary-panel/panel_extinfo"); - DumpFileToFd(fd, "Secondary panel name", "/sys/devices/platform/exynos-drm/secondary-panel/panel_name"); - DumpFileToFd(fd, "Secondary panel extra info", "/sys/devices/platform/exynos-drm/secondary-panel/panel_extinfo"); - if (!PropertiesHelper::IsUserBuild()) { - RunCommandToFd(fd, "HWC Fence States", {"/vendor/bin/sh", "-c", - "for f in $(ls /data/vendor/log/hwc/*_hwc_fence_state*.txt); do " - "echo $f ; cat $f ; done"}, - CommandOptions::WithTimeout(2).Build()); - RunCommandToFd(fd, "HWC Error Logs", {"/vendor/bin/sh", "-c", - "for f in $(ls /data/vendor/log/hwc/*_hwc_error_log*.txt); do " - "echo $f ; cat $f ; done"}, - CommandOptions::WithTimeout(2).Build()); - RunCommandToFd(fd, "HWC Debug Dumps", {"/vendor/bin/sh", "-c", - "for f in $(ls /data/vendor/log/hwc/*_hwc_debug*.dump); do " - "echo $f ; cat $f ; done"}, - CommandOptions::WithTimeout(2).Build()); - } -} - -void Dumpstate::dumpModemLogs(int fd, const std::string &destDir) { - std::string extendedLogDir = MODEM_EXTENDED_LOG_DIRECTORY; - std::string modemLogHistoryDir = MODEM_LOG_HISTORY_DIRECTORY; - - dumpLogs(fd, extendedLogDir, destDir, 20, EXTENDED_LOG_PREFIX); - dumpLogs(fd, modemLogHistoryDir, destDir, 2, "Logging"); - dumpModemEFS(destDir); -} - -void Dumpstate::dumpRadioLogs(int fd, const std::string &destDir) { - std::string tcpdumpLogDir = TCPDUMP_LOG_DIRECTORY; - bool tcpdumpEnabled = ::android::base::GetBoolProperty(TCPDUMP_PERSIST_PROPERTY, false); - - if (tcpdumpEnabled) { - dumpLogs(fd, tcpdumpLogDir, destDir, ::android::base::GetIntProperty(TCPDUMP_NUMBER_BUGREPORT, 5), TCPDUMP_LOG_PREFIX); - } - dumpRilLogs(fd, destDir); - dumpNetmgrLogs(destDir); -} - -void Dumpstate::dumpGpsLogs(int fd, const std::string &destDir) { - bool gpsLogEnabled = ::android::base::GetBoolProperty(GPS_LOGGING_STATUS_PROPERTY, false); - if (!gpsLogEnabled) { - ALOGD("gps logging is not running\n"); - return; - } - const std::string gpsLogDir = GPS_LOG_DIRECTORY; - const std::string gpsTmpLogDir = gpsLogDir + "/.tmp"; - const std::string gpsDestDir = destDir + "/gps"; - - int maxFileNum = ::android::base::GetIntProperty(GPS_LOG_NUMBER_PROPERTY, 20); - - RunCommandToFd(fd, "MKDIR GPS LOG", {"/vendor/bin/mkdir", "-p", gpsDestDir.c_str()}, - CommandOptions::WithTimeout(2).Build()); - - dumpLogs(fd, gpsTmpLogDir, gpsDestDir, 1, GPS_LOG_PREFIX); - dumpLogs(fd, gpsLogDir, gpsDestDir, 3, GPS_MCU_LOG_PREFIX); - dumpLogs(fd, gpsLogDir, gpsDestDir, maxFileNum, GPS_LOG_PREFIX); -} - -void Dumpstate::dumpCameraLogs(int fd, const std::string &destDir) { - bool cameraLogsEnabled = ::android::base::GetBoolProperty( - "vendor.camera.debug.camera_performance_analyzer.attach_to_bugreport", true); - if (!cameraLogsEnabled) { - return; - } - - static const std::string kCameraLogDir = "/data/vendor/camera/profiler"; - const std::string cameraDestDir = destDir + "/camera"; - - RunCommandToFd(fd, "MKDIR CAMERA LOG", {"/vendor/bin/mkdir", "-p", cameraDestDir.c_str()}, - CommandOptions::WithTimeout(2).Build()); - // Attach multiple latest sessions (in case the user is running concurrent - // sessions or starts a new session after the one with performance issues). - dumpLogs(fd, kCameraLogDir, cameraDestDir, 10, "session-ended-"); - dumpLogs(fd, kCameraLogDir, cameraDestDir, 5, "high-drop-rate-"); - dumpLogs(fd, kCameraLogDir, cameraDestDir, 5, "watchdog-"); - dumpLogs(fd, kCameraLogDir, cameraDestDir, 5, "camera-ended-"); -} - -void Dumpstate::dumpGxpLogs(int fd, const std::string &destDir) { - bool gxpDumpEnabled = ::android::base::GetBoolProperty("vendor.gxp.attach_to_bugreport", false); - - if (gxpDumpEnabled) { - const int maxGxpDebugDumps = 8; - const std::string gxpCoredumpOutputDir = destDir + "/gxp_ssrdump"; - const std::string gxpCoredumpInputDir = "/data/vendor/ssrdump"; - - RunCommandToFd(fd, "MKDIR GXP COREDUMP", {"/vendor/bin/mkdir", "-p", gxpCoredumpOutputDir}, CommandOptions::WithTimeout(2).Build()); - - // Copy GXP coredumps and crashinfo to the output directory. - dumpLogs(fd, gxpCoredumpInputDir + "/coredump", gxpCoredumpOutputDir, maxGxpDebugDumps, "coredump_gxp_platform"); - dumpLogs(fd, gxpCoredumpInputDir, gxpCoredumpOutputDir, maxGxpDebugDumps, "crashinfo_gxp_platform"); - } -} - -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()); - - static const std::string sectionName = "modem DM log"; - auto startTime = startSection(fd, sectionName); - 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(fd, logDir, logAllDir, maxFileNum, MODEM_LOG_PREFIX); - - if (modemLogStarted) { - ALOGD("Restarting modem logging...\n"); - ::android::base::SetProperty(MODEM_LOGGING_PROPERTY, "true"); - } - } - endSection(fd, sectionName, startTime); - - // Dump all module logs - if (!PropertiesHelper::IsUserBuild()) { - for (const auto §ion : mLogSections) { - auto startTime = startSection(fd, section.first); - section.second(fd, logAllDir); - endSection(fd, section.first, startTime); - } - } - - 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<uint8_t> 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 %ld bytes, actually written: %ld", 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()); -} - -void Dumpstate::dumpPixelTraceSection(int fd) { - DumpFileToFd(fd, "Pixel trace", "/sys/kernel/tracing/instances/pixel/trace"); -} - -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_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_mode == IDumpstateDevice::DumpstateMode::WEAR) { - // We aren't a Wear device. - ALOGE("Unsupported mode: %d\n", in_mode); - return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(ERROR_UNSUPPORTED_MODE, - "Unsupported mode"); - } else 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() < 2) { - ALOGE("no FD for dumpstate_board binary\n"); - } else { - int fd_bin = in_fds[1].get(); - dumpLogSection(fd, fd_bin); - } - - dumpTextSection(fd, kAllSections); - - 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<std::string>(args[0])); - - fsync(fd); - return STATUS_OK; -} - -} // namespace dumpstate -} // namespace hardware -} // namespace android -} // namespace aidl diff --git a/dumpstate/Dumpstate.h b/dumpstate/Dumpstate.h deleted file mode 100644 index a91ef13..0000000 --- a/dumpstate/Dumpstate.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 <aidl/android/hardware/dumpstate/BnDumpstateDevice.h> -#include <aidl/android/hardware/dumpstate/IDumpstateDevice.h> -#include <android/binder_status.h> - -namespace aidl { -namespace android { -namespace hardware { -namespace dumpstate { - -class Dumpstate : public BnDumpstateDevice { - public: - Dumpstate(); - - ::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"; - - std::vector<std::pair<std::string, std::function<void(int)>>> mTextSections; - std::vector<std::pair<std::string, std::function<void(int, const std::string &)>>> mLogSections; - - void dumpLogs(int fd, std::string srcDir, std::string destDir, int maxFileNum, - const char *logPrefix); - - void dumpTextSection(int fd, std::string const& sectionName); - - // Text sections that can be dumped individually on the command line in - // addition to being included in full dumps - void dumpWlanSection(int fd); - void dumpPowerSection(int fd); - void dumpDevfreqSection(int fd); - void dumpMemorySection(int fd); - void dumpDisplaySection(int fd); - void dumpPixelTraceSection(int fd); - - void dumpLogSection(int fd, int fdModem); - - // Log sections to be dumped individually into dumpstate_board.bin - void dumpModemLogs(int fd, const std::string &destDir); - void dumpRadioLogs(int fd, const std::string &destDir); - void dumpCameraLogs(int fd, const std::string &destDir); - void dumpGpsLogs(int fd, const std::string &destDir); - void dumpGxpLogs(int fd, const std::string &destDir); - - // Hybrid and binary sections that require an additional file descriptor - void dumpRilLogs(int fd, std::string destDir); - - //bool getVerboseLoggingEnabledImpl(); - //::ndk::ScopedAStatus dumpstateBoardImpl(const int fd, const bool full); -}; - -} // namespace dumpstate -} // namespace hardware -} // namespace android -} // namespace aidl diff --git a/dumpstate/android.hardware.dumpstate-service.gs201.xml b/dumpstate/android.hardware.dumpstate-service.gs201.xml deleted file mode 100644 index 5e51b28..0000000 --- a/dumpstate/android.hardware.dumpstate-service.gs201.xml +++ /dev/null @@ -1,9 +0,0 @@ -<manifest version="1.0" type="device"> - <hal format="aidl"> - <name>android.hardware.dumpstate</name> - <interface> - <name>IDumpstateDevice</name> - <instance>default</instance> - </interface> - </hal> -</manifest> diff --git a/dumpstate/android.hardware.dumpstate@1.1-service.gs201.rc b/dumpstate/android.hardware.dumpstate@1.1-service.gs201.rc deleted file mode 100644 index f2452dc..0000000 --- a/dumpstate/android.hardware.dumpstate@1.1-service.gs201.rc +++ /dev/null @@ -1,5 +0,0 @@ -service vendor.dumpstate-default /vendor/bin/hw/android.hardware.dumpstate-service.gs201 - class hal - user system - group system shell - interface aidl android.hardware.dumpstate.IDumpstateDevice/default diff --git a/dumpstate/dump_power_gs201.sh b/dumpstate/dump_power_gs201.sh new file mode 100644 index 0000000..63875bf --- /dev/null +++ b/dumpstate/dump_power_gs201.sh @@ -0,0 +1,334 @@ +#!/vendor/bin/sh +build_type="$(getprop ro.build.type)" + +echo "\n------ Power Stats Times ------" +echo -n "Boot: " && /vendor/bin/uptime -s && echo -n "Now: " && date; + +echo "\n------ ACPM stats ------" +for f in /sys/devices/platform/acpm_stats/*_stats ; do + echo "\n\n$f" + cat $f +done + +echo "\n------ CPU PM stats ------" +cat "/sys/devices/system/cpu/cpupm/cpupm/time_in_state" + +echo "\n------ GENPD summary ------" +cat "/d/pm_genpd/pm_genpd_summary" + +echo "\n------ Power supply property battery ------" +cat "/sys/class/power_supply/battery/uevent" +echo "\n------ Power supply property dc ------" +cat "/sys/class/power_supply/dc/uevent" +echo "\n------ Power supply property gcpm ------" +cat "/sys/class/power_supply/gcpm/uevent" +echo "\n------ Power supply property gcpm_pps ------" +cat "/sys/class/power_supply/gcpm_pps/uevent" +echo "\n------ Power supply property main-charger ------" +cat "/sys/class/power_supply/main-charger/uevent" + +if [ -d "/sys/class/power_supply/pca9468-mains/uevent" ] +then + echo "\n------ Power supply property pca9468-mains ------" + cat "/sys/class/power_supply/pca9468-mains/uevent" +else + echo "\n------ Power supply property pca94xx-mains ------" + cat "/sys/class/power_supply/pca94xx-mains/uevent" +fi + +echo "\n------ Power supply property tcpm ------" +cat "/sys/class/power_supply/tcpm-source-psy-8-0025/uevent" +echo "\n------ Power supply property usb ------" +cat "/sys/class/power_supply/usb/uevent" +echo "\n------ Power supply property wireless ------" +cat "/sys/class/power_supply/wireless/uevent" + +if [ -d "/sys/class/power_supply/maxfg" ] +then + echo "\n------ Power supply property maxfg ------" + cat "/sys/class/power_supply/maxfg/uevent" + echo "\n------ m5_state ------" + cat "/sys/class/power_supply/maxfg/m5_model_state" + echo "\n------ maxfg ------" + cat "/dev/logbuffer_maxfg" + echo "\n------ maxfg ------" + cat "/dev/logbuffer_maxfg_monitor" +else + echo "\n------ Power supply property maxfg_base ------" + cat "/sys/class/power_supply/maxfg_base/uevent" + echo "\n------ Power supply property maxfg_secondary ------" + cat "/sys/class/power_supply/maxfg_secondary/uevent" + echo "\n------ m5_state ------" + cat "/sys/class/power_supply/maxfg_base/m5_model_state" + echo "\n------ maxfg_base ------" + cat "/dev/logbuffer_maxfg_base" + echo "\n------ maxfg_secondary ------" + cat "/dev/logbuffer_maxfg_secondary" + echo "\n------ maxfg_base ------" + cat "/dev/logbuffer_maxfg_base_monitor" + echo "\n------ maxfg_secondary ------" + cat "/dev/logbuffer_maxfg_secondary_monitor" + echo "\n------ google_dual_batt ------" + cat "/dev/logbuffer_dual_batt" +fi + +if [ -e "/dev/maxfg_history" ] +then + echo "\n------ Maxim FG History ------" + cat "/dev/maxfg_history" +fi + +if [ -d "/sys/class/power_supply/dock" ] +then + echo "\n------ Power supply property dock ------" + cat "/sys/class/power_supply/dock/uevent" +fi + +if [ -e "/dev/logbuffer_tcpm" ] +then + echo "\n------ Logbuffer TCPM ------" + cat "/dev/logbuffer_tcpm" +elif [ $build_type = "userdebug" ] +then + echo "\n------ TCPM logs ------" + if [ -d "/sys/kernel/debug/tcpm" ] + then + cat /sys/kernel/debug/tcpm/* + else + cat /sys/kernel/debug/usb/tcpm* + fi +fi + +echo "\n------ TCPC ------" +for f in /sys/devices/platform/10d60000.hsi2c/i2c-*/i2c-max77759tcpc +do + echo "registers:" + cat $f/registers + echo "frs:" + cat $f/frs + echo "auto_discharge:" + cat $f/auto_discharge + echo "bc12_enabled:" + cat $f/bc12_enabled + echo "cc_toggle_enable:" + cat $f/cc_toggle_enable + echo "contaminant_detection:" + cat $f/contaminant_detection + echo "contaminant_detection_status:" + cat $f/contaminant_detection_status +done + +echo "\n------ PD Engine ------" +cat "/dev/logbuffer_usbpd" +echo "\nPOGO Transport" +cat "/dev/logbuffer_pogo_transport" +echo "\n------ PPS-google_cpm ------" +cat "/dev/logbuffer_cpm" +echo "\n------ PPS-dc ------" +cat "/dev/logbuffer_pca9468" + +echo "\n------ Battery Health ------" +cat "/sys/class/power_supply/battery/health_index_stats" +echo "\n------ BMS ------" +cat "/dev/logbuffer_ssoc" +echo "\n------ TTF ------" +cat "/dev/logbuffer_ttf" +echo "\n------ TTF details ------" +cat "/sys/class/power_supply/battery/ttf_details" +echo "\n------ TTF stats ------" +cat "/sys/class/power_supply/battery/ttf_stats" +echo "\n------ aacr_state ------" +cat "/sys/class/power_supply/battery/aacr_state" +echo "\n------ maxq ------" +cat "/dev/logbuffer_maxq" +echo "\n------ TEMP/DOCK-DEFEND ------" +cat "/dev/logbuffer_bd" + +echo "\n------ TRICKLE-DEFEND Config ------" +cd /sys/devices/platform/google,battery/power_supply/battery/ +for f in `ls bd_*` +do + echo $f: `cat $f` +done + +echo "\n------ DWELL-DEFEND Config ------" +cd /sys/devices/platform/google,charger/ +for f in `ls charge_s*` +do + echo "$f: `cat $f`" +done + +echo "\n------ TEMP-DEFEND Config ------" +cd /sys/devices/platform/google,charger/ +for f in `ls bd_*` +do + echo "$f: `cat $f`" +done + +if [ $build_type = "userdebug" ] +then + echo "\n------ DC_registers dump ------" + cat "/sys/class/power_supply/pca94xx-mains/device/registers_dump" + echo "\n------ max77759_chg registers dump ------" + cat "/d/max77759_chg/registers" + echo "\n------ max77729_pmic registers dump ------" + cat "/d/max77729_pmic/registers" + echo "\n------ Charging table dump ------" + cat "/d/google_battery/chg_raw_profile" + + echo "\n------ fg_model ------" + for f in /d/maxfg* + do + regs=`cat $f/fg_model` + echo $f: + echo "$regs" + done + + echo "\n------ fg_alo_ver ------" + for f in /d/maxfg* + do + regs=`cat $f/algo_ver` + echo $f: + echo "$regs" + done + + echo "\n------ fg_model_ok ------" + for f in /d/maxfg* + do + regs=`cat $f/model_ok` + echo $f: + echo "$regs" + done + + echo "\n------ fg registers ------" + for f in /d/maxfg* + do + regs=`cat $f/registers` + echo $f: + echo "$regs" + done + + echo "\n------ Maxim FG NV RAM ------" + for f in /d/maxfg* + do + regs=`cat $f/nv_registers` + echo $f: + echo "$regs" + done +fi + +echo "\n------ Battery EEPROM ------" +if [ -e "/sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom" ] +then + xxd /sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom +fi + +if [ -e "/sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom" ] +then + xxd /sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom +fi + +if [ -e "/sys/devices/platform/10da0000.hsi2c/i2c-5/5-0050/eeprom" ] +then + xxd /sys/devices/platform/10da0000.hsi2c/i2c-5/5-0050/eeprom +fi + +if [ -e "/sys/devices/platform/10da0000.hsi2c/i2c-6/6-0050/eeprom" ] +then + xxd /sys/devices/platform/10da0000.hsi2c/i2c-6/6-0050/eeprom +fi + +if [ -e "/sys/devices/platform/10da0000.hsi2c/i2c-7/7-0050/eeprom" ] +then + xxd /sys/devices/platform/10da0000.hsi2c/i2c-7/7-0050/eeprom +fi + +echo "\n------ Charger Stats ------" +cat "/sys/class/power_supply/battery/charge_details" +if [ $build_type = "userdebug" ] +then + echo "\n------ Google Charger ------" + cd /sys/kernel/debug/google_charger/ + for f in `ls pps_*` + do + echo "$f: `cat $f`" + done + echo "\n------ Google Battery ------" + cd /sys/kernel/debug/google_battery/ + for f in `ls ssoc_*` + do + echo "$f: `cat $f`" + done +fi + +echo "\n------ WLC logs ------" +cat "/dev/logbuffer_wireless" +echo "\n------ WLC VER ------" +cat "/sys/class/power_supply/wireless/device/version" +echo "\n------ WLC STATUS ------" +cat "/sys/class/power_supply/wireless/device/status" +echo "\n------ WLC FW Version ------" +cat "/sys/class/power_supply/wireless/device/fw_rev" +echo "\n------ RTX ------" +cat "/dev/logbuffer_rtx" + +if [ $build_type = "userdebug" ] +then + echo "\n------ gvotables ------" + cat /sys/kernel/debug/gvotables/*/status +fi + +echo "\n------ Lastmeal ------" +cat "/data/vendor/mitigation/lastmeal.txt" +echo "\n------ Thismeal ------" +cat "/data/vendor/mitigation/thismeal.txt" +echo "\n------ Mitigation Stats ------" +echo "Source\t\tCount\tSOC\tTime\tVoltage" +for f in `ls /sys/devices/virtual/pmic/mitigation/last_triggered_count/*` +do + count=`cat $f` + a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/last_triggered_count\//} + b=${f/last_triggered_count/last_triggered_capacity} + c=${f/last_triggered_count/last_triggered_timestamp/} + d=${f/last_triggered_count/last_triggered_voltage/} + cnt=`cat $f` + cap=`cat ${b/count/cap}` + ti=`cat ${c/count/time}` + volt=`cat ${d/count/volt}` + echo "${a/_count/} \t$cnt\t$cap\t$ti\t$volt" +done + +echo "\n------ Clock Divider Ratio ------" +echo \"Source\t\tRatio\" +for f in `ls /sys/devices/virtual/pmic/mitigation/clock_ratio/*` +do ratio=`cat $f` + a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/clock_ratio\//} + echo "${a/_ratio/} \t$ratio" +done + +echo "\n------ Clock Stats ------" +echo "Source\t\tStats" +for f in `ls /sys/devices/virtual/pmic/mitigation/clock_stats/*` +do + stats=`cat $f` + a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/clock_stats\//}; + echo "${a/_stats/} \t$stats" +done + +echo "\n------ Triggered Level ------" +echo "Source\t\tLevel" +for f in `ls /sys/devices/virtual/pmic/mitigation/triggered_lvl/*` +do + lvl=`cat $f` + a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/triggered_lvl\//} + echo "${a/_lvl/} \t$lvl" +done + +echo "\n------ Instruction ------" +for f in `ls /sys/devices/virtual/pmic/mitigation/instruction/*` +do + val=`cat $f` + a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/instruction\//} + echo "$a=$val" +done + diff --git a/dumpstate/service.cpp b/dumpstate/service.cpp deleted file mode 100644 index 9b4e0fb..0000000 --- a/dumpstate/service.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.gs201" - -#include "Dumpstate.h" - -#include <android-base/logging.h> -#include <android/binder_manager.h> -#include <android/binder_process.h> - -using aidl::android::hardware::dumpstate::Dumpstate; - -int main() { - ABinderProcess_setThreadPoolMaxThreadCount(0); - std::shared_ptr<Dumpstate> dumpstate = ndk::SharedRefBase::make<Dumpstate>(); - - 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/manifest-gralloc3.xml b/manifest-gralloc3.xml index 9ecea75..196d1ac 100644 --- a/manifest-gralloc3.xml +++ b/manifest-gralloc3.xml @@ -1,31 +1,4 @@ <manifest version="1.0" type="device" target-level="7"> - <hal format="hidl"> - <name>android.hardware.audio</name> - <transport>hwbinder</transport> - <version>7.1</version> - <interface> - <name>IDevicesFactory</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>android.hardware.audio.effect</name> - <transport>hwbinder</transport> - <version>7.0</version> - <interface> - <name>IEffectsFactory</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>android.hardware.soundtrigger</name> - <transport>hwbinder</transport> - <version>2.3</version> - <interface> - <name>ISoundTriggerHw</name> - <instance>default</instance> - </interface> - </hal> <hal format="hidl"> <name>android.hardware.graphics.allocator</name> <transport>hwbinder</transport> @@ -126,6 +99,7 @@ </hal> <hal format="aidl"> <name>com.google.input</name> + <version>2</version> <interface> <name>ITouchContextService</name> <instance>default</instance> @@ -139,22 +113,4 @@ <instance>default</instance> </interface> </hal> - <hal format="hidl"> - <name>vendor.google.whitechapel.audio.audioext</name> - <transport>hwbinder</transport> - <version>4.0</version> - <interface> - <name>IAudioExt</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>vendor.google.audiometricext</name> - <transport>hwbinder</transport> - <version>1.0</version> - <interface> - <name>IAudioMetricExt</name> - <instance>default</instance> - </interface> - </hal> </manifest> diff --git a/manifest.xml b/manifest.xml index 9cb4738..7814e22 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,31 +1,4 @@ <manifest version="1.0" type="device" target-level="7"> - <hal format="hidl"> - <name>android.hardware.audio</name> - <transport>hwbinder</transport> - <version>7.1</version> - <interface> - <name>IDevicesFactory</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>android.hardware.audio.effect</name> - <transport>hwbinder</transport> - <version>7.0</version> - <interface> - <name>IEffectsFactory</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>android.hardware.soundtrigger</name> - <transport>hwbinder</transport> - <version>2.3</version> - <interface> - <name>ISoundTriggerHw</name> - <instance>default</instance> - </interface> - </hal> <hal format="hidl"> <name>android.hardware.graphics.mapper</name> <transport arch="32+64">passthrough</transport> @@ -52,27 +25,10 @@ </hal> <hal format="aidl"> <name>com.google.input</name> + <version>2</version> <interface> <name>ITouchContextService</name> <instance>default</instance> </interface> </hal> - <hal format="hidl"> - <name>vendor.google.whitechapel.audio.audioext</name> - <transport>hwbinder</transport> - <version>4.0</version> - <interface> - <name>IAudioExt</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>vendor.google.audiometricext</name> - <transport>hwbinder</transport> - <version>1.0</version> - <interface> - <name>IAudioMetricExt</name> - <instance>default</instance> - </interface> - </hal> </manifest> diff --git a/media_codecs_aosp_c2.xml b/media_codecs_aosp_c2.xml index bae71e6..6846cbe 100644 --- a/media_codecs_aosp_c2.xml +++ b/media_codecs_aosp_c2.xml @@ -49,11 +49,11 @@ <Feature name="low-latency" /> </MediaCodec> <MediaCodec name="c2.exynos.hevc.decoder" type="video/hevc" > - <Limit name="size" min="64x64" max="3840x2160" /> + <Limit name="size" min="64x64" max="3840x2176" /> <Limit name="alignment" value="2x2" /> <Limit name="block-size" value="16x16" /> - <Limit name="block-count" range="1-32400" /> - <Limit name="blocks-per-second" min="1" max="3888000" /> + <Limit name="block-count" range="1-32640" /> + <Limit name="blocks-per-second" min="1" max="3916800" /> <Limit name="bitrate" range="1-120000000" /> <Limit name="performance-point-1920x1080" range="240" /> <Limit name="performance-point-3840x2160" range="120" /> diff --git a/media_codecs_performance_c2.xml b/media_codecs_performance_c2.xml index 08dfd5d..21381a9 100644 --- a/media_codecs_performance_c2.xml +++ b/media_codecs_performance_c2.xml @@ -155,29 +155,25 @@ <Limit name="measured-frame-rate-1920x1080" range="75-112" /> </MediaCodec> <MediaCodec name="c2.google.av1.decoder" type="video/av01" update="true"> - <!-- measured 90%:295-301 med:296 N=2 --> - <Limit name="measured-frame-rate-352x288" range="295-298" /> <!-- v90%=1.0 --> - <!-- measured 90%:196-207 med:196 N=2 --> - <Limit name="measured-frame-rate-640x360" range="196-201" /> <!-- v90%=1.0 --> - <!-- measured 90%:177-180 med:178 N=2 --> - <Limit name="measured-frame-rate-720x480" range="177-178" /> <!-- v90%=1.0 --> - <!-- measured 90%:81-82 med:82 N=2 --> - <Limit name="measured-frame-rate-1280x720" range="81-82" /> <!-- v90%=1.0 --> - <!-- measured 90%:45-47 med:46 N=2 --> - <Limit name="measured-frame-rate-1920x1080" range="45-46" /> <!-- v90%=1.0 --> + <Limit name="measured-frame-rate-352x288" range="630-748" /> + <Limit name="measured-frame-rate-640x360" range="586-700" /> + <Limit name="measured-frame-rate-720x480" range="575-690" /> + <Limit name="measured-frame-rate-1280x720" range="247-460" /> + <Limit name="measured-frame-rate-1920x1080" range="219-252" /> </MediaCodec> <MediaCodec name="c2.google.av1.decoder.secure" type="video/av01" update="true"> - <!-- measured 90%:295-301 med:296 N=2 --> - <Limit name="measured-frame-rate-352x288" range="295-298" /> <!-- v90%=1.0 --> - <!-- measured 90%:196-207 med:196 N=2 --> - <Limit name="measured-frame-rate-640x360" range="196-201" /> <!-- v90%=1.0 --> - <!-- measured 90%:177-180 med:178 N=2 --> - <Limit name="measured-frame-rate-720x480" range="177-178" /> <!-- v90%=1.0 --> - <!-- measured 90%:81-82 med:82 N=2 --> - <Limit name="measured-frame-rate-1280x720" range="81-82" /> <!-- v90%=1.0 --> - <!-- measured 90%:45-47 med:46 N=2 --> - <Limit name="measured-frame-rate-1920x1080" range="45-46" /> <!-- v90%=1.0 --> + <Limit name="measured-frame-rate-352x288" range="630-748" /> + <Limit name="measured-frame-rate-640x360" range="586-700" /> + <Limit name="measured-frame-rate-720x480" range="575-690" /> + <Limit name="measured-frame-rate-1280x720" range="247-460" /> + <Limit name="measured-frame-rate-1920x1080" range="219-252" /> </MediaCodec> + <MediaCodec name="c2.android.av1.decoder" type="video/av01" update="true"> + <Limit name="measured-frame-rate-352x288" range="358-383" /> + <Limit name="measured-frame-rate-640x360" range="207-221" /> + <Limit name="measured-frame-rate-720x480" range="106-148" /> + <Limit name="measured-frame-rate-1280x720" range="65-71" /> + </MediaCodec> </Decoders> <Encoders> @@ -251,5 +247,13 @@ <Limit name="measured-frame-rate-640x360" range="91-136" /> <Limit name="measured-frame-rate-1280x720" range="24-36" /> </MediaCodec> + <MediaCodec name="c2.android.av1.encoder" type="video/av01" update="true"> + <!-- measured 90%:354-361 med:355 N=2 --> + <Limit name="measured-frame-rate-320x240" range="354-358" /> <!-- v90%=1.0 --> + <!-- measured 90%:81-85 med:81 N=2 --> + <Limit name="measured-frame-rate-720x480" range="81-83" /> <!-- v90%=1.0 --> + <!-- measured 90%:32-33 med:33 N=2 --> + <Limit name="measured-frame-rate-1280x720" range="32-33" /> <!-- v90%=1.0 --> + </MediaCodec> </Encoders> </MediaCodecs> diff --git a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml index 67dcdc5..269450e 100644 --- a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml +++ b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml @@ -26,5 +26,5 @@ <!-- Doze: does this device support STATE_DOZE_SUSPEND? --> <bool name="doze_suspend_display_state_supported">false</bool> - <string name="config_rounded_mask">M21,0C19.94,0.01 18.83,0.04 17.73,0.11C16.91,0.17 16.09,0.25 15.3,0.36C14.5,0.48 13.72,0.62 12.95,0.81C11.42,1.19 9.97,1.72 8.65,2.43C7.32,3.14 6.12,4.02 5.08,5.07C4.04,6.11 3.15,7.31 2.44,8.64C1.73,9.97 1.19,11.42 0.82,12.94C0.63,13.7 0.48,14.49 0.37,15.29C0.25,16.09 0.17,16.9 0.12,17.72C0.05,18.82 0.02,19.93 0.01,21.55</string> + <string name="config_rounded_mask" translatable="false">M21,0C19.94,0.01 18.83,0.04 17.73,0.11C16.91,0.17 16.09,0.25 15.3,0.36C14.5,0.48 13.72,0.62 12.95,0.81C11.42,1.19 9.97,1.72 8.65,2.43C7.32,3.14 6.12,4.02 5.08,5.07C4.04,6.11 3.15,7.31 2.44,8.64C1.73,9.97 1.19,11.42 0.82,12.94C0.63,13.7 0.48,14.49 0.37,15.29C0.25,16.09 0.17,16.9 0.12,17.72C0.05,18.82 0.02,19.93 0.01,21.55</string> </resources> diff --git a/storage/Android.bp b/storage/Android.bp new file mode 100644 index 0000000..90a919b --- /dev/null +++ b/storage/Android.bp @@ -0,0 +1,27 @@ +// +// Copyright (C) 2017 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 { + default_applicable_licenses: [ + "//device/google/gs201:device_google_gs201_license", + ], +} + +sh_binary { + name: "ufs_firmware_update.sh", + src: "ufs_firmware_update.sh", + init_rc: ["storage.gs201.rc"], + vendor: true, +} diff --git a/storage/storage.gs201.rc b/storage/storage.gs201.rc new file mode 100644 index 0000000..9873325 --- /dev/null +++ b/storage/storage.gs201.rc @@ -0,0 +1,7 @@ +on property:sys.boot_completed=1 + # Copy ufs firmware to disk + start ufs_firmware_update + +service ufs_firmware_update /vendor/bin/ufs_firmware_update.sh + disabled + oneshot diff --git a/storage/ufs_firmware_update.sh b/storage/ufs_firmware_update.sh new file mode 100755 index 0000000..d118115 --- /dev/null +++ b/storage/ufs_firmware_update.sh @@ -0,0 +1,19 @@ +#!/vendor/bin/sh +# +# The script belongs to the feature of UFS FFU via OTA: go/p23-ffu-ota +# Its purpose is to copy the corresponding firmware into partition for UFS FFU. + +ufs_dev="/dev/sys/block/bootdevice" +fw_dir="/vendor/firmware" +blk_dev="/dev/block/by-name/fips" + +vendor=$(cat ${ufs_dev}/vendor | tr -d "[:space:]") +model=$(cat ${ufs_dev}/model | tr -d "[:space:]") +rev=$(cat ${ufs_dev}/rev | tr -d "[:space:]") + +file=$(find ${fw_dir} -name "*${vendor}${model}${rev}*" | head -n 1) +if [ -n "$file" ]; then + # The first 4KB block at fips partition has been occupied, and unused space begins from 4 KB + # Refer to: go/pixel-mp-ffu-ota-1p + dd if="$file" of=$blk_dev bs=4k seek=1 +fi diff --git a/task_profiles.json b/task_profiles.json index 4bcfe41..961857d 100644 --- a/task_profiles.json +++ b/task_profiles.json @@ -287,7 +287,7 @@ }, { "Name": "OtaProfiles", - "Profiles": [ "OtaPerformance", "ServiceCapacityLow", "LowIoPriority", "TimerSlackHigh" ] + "Profiles": [ "OtaPerformance", "ProcessCapacityNormal", "LowIoPriority", "TimerSlackHigh" ] } ] } diff --git a/usb/usb/Usb.cpp b/usb/usb/Usb.cpp index 3e4f8a1..270a222 100644 --- a/usb/usb/Usb.cpp +++ b/usb/usb/Usb.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "android.hardware.usb.aidl-service" #include <android-base/logging.h> +#include <android-base/parseint.h> #include <android-base/properties.h> #include <android-base/strings.h> #include <assert.h> @@ -95,6 +96,9 @@ void queryVersionHelper(android::hardware::usb::Usb *usb, #define GL852G_PRODUCT_ID1 0x0608 #define GL852G_PRODUCT_ID2 0x0610 #define GL852G_VENDOR_CMD_REQ 0xe3 +// GL852G port 1 and port 2 JK level default settings +#define GL852G_VENDOR_CMD_VALUE_DEFAULT 0x0008 +#define GL852G_VENDOR_CMD_INDEX_DEFAULT 0x0404 ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable, int64_t in_transactionId) { @@ -452,6 +456,61 @@ bool switchMode(const string &portName, const PortRole &in_role, struct Usb *usb return roleSwitch; } +static int usbDeviceRemoved(const char *devname, void* client_data) { + return 0; +} + +static int usbDeviceAdded(const char *devname, void* client_data) { + uint16_t vendorId, productId; + struct usb_device *device; + ::aidl::android::hardware::usb::Usb *usb; + int value, index; + + device = usb_device_open(devname); + if (!device) { + ALOGE("usb_device_open failed\n"); + return 0; + } + + usb = (::aidl::android::hardware::usb::Usb *)client_data; + value = usb->mUsbHubVendorCmdValue; + index = usb->mUsbHubVendorCmdIndex; + + // The vendor cmd only applies to USB Hubs of Genesys Logic, Inc. + // The request field of vendor cmd is fixed to 0xe3. + vendorId = usb_device_get_vendor_id(device); + productId = usb_device_get_product_id(device); + if (vendorId == GL852G_VENDOR_ID && + (productId == GL852G_PRODUCT_ID1 || productId == GL852G_PRODUCT_ID2)) { + int ret = usb_device_control_transfer(device, + USB_DIR_OUT | USB_TYPE_VENDOR, GL852G_VENDOR_CMD_REQ, value, index, + NULL, 0, CTRL_TRANSFER_TIMEOUT_MSEC); + ALOGI("USB hub vendor cmd %s (wValue 0x%x, wIndex 0x%x, return %d)\n", + ret? "failed" : "succeeded", value, index, ret); + } + + usb_device_close(device); + + return 0; +} + +void *usbHostWork(void *param) { + struct usb_host_context *ctx; + + ALOGI("creating USB host thread\n"); + + ctx = usb_host_init(); + if (!ctx) { + ALOGE("usb_host_init failed\n"); + return NULL; + } + + // This will never return, it will keep monitoring USB sysfs inotify events + usb_host_run(ctx, usbDeviceAdded, usbDeviceRemoved, NULL, param); + + return NULL; +} + Usb::Usb() : mLock(PTHREAD_MUTEX_INITIALIZER), mRoleSwitchLock(PTHREAD_MUTEX_INITIALIZER), @@ -465,7 +524,9 @@ Usb::Usb() ThrottlingSeverity::NONE), ZoneInfo(TemperatureType::UNKNOWN, kThermalZoneForTempReadSecondary2, ThrottlingSeverity::NONE)}, kSamplingIntervalSec), - mUsbDataEnabled(true) { + mUsbDataEnabled(true), + mUsbHubVendorCmdValue(GL852G_VENDOR_CMD_VALUE_DEFAULT), + mUsbHubVendorCmdIndex(GL852G_VENDOR_CMD_INDEX_DEFAULT) { pthread_condattr_t attr; if (pthread_condattr_init(&attr)) { ALOGE("pthread_condattr_init failed: %s", strerror(errno)); @@ -483,6 +544,10 @@ Usb::Usb() ALOGE("pthread_condattr_destroy failed: %s", strerror(errno)); abort(); } + if (pthread_create(&mUsbHost, NULL, usbHostWork, this)) { + ALOGE("pthread creation failed %d\n", errno); + abort(); + } } ScopedAStatus Usb::switchRole(const string& in_portName, const PortRole& in_role, @@ -777,7 +842,13 @@ Status getPortStatusHelper(android::hardware::usb::Usb *usb, string pogoUsbActive = "0"; if (ReadFileToString(string(kPogoUsbActive), &pogoUsbActive) && stoi(Trim(pogoUsbActive)) == 1) { - (*currentPortStatus)[i].usbDataStatus.push_back(UsbDataStatus::DISABLED_DOCK); + /* + * Always signal USB device mode disabled irrespective of hub enabled while docked. + * Hub gets automatically enabled as needed. Signalling DISABLED_DOCK_HOST_MODE & + * DEVICE_MODE during pogo direct can cause notifications to show for brief windows + * when the state machine is still moving to steady state. + */ + (*currentPortStatus)[i].usbDataStatus.push_back(UsbDataStatus::DISABLED_DOCK_DEVICE_MODE); dataEnabled = false; } if (!usb->mUsbDataEnabled) { @@ -831,7 +902,9 @@ void queryVersionHelper(android::hardware::usb::Usb *usb, status = getPortStatusHelper(usb, currentPortStatus); queryMoistureDetectionStatus(currentPortStatus); queryPowerTransferStatus(currentPortStatus); +#if 0 /* b/278018111 disable compliance warning; revert it after fixing the issue */ queryNonCompliantChargerStatus(currentPortStatus); +#endif if (usb->mCallback != NULL) { ScopedAStatus ret = usb->mCallback->notifyPortStatusChange(*currentPortStatus, status); @@ -1089,82 +1162,6 @@ ScopedAStatus Usb::setCallback(const shared_ptr<IUsbCallback>& in_callback) { return ScopedAStatus::ok(); } -struct hub_vendor_cmd { - // wValue filed of standard device request - int value; - // wIndex field of standard device request - int index; - // Output pipe to shell command - int out; - // Whether the hub is found - bool found; -}; - -static int usbDeviceAdded(const char *devname, void* client_data) { - struct hub_vendor_cmd *cmd = (struct hub_vendor_cmd *)client_data; - uint16_t vendorId, productId; - struct usb_device *device = usb_device_open(devname); - - if (!device) { - dprintf(cmd->out, "usb_device_open failed\n"); - return 0; - } - - // The vendor cmd only applies to USB Hubs of Genesys Logic, Inc. - // The request field of vendor cmd is fixed to 0xe3. - vendorId = usb_device_get_vendor_id(device); - productId = usb_device_get_product_id(device); - if (vendorId == GL852G_VENDOR_ID && - (productId == GL852G_PRODUCT_ID1 || productId == GL852G_PRODUCT_ID2)) { - int ret = usb_device_control_transfer( - device, USB_DIR_OUT | USB_TYPE_VENDOR, - GL852G_VENDOR_CMD_REQ, cmd->value, cmd->index, NULL, 0, - CTRL_TRANSFER_TIMEOUT_MSEC); - dprintf(cmd->out, "Vendor cmd %s (wValue %x, wIndex %x, return %d)\n", - ret? "failed" : "succeeded", cmd->value, cmd->index, ret); - // Stop iterating through usb devices once the hub is found. - cmd->found = true; - return 1; - } - - return 0; -} - -static int usbDiscoveryDone(void *client_data) -{ - struct hub_vendor_cmd *cmd = (struct hub_vendor_cmd *)client_data; - - dprintf(cmd->out, "Done USB discovery, hub %s found\n", - cmd->found ? "is" : "not"); - - return 1; -} - -static status_t sendHubVendorCmd(int out, Vector<String8>& args) { - if (args.size() < 3) { - dprintf(out, "Incorrect number of argument supplied\n"); - return ::android::UNKNOWN_ERROR; - } - struct hub_vendor_cmd cmd = { - .value = std::stoi(args[1].c_str(), NULL, 16), - .index = std::stoi(args[2].c_str(), NULL, 16), - .out = out, - .found = false - }; - - struct usb_host_context *ctx; - ctx = usb_host_init(); - if (!ctx) { - dprintf(out, "usb_host_init failed\n"); - return ::android::UNKNOWN_ERROR; - } - - usb_host_run(ctx, usbDeviceAdded, NULL, usbDiscoveryDone, &cmd); - usb_host_cleanup(ctx); - - return ::android::NO_ERROR; -} - status_t Usb::handleShellCommand(int in, int out, int err, const char** argv, uint32_t argc) { uid_t uid = AIBinder_getCallingUid(); @@ -1180,13 +1177,28 @@ status_t Usb::handleShellCommand(int in, int out, int err, const char** argv, if (argc >= 1) { if (!utf8Args[0].compare(String8("hub-vendor-cmd"))) { - return sendHubVendorCmd(out, utf8Args); + if (utf8Args.size() < 3) { + dprintf(out, "Incorrect number of argument supplied\n"); + return ::android::UNKNOWN_ERROR; + } + int value, index; + if (!::android::base::ParseInt(utf8Args[1].c_str(), &value) || + !::android::base::ParseInt(utf8Args[2].c_str(), &index)) { + dprintf(out, "Fail to parse arguments\n"); + return ::android::UNKNOWN_ERROR; + } + mUsbHubVendorCmdValue = value; + mUsbHubVendorCmdIndex = index; + ALOGI("USB hub vendor cmd update (wValue 0x%x, wIndex 0x%x)\n", + mUsbHubVendorCmdValue, mUsbHubVendorCmdIndex); + return ::android::NO_ERROR; } } dprintf(out, "usage: adb shell cmd hub-vendor-cmd VALUE INDEX\n" - " VALUE wValue field in hex format, e.g. f321\n" - " INDEX wIndex field in hex format, e.g. f321\n"); + " VALUE wValue field in hex format, e.g. 0xf321\n" + " INDEX wIndex field in hex format, e.g. 0xf321\n" + " The settings take effect next time the hub is enabled\n"); return ::android::NO_ERROR; } diff --git a/usb/usb/Usb.h b/usb/usb/Usb.h index 121694a..e45a5ed 100644 --- a/usb/usb/Usb.h +++ b/usb/usb/Usb.h @@ -93,8 +93,12 @@ struct Usb : public BnUsb { float mPluggedTemperatureCelsius; // Usb Data status bool mUsbDataEnabled; + // Usb hub vendor command settings for JK level tuning + int mUsbHubVendorCmdValue; + int mUsbHubVendorCmdIndex; private: pthread_t mPoll; + pthread_t mUsbHost; }; } // namespace usb diff --git a/usb/usb/android.hardware.usb-service.rc b/usb/usb/android.hardware.usb-service.rc index 06cf891..818ffb0 100644 --- a/usb/usb/android.hardware.usb-service.rc +++ b/usb/usb/android.hardware.usb-service.rc @@ -8,42 +8,126 @@ on post-fs chown root system /sys/class/typec/port0/power_role chown root system /sys/class/typec/port0/data_role chown root system /sys/class/typec/port0/port_type + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/contaminant_detection + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/contaminant_detection + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/contaminant_detection + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/contaminant_detection chown root system /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/contaminant_detection chown root system /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/contaminant_detection chown root system /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/contaminant_detection + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/contaminant_detection + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/contaminant_detection + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/contaminant_detection + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_accessory_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_accessory_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_accessory_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_accessory_current chown root system /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_accessory_current chown root system /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_accessory_current chown root system /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_accessory_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_accessory_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_accessory_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_accessory_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_accessory_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_accessory_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_accessory_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_accessory_enable chown root system /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_accessory_enable chown root system /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_accessory_enable chown root system /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_accessory_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_accessory_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_accessory_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_accessory_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_sink_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_sink_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_sink_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_sink_current chown root system /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_sink_current chown root system /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_sink_current chown root system /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_sink_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_sink_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_sink_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_sink_current + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_sink_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_sink_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_sink_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_sink_enable chown root system /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_sink_enable chown root system /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_sink_enable chown root system /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_sink_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_sink_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_sink_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_sink_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_source_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_source_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_source_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_source_enable chown root system /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_source_enable chown root system /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_source_enable chown root system /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_source_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_source_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_source_enable + chown root system /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_source_enable chmod 664 /sys/class/typec/port0/power_role chmod 664 /sys/class/typec/port0/data_role chmod 664 /sys/class/typec/port0/port_type + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/contaminant_detection + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/contaminant_detection + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/contaminant_detection + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/contaminant_detection chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/contaminant_detection chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/contaminant_detection chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/contaminant_detection + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/contaminant_detection + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/contaminant_detection + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/contaminant_detection + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_accessory_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_accessory_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_accessory_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_accessory_current chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_accessory_current chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_accessory_current chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_accessory_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_accessory_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_accessory_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_accessory_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_accessory_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_accessory_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_accessory_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_accessory_enable chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_accessory_enable chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_accessory_enable chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_accessory_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_accessory_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_accessory_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_accessory_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_sink_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_sink_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_sink_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_sink_current chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_sink_current chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_sink_current chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_sink_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_sink_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_sink_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_sink_current + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_sink_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_sink_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_sink_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_sink_enable chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_sink_enable chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_sink_enable chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_sink_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_sink_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_sink_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_sink_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_source_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_source_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_source_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_source_enable chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_source_enable chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_source_enable chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_source_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_source_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_source_enable + chmod 664 /sys/devices/platform/10d60000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_source_enable diff --git a/widevine/device.mk b/widevine/device.mk index 4451c7c..c711f6f 100644 --- a/widevine/device.mk +++ b/widevine/device.mk @@ -1,5 +1 @@ -PRODUCT_PACKAGES += \ - android.hardware.drm-service.clearkey \ - --include vendor/widevine/libwvdrmengine/apex/device/device.mk BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs201-sepolicy/widevine
\ No newline at end of file diff --git a/wifi/qcom/BoardConfig-wifi.mk b/wifi/qcom/BoardConfig-wifi.mk index dcc75a9..6546ce4 100644 --- a/wifi/qcom/BoardConfig-wifi.mk +++ b/wifi/qcom/BoardConfig-wifi.mk @@ -46,3 +46,6 @@ BOARD_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL := true PRODUCT_COPY_FILES += \ $(LOCAL_WIFI_PATH)/wpa_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant_overlay.conf \ $(LOCAL_WIFI_PATH)/p2p_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/p2p_supplicant_overlay.conf + +# Add BOARD_WLAN_CHIP to soong_config +$(call soong_config_set,qcom_wifi,board_wlan_chip,wcn6740)
\ No newline at end of file |