0

referring to this answer: https://stackoverflow.com/a/25849595/5015502

does this work because only system apps are allowed to change allow_mock regardless of the permissions in the manifest? and you have to have root access to give an app system status?

how to prevent or detect this? as stated in the answer, the setting and unsetting is too fast to get detected.. so would this mean you would have to detect if there is root access and then basically assuming that mocking is possible and possibly restrict features of your app from all the users that have rooted their device and just might be mocking the location?

thank you for clarifying.

Community
  • 1
  • 1
Andi Cox
  • 25
  • 5

1 Answers1

1

It works because it uses root.

You can generally check for mock locations using Location.isFromMockProvider().

shkschneider
  • 17,833
  • 13
  • 59
  • 112
  • @AndiCox well I just happen to use this code :) Glad it helped – shkschneider Jun 16 '15 at 13:23
  • 1
    how reliable is this? is there a way to fake this as well? with root? or would this require a custom rom then? if yes, is there a way to check if the os is modified? – Andi Cox Jun 16 '15 at 13:23
  • 1
    Rooted users could always fake a GPS position, yes. Basically a rooted user can tell the phone its GPS coordinates, making that (fake) position not a *mock* but a *gps* provider one. – shkschneider Jun 16 '15 at 13:25
  • so, even root alone makes this information unreliable... so i guess there is no way of detecting if the user is REALLY at the specified location? – Andi Cox Jun 16 '15 at 13:27
  • 1
    Not that I know of. As root, I always could fake my position as being true GPS position. – shkschneider Jun 16 '15 at 13:47
  • isFromMockProvider does not work on sdk < 18, is there any other option? – Sibelius Seraphini Jun 24 '16 at 14:38
  • @SibeliusSeraphini To Prevent/Detect mock location below API 18 check out this link https://stackoverflow.com/questions/6880232/disable-check-for-mock-location-prevent-gps-spoofing – Harsh Sharma Dec 03 '17 at 09:54