Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
R
ratelvirtuallocation
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ratel-modules
ratelvirtuallocation
Commits
c81046d9
Commit
c81046d9
authored
Jun 07, 2021
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 百度SDK已经设置为GCJ02了,hook端不需要再做经纬度转换
parent
6802981c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
23 deletions
+25
-23
build.gradle
app/build.gradle
+2
-2
XPosedPlugin.java
...ain/java/top/littlerich/virtuallocation/XPosedPlugin.java
+23
-21
No files found.
app/build.gradle
View file @
c81046d9
...
...
@@ -8,8 +8,8 @@ android {
applicationId
"com.virjar.ratel.virtuallocation"
minSdkVersion
19
targetSdkVersion
28
versionCode
20210
513
versionName
"v1.
5
"
versionCode
20210
607
versionName
"v1.
6
"
archivesBaseName
=
"JDY_${versionName}"
.
replace
(
' '
,
'_'
)
ndk
{
abiFilters
"armeabi-v7a"
,
"arm64-v8a"
//, "x86","arm64-v8a","x86_64"
...
...
app/src/main/java/top/littlerich/virtuallocation/XPosedPlugin.java
View file @
c81046d9
...
...
@@ -7,18 +7,13 @@ import android.os.Bundle;
import
android.util.Log
;
import
com.virjar.ratel.api.RatelToolKit
;
import
com.virjar.ratel.api.extension.FileLogger
;
import
com.virjar.ratel.api.inspect.ClassLoadMonitor
;
import
com.virjar.ratel.api.inspect.ForceFiledViewer
;
import
com.virjar.ratel.api.rposed.IRposedHookLoadPackage
;
import
com.virjar.ratel.api.rposed.RC_MethodHook
;
import
com.virjar.ratel.api.rposed.RposedBridge
;
import
com.virjar.ratel.api.rposed.RposedHelpers
;
import
com.virjar.ratel.api.rposed.callbacks.RC_LoadPackage
;
import
org.json.JSONObject
;
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationHandler
;
...
...
@@ -52,6 +47,8 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
}
Log
.
i
(
TAG
,
"虚拟定位位置:"
+
AppApplication
.
mockGPS
.
mLongitude
+
","
+
AppApplication
.
mockGPS
.
mLatitude
);
disableRatelMultiEnvLocationMock
();
handleGaoDeMap
();
handleBaiduMap
();
handleTencent
();
...
...
@@ -61,6 +58,16 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
}
private
static
void
disableRatelMultiEnvLocationMock
()
{
try
{
// 这个功能在ratel 1.5.1才支持,低版本不支持这个功能
RposedHelpers
.
callMethod
(
RatelToolKit
.
virtualEnv
,
"disableLocalMock"
);
}
catch
(
Throwable
throwable
)
{
//ignore
Log
.
e
(
TAG
,
"error"
,
throwable
);
}
}
private
static
void
handleOriginal
()
{
RC_MethodHook
replaceLocationListenerHook
=
new
RC_MethodHook
()
{
@Override
...
...
@@ -85,6 +92,7 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
double
tempLat
=
z
*
Math
.
sin
(
theta
);
location
.
setLatitude
(
tempLat
);
location
.
setLongitude
(
tempLng
);
Log
.
i
(
TAG
,
"onLocationChanged:("
+
location
.
getLongitude
()
+
","
+
location
.
getLatitude
()
+
")"
);
orignalListener
.
onLocationChanged
(
location
);
}
}
...
...
@@ -122,13 +130,13 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
return
;
}
if
(!
hasMapApi
)
{
double
x
=
AppApplication
.
mockGPS
.
mLongitude
-
0.0065
,
y
=
AppApplication
.
mockGPS
.
mLatitude
-
0.0035
;
double
z
=
Math
.
sqrt
(
x
*
x
+
y
*
y
)
-
0.00002
*
Math
.
sin
(
y
*
Math
.
PI
);
double
theta
=
Math
.
atan2
(
y
,
x
)
-
0.000003
*
Math
.
cos
(
x
*
Math
.
PI
);
double
tempLng
=
z
*
Math
.
cos
(
theta
);
double
tempLat
=
z
*
Math
.
sin
(
theta
);
location
.
setLatitude
(
tempLat
);
location
.
setLongitude
(
tempLng
);
//
double x = AppApplication.mockGPS.mLongitude - 0.0065, y = AppApplication.mockGPS.mLatitude - 0.0035;
//
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * Math.PI);
//
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * Math.PI);
//
double tempLng = z * Math.cos(theta);
//
double tempLat = z * Math.sin(theta);
location
.
setLatitude
(
AppApplication
.
mockGPS
.
mLatitude
);
location
.
setLongitude
(
AppApplication
.
mockGPS
.
mLongitude
);
}
}
});
...
...
@@ -307,6 +315,7 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
if
(!(
obj
.
getClass
().
getName
().
equals
(
"com.baidu.location.BDLocation"
)))
{
continue
;
}
//TODO 百度需要探测下坐标系。我们自己使用的GCG02,但是百度习惯使用BD09
//location.setLatitude();
//location.setLongitude();
RposedHelpers
.
callMethod
(
obj
,
"setLatitude"
,
AppApplication
.
mockGPS
.
mLatitude
);
...
...
@@ -379,16 +388,9 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
continue
;
}
// 我们是百度坐标系,这里是高德,所以进行一次坐标系转换
Location
location
=
(
Location
)
obj
;
double
x
=
AppApplication
.
mockGPS
.
mLongitude
-
0.0065
,
y
=
AppApplication
.
mockGPS
.
mLatitude
-
0.0035
;
double
z
=
Math
.
sqrt
(
x
*
x
+
y
*
y
)
-
0.00002
*
Math
.
sin
(
y
*
Math
.
PI
);
double
theta
=
Math
.
atan2
(
y
,
x
)
-
0.000003
*
Math
.
cos
(
x
*
Math
.
PI
);
double
tempLng
=
z
*
Math
.
cos
(
theta
);
double
tempLat
=
z
*
Math
.
sin
(
theta
);
location
.
setLatitude
(
tempLat
);
location
.
setLongitude
(
tempLng
);
location
.
setLatitude
(
AppApplication
.
mockGPS
.
mLatitude
);
location
.
setLongitude
(
AppApplication
.
mockGPS
.
mLongitude
);
// public void setAddress(String var1) {
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment