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
157adb29
Commit
157adb29
authored
Sep 30, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
原生listener
parent
76059892
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
7 deletions
+60
-7
build.gradle
app/build.gradle
+0
-2
XPosedPlugin.java
...ain/java/top/littlerich/virtuallocation/XPosedPlugin.java
+60
-5
No files found.
app/build.gradle
View file @
157adb29
...
...
@@ -55,7 +55,5 @@ dependencies {
implementation
'com.android.support:cardview-v7:28.0.0'
implementation
'com.android.support:recyclerview-v7:28.0.0'
implementation
'com.android.support:design:28.0.0'
implementation
files
(
'libs/tencent-mapsdk-shell-vector-api-originalsearchsheetcloserelease-4.3.9.6.1a2ea2f40c.jar'
)
implementation
files
(
'libs/TencentLocationSdk_v7.2.6_rdbae62b0_20200322_210334.jar'
)
compileOnly
'com.virjar:ratel-api:1.3.4'
}
app/src/main/java/top/littlerich/virtuallocation/XPosedPlugin.java
View file @
157adb29
package
top
.
littlerich
.
virtuallocation
;
import
android.location.Location
;
import
android.location.LocationListener
;
import
android.location.LocationManager
;
import
android.os.Bundle
;
import
android.util.Log
;
import
com.virjar.ratel.api.RatelToolKit
;
...
...
@@ -45,13 +48,64 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
handleGaoDeMap
();
handleBaiduMap
();
handleTencent
();
handleOriginal
();
ClassLoadMonitor
.
addClassLoadMonitor
(
new
ClassLoadMonitor
.
OnClassLoader
()
{
}
private
static
void
handleOriginal
()
{
RC_MethodHook
replaceLocationListenerHook
=
new
RC_MethodHook
()
{
@Override
public
void
onClassLoad
(
Class
<?>
clazz
)
{
// if (clazz.getName().contains("location")) {
// Log.i(AppApplication.tag, "init class: " + clazz.getName());
// }
protected
void
beforeHookedMethod
(
MethodHookParam
param
)
throws
Throwable
{
Log
.
i
(
TAG
,
"进入原声定位逻辑。。。"
);
for
(
int
i
=
0
;
i
<
param
.
args
.
length
;
i
++)
{
Object
locationListener
=
param
.
args
[
i
];
if
(!(
locationListener
instanceof
LocationListener
))
{
continue
;
}
//
final
LocationListener
orignalListener
=
(
LocationListener
)
locationListener
;
LocationListener
fakeLocationListener
=
new
LocationListener
()
{
@Override
public
void
onLocationChanged
(
Location
location
)
{
location
.
setLatitude
(
AppApplication
.
mockGPS
.
mLatitude
);
location
.
setLongitude
(
AppApplication
.
mockGPS
.
mLongitude
);
}
@Override
public
void
onStatusChanged
(
String
s
,
int
i
,
Bundle
bundle
)
{
orignalListener
.
onStatusChanged
(
s
,
i
,
bundle
);
}
@Override
public
void
onProviderEnabled
(
String
s
)
{
orignalListener
.
onProviderEnabled
(
s
);
}
@Override
public
void
onProviderDisabled
(
String
s
)
{
orignalListener
.
onProviderDisabled
(
s
);
}
};
param
.
args
[
i
]
=
fakeLocationListener
;
}
}
};
RposedBridge
.
hookAllMethods
(
LocationManager
.
class
,
"requestLocationUpdates"
,
replaceLocationListenerHook
);
RposedBridge
.
hookAllMethods
(
LocationManager
.
class
,
"requestSingleUpdate"
,
replaceLocationListenerHook
);
//android.location.LocationManager.getLastKnownLocation
RposedHelpers
.
findAndHookMethod
(
LocationManager
.
class
,
"getLastKnownLocation"
,
String
.
class
,
new
RC_MethodHook
()
{
@Override
protected
void
afterHookedMethod
(
MethodHookParam
param
)
throws
Throwable
{
Location
location
=
(
Location
)
param
.
getResult
();
if
(
location
==
null
)
{
return
;
}
location
.
setLatitude
(
AppApplication
.
mockGPS
.
mLatitude
);
location
.
setLongitude
(
AppApplication
.
mockGPS
.
mLongitude
);
}
});
}
...
...
@@ -62,6 +116,7 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
ClassLoadMonitor
.
addClassLoadMonitor
(
"com.tencent.map.geolocation.TencentLocationManager"
,
new
ClassLoadMonitor
.
OnClassLoader
()
{
@Override
public
void
onClassLoad
(
Class
<?>
clazz
)
{
Log
.
i
(
AppApplication
.
tag
,
"命中腾讯API:"
+
clazz
);
// 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) {
...
...
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