summaryrefslogtreecommitdiff
path: root/xr/scripts/boot-to-vr.sh
diff options
context:
space:
mode:
authorGrant Yoshida <gyoshida@google.com>2019-08-19 18:22:09 -0700
committerGrant Yoshida <gyoshida@google.com>2019-08-20 11:24:15 -0700
commit0f30e5e15d81742ce9bac99cbad35ebf758ee1bd (patch)
treebc9d877335181a95f83175a37ed5b4aa261b2d98 /xr/scripts/boot-to-vr.sh
parentfe14c1af518746cf4992f670ddda30e0d09e039f (diff)
downloadvrservices-0f30e5e15d81742ce9bac99cbad35ebf758ee1bd.tar.gz
Move boot-to-vr.sh to device/google/vrservices.
Test: Ran script on a GSI XR MTP. Change-Id: I332fe62d71864465ce25a7013433e404fff00123
Diffstat (limited to 'xr/scripts/boot-to-vr.sh')
-rwxr-xr-xxr/scripts/boot-to-vr.sh74
1 files changed, 74 insertions, 0 deletions
diff --git a/xr/scripts/boot-to-vr.sh b/xr/scripts/boot-to-vr.sh
new file mode 100755
index 0000000..853efb9
--- /dev/null
+++ b/xr/scripts/boot-to-vr.sh
@@ -0,0 +1,74 @@
+#
+# This script finds the init.rc file for a certain Pixel XR device and updates
+# the value of ro.boot.vr being set during the init process.
+#
+PROP_RO_HARDWARE="$(getprop ro.hardware)"
+PROP_RO_BOOT_HARDWARE_PLATFORM="$(getprop ro.boot.hardware.platform)"
+PROP_RO_PRODUCT_NAME="$(getprop ro.product.name)"
+
+function print_usage {
+ echo "Update $(get_init_rc_file)"
+ echo "Usage:"
+ echo " boot-to-vr.sh (true|false))"
+ echo " Enable or disable whether the system should boot into VR."
+ exit 1
+}
+
+function get_hardware_name() {
+ case $PROP_RO_HARDWARE in
+ walleye) echo walleye ;;
+ taimen) echo taimen ;;
+ blueline) echo $PROP_RO_BOOT_HARDWARE_PLATFORM ;;
+ crosshatch) echo $PROP_RO_BOOT_HARDWARE_PLATFORM ;;
+ esac
+}
+
+function get_init_rc_file() {
+ echo "/vendor/etc/init/hw/init.$(get_hardware_name).rc"
+}
+
+function print_init_rc() {
+ cat $(get_init_rc_file) | grep -A10 -B10 ro.boot.vr
+}
+
+function fail_to_write_file() {
+ echo "Cannot modify $(get_init_rc_file). The following commands may help:
+ adb disable-verity
+ adb reboot
+ adb remount"
+ exit 1
+}
+
+function enable_boot_to_vr() {
+ sed -i "s/setprop ro.boot.vr 0/setprop ro.boot.vr 1/" $(get_init_rc_file)
+ rc=$?
+
+ if [[ $rc != 0 ]]; then
+ fail_to_write_file
+ else
+ print_init_rc
+ fi
+}
+
+function disable_boot_to_vr() {
+ sed -i "s/setprop ro.boot.vr 1/setprop ro.boot.vr 0/" $(get_init_rc_file)
+ rc=$?
+
+ if [[ $rc != 0 ]]; then
+ fail_to_write_file
+ else
+ print_init_rc
+ fi
+}
+
+WHOAMI=$(whoami)
+if ! [ "$WHOAMI" == "root" ]; then
+ echo "*** Root access required. Run 'adb root' first."
+ exit 1
+fi
+
+case "$1" in
+ true) enable_boot_to_vr ;;
+ false) disable_boot_to_vr ;;
+ *) print_usage ;;
+esac