From bcbffd18cda8b95daa2b37c5d0a3c9ae2d98581b Mon Sep 17 00:00:00 2001 From: Andreas Blaesius Date: Tue, 23 Feb 2016 13:39:04 -0800 Subject: espresso: set espresso and espressowifi variants to portrait mode PS1: initial setup, hwrotation on init for espresso and espressowifi variants PS2-5: proper Selinux rules for Android 5.1 and newer, move ramdisk to system/bin PS6: also set accelerometer and geomagnetic position via sysfs and update Selinux rules Change-Id: I43c662fe98f460e3380aeaa230b1d139d95bd262 --- espresso-common.mk | 3 +++ init.espresso.variant.sh | 29 +++++++++++++++++++++++++++++ rootdir/etc/init.tab2.rc | 6 ++++++ sepolicy/file_contexts | 3 +++ sepolicy/property.te | 3 +++ sepolicy/property_contexts | 2 ++ sepolicy/variant_setup.te | 21 +++++++++++++++++++++ 7 files changed, 67 insertions(+) create mode 100644 init.espresso.variant.sh create mode 100644 sepolicy/property.te create mode 100644 sepolicy/property_contexts create mode 100644 sepolicy/variant_setup.te diff --git a/espresso-common.mk b/espresso-common.mk index 3c01fb1..04f3562 100644 --- a/espresso-common.mk +++ b/espresso-common.mk @@ -39,6 +39,9 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ init.recovery.espresso.rc +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/init.espresso.variant.sh:system/bin/init.espresso.variant.sh + # GPS # gps config appropriate for this device $(call inherit-product, device/common/gps/gps_us_supl.mk) diff --git a/init.espresso.variant.sh b/init.espresso.variant.sh new file mode 100644 index 0000000..81ff4e2 --- /dev/null +++ b/init.espresso.variant.sh @@ -0,0 +1,29 @@ +#!/system/bin/sh +# Copyright (c) 2016 OMAP4-AOSP +# Copyright (c) Ketut P. Kumajaya, Sept 2013 + +export PATH=/system/bin + +DEVICE=/sys/board_properties/type + +if [ -f "$DEVICE" ] +then + variant=`cat $DEVICE` + case "$variant" in + "espresso" | "espressowifi") + # set p31xx to portrait mode + setprop ro.sf.hwrotation 270 + + # set mms136 touchcreen driver orientation + echo 1 > /sys/devices/virtual/sec/tsp/pivot + + # set accelerometer position + position=$(find /sys/devices/virtual/input/ -type f -name name | xargs grep '^accelerometer$' | sed 's@name:accelerometer@position@') + echo -n 6 > $position + + # set geomagnetic position + position=$(find /sys/devices/platform/omap/omap_i2c.4/i2c-4/4-002e/input/ -type f -name name | xargs grep '^geomagnetic$' | sed 's@name:geomagnetic@position@') + echo -n 6 > $position + ;; + esac +fi diff --git a/rootdir/etc/init.tab2.rc b/rootdir/etc/init.tab2.rc index fb87c16..aaa10c7 100644 --- a/rootdir/etc/init.tab2.rc +++ b/rootdir/etc/init.tab2.rc @@ -365,6 +365,12 @@ service dock_kbd_attach /system/bin/dock_kbd_attach /dev/ttyO3 user root oneshot +# Set 7 inch devices as portrait device +service variant_setup /system/bin/init.espresso.variant.sh + class main + user root + oneshot + # LPM on property:ro.bootmode=charger mount ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/FACTORYFS /system wait ro diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index 2161cde..960bc88 100644 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -44,3 +44,6 @@ # Firmwares /system/vendor/firmware/ducati-m3.bin u:object_r:firmware_ducati:s0 + +# variant setup +/system/bin/init\.espresso\.variant\.sh u:object_r:variant_setup_exec:s0 diff --git a/sepolicy/property.te b/sepolicy/property.te new file mode 100644 index 0000000..a6ba71b --- /dev/null +++ b/sepolicy/property.te @@ -0,0 +1,3 @@ +# hwrotation prop need a own type to be set on init.espreso.variants.sh, +# else it would conflict with a neverallow rule +type rotation_prop, property_type; diff --git a/sepolicy/property_contexts b/sepolicy/property_contexts new file mode 100644 index 0000000..69ad081 --- /dev/null +++ b/sepolicy/property_contexts @@ -0,0 +1,2 @@ +# label hwrotation prop to set it on init.espreso.variants.sh +sf.hwrotation u:object_r:rotation_prop:s0 diff --git a/sepolicy/variant_setup.te b/sepolicy/variant_setup.te new file mode 100644 index 0000000..b4072ca --- /dev/null +++ b/sepolicy/variant_setup.te @@ -0,0 +1,21 @@ +# Variant-Setup script (init.espresso.variant.sh) +type variant_setup, domain; +type variant_setup_exec, exec_type, file_type; + +init_daemon_domain(variant_setup) + +# Run init.espresso.variant.sh +allow variant_setup shell_exec:file rx_file_perms; +allow variant_setup variant_setup_exec:file rx_file_perms; + +# Talk to init over the property socket +unix_socket_connect(variant_setup, property, init) + +# Allow getprop/setprop for init.espresso.variant.sh +allow variant_setup system_file:file execute_no_trans; +allow variant_setup rotation_prop:property_service set; + +# Set accelerometer and geomagnetic position via sysfs +allow variant_setup sysfs:file write; + +allow variant_setup self:capability dac_override; -- cgit v1.1