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
open-source
RatelVirtualLocation
Commits
1eca0652
Commit
1eca0652
authored
Aug 27, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定位,经纬度数据同步完成
parent
39366e74
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
326 additions
and
107 deletions
+326
-107
build.gradle
app/build.gradle
+1
-3
XposedBridgeApi-54.jar
app/jar/XposedBridgeApi-54.jar
+0
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+8
-1
XPosedPlugin.java
...ain/java/top/littlerich/virtuallocation/XPosedPlugin.java
+162
-28
AppApplication.java
...top/littlerich/virtuallocation/common/AppApplication.java
+27
-0
Common.java
...in/java/top/littlerich/virtuallocation/common/Common.java
+0
-9
AsyncLocationResultListener.java
...virtuallocation/listener/AsyncLocationResultListener.java
+1
-1
SdkHookManager.java
.../littlerich/virtuallocation/presenter/SdkHookManager.java
+65
-65
GPSContentProvider.java
...ittlerich/virtuallocation/service/GPSContentProvider.java
+62
-0
No files found.
app/build.gradle
View file @
1eca0652
...
...
@@ -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'
}
app/jar/XposedBridgeApi-54.jar
deleted
100644 → 0
View file @
39366e74
File deleted
app/src/main/AndroidManifest.xml
View file @
1eca0652
...
...
@@ -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
app/src/main/java/top/littlerich/virtuallocation/XPosedPlugin.java
View file @
1eca0652
This diff is collapsed.
Click to expand it.
app/src/main/java/top/littlerich/virtuallocation/common/AppApplication.java
View file @
1eca0652
...
...
@@ -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
app/src/main/java/top/littlerich/virtuallocation/common/Common.java
deleted
100644 → 0
View file @
39366e74
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"
;
}
app/src/main/java/top/littlerich/virtuallocation/listener/AsyncLocationResultListener.java
View file @
1eca0652
...
...
@@ -27,7 +27,7 @@ public class AsyncLocationResultListener implements BDLocationListener {
mMapView
=
mapView
;
this
.
isFirstLoc
=
isFirstLoc
;
//this.myGpslatitude = myGpslatitude;
// this.myGpslongitude = myGpslongitude;
// this.myGpslongitude = myGpslongitude;
}
@Override
...
...
app/src/main/java/top/littlerich/virtuallocation/presenter/SdkHookManager.java
View file @
1eca0652
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;
//
}
//
});
//
}
//
//
//
//
}
app/src/main/java/top/littlerich/virtuallocation/service/GPSContentProvider.java
0 → 100644
View file @
1eca0652
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
;
}
}
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