diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-03-14 20:15:44 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-03-14 20:15:44 +0000 |
commit | f0def9e5b3fead97a85f09796dae5e428b5cd5eb (patch) | |
tree | 21b2f5c5fe27fae96eb8e8ba460f8b98638df826 | |
parent | 6f9140f18e4a07f3325ff75d5dcb1c1e7e1bbbc7 (diff) | |
parent | d015e94772b05850254427cbb1bf56d3c6c422ff (diff) | |
download | goldfish-f0def9e5b3fead97a85f09796dae5e428b5cd5eb.tar.gz |
Merge "Replace the qemu-export-property binary with a script" into main
-rw-r--r-- | init.ranchu.rc | 4 | ||||
-rw-r--r-- | init.system_ext.rc | 4 | ||||
-rwxr-xr-x | init_ranchu_device_state.sh | 8 | ||||
-rw-r--r-- | product/generic.mk | 2 | ||||
-rw-r--r-- | qemu-export-property/Android.bp | 44 | ||||
-rw-r--r-- | qemu-export-property/main.cpp | 72 | ||||
-rw-r--r-- | sepolicy/vendor/file_contexts | 2 | ||||
-rw-r--r-- | sepolicy/vendor/init_ranchu_device_state.te | 11 | ||||
-rw-r--r-- | sepolicy/vendor/qemu_export_property.te | 14 |
9 files changed, 25 insertions, 136 deletions
diff --git a/init.ranchu.rc b/init.ranchu.rc index d1c844a2..f8045afc 100644 --- a/init.ranchu.rc +++ b/init.ranchu.rc @@ -57,7 +57,6 @@ on init start qemu-props on post-fs-data - mkdir /data/vendor/devicestate 0755 root root mkdir /data/vendor/var 0755 root root mkdir /data/vendor/var/run 0755 root root @@ -146,11 +145,12 @@ service qemu-props-bootcomplete /vendor/bin/qemu-props "bootcomplete" oneshot disabled -service qemu-device-state /vendor/bin/qemu-export-property -f qemu.device_state /data/vendor/devicestate/device_state_configuration.xml +service qemu-device-state /vendor/bin/init_ranchu_device_state.sh user root group root oneshot disabled + stdio_to_kmsg service goldfish-logcat /system/bin/logcat -f /dev/hvc1 ${ro.boot.logcat} class main diff --git a/init.system_ext.rc b/init.system_ext.rc index a053c814..07711d16 100644 --- a/init.system_ext.rc +++ b/init.system_ext.rc @@ -3,6 +3,6 @@ on property:init.svc.ranchu-adb-setup=stopped on property:init.svc.qemu-device-state=stopped && property:ro.boot.qemu.device_state=* mkdir /data/system/devicestate/ 0755 system system - copy /data/vendor/devicestate/device_state_configuration.xml /data/system/devicestate/device_state_configuration.xml - rm /data/vendor/devicestate/device_state_configuration.xml + copy /data/vendor/device_state_configuration.xml /data/system/devicestate/device_state_configuration.xml + rm /data/vendor/device_state_configuration.xml chown system system /data/system/devicestate/device_state_configuration.xml diff --git a/init_ranchu_device_state.sh b/init_ranchu_device_state.sh new file mode 100755 index 00000000..fbe71ac3 --- /dev/null +++ b/init_ranchu_device_state.sh @@ -0,0 +1,8 @@ +#!/system/bin/sh -e +DEVICE_STATE_FILE="/data/vendor/device_state_configuration.xml" +STATE=`getprop ro.boot.qemu.device_state` + +if [ -n "$STATE" ]; then + echo "$STATE" > "$DEVICE_STATE_FILE" + chmod 0755 "$DEVICE_STATE_FILE" +fi diff --git a/product/generic.mk b/product/generic.mk index b1590015..541f24f1 100644 --- a/product/generic.mk +++ b/product/generic.mk @@ -72,7 +72,6 @@ PRODUCT_PACKAGES += \ libandroidemu \ libOpenglCodecCommon \ libOpenglSystemCommon \ - qemu-export-property \ qemu-props \ stagefright \ android.hardware.graphics.composer3-service.ranchu \ @@ -300,6 +299,7 @@ PRODUCT_COPY_FILES += \ device/generic/goldfish/data/etc/numeric_operator.xml:data/misc/modem_simulator/etc/modem_simulator/files/numeric_operator.xml \ device/generic/goldfish/data/etc/local.prop:data/local.prop \ device/generic/goldfish/init.ranchu.adb.setup.sh:$(TARGET_COPY_OUT_SYSTEM_EXT)/bin/init.ranchu.adb.setup.sh \ + device/generic/goldfish/init_ranchu_device_state.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init_ranchu_device_state.sh \ device/generic/goldfish/init.ranchu-core.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-core.sh \ device/generic/goldfish/init.ranchu-net.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-net.sh \ device/generic/goldfish/init.ranchu.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.ranchu.rc \ diff --git a/qemu-export-property/Android.bp b/qemu-export-property/Android.bp deleted file mode 100644 index 8bbca83e..00000000 --- a/qemu-export-property/Android.bp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2021 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. - -// this file is used to build emulator-specific program tools -// that should only run in the emulator. -// - -package { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "device_generic_goldfish_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["device_generic_goldfish_license"], -} - -cc_binary { - name: "qemu-export-property", - vendor: true, - srcs: [ - "main.cpp", - ], - shared_libs: [ - "libbase", - "liblog", - ], - static_libs: [ - "libfstab", - ], - cflags: [ - "-DLOG_TAG=\"qemu-export-property\"", - ], -} diff --git a/qemu-export-property/main.cpp b/qemu-export-property/main.cpp deleted file mode 100644 index 480ea08a..00000000 --- a/qemu-export-property/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2021 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 <fstream> -#include <string> -#include <log/log.h> -#include <sys/stat.h> - -extern bool fs_mgr_get_boot_config(const std::string& key, std::string* out_val); - -namespace { -int printUsage() { - ALOGE("Usage: qemu-export-property [-f] property_name filename"); - return 1; -} - -int exportPropertyImpl(const char* propName, const char* filename) { - std::string propValue; - if (!fs_mgr_get_boot_config(propName, &propValue)) { - ALOGV("'%s' bootconfig property is not set", propName); - return 0; - } - - std::ofstream f; - f.open(filename); - if (f.is_open()) { - f << propValue; - f.close(); - return 0; - } else { - ALOGE("Failed to open '%s'\n", filename); - return 1; - } -} -} // namespace - -int main(const int argc, const char* argv[]) { - if (argc < 2) { - return printUsage(); - } - - if (strcmp(argv[1], "-f") == 0) { - if (argc == 4) { - return exportPropertyImpl(argv[2], argv[3]); - } else { - return printUsage(); - } - } else if (argc == 3) { - struct stat st; - if (stat(argv[2], &st) == 0) { - ALOGV("'%s' already exists", argv[2]); - return 0; - } else { - return exportPropertyImpl(argv[1], argv[2]); - } - } else { - return printUsage(); - } -} diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index f20af17d..7a8b1ee5 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -32,10 +32,10 @@ /system_ext/bin/init\.ranchu\.adb\.setup\.sh u:object_r:goldfish_system_setup_exec:s0 +/vendor/bin/init_ranchu_device_state\.sh u:object_r:init_ranchu_device_state_exec:s0 /vendor/bin/init\.ranchu-core\.sh u:object_r:goldfish_setup_exec:s0 /vendor/bin/init\.ranchu-net\.sh u:object_r:goldfish_setup_exec:s0 /vendor/bin/dlkm_loader u:object_r:dlkm_loader_exec:s0 -/vendor/bin/qemu-export-property u:object_r:qemu_export_property_exec:s0 /vendor/bin/qemu-props u:object_r:qemu_props_exec:s0 /vendor/bin/mac80211_create_radios u:object_r:mac80211_create_radios_exec:s0 /vendor/bin/hw/libgoldfish-rild u:object_r:rild_exec:s0 diff --git a/sepolicy/vendor/init_ranchu_device_state.te b/sepolicy/vendor/init_ranchu_device_state.te new file mode 100644 index 00000000..a7fb82a4 --- /dev/null +++ b/sepolicy/vendor/init_ranchu_device_state.te @@ -0,0 +1,11 @@ +type init_ranchu_device_state, domain; +type init_ranchu_device_state_exec, vendor_file_type, exec_type, file_type; + +init_daemon_domain(init_ranchu_device_state) + +# Permission to write to /data/vendor/* +allow init_ranchu_device_state vendor_data_file:dir create_dir_perms; +allow init_ranchu_device_state vendor_data_file:file create_file_perms; + +# Allow write to /dev/kmsg +allow init_ranchu_device_state kmsg_debug_device:chr_file { w_file_perms getattr ioctl }; diff --git a/sepolicy/vendor/qemu_export_property.te b/sepolicy/vendor/qemu_export_property.te deleted file mode 100644 index e73589ea..00000000 --- a/sepolicy/vendor/qemu_export_property.te +++ /dev/null @@ -1,14 +0,0 @@ -type qemu_export_property, domain; -type qemu_export_property_exec, vendor_file_type, exec_type, file_type; - -init_daemon_domain(qemu_export_property) - -# Allow qemu_export_property to read /proc/bootconfig -allow qemu_export_property proc_cmdline:file r_file_perms; -allow qemu_export_property proc_bootconfig:file r_file_perms; - -# Permission to write to /data/vendor/* -allow qemu_export_property vendor_data_file:dir create_dir_perms; -allow qemu_export_property vendor_data_file:file create_file_perms; -allow qemu_export_property sysfs_dt_firmware_android:dir search; -allow qemu_export_property sysfs_dt_firmware_android:file r_file_perms; |