Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if device is landscape via ADB

Tags:

android

Is it possible to check a devices orientation via ADB?

Not by installing any software, calling any existing software, just through ADB. Would guess there is a status file somewhere in /proc, but could not find it yet.

like image 740
Sebastian Roth Avatar asked Apr 06 '12 07:04

Sebastian Roth


1 Answers

This can be done through the following command:

adb shell dumpsys | grep 'SurfaceOrientation' | awk '{ print $2 }'

The output will be an integer ranging from 0 to 3 for each of the four possible orientations. 0 and 2 are landscapes while 1 and 3 are portraits. As the dumpsys output is very large, the command might take a few seconds to complete.

Update: dgmltn's modification is likely much faster:

adb shell dumpsys input | grep 'SurfaceOrientation' | awk '{ print $2 }'
like image 152
tvkanters Avatar answered Oct 15 '22 23:10

tvkanters