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
9d78c49e
Commit
9d78c49e
authored
Aug 26, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
udpate
parent
17de1ef6
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
198 additions
and
240 deletions
+198
-240
AppsActivity.java
...top/littlerich/virtuallocation/activity/AppsActivity.java
+1
-1
MainActivity.java
...top/littlerich/virtuallocation/activity/MainActivity.java
+4
-27
PreciseLocationActivity.java
...ich/virtuallocation/activity/PreciseLocationActivity.java
+9
-12
AppAdapter.java
...va/top/littlerich/virtuallocation/adapter/AppAdapter.java
+27
-12
AppApplication.java
...top/littlerich/virtuallocation/common/AppApplication.java
+61
-8
HookApis.java
...va/top/littlerich/virtuallocation/presenter/HookApis.java
+17
-23
FileUtils.java
...n/java/top/littlerich/virtuallocation/util/FileUtils.java
+78
-0
LocationUtil.java
...ava/top/littlerich/virtuallocation/util/LocationUtil.java
+0
-119
SharePreferenceUtil.java
.../littlerich/virtuallocation/util/SharePreferenceUtil.java
+0
-38
item_app_info.xml
app/src/main/res/layout/item_app_info.xml
+1
-0
No files found.
app/src/main/java/top/littlerich/virtuallocation/activity/AppsActivity.java
View file @
9d78c49e
...
@@ -44,7 +44,7 @@ public class AppsActivity extends AppCompatActivity {
...
@@ -44,7 +44,7 @@ public class AppsActivity extends AppCompatActivity {
//如果可以确定每个item的高度是固定的,设置这个选项可以提高性能
//如果可以确定每个item的高度是固定的,设置这个选项可以提高性能
mRecyclerView
.
setHasFixedSize
(
true
);
mRecyclerView
.
setHasFixedSize
(
true
);
//创建并设置Adapter
//创建并设置Adapter
mAppAdapter
=
new
AppAdapter
(
AppsActivity
.
this
);
mAppAdapter
=
new
AppAdapter
();
mRecyclerView
.
setAdapter
(
mAppAdapter
);
mRecyclerView
.
setAdapter
(
mAppAdapter
);
initAppList
(
false
);
initAppList
(
false
);
}
}
...
...
app/src/main/java/top/littlerich/virtuallocation/activity/MainActivity.java
View file @
9d78c49e
...
@@ -44,7 +44,7 @@ import top.littlerich.virtuallocation.listener.AsyncLocationResultListener;
...
@@ -44,7 +44,7 @@ import top.littlerich.virtuallocation.listener.AsyncLocationResultListener;
import
top.littlerich.virtuallocation.listener.GeoCoderListener
;
import
top.littlerich.virtuallocation.listener.GeoCoderListener
;
import
top.littlerich.virtuallocation.listener.MapClickListener
;
import
top.littlerich.virtuallocation.listener.MapClickListener
;
import
top.littlerich.virtuallocation.listener.MarkerDragListener
;
import
top.littlerich.virtuallocation.listener.MarkerDragListener
;
import
top.littlerich.virtuallocation.
util.LocationUtil
;
import
top.littlerich.virtuallocation.
model.Gps
;
import
top.littlerich.virtuallocation.util.PermissionUtil
;
import
top.littlerich.virtuallocation.util.PermissionUtil
;
import
top.littlerich.virtuallocation.view.TopBanner
;
import
top.littlerich.virtuallocation.view.TopBanner
;
...
@@ -207,7 +207,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
...
@@ -207,7 +207,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
mStopMock
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
mStopMock
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
LocationUtil
.
stopMockLocation
();
Toast
.
makeText
(
MainActivity
.
this
,
"虚拟定位已暂停!"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
MainActivity
.
this
,
"虚拟定位已暂停!"
,
Toast
.
LENGTH_SHORT
).
show
();
bt_Ok
.
setText
(
"立即穿越"
);
bt_Ok
.
setText
(
"立即穿越"
);
}
}
...
@@ -217,28 +216,13 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
...
@@ -217,28 +216,13 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
@Override
@Override
protected
void
IniData
()
{
protected
void
IniData
()
{
inilocation
();
iniMap
();
iniMap
();
if
(
mOperatingAnim
!=
null
)
{
if
(
mOperatingAnim
!=
null
)
{
mCurrentLocation
.
startAnimation
(
mOperatingAnim
);
mCurrentLocation
.
startAnimation
(
mOperatingAnim
);
}
}
}
}
/**
* inilocation 初始化 位置模拟
*/
private
void
inilocation
()
{
try
{
if
(
LocationUtil
.
initLocation
(
MainActivity
.
this
))
{
LocationUtil
.
initLocationManager
();
}
}
catch
(
Exception
e
)
{
Toast
.
makeText
(
MainActivity
.
this
,
"虚拟定位功能未打开!"
,
Toast
.
LENGTH_SHORT
).
show
();
e
.
printStackTrace
();
}
}
/**
/**
* iniMap 初始化地图
* iniMap 初始化地图
...
@@ -259,15 +243,14 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
...
@@ -259,15 +243,14 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
mLocClient
.
start
();
mLocClient
.
start
();
initOverlay
();
initOverlay
();
// 开启线程,一直修改GPS坐标
LocationUtil
.
startLocaton
();
}
}
/**
/**
* initOverlay 设置覆盖物,这里就是地图上那个点
* initOverlay 设置覆盖物,这里就是地图上那个点
*/
*/
private
void
initOverlay
()
{
private
void
initOverlay
()
{
LatLng
ll
=
new
LatLng
(
AppApplication
.
mMockGps
.
mLatitude
,
AppApplication
.
mMockGps
.
mLongitude
);
Gps
configGPS
=
AppApplication
.
getConfigGPS
();
LatLng
ll
=
new
LatLng
(
configGPS
.
mLatitude
,
configGPS
.
mLongitude
);
OverlayOptions
oo
=
new
MarkerOptions
().
position
(
ll
).
icon
(
bd
).
zIndex
(
9
)
OverlayOptions
oo
=
new
MarkerOptions
().
position
(
ll
).
icon
(
bd
).
zIndex
(
9
)
.
draggable
(
true
);
.
draggable
(
true
);
mMarker
=
(
Marker
)
(
mBaiduMap
.
addOverlay
(
oo
));
mMarker
=
(
Marker
)
(
mBaiduMap
.
addOverlay
(
oo
));
...
@@ -357,13 +340,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
...
@@ -357,13 +340,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
latitude
=
curLatlng
.
latitude
;
latitude
=
curLatlng
.
latitude
;
longitude
=
curLatlng
.
longitude
;
longitude
=
curLatlng
.
longitude
;
try
{
try
{
AppApplication
.
saveConfigGPS
(
longitude
,
latitude
);
LocationUtil
.
initLocation
(
MainActivity
.
this
);
LocationUtil
.
initLocationManager
();
LocationUtil
.
setLongitudeAndLatitude
(
curLatlng
.
longitude
,
curLatlng
.
latitude
);
AppApplication
.
mMockGps
.
mLatitude
=
curLatlng
.
latitude
;
AppApplication
.
mMockGps
.
mLongitude
=
curLatlng
.
longitude
;
bt_Ok
.
setText
(
"穿越完成"
);
bt_Ok
.
setText
(
"穿越完成"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
app/src/main/java/top/littlerich/virtuallocation/activity/PreciseLocationActivity.java
View file @
9d78c49e
...
@@ -18,11 +18,9 @@ import android.widget.ProgressBar;
...
@@ -18,11 +18,9 @@ import android.widget.ProgressBar;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.virjar.ratel.virtuallocation.R
;
import
com.virjar.ratel.virtuallocation.R
;
import
top.littlerich.virtuallocation.presenter.JellyInterpolator
;
import
top.littlerich.virtuallocation.presenter.JellyInterpolator
;
import
top.littlerich.virtuallocation.util.LocationUtil
;
import
top.littlerich.virtuallocation.view.TopBanner
;
import
top.littlerich.virtuallocation.view.TopBanner
;
public
class
PreciseLocationActivity
extends
AppCompatActivity
{
public
class
PreciseLocationActivity
extends
AppCompatActivity
{
...
@@ -48,8 +46,6 @@ public class PreciseLocationActivity extends AppCompatActivity {
...
@@ -48,8 +46,6 @@ public class PreciseLocationActivity extends AppCompatActivity {
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
try
{
try
{
LocationUtil
.
setLongitudeAndLatitude
(
Double
.
valueOf
(
mLongitudeValue
.
getText
().
toString
()),
Double
.
valueOf
(
mLatitudeValue
.
getText
().
toString
()));
width
=
mBeginLocation
.
getMeasuredWidth
();
width
=
mBeginLocation
.
getMeasuredWidth
();
float
height
=
mBeginLocation
.
getMeasuredHeight
();
float
height
=
mBeginLocation
.
getMeasuredHeight
();
inputAnimator
(
mBeginLocation
,
width
,
height
);
inputAnimator
(
mBeginLocation
,
width
,
height
);
...
@@ -61,7 +57,7 @@ public class PreciseLocationActivity extends AppCompatActivity {
...
@@ -61,7 +57,7 @@ public class PreciseLocationActivity extends AppCompatActivity {
mTopbanner
.
setTopBannerListener
(
new
TopBanner
.
OnTopBannerListener
()
{
mTopbanner
.
setTopBannerListener
(
new
TopBanner
.
OnTopBannerListener
()
{
@Override
@Override
public
void
leftClick
(
View
v
)
{
public
void
leftClick
(
View
v
)
{
finish
();
finish
();
}
}
@Override
@Override
...
@@ -82,9 +78,10 @@ public class PreciseLocationActivity extends AppCompatActivity {
...
@@ -82,9 +78,10 @@ public class PreciseLocationActivity extends AppCompatActivity {
/**
/**
* 使组件变回原有形状
* 使组件变回原有形状
*
* @param view
* @param view
*/
*/
private
void
repaintView
(
final
View
view
){
private
void
repaintView
(
final
View
view
)
{
AnimatorSet
set
=
new
AnimatorSet
();
AnimatorSet
set
=
new
AnimatorSet
();
ValueAnimator
animator
=
ValueAnimator
.
ofFloat
(
width
,
0
);
ValueAnimator
animator
=
ValueAnimator
.
ofFloat
(
width
,
0
);
...
@@ -110,12 +107,12 @@ public class PreciseLocationActivity extends AppCompatActivity {
...
@@ -110,12 +107,12 @@ public class PreciseLocationActivity extends AppCompatActivity {
}
}
private
void
initViews
()
{
private
void
initViews
()
{
mLatitudeValue
=
(
EditText
)
findViewById
(
R
.
id
.
et_latitude
);
mLatitudeValue
=
(
EditText
)
findViewById
(
R
.
id
.
et_latitude
);
mLongitudeValue
=
(
EditText
)
findViewById
(
R
.
id
.
et_longitude
);
mLongitudeValue
=
(
EditText
)
findViewById
(
R
.
id
.
et_longitude
);
mBeginLocation
=
(
AppCompatButton
)
findViewById
(
R
.
id
.
btn_precise_location
);
mBeginLocation
=
(
AppCompatButton
)
findViewById
(
R
.
id
.
btn_precise_location
);
mTopbanner
=
(
TopBanner
)
findViewById
(
R
.
id
.
topbanner
);
mTopbanner
=
(
TopBanner
)
findViewById
(
R
.
id
.
topbanner
);
mPbLocating
=
(
ProgressBar
)
findViewById
(
R
.
id
.
pb_locating
);
mPbLocating
=
(
ProgressBar
)
findViewById
(
R
.
id
.
pb_locating
);
mTip
=
(
TextView
)
findViewById
(
R
.
id
.
tv_tip
);
mTip
=
(
TextView
)
findViewById
(
R
.
id
.
tv_tip
);
}
}
...
@@ -190,7 +187,7 @@ public class PreciseLocationActivity extends AppCompatActivity {
...
@@ -190,7 +187,7 @@ public class PreciseLocationActivity extends AppCompatActivity {
animator3
.
start
();
animator3
.
start
();
}
}
public
static
void
openActivity
(
Context
context
){
public
static
void
openActivity
(
Context
context
)
{
Intent
intent
=
new
Intent
(
context
,
PreciseLocationActivity
.
class
);
Intent
intent
=
new
Intent
(
context
,
PreciseLocationActivity
.
class
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
...
...
app/src/main/java/top/littlerich/virtuallocation/adapter/AppAdapter.java
View file @
9d78c49e
package
top
.
littlerich
.
virtuallocation
.
adapter
;
package
top
.
littlerich
.
virtuallocation
.
adapter
;
import
android.content.Context
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.CheckBox
;
import
android.widget.CompoundButton
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
...
@@ -13,7 +14,7 @@ import com.virjar.ratel.virtuallocation.R;
...
@@ -13,7 +14,7 @@ import com.virjar.ratel.virtuallocation.R;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
top.littlerich.virtuallocation.common.AppApplication
;
import
top.littlerich.virtuallocation.model.MyAppInfo
;
import
top.littlerich.virtuallocation.model.MyAppInfo
;
/**
/**
...
@@ -23,17 +24,24 @@ import top.littlerich.virtuallocation.model.MyAppInfo;
...
@@ -23,17 +24,24 @@ import top.littlerich.virtuallocation.model.MyAppInfo;
public
class
AppAdapter
extends
RecyclerView
.
Adapter
<
AppAdapter
.
ViewHolder
>
{
public
class
AppAdapter
extends
RecyclerView
.
Adapter
<
AppAdapter
.
ViewHolder
>
{
List
<
MyAppInfo
>
mListData
=
new
ArrayList
<
MyAppInfo
>();
List
<
MyAppInfo
>
mListData
=
new
ArrayList
<
MyAppInfo
>();
private
Context
mContext
;
public
AppAdapter
(
Context
context
)
{
public
AppAdapter
()
{
mContext
=
context
;
}
}
@Override
@Override
public
ViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
public
ViewHolder
onCreateViewHolder
(
final
ViewGroup
parent
,
int
viewType
)
{
View
view
=
LayoutInflater
.
from
(
parent
.
getContext
()).
inflate
(
R
.
layout
.
item_app_info
,
parent
,
false
);
final
View
view
=
LayoutInflater
.
from
(
parent
.
getContext
()).
inflate
(
R
.
layout
.
item_app_info
,
parent
,
false
);
ViewHolder
vh
=
new
ViewHolder
(
view
);
return
vh
;
final
ViewHolder
viewHolder
=
new
ViewHolder
(
view
);
viewHolder
.
cbAppSelect
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
buttonView
,
boolean
isChecked
)
{
AppApplication
.
setAppMock
(
viewHolder
.
myAppInfo
.
getPkgName
(),
isChecked
);
}
});
return
viewHolder
;
}
}
@Override
@Override
...
@@ -42,6 +50,10 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> {
...
@@ -42,6 +50,10 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> {
holder
.
iv_app_icon
.
setImageDrawable
(
myAppInfo
.
getImage
());
holder
.
iv_app_icon
.
setImageDrawable
(
myAppInfo
.
getImage
());
holder
.
tx_app_name
.
setText
(
myAppInfo
.
getAppName
());
holder
.
tx_app_name
.
setText
(
myAppInfo
.
getAppName
());
holder
.
tx_app_pkg
.
setText
(
myAppInfo
.
getPkgName
());
holder
.
tx_app_pkg
.
setText
(
myAppInfo
.
getPkgName
());
holder
.
myAppInfo
=
myAppInfo
;
holder
.
cbAppSelect
.
setChecked
(
AppApplication
.
getAppMockStatus
(
myAppInfo
.
getPkgName
())
);
}
}
@Override
@Override
...
@@ -82,12 +94,15 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> {
...
@@ -82,12 +94,15 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> {
ImageView
iv_app_icon
;
ImageView
iv_app_icon
;
TextView
tx_app_name
;
TextView
tx_app_name
;
TextView
tx_app_pkg
;
TextView
tx_app_pkg
;
CheckBox
cbAppSelect
;
MyAppInfo
myAppInfo
;
public
ViewHolder
(
View
itemView
)
{
public
ViewHolder
(
View
itemView
)
{
super
(
itemView
);
super
(
itemView
);
iv_app_icon
=
(
ImageView
)
itemView
.
findViewById
(
R
.
id
.
iv_app_icon
);
iv_app_icon
=
itemView
.
findViewById
(
R
.
id
.
iv_app_icon
);
tx_app_name
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
tv_app_name
);
tx_app_name
=
itemView
.
findViewById
(
R
.
id
.
tv_app_name
);
tx_app_pkg
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
tv_app_pkg
);
tx_app_pkg
=
itemView
.
findViewById
(
R
.
id
.
tv_app_pkg
);
cbAppSelect
=
itemView
.
findViewById
(
R
.
id
.
cb_app_select
);
}
}
}
}
}
}
app/src/main/java/top/littlerich/virtuallocation/common/AppApplication.java
View file @
9d78c49e
...
@@ -9,8 +9,15 @@ import android.os.Vibrator;
...
@@ -9,8 +9,15 @@ import android.os.Vibrator;
import
com.baidu.mapapi.CoordType
;
import
com.baidu.mapapi.CoordType
;
import
com.baidu.mapapi.SDKInitializer
;
import
com.baidu.mapapi.SDKInitializer
;
import
org.json.JSONObject
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
top.littlerich.virtuallocation.model.Gps
;
import
top.littlerich.virtuallocation.model.Gps
;
import
top.littlerich.virtuallocation.service.LocationService
;
import
top.littlerich.virtuallocation.service.LocationService
;
import
top.littlerich.virtuallocation.util.FileUtils
;
import
top.littlerich.virtuallocation.util.PermissionUtil
;
import
top.littlerich.virtuallocation.util.PermissionUtil
;
/**
/**
...
@@ -20,18 +27,12 @@ public class AppApplication extends Application {
...
@@ -20,18 +27,12 @@ public class AppApplication extends Application {
public
LocationService
locationService
;
public
LocationService
locationService
;
public
Vibrator
mVibrator
;
public
Vibrator
mVibrator
;
/**
private
static
AppApplication
appApplication
;
* 全局GPS
*/
public
static
Gps
mMockGps
;
static
{
mMockGps
=
Config
.
COMPANY
;
}
@Override
@Override
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
appApplication
=
this
;
/***
/***
* 初始化定位sdk,建议在Application中创建
* 初始化定位sdk,建议在Application中创建
*/
*/
...
@@ -48,4 +49,56 @@ public class AppApplication extends Application {
...
@@ -48,4 +49,56 @@ public class AppApplication extends Application {
}
}
public
static
void
setAppMock
(
String
pkg
,
boolean
isChecked
)
{
File
configFile
=
new
File
(
appApplication
.
getFilesDir
(),
pkg
+
"_status.conf"
);
if
(
isChecked
)
{
try
{
FileWriter
fileWriter
=
new
FileWriter
(
configFile
);
fileWriter
.
write
(
"mock"
);
fileWriter
.
flush
();
fileWriter
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
configFile
.
exists
())
{
configFile
.
delete
();
}
}
public
static
boolean
getAppMockStatus
(
String
pkg
)
{
File
configFile
=
new
File
(
appApplication
.
getFilesDir
(),
pkg
+
"_status.conf"
);
return
configFile
.
exists
();
}
public
static
Gps
getConfigGPS
()
{
File
configFile
=
new
File
(
appApplication
.
getFilesDir
(),
"mockGPS.json"
);
if
(!
configFile
.
exists
())
{
return
Config
.
COMPANY
;
}
try
{
String
config
=
FileUtils
.
readLine
(
configFile
);
JSONObject
jsonObject
=
new
JSONObject
(
config
);
double
longitude
=
jsonObject
.
optDouble
(
"longitude"
);
double
latitude
=
jsonObject
.
optDouble
(
"latitude"
);
return
new
Gps
(
latitude
,
longitude
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
Config
.
COMPANY
;
}
}
public
static
void
saveConfigGPS
(
double
longitude
,
double
latitude
)
{
File
configFile
=
new
File
(
appApplication
.
getFilesDir
(),
"mockGPS.json"
);
JSONObject
jsonObject
=
new
JSONObject
();
try
{
jsonObject
.
put
(
"longitude"
,
longitude
);
jsonObject
.
put
(
"latitude"
,
latitude
);
FileUtils
.
writeLine
(
configFile
,
jsonObject
.
toString
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
\ No newline at end of file
app/src/main/java/top/littlerich/virtuallocation/presenter/HookApis.java
View file @
9d78c49e
package
top
.
littlerich
.
virtuallocation
.
presenter
;
package
top
.
littlerich
.
virtuallocation
.
presenter
;
import
android.util.Log
;
import
de.robv.android.xposed.XC_MethodHook
;
import
de.robv.android.xposed.XposedHelpers
;
import
top.littlerich.virtuallocation.common.AppApplication
;
/**
/**
* Created by xuqingfu on 2017/5/26.
* Created by xuqingfu on 2017/5/26.
*/
*/
...
@@ -20,23 +14,23 @@ public class HookApis {
...
@@ -20,23 +14,23 @@ public class HookApis {
* @throws ClassNotFoundException
* @throws ClassNotFoundException
*/
*/
public
static
void
findMethodAmapLongitudeAndLatitude
(
ClassLoader
classLoader
)
{
public
static
void
findMethodAmapLongitudeAndLatitude
(
ClassLoader
classLoader
)
{
try
{
//
try {
Class
aMapLocationClazz
=
classLoader
.
loadClass
(
"com.amap.api.location.AMapLocation"
);
//
Class aMapLocationClazz = classLoader.loadClass("com.amap.api.location.AMapLocation");
XposedHelpers
.
findAndHookMethod
(
aMapLocationClazz
,
"getLongitude"
,
new
Object
[]{
new
XC_MethodHook
()
{
//
XposedHelpers.findAndHookMethod(aMapLocationClazz, "getLongitude", new Object[]{new XC_MethodHook() {
protected
void
beforeHookedMethod
(
MethodHookParam
arg3
)
throws
Throwable
{
//
protected void beforeHookedMethod(MethodHookParam arg3) throws Throwable {
arg3
.
setResult
(
Double
.
valueOf
(
AppApplication
.
mMockGps
.
mLongitude
));
//
arg3.setResult(Double.valueOf(AppApplication.mMockGps.mLongitude));
Log
.
d
(
TAG
,
"修改高德地图的经纬度值:"
+
AppApplication
.
mMockGps
.
mLongitude
+
":"
+
AppApplication
.
mMockGps
.
mLatitude
);
//
Log.d(TAG, "修改高德地图的经纬度值:" + AppApplication.mMockGps.mLongitude + ":" + AppApplication.mMockGps.mLatitude);
}
//
}
}});
//
}});
//
XposedHelpers
.
findAndHookMethod
(
aMapLocationClazz
,
"getLatitude"
,
new
Object
[]{
new
XC_MethodHook
()
{
//
XposedHelpers.findAndHookMethod(aMapLocationClazz, "getLatitude", new Object[]{new XC_MethodHook() {
protected
void
beforeHookedMethod
(
MethodHookParam
arg3
)
throws
Throwable
{
//
protected void beforeHookedMethod(MethodHookParam arg3) throws Throwable {
arg3
.
setResult
(
Double
.
valueOf
(
AppApplication
.
mMockGps
.
mLatitude
));
//
arg3.setResult(Double.valueOf(AppApplication.mMockGps.mLatitude));
}
//
}
}});
//
}});
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
Log
.
i
(
TAG
,
"该程序无高德地图模块,无法HOOK"
);
//
Log.i(TAG, "该程序无高德地图模块,无法HOOK");
}
//
}
}
}
...
...
app/src/main/java/top/littlerich/virtuallocation/util/FileUtils.java
0 → 100644
View file @
9d78c49e
package
top
.
littlerich
.
virtuallocation
.
util
;
import
android.os.Build
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.FileWriter
;
import
java.io.IOException
;
public
class
FileUtils
{
public
static
final
boolean
IS_USING_PROTECTED_STORAGE
=
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
;
/**
* Delete a file or a directory and its children.
*
* @param file The directory to delete.
* @throws IOException Exception when problem occurs during deleting the directory.
*/
public
static
void
delete
(
File
file
)
throws
IOException
{
for
(
File
childFile
:
file
.
listFiles
())
{
if
(
childFile
.
isDirectory
())
{
delete
(
childFile
);
}
else
{
if
(!
childFile
.
delete
())
{
throw
new
IOException
();
}
}
}
if
(!
file
.
delete
())
{
throw
new
IOException
();
}
}
public
static
String
readLine
(
File
file
)
{
try
(
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
file
)))
{
return
reader
.
readLine
();
}
catch
(
Throwable
throwable
)
{
return
""
;
}
}
public
static
void
writeLine
(
File
file
,
String
line
)
{
try
{
file
.
createNewFile
();
}
catch
(
IOException
ex
)
{
}
try
(
BufferedWriter
writer
=
new
BufferedWriter
(
new
FileWriter
(
file
)))
{
writer
.
write
(
line
);
writer
.
flush
();
}
catch
(
Throwable
throwable
)
{
Log
.
e
(
"virjar"
,
"error writing line to file "
+
file
+
": "
+
throwable
.
getMessage
());
}
}
public
static
String
getPackageName
(
String
dataDir
)
{
if
(
TextUtils
.
isEmpty
(
dataDir
))
{
Log
.
e
(
"virjar"
,
"getPackageName using empty dataDir"
);
return
""
;
}
int
lastIndex
=
dataDir
.
lastIndexOf
(
"/"
);
if
(
lastIndex
<
0
)
{
return
dataDir
;
}
return
dataDir
.
substring
(
lastIndex
+
1
);
}
public
static
String
getDataPathPrefix
()
{
return
IS_USING_PROTECTED_STORAGE
?
"/data/user_de/0/"
:
"/data/data/"
;
}
}
app/src/main/java/top/littlerich/virtuallocation/util/LocationUtil.java
deleted
100644 → 0
View file @
17de1ef6
package
top
.
littlerich
.
virtuallocation
.
util
;
import
android.content.Context
;
import
android.location.Location
;
import
android.location.LocationListener
;
import
android.location.LocationManager
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.SystemClock
;
import
android.util.Log
;
/**
* Created by xuqingfu on 2017/4/24.
*/
public
class
LocationUtil
{
private
static
final
String
TAG
=
"silence"
;
private
static
Double
mLatitude
=
30.6363334898
;
private
static
Double
mLongitude
=
104.0486168861
;
private
static
LocationManager
locationManager
;
private
static
Thread
mMockThread
;
/**
* 初始化模拟定位,并检测是否开启ADB模拟定位
*
* @param context
* @return
*/
public
static
boolean
initLocation
(
Context
context
)
{
locationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
return
false
;
}
/**
* 配置LocationManger参数
*/
public
static
void
initLocationManager
()
throws
Exception
{
}
/**
* 开启虚拟定位线程
*/
public
static
void
startLocaton
()
{
}
/**
* GPS定位需要不停的刷新经纬度值
*/
private
static
void
setLocation
(
double
latitude
,
double
longitude
)
throws
Exception
{
try
{
String
providerStr
=
LocationManager
.
GPS_PROVIDER
;
Location
mockLocation
=
new
Location
(
providerStr
);
mockLocation
.
setLatitude
(
latitude
);
mockLocation
.
setLongitude
(
longitude
);
mockLocation
.
setAltitude
(
0
);
// 高程(米)
mockLocation
.
setBearing
(
0
);
// 方向(度)
mockLocation
.
setSpeed
(
0
);
//速度(米/秒)
mockLocation
.
setAccuracy
(
2
);
// 精度(米)
mockLocation
.
setTime
(
System
.
currentTimeMillis
());
// 本地时间
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
//api 16以上的需要加上这一句才能模拟定位 , 也就是targetSdkVersion > 16
mockLocation
.
setElapsedRealtimeNanos
(
SystemClock
.
elapsedRealtimeNanos
());
}
}
catch
(
Exception
e
)
{
// 防止用户在软件运行过程中关闭模拟位置或选择其他应用
stopMockLocation
();
throw
e
;
}
}
public
static
void
stopMockLocation
()
{
}
/**
* 设置地理经纬度值
*
* @param mLongitude
* @param mLatitude
*/
public
static
void
setLongitudeAndLatitude
(
Double
mLongitude
,
Double
mLatitude
)
{
LocationUtil
.
mLatitude
=
mLatitude
;
LocationUtil
.
mLongitude
=
mLongitude
;
}
/**
* 监听Location经纬度值的修改状态
*/
private
static
class
LocationStatuListener
implements
LocationListener
{
@Override
public
void
onLocationChanged
(
Location
location
)
{
double
lat
=
location
.
getLatitude
();
double
lng
=
location
.
getLongitude
();
Log
.
i
(
TAG
,
String
.
format
(
"location: x=%s y=%s"
,
lat
,
lng
));
}
@Override
public
void
onStatusChanged
(
String
provider
,
int
status
,
Bundle
extras
)
{
}
@Override
public
void
onProviderEnabled
(
String
provider
)
{
}
@Override
public
void
onProviderDisabled
(
String
provider
)
{
}
}
}
app/src/main/java/top/littlerich/virtuallocation/util/SharePreferenceUtil.java
deleted
100644 → 0
View file @
17de1ef6
package
top
.
littlerich
.
virtuallocation
.
util
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
top.littlerich.virtuallocation.common.Common
;
import
static
android
.
content
.
Context
.
MODE_PRIVATE
;
/**
* Created by xuqingfu on 2017/3/14.
*/
public
class
SharePreferenceUtil
{
private
static
final
String
SP_FILENAME
=
"config"
;
public
static
void
saveData
(
Context
context
,
String
userName
,
String
psd
)
{
SharedPreferences
sp
=
context
.
getSharedPreferences
(
SP_FILENAME
,
MODE_PRIVATE
);
SharedPreferences
.
Editor
editor
=
sp
.
edit
();
editor
.
putString
(
Common
.
SP_FILTER_APP_PKG_NAME
,
userName
);
editor
.
commit
();
}
public
static
boolean
loadData
(
Context
context
)
{
SharedPreferences
sp
=
context
.
getSharedPreferences
(
SP_FILENAME
,
MODE_PRIVATE
);
// Common.USER_NAME = sp.getString(Common.SP_FILTER_APP_PKG_NAME, "").toString();
/*if (TextUtils.isEmpty(Common.USER_NAME) || TextUtils.isEmpty(Common.USER_PWD)) {
return false;
}*/
return
true
;
}
public
static
void
cleanData
(
Context
context
){
saveData
(
context
,
""
,
""
);
}
}
app/src/main/res/layout/item_app_info.xml
View file @
9d78c49e
...
@@ -54,6 +54,7 @@
...
@@ -54,6 +54,7 @@
</LinearLayout>
</LinearLayout>
<CheckBox
<CheckBox
android:id=
"@+id/cb_app_select"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_alignParentRight=
"true"
...
...
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