Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACCESS_MOCK_LOCATION #154

Closed
rompic opened this issue Jun 10, 2016 · 13 comments
Closed

ACCESS_MOCK_LOCATION #154

rompic opened this issue Jun 10, 2016 · 13 comments

Comments

@rompic
Copy link

rompic commented Jun 10, 2016

When I try to set a mock location on an emulator (Nexus_5_API_22) the appium settings is killed and I get the following info in the emulator log:

06-10 13:17:03.080: E/AndroidRuntime(7966): FATAL EXCEPTION: main
06-10 13:17:03.080: E/AndroidRuntime(7966): Process: io.appium.settings, PID: 7966
06-10 13:17:03.080: E/AndroidRuntime(7966): java.lang.RuntimeException: Unable to start service io.appium.settings.LocationService@21c91729 with Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=io.appium.settings/.LocationService (has extras) }: java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION secure setting
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2911)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread.access$2100(ActivityThread.java:151)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1401)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.os.Handler.dispatchMessage(Handler.java:102)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.os.Looper.loop(Looper.java:135)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread.main(ActivityThread.java:5254)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at java.lang.reflect.Method.invoke(Native Method)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at java.lang.reflect.Method.invoke(Method.java:372)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
06-10 13:17:03.080: E/AndroidRuntime(7966): Caused by: java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION secure setting
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.os.Parcel.readException(Parcel.java:1546)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.os.Parcel.readException(Parcel.java:1499)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.location.ILocationManager$Stub$Proxy.addTestProvider(ILocationManager.java:1054)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.location.LocationManager.addTestProvider(LocationManager.java:1216)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at io.appium.settings.MockLocationProvider.pushLocation(MockLocationProvider.java:20)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at io.appium.settings.LocationService.onStartCommand(LocationService.java:25)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2894)
06-10 13:17:03.080: E/AndroidRuntime(7966):     ... 9 more

I'm running appium 1.5.3 on MacOSX 10.11.5
any hints?

@rompic
Copy link
Author

rompic commented Jun 10, 2016

settings

@rompic
Copy link
Author

rompic commented Jun 10, 2016

@SrinivasanTarget
Copy link
Member

Can you please try the same in API Level 21 or lesser than 22 and update us?

@rompic
Copy link
Author

rompic commented Jun 10, 2016

can do (again).. guess it is the same as appium/java-client#407

@rompic
Copy link
Author

rompic commented Jun 10, 2016

on API level 21 I get:
06-10 14:09:13.599: W/ActivityManager(1484): Unable to start service Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=io.appium.settings/.LocationService (has extras) } U=0: not found

in the android log

@rompic
Copy link
Author

rompic commented Jun 10, 2016

may that's also why it doesn't work on API level 21

@imurchie
Copy link
Contributor

The app has mock location access on (see https://github.com/appium/io.appium.settings/blob/master/AndroidManifest.xml#L32). Not sure why it is failing.

@rompic
Copy link
Author

rompic commented Jun 11, 2016

i just noticed that allow mock locations is not enabled by default in the api level 22 nexus 5 emulators (with google api).
it works after activating this setting.

however no luck with api level 21.

@rompic
Copy link
Author

rompic commented Jun 11, 2016

i can start the service via adb shell on api level 22 but not on 21

am startservice -e longitude 1 -e latitude 2 io.appium.settings/.LocationService
Starting service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=io.appium.settings/.LocationServiceam (has extras) }
Error: Not found; no service started.

@rompic
Copy link
Author

rompic commented Jun 11, 2016

i manually uninstalled the appium settings app from the emulator and it seems that a newer version was installed by appium now. it now also works on api level 21.

However Appium should propably check the version.
06-10 15:38:16.747: W/PackageManager(1484): Attempt to re-install io.appium.settings without first uninstalling.

the problem could be that https://github.com/appium/io.appium.settings/blob/master/AndroidManifest.xml#L32 still has version 1.0 ?

@rompic
Copy link
Author

rompic commented Jun 11, 2016

maybe this should be true otherwise?

await adb.install(settingsApkPath, false);

@rompic
Copy link
Author

rompic commented Jun 11, 2016

for completeness: setting locations also works on Api 23 after sleecting the app in the developer settings to allow setting mock locations.

@rkavalap
Copy link

rkavalap commented Dec 6, 2016

Issue moved to appium/appium #7404 via ZenHub

@rkavalap rkavalap closed this as completed Dec 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants