Page 1 of 1

"Simulation" on real devices

Posted: Wed Feb 07, 2018 12:00 pm
by aikvahidi
Is it possible to simulate (or set) the following options on real devices?
1) Wifi on/of
2) SIM card
3) Battery on/off
4) Airplane mode on/off
5) Wifi/Local network change
6) Screen orientation change

Re: "Simulation" on real devices

Posted: Thu Feb 08, 2018 1:32 pm
by qwertzu
Hi,
you could try to use android OS automation which helps automating system apps on an android device.
osautomation.jpg
regards, qwertzu

Re: "Simulation" on real devices

Posted: Thu Feb 08, 2018 2:23 pm
by aikvahidi
Thanks. But what if I want to test iOS?

Re: "Simulation" on real devices

Posted: Thu Feb 08, 2018 2:31 pm
by odklizec
Hi,

iOS does not allow automate system apps. It's iOS security thing. There is nothing Ranorex can do about this. In fact, some of the mentioned apps may not be possible to automate even on Android.

Re: "Simulation" on real devices

Posted: Mon Feb 26, 2018 2:54 pm
by hubjohn
I think some of the mentioned apps may not be possible to automate even on Android.

Re: "Simulation" on real devices

Posted: Tue Apr 23, 2019 9:31 am
by SanMan
On Android device (Android OS automation true)

How I can change e.g. Airplane mode ?

It must be some user code...?

Re: "Simulation" on real devices

Posted: Tue Apr 23, 2019 9:31 am
by SanMan
On Android device (Android OS automation true)

How I can change e.g. Airplane mode ?

It must be some user code...?

Re: "Simulation" on real devices

Posted: Tue Apr 23, 2019 9:39 am
by odklizec
Hi,

You will most probably have to use ADB command for this. You can learn how to send ADB commands in Ranorex for example here:
send-adb-commands-via-ranorex-t10596.html#p42515

For an example of code for switching airplane mode, check this page:
https://stackoverflow.com/questions/105 ... b/23413344
Basically, you just need to extract the adb arguments from the above link and apply them in Ranorex code from the first link.

Re: "Simulation" on real devices

Posted: Tue Apr 23, 2019 11:19 am
by SanMan
Hi odklizec,

thank you for your answer.

I managed to set the airplane mode UI status on/off, but could not switch the mode really on/off

C:\Program Files (x86)\Ranorex\Studio\Bin\RxEnv\Android\Tools>adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
Broadcasting: Intent { act=android.intent.action.AIRPLANE_MODE flg=0x400000 }
Security exception: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=27709, uid=2000

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=27709, uid=2000
at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:21899)
at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:22588)
at com.android.server.am.ActivityManagerShellCommand.runSendBroadcast(ActivityManagerShellCommand.java:683)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:174)
at android.os.ShellCommand.exec(ShellCommand.java:103)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:16532)
at android.os.Binder.shellCommand(Binder.java:634)
at android.os.Binder.onTransact(Binder.java:532)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3530)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3426)
at android.os.Binder.execTransact(Binder.java:731)

Seems that I need to modify "AndroidManifest.xml" file and add there permission:

<uses-permission android:name="android.permission.WRITE_SETTINGS" />

Is that right?

And where can I found this AndroidManifest.xml file? I did remove the folder "decomp" under..\Android\temp. Should it be auto created when building a project?

Re: "Simulation" on real devices

Posted: Tue Apr 23, 2019 11:46 am
by odklizec
Hi,

I believe the AndroidManifest.xml is created during APK instrumentation, not during building the test project?

Re: "Simulation" on real devices

Posted: Tue Apr 23, 2019 12:10 pm
by SanMan
Hi,

And now when I cannot instrument/use APK (made with crosswalk tech), is there any way I can get the AndroidManifest.xml what I could modify?

Re: "Simulation" on real devices

Posted: Wed Apr 24, 2019 11:17 am
by SanMan
I think "Install RxBrowser" did the job and got the AndroidManifest.xml

When I added the <uses-permission android:name="android.permission.WRITE_SETTINGS" />, I still got this error:

C:\Program Files (x86)\Ranorex\Studio\Bin\RxEnv\Android\Tools>adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
Broadcasting: Intent { act=android.intent.action.AIRPLANE_MODE flg=0x400000 }
Security exception: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=29648, uid=2000

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=29648, uid=2000
at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:21899)
at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:22588)
at com.android.server.am.ActivityManagerShellCommand.runSendBroadcast(ActivityManagerShellCommand.java:683)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:174)
at android.os.ShellCommand.exec(ShellCommand.java:103)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:16532)
at android.os.Binder.shellCommand(Binder.java:634)
at android.os.Binder.onTransact(Binder.java:532)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3530)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3426)
at android.os.Binder.execTransact(Binder.java:731)

What I browsed (and understood : ) ), seems that it is no longer possible to set airplane mode or mobile data mode on/off?

Wlan can be easily set by:
adb shell "svc wifi enable"

adb shell "svc wifi disable"

Re: "Simulation" on real devices

Posted: Fri Apr 26, 2019 12:43 pm
by RobinHood42
That seems to be true. According to this post, it is not possible.
https://stackoverflow.com/questions/438 ... -android-7

Cheers,
Robin