query to get the device orientation

1,358 views
Skip to first unread message

sahiti ch

unread,
Sep 18, 2014, 9:06:59 AM9/18/14
to calabash...@googlegroups.com
Is there any way that we can get the orientation of a device??



Thanks
Sahiti

Noffica

unread,
Sep 26, 2014, 1:19:55 PM9/26/14
to calabash...@googlegroups.com
Do wish to check whether the orientation changes automatically depending on certain situations or do you simply wish to check the orientation before performing further actions?

Jani Jegoroff

unread,
Sep 27, 2014, 1:49:23 PM9/27/14
to calabash...@googlegroups.com
I see three options:

1. Try out the simple gem I just published: https://rubygems.org/gems/android-adb-extension
See documentation and github page how to use it.

2. Query orientation using adb shell command.

3. Most probably your application source code contains an utility method to check current orientation. Call that method through Calabash backdoor.

sahiti chittimotu

unread,
Sep 27, 2014, 5:40:20 PM9/27/14
to calabash...@googlegroups.com
I would like to check the orientation before performing further actions. At the moment,  I had a test to rotate the device using  perform_action('set_activity_orientation', 'landscape') however there's no verification step whether the device really rotated or not as we had it in iOS using backdoor method which returns the present device orientation. 

I will try these below options mentioned by Jani

Thanks
Sahiti

On Fri, Sep 26, 2014 at 6:19 PM, Noffica <nauman....@goclio.com> wrote:
Do wish to check whether the orientation changes automatically depending on certain situations or do you simply wish to check the orientation before performing further actions?

--
You received this message because you are subscribed to a topic in the Google Groups "calabash-android" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/calabash-android/WebaOnAsgok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to calabash-andro...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sahiti chittimotu

unread,
Sep 29, 2014, 6:24:37 AM9/29/14
to calabash...@googlegroups.com
Hi Jani,

I have got this below adb command to return the device orientation, however is there a way to use this in ruby i.e inside our steps

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

Thanks



--

sahiti chittimotu

unread,
Sep 29, 2014, 6:31:23 AM9/29/14
to calabash...@googlegroups.com
It worked using below command... Thanks for your help.

system("adb shell dumpsys | grep 'SurfaceOrientation' | awk '{ print $2 }'")

Jani Jegoroff

unread,
Sep 29, 2014, 7:37:54 AM9/29/14
to calabash...@googlegroups.com
Yep, that will work. However, it is quite slow command (will take 2-3 seconds to complete).

sahiti chittimotu

unread,
Sep 30, 2014, 10:34:57 AM9/30/14
to calabash...@googlegroups.com
Thank you very much Jani.  Now I have added this gem ' android-adb-extension' to my gemFile. 
It's working perfectly for all my rotation needs.


Thanks

sahiti ch

unread,
Oct 16, 2014, 4:01:59 AM10/16/14
to calabash...@googlegroups.com
Hi Jani,

All of my rotation tests are failing on Jenkins with below error, on my local machine working fine. Can't figure it out what might have gone wrong. 

 No such file or directory - adb (Errno::ENOENT)
      /var/lib/jenkins/.rvm/gems/ruby-2.1.1/gems/android-adb-extension-0.0.1/lib/android-adb-extension/adb.rb:66:in ``'
      /var/lib/jenkins/.rvm/gems/ruby-2.1.1/gems/android-adb-extension-0.0.1/lib/android-adb-extension/adb.rb:66:in `set_accelerometer_control'
      /var/lib/jenkins/.rvm/gems/ruby-2.1.1/gems/android-adb-extension-0.0.1/lib/android-adb-extension/adb.rb:28:in `After'

Please help me?

Thanks

Jani Jegoroff

unread,
Oct 16, 2014, 7:55:40 AM10/16/14
to calabash...@googlegroups.com
Could you take latest version (android-adb-extension-0.0.3) in use?

Is Android SDK installed correctly to the Jenkins? What happens if you execute command adb in jenkins terminal?

sahiti chittimotu

unread,
Oct 16, 2014, 11:15:45 AM10/16/14
to calabash...@googlegroups.com
Hi Jani,

When i executed adb command in the jenkins terminal, it returned 'command not found'.

So I have executed: 1)    'apt-get install android-tools-adb'  command, then 2)  adb

Now it returned below output:

 -a                            - directs adb to listen on all interfaces for a connection
 -d                            - directs command to the only connected USB device
                                 returns an error if more than one USB device is present.
 -e                            - directs command to the only running emulator.
                                 returns an error if more than one emulator is running.
......etc

However on my jenkins, tests are still failing with the below error

ADB server didn't ACK
* failed to start daemon *



Thanks
Sahiti

Jani Jegoroff

unread,
Oct 16, 2014, 11:44:01 AM10/16/14
to calabash...@googlegroups.com
I'm not familiar installing android tools via apt-get. I recommend you install android tools via android SDK manager.

sahiti chittimotu

unread,
Oct 17, 2014, 6:29:50 AM10/17/14
to calabash...@googlegroups.com
Hi Jani,

Android tools have already installed in Jenkins machine by using Android SDK manager. 

When I executed  'which adb' command, it returned:     /usr/lib/android-sdk-linux/platform-tools/adb



Thanks
Sahiti
Reply all
Reply to author
Forward
0 new messages