From 1915b3df20e3727a780b831f59409b89228d68c1 Mon Sep 17 00:00:00 2001 From: Adam Shih Date: Tue, 28 Mar 2023 11:18:17 +0800 Subject: [PATCH] comply with VTS requirements Bug: 275142299 Test: atest VtsHalDumpstateTargetTest:PerInstanceAndMode/DumpstateAidlPerModeTest#TestOk/0_android_hardware_dumpstate_IDumpstateDevice_default_FULL atest VtsHalDumpstateTargetTest:PerInstance/DumpstateAidlGeneralTest#TestInvalidModeArgument_Negative/0_android_hardware_dumpstate_IDumpstateDevice_default Built pass on target-userdebug and aosp_target-userdebug Change-Id: Ifd980bc1fbb543c43e729d52735c97e2cde6a641 --- gear/dumpstate/Dumpstate.cpp | 7 ++++++- gear/dumpstate/sepolicy/file.te | 1 + gear/dumpstate/sepolicy/file_contexts | 1 + gear/dumpstate/sepolicy/hal_dumpstate_default.te | 2 ++ gear/dumpstate/sepolicy/property.te | 3 +++ gear/dumpstate/sepolicy/property_contexts | 3 +++ 6 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gear/dumpstate/sepolicy/property.te create mode 100644 gear/dumpstate/sepolicy/property_contexts diff --git a/gear/dumpstate/Dumpstate.cpp b/gear/dumpstate/Dumpstate.cpp index 1e4d982..8abc237 100644 --- a/gear/dumpstate/Dumpstate.cpp +++ b/gear/dumpstate/Dumpstate.cpp @@ -154,7 +154,11 @@ ndk::ScopedAStatus Dumpstate::dumpstateBoard(const std::vector<::ndk::ScopedFile int64_t in_timeoutMillis) { // Unused arguments. (void) in_timeoutMillis; - (void) in_mode; + + if (in_mode < IDumpstateDevice::DumpstateMode::FULL || in_mode > IDumpstateDevice::DumpstateMode::PROTO) { + ALOGE("Invalid mode: %d\n", in_mode); + return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT, "Invalid mode"); + } if (in_fds.size() < 1) { ALOGE("no FDs\n"); @@ -171,6 +175,7 @@ ndk::ScopedAStatus Dumpstate::dumpstateBoard(const std::vector<::ndk::ScopedFile if (in_fds.size() < 2) { ALOGE("no FD for dumpstate_board binary\n"); + dumpTextSection(fd, ""); } else { int fd_bin = in_fds[1].get(); dumpLogSection(fd, fd_bin); diff --git a/gear/dumpstate/sepolicy/file.te b/gear/dumpstate/sepolicy/file.te index 6c686a0..1777353 100644 --- a/gear/dumpstate/sepolicy/file.te +++ b/gear/dumpstate/sepolicy/file.te @@ -1,3 +1,4 @@ +# dumpstate packing directory type radio_vendor_data_file, file_type, data_file_type; userdebug_or_eng(` typeattribute radio_vendor_data_file mlstrustedobject; diff --git a/gear/dumpstate/sepolicy/file_contexts b/gear/dumpstate/sepolicy/file_contexts index 5c65e43..086b481 100644 --- a/gear/dumpstate/sepolicy/file_contexts +++ b/gear/dumpstate/sepolicy/file_contexts @@ -1,3 +1,4 @@ +# generic dumpstate for pixel /vendor/bin/hw/android\.hardware\.dumpstate-service u:object_r:hal_dumpstate_default_exec:s0 /data/vendor/radio(/.*)? u:object_r:radio_vendor_data_file:s0 diff --git a/gear/dumpstate/sepolicy/hal_dumpstate_default.te b/gear/dumpstate/sepolicy/hal_dumpstate_default.te index 3e4db45..06ebb75 100644 --- a/gear/dumpstate/sepolicy/hal_dumpstate_default.te +++ b/gear/dumpstate/sepolicy/hal_dumpstate_default.te @@ -1,5 +1,7 @@ +# required permission to use tar to pack dumpsate_board.bin allow hal_dumpstate_default vendor_toolbox_exec:file execute_no_trans; allow hal_dumpstate_default radio_vendor_data_file:dir create_dir_perms; allow hal_dumpstate_default radio_vendor_data_file:file create_file_perms; allow hal_dumpstate_default shell_data_file:file getattr; +set_prop(hal_dumpstate_default, vendor_logger_prop) diff --git a/gear/dumpstate/sepolicy/property.te b/gear/dumpstate/sepolicy/property.te new file mode 100644 index 0000000..c6f5a4f --- /dev/null +++ b/gear/dumpstate/sepolicy/property.te @@ -0,0 +1,3 @@ +# verbose property +vendor_internal_prop(vendor_logger_prop) + diff --git a/gear/dumpstate/sepolicy/property_contexts b/gear/dumpstate/sepolicy/property_contexts new file mode 100644 index 0000000..5ead16f --- /dev/null +++ b/gear/dumpstate/sepolicy/property_contexts @@ -0,0 +1,3 @@ +# verbose property name +persist.vendor.verbose_logging_enabled u:object_r:vendor_logger_prop:s0 +