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
4908210b
Commit
4908210b
authored
Apr 21, 2021
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
个大图商坐标系转换
parent
b27b4934
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
9 deletions
+37
-9
build.gradle
app/build.gradle
+2
-2
XPosedPlugin.java
...ain/java/top/littlerich/virtuallocation/XPosedPlugin.java
+31
-7
AppApplication.java
...top/littlerich/virtuallocation/common/AppApplication.java
+4
-0
No files found.
app/build.gradle
View file @
4908210b
...
...
@@ -8,8 +8,8 @@ android {
applicationId
"com.virjar.ratel.virtuallocation"
minSdkVersion
19
targetSdkVersion
28
versionCode
2021042
0
versionName
"v1.
3
"
versionCode
2021042
1
versionName
"v1.
4
"
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 @
4908210b
...
...
@@ -36,6 +36,7 @@ import top.littlerich.virtuallocation.common.AppApplication;
public
class
XPosedPlugin
implements
IRposedHookLoadPackage
{
private
static
final
String
TAG
=
AppApplication
.
tag
;
private
static
boolean
hasMapApi
=
false
;
@Override
public
void
handleLoadPackage
(
RC_LoadPackage
.
LoadPackageParam
loadPackageParam
)
throws
Throwable
{
...
...
@@ -76,8 +77,15 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
LocationListener
fakeLocationListener
=
new
LocationListener
()
{
@Override
public
void
onLocationChanged
(
Location
location
)
{
location
.
setLatitude
(
AppApplication
.
mockGPS
.
mLatitude
);
location
.
setLongitude
(
AppApplication
.
mockGPS
.
mLongitude
);
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
);
}
}
@Override
...
...
@@ -112,8 +120,15 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
if
(
location
==
null
)
{
return
;
}
location
.
setLatitude
(
AppApplication
.
mockGPS
.
mLatitude
);
location
.
setLongitude
(
AppApplication
.
mockGPS
.
mLongitude
);
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
);
}
}
});
}
...
...
@@ -128,6 +143,7 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
@Override
public
void
onClassLoad
(
final
Class
<?>
clazz
)
{
Log
.
i
(
AppApplication
.
tag
,
"命中腾讯API:"
+
clazz
);
hasMapApi
=
true
;
// public final int requestLocationUpdates(TencentLocationRequest var1, TencentLocationListener var2) {
// public final int requestLocationUpdates(TencentLocationRequest var1, TencentLocationListener var2, Looper var3) {
//public final int requestSingleFreshLocation(TencentLocationRequest var1, TencentLocationListener var2, Looper var3) {
...
...
@@ -263,6 +279,7 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
@Override
public
void
onClassLoad
(
Class
<?>
clazz
)
{
Log
.
i
(
AppApplication
.
tag
,
"命中百度API:"
+
clazz
);
hasMapApi
=
true
;
RposedBridge
.
hookAllMethods
(
clazz
,
"registerLocationListener"
,
new
RC_MethodHook
()
{
@Override
protected
void
beforeHookedMethod
(
MethodHookParam
param
)
throws
Throwable
{
...
...
@@ -326,7 +343,7 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
@Override
public
void
onClassLoad
(
Class
<?>
clazz
)
{
Log
.
i
(
AppApplication
.
tag
,
"命中高德API:"
+
clazz
);
hasMapApi
=
true
;
RposedHelpers
.
findAndHookMethod
(
clazz
,
"setLocationListener"
,
"com.amap.api.location.AMapLocationListener"
,
new
RC_MethodHook
()
{
...
...
@@ -361,9 +378,16 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
continue
;
}
// 我们是百度坐标系,这里是高德,所以进行一次坐标系转换
Location
location
=
(
Location
)
obj
;
location
.
setLatitude
(
AppApplication
.
mockGPS
.
mLatitude
);
location
.
setLongitude
(
AppApplication
.
mockGPS
.
mLongitude
);
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
);
// public void setAddress(String var1) {
try
{
...
...
app/src/main/java/top/littlerich/virtuallocation/common/AppApplication.java
View file @
4908210b
...
...
@@ -19,6 +19,7 @@ import org.json.JSONObject;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.Random
;
import
top.littlerich.virtuallocation.model.Gps
;
import
top.littlerich.virtuallocation.service.LocationService
;
...
...
@@ -150,6 +151,9 @@ public class AppApplication extends Application {
if
(
lat
==
-
1
&&
lng
==
-
1
)
{
return
;
}
Random
random
=
new
Random
();
lat
+=
(
random
.
nextDouble
()
-
0.5
)
*
0.0012
;
lng
+=
(
random
.
nextDouble
()
-
0.5
)
*
0.001
;
mockGPS
=
new
Gps
(
lat
,
lng
,
address
);
}
catch
(
Exception
e
)
{
Log
.
e
(
AppApplication
.
tag
,
"error for queryMockGPS"
,
e
);
...
...
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