Commit 157adb29 authored by Administrator's avatar Administrator

原生listener

parent 76059892
......@@ -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'
}
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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment