You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何修改Smali代码以规避Mock Location检测?

Bypassing Mock Location Detection in This Smali Code

Great question! Let's break down how to modify this Smali snippet to avoid triggering the mock location warning. First, let's understand what the original code does:

The core logic here relies on Location.isFromMockProvider() to check if the location is spoofed. If the result (v1) is non-zero (meaning it's a mock location), the app sends a broadcast that likely triggers the warning interface. If it's zero (legitimate location), it proceeds with normal location handling.

Here are three straightforward ways to bypass this check:

Option 1: Force the mock check result to always be "legitimate"

Add a line right after getting the result of isFromMockProvider() to override it with a "false" value. This makes the app think every location is legitimate:

.registers 10
.annotation build Landroidx/annotation/RequiresApi; api = 0x12
.end annotation
const-string v0, "0"
.line 1
invoke-virtual {p1}, Landroid/location/Location;->isFromMockProvider()Z
move-result v1
# Force v1 to 0 (non-mock) regardless of actual value
const/4 v1, 0x0
const-string v2, "IS_MOCK"
const-string v3, "LIVE_TRACKING_MOCK_LOCATION"
if-eqz v1, :cond_1e
.line 2
new-instance p1, Landroid/content/Intent;
invoke-direct {p1, v3}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
const-string v0, "false"
.line 3
invoke-virtual {p1, v2, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
.line 4
invoke-static {p0}, Landroidx/localbroadcastmanager/content/LocalBroadcastManager;->getInstance(Landroid/content/Context;)Landroidx/localbroadcastmanager/content/LocalBroadcastManager;
move-result-object v0
invoke-virtual {v0, p1}, Landroidx/localbroadcastmanager/content/LocalBroadcastManager;->sendBroadcast(Landroid/content/Intent;)Z
return-void
.line 5
:cond_1e
new-instance v1, Landroid/content/Intent;
invoke-direct {v1, v3}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
const-string v3, "false"

Option 2: Skip the mock check entirely

Replace the conditional check with a direct jump to the normal location handling branch. This skips the mock warning logic entirely:

.registers 10
.annotation build Landroidx/annotation/RequiresApi; api = 0x12
.end annotation
const-string v0, "0"
.line 1
invoke-virtual {p1}, Landroid/location/Location;->isFromMockProvider()Z
move-result v1
const-string v2, "IS_MOCK"
const-string v3, "LIVE_TRACKING_MOCK_LOCATION"
# Jump straight to normal location handling, bypassing mock check
goto :cond_1e
.line 2
new-instance p1, Landroid/content/Intent;
invoke-direct {p1, v3}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
const-string v0, "false"
.line 3
invoke-virtual {p1, v2, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
.line 4
invoke-static {p0}, Landroidx/localbroadcastmanager/content/LocalBroadcastManager;->getInstance(Landroid/content/Context;)Landroidx/localbroadcastmanager/content/LocalBroadcastManager;
move-result-object v0
invoke-virtual {v0, p1}, Landroidx/localbroadcastmanager/content/LocalBroadcastManager;->sendBroadcast(Landroid/content/Intent;)Z
return-void
.line 5
:cond_1e
new-instance v1, Landroid/content/Intent;
invoke-direct {v1, v3}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
const-string v3, "false"

Option 3: Remove the mock detection logic completely

Delete the entire block that handles mock locations. This cleans up the code and eliminates any chance of the warning triggering:

.registers 10
.annotation build Landroidx/annotation/RequiresApi; api = 0x12
.end annotation
const-string v0, "0"
.line 1
invoke-virtual {p1}, Landroid/location/Location;->isFromMockProvider()Z
move-result v1
const-string v2, "IS_MOCK"
const-string v3, "LIVE_TRACKING_MOCK_LOCATION"
.line 5
:cond_1e
new-instance v1, Landroid/content/Intent;
invoke-direct {v1, v3}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
const-string v3, "false"

After making any of these changes, recompile the Smali file back into the APK and sign it properly, and the app will no longer detect your mock location.

内容的提问来源于stack exchange,提问作者AJESHKUMAR T G

火山引擎 最新活动