summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-25 01:00:46 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-25 01:00:46 +0000
commitb1d4951da3244f92ad60608d7736d6ea7a00a26e (patch)
tree13f653b5c878fb88d67e500e1ef49ccc2b74f5b3
parent3c445108a05dc47d285f7dd43c8bb1f719f5f6bc (diff)
parent21ed880685fe2b36cc73a7f4950e72132785840e (diff)
downloadgoldfish-b1d4951da3244f92ad60608d7736d6ea7a00a26e.tar.gz
Snap for 7671179 from 21ed880685fe2b36cc73a7f4950e72132785840e to sc-qpr1-release
Change-Id: Ifc20bbb3c0f632f0dd4ec02a1c4b87aa3e690613
-rw-r--r--64bitonly/product/vendor.mk3
-rw-r--r--data/etc/advancedFeatures.ini1
-rw-r--r--data/etc/advancedFeatures.ini.arm1
-rw-r--r--data/etc/google/64bit/user/advancedFeatures.ini1
-rw-r--r--data/etc/google/64bit/user/arm64/advancedFeatures.ini1
-rw-r--r--data/etc/google/64bit/userdebug/advancedFeatures.ini1
-rw-r--r--data/etc/google/64bit/userdebug/arm64/advancedFeatures.ini1
-rw-r--r--data/etc/google/user/advancedFeatures.ini1
-rw-r--r--data/etc/google/user/arm64/advancedFeatures.ini1
-rw-r--r--data/etc/google/userdebug/advancedFeatures.ini1
-rw-r--r--data/etc/google/userdebug/arm64/advancedFeatures.ini1
-rw-r--r--device_state_configuration.xml18
-rw-r--r--emulator-info.txt2
-rw-r--r--init.ranchu.rc8
-rw-r--r--init.system_ext.rc6
-rw-r--r--overlay/frameworks/base/core/res/res/values/config.xml2
-rw-r--r--qemu-device-state/Android.bp44
-rw-r--r--qemu-device-state/qemu-device-state.cpp67
-rw-r--r--sepolicy/common/file_contexts1
-rw-r--r--sepolicy/common/genfs_contexts2
-rw-r--r--sepolicy/common/property_contexts1
-rw-r--r--sepolicy/common/qemu_device_state.te13
-rw-r--r--vendor.mk3
23 files changed, 158 insertions, 22 deletions
diff --git a/64bitonly/product/vendor.mk b/64bitonly/product/vendor.mk
index 3a349167..b4f1e240 100644
--- a/64bitonly/product/vendor.mk
+++ b/64bitonly/product/vendor.mk
@@ -42,6 +42,7 @@ PRODUCT_PACKAGES += \
libcuttlefish-ril-2 \
libgoldfish-rild \
qemu-adb-keys \
+ qemu-device-state \
qemu-props \
stagefright \
fingerprint.ranchu \
@@ -263,6 +264,7 @@ PRODUCT_PROPERTY_OVERRIDES += ro.incremental.enable=yes
PRODUCT_COPY_FILES += \
device/generic/goldfish/data/etc/dtb.img:dtb.img \
+ device/generic/goldfish/emulator-info.txt:data/misc/emulator/version.txt \
device/generic/goldfish/data/etc/apns-conf.xml:data/misc/apns/apns-conf.xml \
device/generic/goldfish/radio/RadioConfig/radioconfig.xml:data/misc/emulator/config/radioconfig.xml \
device/generic/goldfish/data/etc/iccprofile_for_sim0.xml:data/misc/modem_simulator/iccprofile_for_sim0.xml \
@@ -293,7 +295,6 @@ PRODUCT_COPY_FILES += \
device/generic/goldfish/input/virtio_input_multi_touch_11.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/virtio_input_multi_touch_11.idc \
device/generic/goldfish/display_settings_freeform.xml:$(TARGET_COPY_OUT_VENDOR)/etc/display_settings_freeform.xml \
device/generic/goldfish/display_settings.xml:$(TARGET_COPY_OUT_VENDOR)/etc/display_settings.xml \
- device/generic/goldfish/device_state_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/devicestate/device_state_configuration.xml \
device/generic/goldfish/data/etc/config.ini:config.ini \
device/generic/goldfish/wifi/simulated_hostapd.conf:$(TARGET_COPY_OUT_VENDOR)/etc/simulated_hostapd.conf \
device/generic/goldfish/wifi/wpa_supplicant.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant.conf \
diff --git a/data/etc/advancedFeatures.ini b/data/etc/advancedFeatures.ini
index 211c31cd..d6cb066e 100644
--- a/data/etc/advancedFeatures.ini
+++ b/data/etc/advancedFeatures.ini
@@ -26,3 +26,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/data/etc/advancedFeatures.ini.arm b/data/etc/advancedFeatures.ini.arm
index 2d8d0066..a7bc7f93 100644
--- a/data/etc/advancedFeatures.ini.arm
+++ b/data/etc/advancedFeatures.ini.arm
@@ -25,3 +25,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/data/etc/google/64bit/user/advancedFeatures.ini b/data/etc/google/64bit/user/advancedFeatures.ini
index 8e362e15..91f7635b 100644
--- a/data/etc/google/64bit/user/advancedFeatures.ini
+++ b/data/etc/google/64bit/user/advancedFeatures.ini
@@ -27,3 +27,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/data/etc/google/64bit/user/arm64/advancedFeatures.ini b/data/etc/google/64bit/user/arm64/advancedFeatures.ini
index f4bea5ea..dbfb12c8 100644
--- a/data/etc/google/64bit/user/arm64/advancedFeatures.ini
+++ b/data/etc/google/64bit/user/arm64/advancedFeatures.ini
@@ -26,3 +26,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/data/etc/google/64bit/userdebug/advancedFeatures.ini b/data/etc/google/64bit/userdebug/advancedFeatures.ini
index 8e362e15..91f7635b 100644
--- a/data/etc/google/64bit/userdebug/advancedFeatures.ini
+++ b/data/etc/google/64bit/userdebug/advancedFeatures.ini
@@ -27,3 +27,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/data/etc/google/64bit/userdebug/arm64/advancedFeatures.ini b/data/etc/google/64bit/userdebug/arm64/advancedFeatures.ini
index 70bd240f..372836db 100644
--- a/data/etc/google/64bit/userdebug/arm64/advancedFeatures.ini
+++ b/data/etc/google/64bit/userdebug/arm64/advancedFeatures.ini
@@ -25,3 +25,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/data/etc/google/user/advancedFeatures.ini b/data/etc/google/user/advancedFeatures.ini
index 96b75e3b..1e9327be 100644
--- a/data/etc/google/user/advancedFeatures.ini
+++ b/data/etc/google/user/advancedFeatures.ini
@@ -27,3 +27,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/data/etc/google/user/arm64/advancedFeatures.ini b/data/etc/google/user/arm64/advancedFeatures.ini
index 784af9b7..64ede30b 100644
--- a/data/etc/google/user/arm64/advancedFeatures.ini
+++ b/data/etc/google/user/arm64/advancedFeatures.ini
@@ -26,3 +26,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/data/etc/google/userdebug/advancedFeatures.ini b/data/etc/google/userdebug/advancedFeatures.ini
index d70f9f22..ceef6744 100644
--- a/data/etc/google/userdebug/advancedFeatures.ini
+++ b/data/etc/google/userdebug/advancedFeatures.ini
@@ -28,3 +28,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/data/etc/google/userdebug/arm64/advancedFeatures.ini b/data/etc/google/userdebug/arm64/advancedFeatures.ini
index 2d8d0066..a7bc7f93 100644
--- a/data/etc/google/userdebug/arm64/advancedFeatures.ini
+++ b/data/etc/google/userdebug/arm64/advancedFeatures.ini
@@ -25,3 +25,4 @@ AndroidbootProps2 = on
DeviceSkinOverlay = on
VulkanQueueSubmitWithCommands = on
VulkanBatchedDescriptorSetUpdate = on
+DeviceStateOnBoot = on
diff --git a/device_state_configuration.xml b/device_state_configuration.xml
deleted file mode 100644
index 17a09c45..00000000
--- a/device_state_configuration.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<device-state-config>
- <device-state>
- <identifier>0</identifier>
- <conditions>
- <lid-switch>
- <open>false</open>
- </lid-switch>
- </conditions>
- </device-state>
- <device-state>
- <identifier>1</identifier>
- <conditions>
- <lid-switch>
- <open>true</open>
- </lid-switch>
- </conditions>
- </device-state>
-</device-state-config>
diff --git a/emulator-info.txt b/emulator-info.txt
index 532435c5..d1151206 100644
--- a/emulator-info.txt
+++ b/emulator-info.txt
@@ -1,2 +1,2 @@
# Emulator (stable) version
-require version-emulator=7479360
+require version-emulator=7637665
diff --git a/init.ranchu.rc b/init.ranchu.rc
index 327ac578..d62215dd 100644
--- a/init.ranchu.rc
+++ b/init.ranchu.rc
@@ -65,11 +65,13 @@ on init
on post-fs-data
setprop vold.post_fs_data_done 1
mkdir /data/vendor/adb 0755 root root
+ mkdir /data/vendor/devicestate 0755 root root
mkdir /data/vendor/var 0755 root root
mkdir /data/vendor/var/run 0755 root root
mkdir /data/vendor/var/run/netns 0755 root root
start qemu-adb-keys
+ start qemu-device-state
on zygote-start
# Create the directories used by the Wireless subsystem
@@ -200,6 +202,12 @@ service qemu-adb-keys /vendor/bin/qemu-adb-keys
group root
oneshot
+service qemu-device-state /vendor/bin/qemu-device-state
+ class core
+ user root
+ group root
+ oneshot
+
service goldfish-logcat /system/bin/logcat -f /dev/hvc1 ${ro.boot.logcat}
class main
user logd
diff --git a/init.system_ext.rc b/init.system_ext.rc
index 5f8cb4e0..5c2db835 100644
--- a/init.system_ext.rc
+++ b/init.system_ext.rc
@@ -5,3 +5,9 @@ on property:vendor.qemu.adb.copykey=1
copy /data/vendor/adb/adb_keys /data/misc/adb/adb_keys
chown system shell /data/misc/adb/adb_keys
chmod 0640 /data/misc/adb/adb_keys
+
+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
+ chown system system /data/system/devicestate/device_state_configuration.xml
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index e6524850..b7e54f5b 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -57,7 +57,7 @@
<!-- The device states (supplied by DeviceStateManager) that should be treated as folded by the
display fold controller. -->
<integer-array name="config_foldedDeviceStates" translatable="false">
- <item>0</item> <!-- CLOSED -->
+ <item>1</item> <!-- CLOSED -->
</integer-array>
<!-- This device is able to support the microphone and camera global toggles. -->
diff --git a/qemu-device-state/Android.bp b/qemu-device-state/Android.bp
new file mode 100644
index 00000000..ca186e0b
--- /dev/null
+++ b/qemu-device-state/Android.bp
@@ -0,0 +1,44 @@
+// 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-device-state",
+ vendor: true,
+ srcs: [
+ "qemu-device-state.cpp",
+ ],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ ],
+ static_libs: [
+ "libfstab",
+ ],
+ cflags: [
+ "-DLOG_TAG=\"qemu-device-state\"",
+ ],
+}
diff --git a/qemu-device-state/qemu-device-state.cpp b/qemu-device-state/qemu-device-state.cpp
new file mode 100644
index 00000000..f85f54f3
--- /dev/null
+++ b/qemu-device-state/qemu-device-state.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 program is used to read a set of system properties and their values
+ * from the emulator program and set them in the currently-running emulated
+ * system. It does so by connecting to the 'boot-properties' qemud service.
+ *
+ * This program should be run as root and called from
+ * /system/etc/init.ranchu.rc exclusively.
+ */
+
+#define LOG_TAG "qemu-device-state"
+
+#define DEBUG 0
+//#define LOG_NDEBUG 0
+
+#include <fstream>
+#include <iostream>
+#include <string.h>
+
+#include <log/log.h>
+
+#if DEBUG
+# define DD(...) ALOGD(__VA_ARGS__)
+#else
+# define DD(...) ((void)0)
+#endif
+
+#define DEVIE_STATE_PROP "qemu.device_state"
+// init will copy over this file to
+// /data/system/devicestate/device_state_configuration.xml
+#define DEVICE_STATE_FILE "/data/vendor/devicestate/device_state_configuration.xml"
+
+extern bool fs_mgr_get_boot_config(const std::string& key, std::string* out_val);
+
+int main(void) {
+ std::string deviceState;
+ if (!fs_mgr_get_boot_config(DEVIE_STATE_PROP, &deviceState)) {
+ ALOGV("%s bootconfig prop not set", DEVIE_STATE_PROP);
+ return 0;
+ }
+
+ std::ofstream f;
+ f.open(DEVICE_STATE_FILE);
+ if (!f.is_open()) {
+ ALOGE("Failed to open %s\n", DEVICE_STATE_FILE);
+ exit(1);
+ }
+
+ ALOGI("write to %s", DEVICE_STATE_FILE);
+ f << deviceState;
+ f.close();
+ return 0;
+}
diff --git a/sepolicy/common/file_contexts b/sepolicy/common/file_contexts
index aeeecbba..e259c3b4 100644
--- a/sepolicy/common/file_contexts
+++ b/sepolicy/common/file_contexts
@@ -31,6 +31,7 @@
/vendor/bin/init\.ranchu-net\.sh u:object_r:goldfish_setup_exec:s0
/vendor/bin/init\.wifi\.sh u:object_r:goldfish_setup_exec:s0
/vendor/bin/qemu-adb-keys u:object_r:qemu_adb_keys_exec:s0
+/vendor/bin/qemu-device-state u:object_r:qemu_device_state_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/createns u:object_r:createns_exec:s0
diff --git a/sepolicy/common/genfs_contexts b/sepolicy/common/genfs_contexts
index 3484eae9..68acdf25 100644
--- a/sepolicy/common/genfs_contexts
+++ b/sepolicy/common/genfs_contexts
@@ -86,6 +86,8 @@ genfscon sysfs /devices/pnp0/00:00/rtc/rtc0/alarmtimer.0.auto/wakeup/wakeup31
genfscon sysfs /devices/pnp0/00:00/rtc/rtc0/alarmtimer.0.auto/wakeup/wakeup31/event_count u:object_r:sysfs_wakeup:s0
genfscon sysfs /devices/pnp0/00:00/rtc/rtc0/alarmtimer.0.auto/wakeup/wakeup32 u:object_r:sysfs_wakeup:s0
genfscon sysfs /devices/pnp0/00:00/rtc/rtc0/alarmtimer.0.auto/wakeup/wakeup32/event_count u:object_r:sysfs_wakeup:s0
+genfscon sysfs /devices/pnp0/00:00/rtc/rtc0/alarmtimer.0.auto/wakeup/wakeup33 u:object_r:sysfs_wakeup:s0
+genfscon sysfs /devices/pnp0/00:00/rtc/rtc0/alarmtimer.0.auto/wakeup/wakeup33/event_count u:object_r:sysfs_wakeup:s0
genfscon sysfs /devices/pnp0/00:00/rtc/rtc0/wakeup u:object_r:sysfs_wakeup:s0
genfscon sysfs /devices/pnp0/00:00/wakeup/wakeup u:object_r:sysfs_wakeup:s0
genfscon sysfs /devices/virtual/wakeup/wakeup u:object_r:sysfs_wakeup:s0
diff --git a/sepolicy/common/property_contexts b/sepolicy/common/property_contexts
index 70d8c5c1..a776b0de 100644
--- a/sepolicy/common/property_contexts
+++ b/sepolicy/common/property_contexts
@@ -3,6 +3,7 @@ vendor.qemu.keyboard_layout u:object_r:vendor_qemu_prop:s0 exact string
vendor.qemu.networknamespace u:object_r:vendor_qemu_prop:s0 exact string
vendor.qemu.logcat_filter u:object_r:vendor_qemu_prop:s0 exact string
vendor.qemu.sf.fake_camera u:object_r:vendor_qemu_prop:s0 exact string
+vendor.qemu.vport.bluetooth u:object_r:vendor_qemu_prop:s0 exact string
vendor.qemu.vport.modem u:object_r:vendor_qemu_prop:s0 exact string
vendor.qemu.vport.gnss u:object_r:vendor_qemu_prop:s0 exact string
vendor.qemu.timezone u:object_r:vendor_qemu_prop:s0 exact string
diff --git a/sepolicy/common/qemu_device_state.te b/sepolicy/common/qemu_device_state.te
new file mode 100644
index 00000000..22952361
--- /dev/null
+++ b/sepolicy/common/qemu_device_state.te
@@ -0,0 +1,13 @@
+# qemu-device-state service: Writes host adb key for adbd on boot.
+type qemu_device_state, domain;
+type qemu_device_state_exec, vendor_file_type, exec_type, file_type;
+
+init_daemon_domain(qemu_device_state)
+
+# Allow qemu_device_state to read /proc/bootconfig
+allow qemu_device_state proc_cmdline:file r_file_perms;
+allow qemu_device_state proc_bootconfig:file r_file_perms;
+
+# Permission to write to /data/vendor/system/devicestate.
+allow qemu_device_state vendor_data_file:dir create_dir_perms;
+allow qemu_device_state vendor_data_file:file create_file_perms;
diff --git a/vendor.mk b/vendor.mk
index f0119f0b..8013dde6 100644
--- a/vendor.mk
+++ b/vendor.mk
@@ -42,6 +42,7 @@ PRODUCT_PACKAGES += \
libcuttlefish-ril-2 \
libgoldfish-rild \
qemu-adb-keys \
+ qemu-device-state \
qemu-props \
stagefright \
fingerprint.ranchu \
@@ -267,6 +268,7 @@ PRODUCT_PROPERTY_OVERRIDES += ro.incremental.enable=yes
PRODUCT_COPY_FILES += \
device/generic/goldfish/data/etc/dtb.img:dtb.img \
+ device/generic/goldfish/emulator-info.txt:data/misc/emulator/version.txt \
device/generic/goldfish/data/etc/apns-conf.xml:data/misc/apns/apns-conf.xml \
device/generic/goldfish/radio/RadioConfig/radioconfig.xml:data/misc/emulator/config/radioconfig.xml \
device/generic/goldfish/data/etc/iccprofile_for_sim0.xml:data/misc/modem_simulator/iccprofile_for_sim0.xml \
@@ -297,7 +299,6 @@ PRODUCT_COPY_FILES += \
device/generic/goldfish/input/virtio_input_multi_touch_11.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/virtio_input_multi_touch_11.idc \
device/generic/goldfish/display_settings_freeform.xml:$(TARGET_COPY_OUT_VENDOR)/etc/display_settings_freeform.xml \
device/generic/goldfish/display_settings.xml:$(TARGET_COPY_OUT_VENDOR)/etc/display_settings.xml \
- device/generic/goldfish/device_state_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/devicestate/device_state_configuration.xml \
device/generic/goldfish/data/etc/config.ini:config.ini \
device/generic/goldfish/wifi/simulated_hostapd.conf:$(TARGET_COPY_OUT_VENDOR)/etc/simulated_hostapd.conf \
device/generic/goldfish/wifi/wpa_supplicant.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant.conf \