move sensors dump to gs-common

Bug: 250475720
Test: adb bugreport
Change-Id: I15ec38810792c9216ad63de59a8f3aeb5f871bc5
This commit is contained in:
Adam Shih 2022-10-17 13:36:58 +08:00
parent 4b68f5fe95
commit 9c93403876
6 changed files with 77 additions and 0 deletions

20
sensors/Android.bp Normal file
View File

@ -0,0 +1,20 @@
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
cc_binary {
name: "dump_sensors",
srcs: ["dump_sensors.cpp"],
cflags: [
"-Wall",
"-Wextra",
"-Werror",
],
shared_libs: [
"libbase",
"libdumpstateutil",
"libdump",
],
vendor: true,
relative_install_path: "dump",
}

38
sensors/dump_sensors.cpp Normal file
View File

@ -0,0 +1,38 @@
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string>
#include <android-base/properties.h>
#include <dump/pixel_dump.h>
#include "DumpstateUtil.h"
int main() {
setbuf(stdout, NULL);
runCommand("USF statistics", "/vendor/bin/usf_stats get --all");
if (!::android::os::dumpstate::PropertiesHelper::IsUserBuild()) {
// Not a user build, if this is also not a production device dump the USF registry.
std::string hwRev = ::android::base::GetProperty("ro.boot.hardware.revision", "");
if (hwRev.find("PROTO") != std::string::npos ||
hwRev.find("EVT") != std::string::npos ||
hwRev.find("DVT") != std::string::npos ||
hwRev.find("PVT") != std::string::npos) {
runCommand("USF Registry", "/vendor/bin/usf_reg_edit save -");
dumpFileContent("USF Last Stat Buffer", "/data/vendor/sensors/debug/stats.history");
}
}
return 0;
}

3
sensors/sensors.mk Normal file
View File

@ -0,0 +1,3 @@
$(call inherit-product-if-exists, vendor/google/sensors/usf/android/usf_efw_product.mk)
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/sensors/sepolicy

View File

@ -0,0 +1,11 @@
pixel_bugreport(dump_sensors)
allow dump_sensors aoc_device:chr_file rw_file_perms;
allow dump_sensors device:dir r_dir_perms;
allow dump_sensors vendor_shell_exec:file execute_no_trans;
allow dump_sensors vendor_usf_stats:file execute_no_trans;
userdebug_or_eng(`
allow dump_sensors vendor_usf_reg_edit:file execute_no_trans;
allow dump_sensors sensor_debug_data_file:dir r_dir_perms;
allow dump_sensors sensor_debug_data_file:file r_file_perms;
')

2
sensors/sepolicy/file.te Normal file
View File

@ -0,0 +1,2 @@
type vendor_usf_stats, vendor_file_type, file_type;
type vendor_usf_reg_edit, vendor_file_type, file_type;

View File

@ -0,0 +1,3 @@
/vendor/bin/dump/dump_sensors u:object_r:dump_sensors_exec:s0
/vendor/bin/usf_stats u:object_r:vendor_usf_stats:s0
/vendor/bin/usf_reg_edit u:object_r:vendor_usf_reg_edit:s0