androidapkdecompilingsmalimock-location

Can anyone help me avoid being detected when using mock locations on an app, I have decompiled and pasted a code from it,s smali file


.line 1854
invoke-virtual {p1}, Landroid/location/Location;->isFromMockProvider()Z

move-result p1

goto :goto_6

.line 1856
:cond_d
iget-object p1, p0, Lcom/bel/HYS/FileexplorerActivity$NetworkHitLatLong;->this$0:Lcom/bel/HYS/FileexplorerActivity;

invoke-static {p1}, Lcom/bel/HYS/FileexplorerActivity;->access$100(Lcom/bel/HYS/FileexplorerActivity;)Landroid/content/Context;

move-result-object p1

invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object p1

const-string v7, "mock_location"

invoke-static {p1, v7}, Landroid/provider/Settings$Secure;->getString(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;

move-result-object p1

const-string v7, "0"

invoke-virtual {p1, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result p1

xor-int/2addr p1, v5

:goto_6
if-eqz p1, :cond_e

I tried fixing the value of p1 by const/4 p1, 0x0 after the line containing isfrommockprovider()Z but the problem persisted. I also tried to change if-eqz p1 directly to goto but it still didn't resolve.


Solution

  • Directly modifying p1 after the invoke-virtual call

    invoke-virtual {p1}, Landroid/location/Location;->isFromMockProvider()Z
    move-result p1
    ...
    

    is not a good idea. Because the return value of isFromMockProvider() will be written one command later by move-result p1 into p1. So changing it before that will not have any effect as it is overwritten by move-result.

    As invoking isFromMockProvider() has no other effect than the return value I would replace both calls shown above (invoke-virtual and move-result) by the line

    const/4 p1, 0x0
    

    If it still doesn't work then this is not the only check.