OSDN Git Service

Force orientation if no sensors
authorChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 18 Oct 2016 16:37:31 +0000 (00:37 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 18 Oct 2016 16:37:31 +0000 (00:37 +0800)
If no known sensors are detected, force the device to remain in its
default orientation. Activities that desire to run in a non-compatible
orientation will be run from an emulated display within the physical
display.

init.sh
overlay/frameworks/base/core/res/res/values/config.xml

diff --git a/init.sh b/init.sh
index b287ec7..f9b268b 100644 (file)
--- a/init.sh
+++ b/init.sh
@@ -169,6 +169,7 @@ function init_hal_sensors()
        [ -f /system/lib/hw/sensors.${ro_hardware}.so ] && return 0
 
        local hal_sensors=kbd
+       local has_sensors=true
        case "$(cat $DMIPATH/uevent)" in
                *Lucid-MWE*)
                        set_property ro.ignore_atkbd 1
@@ -236,6 +237,7 @@ function init_hal_sensors()
                        set_property hal.sensors.iio.accel.matrix 0,1,0,1,0,0,0,0,-1
                        ;;
                *)
+                       has_sensors=false
                        ;;
        esac
 
@@ -248,6 +250,8 @@ function init_hal_sensors()
        fi
 
        set_property ro.hardware.sensors $hal_sensors
+       [ "$hal_sensors" != "kbd" ] && has_sensors=true
+       set_property config.override_forced_orient $has_sensors
 }
 
 function create_pointercal()
index ec4dec5..0762c94 100644 (file)
@@ -82,4 +82,9 @@
     <!-- When true use the linux /dev/input/event subsystem to detect the switch changes
          on the headphone/microphone jack. When false use the older uevent framework. -->
     <bool name="config_useDevInputEventForAudioJack">true</bool>
+
+    <!-- Flag indicating that this device does not rotate and will always remain in its default
+         orientation. Activities that desire to run in a non-compatible orientation will be run
+         from an emulated display within the physical display. -->
+    <bool name="config_forceDefaultOrientation">true</bool>
 </resources>