Commit 1eca0652 authored by Administrator's avatar Administrator

定位,经纬度数据同步完成

parent 39366e74
......@@ -49,12 +49,10 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: ['*.aar'], dir: 'libs')
provided files('jar/XposedBridgeApi-54.jar')
// implementation(name: 'BaiduLBS_aar_android', ext: 'aar')
// jniLibs.srcDir 'src/main/jniLibs'
implementation 'com.android.support:appcompat-v7:28.0.0'
//implementation 'com.android.support.constraint:constraint-layout:2.0.0-rc1'
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'
compileOnly 'com.virjar:ratel-api:1.3.4'
}
......@@ -34,7 +34,7 @@
<!-- 模块描述 -->
<meta-data
android:name="xposeddescription"
android:value="微信运行虚拟定位"/>
android:value="虚拟定位"/>
<!-- XposedBridgeApi的最低版本号 -->
<meta-data
......@@ -65,6 +65,13 @@
</activity>
<activity android:name="top.littlerich.virtuallocation.activity.AppsActivity">
</activity>
<provider
android:name="top.littlerich.virtuallocation.service.GPSContentProvider"
android:authorities="com.virjar.ratel.virtuallocation"
android:exported="true"
android:grantUriPermissions="true"
tools:ignore="ExportedContentProvider" />
</application>
</manifest>
\ No newline at end of file
......@@ -3,8 +3,12 @@ package top.littlerich.virtuallocation.common;
import android.Manifest;
import android.app.Application;
import android.app.Service;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Vibrator;
import android.util.Log;
import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;
......@@ -24,11 +28,14 @@ import top.littlerich.virtuallocation.util.PermissionUtil;
* Created by xuqingfu on 2017/4/15.
*/
public class AppApplication extends Application {
public static final String tag = "RVLocation";
public LocationService locationService;
public Vibrator mVibrator;
private static AppApplication appApplication;
public static Gps mockGPS = null;
@Override
public void onCreate() {
super.onCreate();
......@@ -101,4 +108,24 @@ public class AppApplication extends Application {
}
}
public static void queryMockGPS(Context context) {
try {
Bundle bundle = context.getContentResolver()
.call(Uri.parse("content://com.virjar.ratel.virtuallocation"),
"invoke", context.getPackageName(), null);
if (bundle == null) {
return;
}
double lat = bundle.getDouble("lat", -1);
double lng = bundle.getDouble("lng", -1);
Log.i(AppApplication.tag, "queryMockGPS: " + lng + "," + lat);
if (lat == -1 && lng == -1) {
return;
}
mockGPS = new Gps(lat, lng);
} catch (Exception e) {
Log.e(AppApplication.tag, "error for queryMockGPS", e);
}
}
}
\ No newline at end of file
package top.littlerich.virtuallocation.common;
/**
* Created by xuqingfu on 2017/5/31.
*/
public class Common {
public static final String SP_FILTER_APP_PKG_NAME = "hook_app_name";
}
......@@ -27,7 +27,7 @@ public class AsyncLocationResultListener implements BDLocationListener {
mMapView = mapView;
this.isFirstLoc = isFirstLoc;
//this.myGpslatitude = myGpslatitude;
// this.myGpslongitude = myGpslongitude;
// this.myGpslongitude = myGpslongitude;
}
@Override
......
package top.littlerich.virtuallocation.presenter;
import android.content.ContentResolver;
import android.location.Location;
import android.provider.Settings;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import static android.provider.Settings.Secure.LOCATION_MODE_SENSORS_ONLY;
/**
* Created by xuqingfu on 2017/5/31.
*/
public class SdkHookManager {
/**
* 判断是否开启允许ADB模拟定位功能
*/
public static void findMethodIsFromMockProvider(){
XposedHelpers.findAndHookMethod(Location.class, "isFromMockProvider", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
param.setResult(false);
}
});
}
/**
* 劫持判断是否使用虚拟定位
* @param loadPackageParam
*/
public static void findMethodGetInt(XC_LoadPackage.LoadPackageParam loadPackageParam){
// boolean isOpen = Settings.Secure.getInt(getContentResolver(),Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0;
XposedHelpers.findAndHookMethod("android.provider.Settings$Secure", loadPackageParam.classLoader, "getInt", ContentResolver.class, String.class, int.class, new XC_MethodHook() {
/**
* 设置返回值类型:
* 1、gpsEnabled && networkEnabled:LOCATION_MODE_HIGH_ACCURACY
* 2、gpsEnabled:LOCATION_MODE_SENSORS_ONLY
* 3、networkEnabled:LOCATION_MODE_BATTERY_SAVING
* 4、disable:LOCATION_MODE_OFF
*/
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
param.setResult(LOCATION_MODE_SENSORS_ONLY);
}
});
XposedHelpers.findAndHookMethod(Settings.Secure.class, "getInt", ContentResolver.class, String.class, int.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
return LOCATION_MODE_SENSORS_ONLY;
}
});
}
}
//package top.littlerich.virtuallocation.presenter;
//
//import android.content.ContentResolver;
//import android.location.Location;
//import android.provider.Settings;
//
//import de.robv.android.xposed.XC_MethodHook;
//import de.robv.android.xposed.XC_MethodReplacement;
//import de.robv.android.xposed.XposedHelpers;
//import de.robv.android.xposed.callbacks.XC_LoadPackage;
//
//import static android.provider.Settings.Secure.LOCATION_MODE_SENSORS_ONLY;
//
///**
// * Created by xuqingfu on 2017/5/31.
// */
//
//public class SdkHookManager {
//
// /**
// * 判断是否开启允许ADB模拟定位功能
// */
// public static void findMethodIsFromMockProvider(){
// XposedHelpers.findAndHookMethod(Location.class, "isFromMockProvider", new XC_MethodHook() {
// @Override
// protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// super.afterHookedMethod(param);
// param.setResult(false);
// }
// });
// }
//
// /**
// * 劫持判断是否使用虚拟定位
// * @param loadPackageParam
// */
// public static void findMethodGetInt(XC_LoadPackage.LoadPackageParam loadPackageParam){
// // boolean isOpen = Settings.Secure.getInt(getContentResolver(),Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0;
// XposedHelpers.findAndHookMethod("android.provider.Settings$Secure", loadPackageParam.classLoader, "getInt", ContentResolver.class, String.class, int.class, new XC_MethodHook() {
//
// /**
// * 设置返回值类型:
// * 1、gpsEnabled && networkEnabled:LOCATION_MODE_HIGH_ACCURACY
// * 2、gpsEnabled:LOCATION_MODE_SENSORS_ONLY
// * 3、networkEnabled:LOCATION_MODE_BATTERY_SAVING
// * 4、disable:LOCATION_MODE_OFF
// */
// @Override
// protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// super.afterHookedMethod(param);
// param.setResult(LOCATION_MODE_SENSORS_ONLY);
// }
// });
//
// XposedHelpers.findAndHookMethod(Settings.Secure.class, "getInt", ContentResolver.class, String.class, int.class, new XC_MethodReplacement() {
// @Override
// protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
// return LOCATION_MODE_SENSORS_ONLY;
// }
// });
// }
//
//
//
//}
package top.littlerich.virtuallocation.service;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import top.littlerich.virtuallocation.common.AppApplication;
import top.littlerich.virtuallocation.model.Gps;
public class GPSContentProvider extends ContentProvider {
@Override
public boolean onCreate() {
return false;
}
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
return null;
}
@Nullable
@Override
public String getType(@NonNull Uri uri) {
return null;
}
@Nullable
@Override
public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
return null;
}
@Override
public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
return 0;
}
@Override
public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
return 0;
}
@Nullable
@Override
public Bundle call(@NonNull String method, @Nullable String arg, @Nullable Bundle extras) {
//return super.call(method, arg, extras);
boolean appMockStatus = AppApplication.getAppMockStatus(arg);
Bundle bundle = new Bundle();
if (!appMockStatus) {
return bundle;
}
Gps configGPS = AppApplication.getConfigGPS();
bundle.putDouble("lat", configGPS.mLatitude);
bundle.putDouble("lng", configGPS.mLongitude);
return bundle;
}
}
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