Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
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
dbeef15f
Commit
dbeef15f
authored
Aug 27, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基本测试通过
parent
1eca0652
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
82 additions
and
32 deletions
+82
-32
XPosedPlugin.java
...ain/java/top/littlerich/virtuallocation/XPosedPlugin.java
+8
-0
MainActivity.java
...top/littlerich/virtuallocation/activity/MainActivity.java
+21
-14
AppApplication.java
...top/littlerich/virtuallocation/common/AppApplication.java
+26
-3
AsyncLocationResultListener.java
...virtuallocation/listener/AsyncLocationResultListener.java
+3
-12
GeoCoderListener.java
...littlerich/virtuallocation/listener/GeoCoderListener.java
+8
-2
MapClickListener.java
...littlerich/virtuallocation/listener/MapClickListener.java
+7
-1
Gps.java
...c/main/java/top/littlerich/virtuallocation/model/Gps.java
+8
-0
GPSContentProvider.java
...ittlerich/virtuallocation/service/GPSContentProvider.java
+1
-0
No files found.
app/src/main/java/top/littlerich/virtuallocation/XPosedPlugin.java
View file @
dbeef15f
...
...
@@ -158,6 +158,14 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
Location
location
=
(
Location
)
obj
;
location
.
setLatitude
(
AppApplication
.
mockGPS
.
mLatitude
);
location
.
setLongitude
(
AppApplication
.
mockGPS
.
mLongitude
);
// public void setAddress(String var1) {
try
{
RposedHelpers
.
callMethod
(
obj
,
"setAddress"
,
AppApplication
.
mockGPS
.
address
);
}
catch
(
Throwable
throwable
)
{
throwable
.
printStackTrace
();
}
}
}
return
RposedHelpers
.
callMethod
(
originListener
,
method
.
getName
(),
args
);
...
...
app/src/main/java/top/littlerich/virtuallocation/activity/MainActivity.java
View file @
dbeef15f
...
...
@@ -7,9 +7,9 @@ import android.content.pm.PackageManager;
import
android.location.LocationManager
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.support.annotation.NonNull
;
import
android.support.v4.widget.DrawerLayout
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.view.animation.Animation
;
...
...
@@ -46,7 +46,6 @@ import top.littlerich.virtuallocation.listener.GeoCoderListener;
import
top.littlerich.virtuallocation.listener.MapClickListener
;
import
top.littlerich.virtuallocation.listener.MarkerDragListener
;
import
top.littlerich.virtuallocation.model.Gps
;
import
top.littlerich.virtuallocation.util.MapDistanceUtil
;
import
top.littlerich.virtuallocation.util.PermissionUtil
;
import
top.littlerich.virtuallocation.view.TopBanner
;
...
...
@@ -66,7 +65,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
private
TextView
tv_location
;
boolean
isFirstLoc
=
true
;
// 是否首次定位
// 百度定位相关
private
LocationClient
mLocClient
;
private
static
LocationClient
mLocClient
;
private
MyLocationConfiguration
.
LocationMode
mCurrentMode
;
// 定位模式
private
BitmapDescriptor
mCurrentMarker
;
// 定位图标
private
MapView
mMapView
;
...
...
@@ -76,7 +75,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
private
static
Marker
mMarker
;
private
static
LatLng
curLatlng
;
private
static
GeoCoder
mSearch
;
public
static
double
myGpslatitude
,
myGpslongitude
;
DrawerLayout
mDrawerLayout
;
TopBanner
mTopbanner
;
private
TextView
mAboutAuthor
;
...
...
@@ -179,8 +177,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
mCurrentLocation
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
LatLng
ll
=
new
LatLng
(
myGpslatitude
,
myGpslongitude
);
setCurrentMapLatLng
(
ll
);
mLocClient
.
start
();
}
});
mBaiduMap
.
setOnMapLoadedCallback
(
new
BaiduMap
.
OnMapLoadedCallback
()
{
...
...
@@ -210,7 +207,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
mStopMock
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Toast
.
makeText
(
MainActivity
.
this
,
"虚拟定位已暂停!"
,
Toast
.
LENGTH_SHORT
).
show
();
mLocClient
.
stop
();
bt_Ok
.
setText
(
"立即穿越"
);
}
});
...
...
@@ -224,6 +221,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
mCurrentLocation
.
startAnimation
(
mOperatingAnim
);
}
}
...
...
@@ -243,7 +241,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
mBaiduMap
.
setMyLocationConfigeration
(
new
MyLocationConfiguration
(
mCurrentMode
,
true
,
mCurrentMarker
));
mLocClient
.
setLocOption
(
option
);
mLocClient
.
start
();
initOverlay
();
}
...
...
@@ -253,34 +250,44 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
*/
private
void
initOverlay
()
{
Gps
configGPS
=
AppApplication
.
getConfigGPS
();
LatLng
ll
=
new
LatLng
(
configGPS
.
mLatitude
,
configGPS
.
mLongitude
);
final
LatLng
ll
=
new
LatLng
(
configGPS
.
mLatitude
,
configGPS
.
mLongitude
);
OverlayOptions
oo
=
new
MarkerOptions
().
position
(
ll
).
icon
(
bd
).
zIndex
(
9
)
.
draggable
(
true
);
mMarker
=
(
Marker
)
(
mBaiduMap
.
addOverlay
(
oo
));
new
Handler
(
Looper
.
getMainLooper
())
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
// search初始化应该是异步的,刚刚启动就调用POI的话,会搜索失败
setCurrentMapLatLng
(
ll
);
}
},
1500
);
}
/**
* setCurrentMapLatLng 设置当前坐标
*/
public
static
void
setCurrentMapLatLng
(
LatLng
arg0
)
{
// Debug.waitForDebugger();
curLatlng
=
arg0
;
mMarker
.
setPosition
(
arg0
);
if
(
mLocClient
.
isStarted
())
{
mLocClient
.
stop
();
}
// 设置地图中心点为这是位置
LatLng
ll
=
new
LatLng
(
arg0
.
latitude
,
arg0
.
longitude
);
MapStatusUpdate
u
=
MapStatusUpdateFactory
.
newLatLng
(
ll
);
mBaiduMap
.
animateMapStatus
(
u
);
Log
.
i
(
"virjar"
,
"移动坐标: "
+
ll
+
" "
+
ll
.
longitude
+
","
+
ll
.
latitude
);
MapDistanceUtil
.
GeoPoint
geoPoint
=
MapDistanceUtil
.
gcj02ToGps84
(
arg0
.
latitude
,
arg0
.
longitude
);
Log
.
i
(
"virjar"
,
"bd09:"
+
geoPoint
.
getLon
()
+
","
+
geoPoint
.
getLat
());
LatLng
reverseGeoRequestLatLng
=
new
LatLng
(
geoPoint
.
getLat
(),
geoPoint
.
getLon
());
// 根据经纬度坐标 找到实地信息,会在接口onGetReverseGeoCodeResult中呈现结果
mSearch
.
reverseGeoCode
(
new
ReverseGeoCodeOption
()
.
newVersion
(
0
)
.
pageNum
(
0
)
.
location
(
reverseGeoRequestLatLng
)
.
location
(
arg0
)
.
radius
(
150
)
);
}
...
...
app/src/main/java/top/littlerich/virtuallocation/common/AppApplication.java
View file @
dbeef15f
...
...
@@ -89,7 +89,7 @@ public class AppApplication extends Application {
JSONObject
jsonObject
=
new
JSONObject
(
config
);
double
longitude
=
jsonObject
.
optDouble
(
"longitude"
);
double
latitude
=
jsonObject
.
optDouble
(
"latitude"
);
return
new
Gps
(
latitude
,
longitude
);
return
new
Gps
(
latitude
,
longitude
,
getAddress
()
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
Config
.
COMPANY
;
...
...
@@ -108,6 +108,28 @@ public class AppApplication extends Application {
}
}
public
static
void
storeAddress
(
String
address
)
{
File
configFile
=
new
File
(
appApplication
.
getFilesDir
(),
"mockAddress.txt"
);
try
{
FileUtils
.
writeLine
(
configFile
,
address
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
static
String
getAddress
()
{
File
configFile
=
new
File
(
appApplication
.
getFilesDir
(),
"mockAddress.txt"
);
if
(!
configFile
.
exists
())
{
return
""
;
}
try
{
return
FileUtils
.
readLine
(
configFile
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
public
static
void
queryMockGPS
(
Context
context
)
{
try
{
Bundle
bundle
=
context
.
getContentResolver
()
...
...
@@ -118,11 +140,12 @@ public class AppApplication extends Application {
}
double
lat
=
bundle
.
getDouble
(
"lat"
,
-
1
);
double
lng
=
bundle
.
getDouble
(
"lng"
,
-
1
);
Log
.
i
(
AppApplication
.
tag
,
"queryMockGPS: "
+
lng
+
","
+
lat
);
String
address
=
bundle
.
getString
(
"address"
);
Log
.
i
(
AppApplication
.
tag
,
"queryMockGPS: "
+
lng
+
","
+
lat
+
" "
+
address
);
if
(
lat
==
-
1
&&
lng
==
-
1
)
{
return
;
}
mockGPS
=
new
Gps
(
lat
,
lng
);
mockGPS
=
new
Gps
(
lat
,
lng
,
address
);
}
catch
(
Exception
e
)
{
Log
.
e
(
AppApplication
.
tag
,
"error for queryMockGPS"
,
e
);
}
...
...
app/src/main/java/top/littlerich/virtuallocation/listener/AsyncLocationResultListener.java
View file @
dbeef15f
...
...
@@ -5,10 +5,6 @@ import com.baidu.location.BDLocationListener;
import
com.baidu.mapapi.map.MapView
;
import
com.baidu.mapapi.model.LatLng
;
import
top.littlerich.virtuallocation.activity.MainActivity
;
import
static
top
.
littlerich
.
virtuallocation
.
activity
.
MainActivity
.
myGpslatitude
;
import
static
top
.
littlerich
.
virtuallocation
.
activity
.
MainActivity
.
myGpslongitude
;
import
static
top
.
littlerich
.
virtuallocation
.
activity
.
MainActivity
.
setCurrentMapLatLng
;
/**
...
...
@@ -20,7 +16,7 @@ import static top.littlerich.virtuallocation.activity.MainActivity.setCurrentMap
public
class
AsyncLocationResultListener
implements
BDLocationListener
{
private
MapView
mMapView
;
boolean
isFirstLoc
=
true
;
// 是否首次定位
boolean
isFirstLoc
;
// 是否首次定位
//private double myGpslatitude, myGpslongitude;
public
AsyncLocationResultListener
(
MapView
mapView
,
boolean
isFirstLoc
)
{
...
...
@@ -37,12 +33,7 @@ public class AsyncLocationResultListener implements BDLocationListener {
return
;
}
if
(
isFirstLoc
)
{
isFirstLoc
=
false
;
MainActivity
.
myGpslatitude
=
location
.
getLatitude
();
MainActivity
.
myGpslongitude
=
location
.
getLongitude
();
LatLng
ll
=
new
LatLng
(
myGpslatitude
,
myGpslongitude
);
setCurrentMapLatLng
(
ll
);
}
LatLng
ll
=
new
LatLng
(
location
.
getLatitude
(),
location
.
getLongitude
());
setCurrentMapLatLng
(
ll
);
}
}
app/src/main/java/top/littlerich/virtuallocation/listener/GeoCoderListener.java
View file @
dbeef15f
...
...
@@ -10,6 +10,8 @@ import com.baidu.mapapi.search.geocode.GeoCodeResult;
import
com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener
;
import
com.baidu.mapapi.search.geocode.ReverseGeoCodeResult
;
import
top.littlerich.virtuallocation.common.AppApplication
;
/**
* 地理编码:1、正向地图编码 2、反向地图编码
* Created by xuqingfu on 2017/5/4.
...
...
@@ -43,10 +45,14 @@ public class GeoCoderListener implements OnGetGeoCoderResultListener {
@Override
public
void
onGetReverseGeoCodeResult
(
ReverseGeoCodeResult
result
)
{
if
(
result
==
null
||
result
.
error
!=
SearchResult
.
ERRORNO
.
NO_ERROR
)
{
Log
.
w
(
AppApplication
.
tag
,
"error:"
+
result
);
Toast
.
makeText
(
mContext
,
"抱歉,未能找到结果"
,
Toast
.
LENGTH_LONG
).
show
();
return
;
}
Log
.
i
(
"virjar"
,
"逆地理:"
+
result
);
mLocationTip
.
setText
(
String
.
format
(
"伪造位置:%s"
,
result
.
getAddress
()));
String
address
=
String
.
format
(
"%s %s"
,
result
.
getAddress
(),
result
.
getSematicDescription
());
AppApplication
.
storeAddress
(
address
);
Log
.
i
(
AppApplication
.
tag
,
"逆地理:"
+
result
);
mLocationTip
.
setText
(
String
.
format
(
"伪造位置:%s"
,
address
));
}
}
app/src/main/java/top/littlerich/virtuallocation/listener/MapClickListener.java
View file @
dbeef15f
package
top
.
littlerich
.
virtuallocation
.
listener
;
import
android.util.Log
;
import
android.widget.Button
;
import
com.baidu.mapapi.map.BaiduMap
;
import
com.baidu.mapapi.map.MapPoi
;
import
com.baidu.mapapi.model.LatLng
;
import
top.littlerich.virtuallocation.common.AppApplication
;
import
static
top
.
littlerich
.
virtuallocation
.
activity
.
MainActivity
.
setCurrentMapLatLng
;
/**
...
...
@@ -42,7 +45,10 @@ public class MapClickListener implements BaiduMap.OnMapClickListener {
*/
@Override
public
void
onMapPoiClick
(
MapPoi
mapPoi
)
{
// return false;
Log
.
i
(
AppApplication
.
tag
,
"clickPOI: "
+
mapPoi
.
getPosition
()
+
" name:"
+
mapPoi
.
getName
()
+
" uid:"
+
mapPoi
.
getUid
()
);
LatLng
position
=
mapPoi
.
getPosition
();
this
.
onMapClick
(
position
);
}
...
...
app/src/main/java/top/littlerich/virtuallocation/model/Gps.java
View file @
dbeef15f
...
...
@@ -7,9 +7,17 @@ package top.littlerich.virtuallocation.model;
public
class
Gps
{
public
double
mLatitude
;
public
double
mLongitude
;
public
String
address
;
public
Gps
(
double
latitude
,
double
longitude
)
{
mLatitude
=
latitude
;
mLongitude
=
longitude
;
}
public
Gps
(
double
latitude
,
double
longitude
,
String
address
)
{
this
(
latitude
,
longitude
);
this
.
address
=
address
;
}
}
app/src/main/java/top/littlerich/virtuallocation/service/GPSContentProvider.java
View file @
dbeef15f
...
...
@@ -57,6 +57,7 @@ public class GPSContentProvider extends ContentProvider {
Gps
configGPS
=
AppApplication
.
getConfigGPS
();
bundle
.
putDouble
(
"lat"
,
configGPS
.
mLatitude
);
bundle
.
putDouble
(
"lng"
,
configGPS
.
mLongitude
);
bundle
.
putString
(
"address"
,
configGPS
.
address
);
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