Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
G
g4proxy
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
Administrator
g4proxy
Commits
c5491608
Commit
c5491608
authored
Apr 18, 2019
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
934b29df
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
320 additions
and
218 deletions
+320
-218
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+14
-5
Constant.java
app/src/main/java/com/virjar/g4proxy/Constant.java
+7
-0
HttpProxyService.java
app/src/main/java/com/virjar/g4proxy/HttpProxyService.java
+0
-8
MainActivity.java
app/src/main/java/com/virjar/g4proxy/MainActivity.java
+22
-24
SelfStartReceiver.java
app/src/main/java/com/virjar/g4proxy/SelfStartReceiver.java
+10
-8
StartOnBootBroadcastReceiver.java
...java/com/virjar/g4proxy/StartOnBootBroadcastReceiver.java
+3
-1
App.java
app/src/main/java/com/virjar/g4proxy/bean/App.java
+1
-1
SchedulerTaskService.java
...java/com/virjar/g4proxy/service/SchedulerTaskService.java
+55
-38
DeviceInfoHolder.java
.../main/java/com/virjar/g4proxy/utils/DeviceInfoHolder.java
+118
-0
DeviceMessageUtil.java
...main/java/com/virjar/g4proxy/utils/DeviceMessageUtil.java
+81
-108
MyApplication.java
...src/main/java/com/virjar/g4proxy/utils/MyApplication.java
+0
-24
AutoInstaller.java
...ain/java/top/wuhaojie/installerlibrary/AutoInstaller.java
+9
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
c5491608
...
...
@@ -36,7 +36,6 @@
<uses-permission
android:name=
"android.permission.REQUEST_INSTALL_PACKAGES"
/>
<application
android:name=
"com.virjar.g4proxy.utils.MyApplication"
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
...
...
@@ -64,6 +63,16 @@
</intent-filter>
</service>
<service
android:name=
"com.virjar.g4proxy.service.SchedulerTaskService"
tools:ignore=
"ExportedService"
>
<intent-filter
android:priority=
"1000"
>
<action
android:name=
"com.virjar.g4proxy.service.scheuler"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</service>
<!--开机自启服务-->
<receiver
android:name=
"com.virjar.g4proxy.StartOnBootBroadcastReceiver"
...
...
@@ -83,11 +92,11 @@
<!--<!–覆盖安装后唤醒service–>-->
<!--<receiver android:name="com.virjar.g4proxy.SelfStartReceiver">-->
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.PACKAGE_REPLACED" />-->
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.PACKAGE_REPLACED" />-->
<!--<data android:scheme="package" />-->
<!--</intent-filter>-->
<!--<data android:scheme="package" />-->
<!--</intent-filter>-->
<!--</receiver>-->
<service
...
...
app/src/main/java/com/virjar/g4proxy/Constant.java
0 → 100644
View file @
c5491608
package
com
.
virjar
.
g4proxy
;
public
class
Constant
{
public
static
final
String
TAG
=
"G4ProxyAgent"
;
public
static
final
String
sharedPreferenceFile
=
"config"
;
}
app/src/main/java/com/virjar/g4proxy/HttpProxyService.java
View file @
c5491608
...
...
@@ -109,14 +109,6 @@ public class HttpProxyService extends Service {
String
clientKey
=
Settings
.
System
.
getString
(
getContentResolver
(),
Settings
.
Secure
.
ANDROID_ID
);
Log
.
i
(
"weijia"
,
"start G4Proxy front service"
);
Launcher
.
startHttpProxyService
(
3128
);
// Log.i("weijia", "start private network forward task");
//
// ProxyClient.start(Constants.g4ProxyServerHost_1, Constants.g4ProxyServerPort, clientKey);
//
// ProxyClient.start(Constants.g4ProxyServerHost_2, Constants.g4ProxyServerPort, clientKey);
//新的代理服务器实现
LogbackConfig
.
config
();
...
...
app/src/main/java/com/virjar/g4proxy/MainActivity.java
View file @
c5491608
package
com
.
virjar
.
g4proxy
;
import
android.app.ActivityManager
;
import
android.app.Application
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.location.LocationManager
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.provider.Settings
;
import
android.support.annotation.NonNull
;
import
android.support.v7.app.AppCompatActivity
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.tencent.mm.R
;
import
com.virjar.g4proxy.service.SchedulerTaskService
;
import
com.virjar.g4proxy.utils.AccessAuthority
;
import
com.virjar.g4proxy.utils.DeviceInfoHolder
;
import
com.virjar.g4proxy.utils.DeviceMessageUtil
;
import
com.virjar.g4proxy.utils.HttpClientUtils
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.List
;
import
top.wuhaojie.installerlibrary.AutoInstaller
;
public
class
MainActivity
extends
AppCompatActivity
{
public
LocationManager
locationManager
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -44,20 +28,34 @@ public class MainActivity extends AppCompatActivity {
TextView
textView
=
findViewById
(
R
.
id
.
text
);
locationManager
=
(
LocationManager
)
getSystemService
(
Context
.
LOCATION_SERVICE
);
String
clientKey
=
Settings
.
System
.
getString
(
getContentResolver
(),
Settings
.
Secure
.
ANDROID_ID
);
textView
.
setText
(
"device: "
+
clientKey
+
"\n"
);
textView
.
setText
(
"device: "
+
clientKey
+
"\n
\n
"
);
//待上传的设备信息:devicesMsg
JSONObject
deviceMsg
=
DeviceMessageUtil
.
getDeviceMessage
(
locationManager
,
this
,
this
);
JSONObject
deviceMsg
=
DeviceMessageUtil
.
getDeviceMessage
(
this
);
textView
.
append
(
deviceMsg
.
toString
());
startService
(
new
Intent
(
this
,
AppUpdateService
.
class
));
startService
(
new
Intent
(
this
,
SchedulerTaskService
.
class
));
startService
(
new
Intent
(
this
,
HttpProxyService
.
class
));
AutoInstaller
.
getDefault
(
this
).
autoConfigAccessibilitySetting
(
this
);
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
DeviceInfoHolder
.
initDeviceInfo
(
this
);
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
//不给权限的话,循环申请
DeviceInfoHolder
.
initDeviceInfo
(
this
);
}
}
app/src/main/java/com/virjar/g4proxy/SelfStartReceiver.java
View file @
c5491608
...
...
@@ -5,15 +5,17 @@ import android.content.Context;
import
android.content.Intent
;
import
android.net.Uri
;
import
com.virjar.g4proxy.service.SchedulerTaskService
;
/**
* Created by liuzhaoce on 2019/4/14.
*/
public
class
SelfStartReceiver
extends
BroadcastReceiver
{
// 这里我们先依靠slave进行守护保活
public
class
SelfStartReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
){
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
String
action
=
intent
.
getAction
();
...
...
@@ -22,19 +24,19 @@ public class SelfStartReceiver extends BroadcastReceiver{
Uri
data
=
intent
.
getData
();
if
(
data
==
null
){
if
(
data
==
null
)
{
return
;
}
//取得安装的Apk的包名,只在该app覆盖安装后自启动
String
installedPkgName
=
data
.
getSchemeSpecificPart
();
if
(
action
==
null
){
if
(
action
==
null
)
{
return
;
}
if
((
action
.
equals
(
Intent
.
ACTION_PACKAGE_ADDED
)
||
action
.
equals
(
Intent
.
ACTION_PACKAGE_REPLACED
))
&&
installedPkgName
.
equals
(
localPkgName
)){
if
((
action
.
equals
(
Intent
.
ACTION_PACKAGE_ADDED
)
||
action
.
equals
(
Intent
.
ACTION_PACKAGE_REPLACED
))
&&
installedPkgName
.
equals
(
localPkgName
))
{
Intent
launchAppUpdateService
=
new
Intent
(
context
,
AppUpdate
Service
.
class
);
Intent
launchAppUpdateService
=
new
Intent
(
context
,
SchedulerTask
Service
.
class
);
launchAppUpdateService
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
Intent
launchHttpProxyService
=
new
Intent
(
context
,
HttpProxyService
.
class
);
...
...
app/src/main/java/com/virjar/g4proxy/StartOnBootBroadcastReceiver.java
View file @
c5491608
...
...
@@ -6,6 +6,8 @@ import android.content.Context;
import
android.content.Intent
;
import
android.util.Log
;
import
com.virjar.g4proxy.service.SchedulerTaskService
;
/**
* Created by virjar on 2018/8/23.
*/
...
...
@@ -16,7 +18,7 @@ public class StartOnBootBroadcastReceiver extends BroadcastReceiver {
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
Log
.
i
(
"weijia"
,
"receive start service broadcast"
);
context
.
startService
(
new
Intent
(
context
,
AppUpdate
Service
.
class
));
context
.
startService
(
new
Intent
(
context
,
SchedulerTask
Service
.
class
));
context
.
startService
(
new
Intent
(
context
,
HttpProxyService
.
class
));
...
...
app/src/main/java/com/virjar/g4proxy/App.java
→
app/src/main/java/com/virjar/g4proxy/
bean/
App.java
View file @
c5491608
package
com
.
virjar
.
g4proxy
;
package
com
.
virjar
.
g4proxy
.
bean
;
/**
* Created by liuzhaoce on 2019/4/11.
...
...
app/src/main/java/com/virjar/g4proxy/
AppUpdate
Service.java
→
app/src/main/java/com/virjar/g4proxy/
service/SchedulerTask
Service.java
View file @
c5491608
package
com
.
virjar
.
g4proxy
;
package
com
.
virjar
.
g4proxy
.
service
;
import
android.app.AlarmManager
;
import
android.app.PendingIntent
;
import
android.app.ProgressDialog
;
import
android.app.Service
;
import
android.content.Context
;
import
android.content.Intent
;
...
...
@@ -11,11 +10,13 @@ import android.content.pm.PackageManager;
import
android.os.Handler
;
import
android.os.IBinder
;
import
android.os.Looper
;
import
android.os.Message
;
import
android.os.SystemClock
;
import
android.support.annotation.Nullable
;
import
android.util.Log
;
import
android.widget.Toast
;
import
com.virjar.g4proxy.Constant
;
import
com.virjar.g4proxy.utils.DeviceMessageUtil
;
import
com.virjar.g4proxy.utils.HttpClientUtils
;
import
org.json.JSONException
;
...
...
@@ -23,61 +24,76 @@ import org.json.JSONObject;
import
java.io.IOException
;
import
javax.annotation.Nullable
;
import
okhttp3.Call
;
import
okhttp3.Callback
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
top.wuhaojie.installerlibrary.AutoInstaller
;
public
class
AppUpdate
Service
extends
Service
{
public
class
SchedulerTask
Service
extends
Service
{
//查询更新的间隔 (单位:分钟)
public
static
final
int
updateInterval
=
10
;
public
static
final
String
TAG
=
"AppUpdateService"
;
public
static
final
String
getNewestModifiedApkUrl
=
"http://www.scumall.com:5597/hermes/ModifiedApp/getNewestModifiedApk?appPackageName="
;
private
long
lastCheckUpdateTimestamp
=
0
;
@Nullable
@Override
public
IBinder
onBind
(
Intent
intent
)
{
startService
();
checkAndRunTask
();
return
null
;
}
@Override
public
void
onCreate
()
{
registerAlarm
();
checkAndRunTask
();
super
.
onCreate
();
startService
();
}
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
startService
();
checkAndRunTask
();
return
START_STICKY
;
}
private
void
startService
()
{
private
void
checkAndRunTask
()
{
if
(
System
.
currentTimeMillis
()
-
lastCheckUpdateTimestamp
<
(
updateInterval
*
1000
*
60
)
/
3
)
{
return
;
}
lastCheckUpdateTimestamp
=
System
.
currentTimeMillis
();
runAppInstallTask
();
runUploadMessageTask
();
}
private
void
runUploadMessageTask
()
{
JSONObject
deviceMessage
=
DeviceMessageUtil
.
getDeviceMessage
(
this
);
}
private
void
runAppInstallTask
()
{
final
String
packageName
=
getApplicationInfo
().
packageName
;
Request
request
=
HttpClientUtils
.
getRequest
(
getNewestModifiedApkUrl
+
packageName
);
HttpClientUtils
.
getClient
().
newCall
(
request
).
enqueue
(
new
Callback
()
{
@Override
public
void
onFailure
(
@
Nullable
Call
call
,
@
Nullable
IOException
e
)
{
Log
.
e
(
"get request"
,
"get downloadUrl failed"
,
e
);
public
void
onFailure
(
@
javax
.
annotation
.
Nullable
Call
call
,
@javax
.
annotation
.
Nullable
IOException
e
)
{
Log
.
e
(
Constant
.
TAG
,
"get downloadUrl failed"
,
e
);
}
@Override
public
void
onResponse
(
@
Nullable
Call
call
,
@
Nullable
Response
response
)
{
public
void
onResponse
(
@
javax
.
annotation
.
Nullable
Call
call
,
@javax
.
annotation
.
Nullable
Response
response
)
{
try
{
handleResponse
(
response
,
packageName
);
}
catch
(
JSONException
|
PackageManager
.
NameNotFoundException
|
IOException
e
)
{
...
...
@@ -85,25 +101,14 @@ public class AppUpdateService extends Service {
}
}
});
AlarmManager
alarmManager
=
(
AlarmManager
)
getSystemService
(
Context
.
ALARM_SERVICE
);
int
time
=
1000
*
60
*
updateInterval
;
//获取系统开机至今所经历的毫秒
long
startTime
=
SystemClock
.
elapsedRealtime
()
+
time
;
Intent
intent
=
new
Intent
(
this
,
AppUpdateService
.
class
);
PendingIntent
pendingIntent
=
PendingIntent
.
getService
(
this
,
0
,
intent
,
0
);
if
(
alarmManager
==
null
){
return
;
}
alarmManager
.
set
(
AlarmManager
.
ELAPSED_REALTIME_WAKEUP
,
startTime
,
pendingIntent
);
}
private
void
doInstall
(
final
String
url
)
{
new
Handler
(
Looper
.
getMainLooper
()).
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
Log
.
e
(
TAG
,
"installing"
);
AutoInstaller
installer
=
AutoInstaller
.
getDefault
(
AppUpdate
Service
.
this
);
Log
.
e
(
Constant
.
TAG
,
"installing"
);
AutoInstaller
installer
=
AutoInstaller
.
getDefault
(
SchedulerTask
Service
.
this
);
installer
.
installFromUrl
(
url
);
installer
.
setOnStateChangedListener
(
new
AutoInstaller
.
OnStateChangedListener
()
{
@Override
...
...
@@ -118,12 +123,12 @@ public class AppUpdateService extends Service {
@Override
public
void
onNeed2OpenService
()
{
Toast
.
makeText
(
AppUpdate
Service
.
this
,
"请打开辅助功能服务"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
SchedulerTask
Service
.
this
,
"请打开辅助功能服务"
,
Toast
.
LENGTH_SHORT
).
show
();
}
@Override
public
void
needPermission
()
{
Toast
.
makeText
(
AppUpdate
Service
.
this
,
"需要申请存储空间权限"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
SchedulerTask
Service
.
this
,
"需要申请存储空间权限"
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
}
...
...
@@ -132,25 +137,37 @@ public class AppUpdateService extends Service {
public
void
handleResponse
(
Response
response
,
String
packageName
)
throws
JSONException
,
PackageManager
.
NameNotFoundException
,
IOException
{
if
(
response
.
body
()
==
null
){
if
(
response
.
body
()
==
null
)
{
return
;
}
String
responseJson
=
response
.
body
().
string
();
Log
.
i
(
Constant
.
TAG
,
"app update config service response: "
+
responseJson
);
JSONObject
jsonObject
=
new
JSONObject
(
responseJson
);
jsonObject
=
jsonObject
.
optJSONObject
(
"data"
);
String
downloadUrl
=
jsonObject
.
optString
(
"downloadUrl"
);
long
versionCode
=
jsonObject
.
optLong
(
"versionCode"
);
Log
.
i
(
"app_update"
,
"downloadUrl: "
+
downloadUrl
);
Log
.
i
(
"app_update"
,
"up-to-date versionCode: "
+
versionCode
);
Log
.
i
(
Constant
.
TAG
,
"downloadUrl: "
+
downloadUrl
);
Log
.
i
(
Constant
.
TAG
,
"up-to-date versionCode: "
+
versionCode
);
PackageInfo
packageInfo
=
getPackageManager
().
getPackageInfo
(
packageName
,
PackageManager
.
GET_META_DATA
);
if
(
packageInfo
.
versionCode
<
versionCode
)
{
Log
.
i
(
Constant
.
TAG
,
"the app need update,with download url: "
+
downloadUrl
);
doInstall
(
downloadUrl
);
}
}
@Override
public
void
onDestroy
()
{
super
.
onDestroy
();
private
void
registerAlarm
()
{
AlarmManager
alarmManager
=
(
AlarmManager
)
getSystemService
(
Context
.
ALARM_SERVICE
);
int
time
=
1000
*
60
*
updateInterval
;
//获取系统开机至今所经历的毫秒
long
startTime
=
SystemClock
.
elapsedRealtime
()
+
time
;
Intent
intent
=
new
Intent
(
this
,
SchedulerTaskService
.
class
);
PendingIntent
pendingIntent
=
PendingIntent
.
getService
(
this
,
0
,
intent
,
0
);
if
(
alarmManager
==
null
)
{
return
;
}
alarmManager
.
set
(
AlarmManager
.
ELAPSED_REALTIME_WAKEUP
,
startTime
,
pendingIntent
);
}
}
app/src/main/java/com/virjar/g4proxy/utils/DeviceInfoHolder.java
0 → 100644
View file @
c5491608
package
com
.
virjar
.
g4proxy
.
utils
;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageManager
;
import
android.provider.Settings
;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.telephony.TelephonyManager
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
com.virjar.g4proxy.Constant
;
import
com.virjar.g4proxy.MainActivity
;
public
class
DeviceInfoHolder
{
private
static
String
imei
;
private
static
String
androidId
;
public
static
void
initDeviceInfo
(
MainActivity
activity
)
{
if
(
ActivityCompat
.
checkSelfPermission
(
activity
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
activity
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
))
{
Log
.
e
(
Constant
.
TAG
,
"checkSelfPermission ACCESS_FINE_LOCATION did not show."
);
}
else
{
ActivityCompat
.
requestPermissions
(
activity
,
new
String
[]{
Manifest
.
permission
.
ACCESS_FINE_LOCATION
},
AccessAuthority
.
ACCESS_FINE_LOCATION_REQUEST_CODE
.
getRequestCode
());
}
return
;
}
if
(
ContextCompat
.
checkSelfPermission
(
activity
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
activity
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
))
{
Log
.
e
(
Constant
.
TAG
,
"checkSelfPermission WRITE_EXTERNAL_STORAGE did not show."
);
}
else
{
ActivityCompat
.
requestPermissions
(
activity
,
new
String
[]{
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
},
AccessAuthority
.
WRITE_EXTERNAL_STORAGE_REQUEST_CODE
.
getRequestCode
());
}
return
;
}
if
(
restoreInfo
(
activity
))
{
return
;
}
if
(
ContextCompat
.
checkSelfPermission
(
activity
,
Manifest
.
permission
.
READ_PHONE_STATE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
activity
,
Manifest
.
permission
.
READ_PHONE_STATE
))
{
Log
.
e
(
Constant
.
TAG
,
"checkSelfPermission READ_PHONE_STATE did not show."
);
}
else
{
ActivityCompat
.
requestPermissions
(
activity
,
new
String
[]{
Manifest
.
permission
.
READ_PHONE_STATE
},
AccessAuthority
.
READ_PHONE_STATE_REQUEST_CODE
.
getRequestCode
());
}
return
;
}
try
{
TelephonyManager
telephonyManager
=
(
TelephonyManager
)
activity
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
if
(
telephonyManager
==
null
)
{
Log
.
e
(
Constant
.
TAG
,
"can not get telephonyManager instance"
);
return
;
}
@SuppressLint
(
"HardwareIds"
)
String
imeiCopy
=
telephonyManager
.
getDeviceId
();
if
(!
TextUtils
.
isEmpty
(
imeiCopy
))
{
imei
=
imeiCopy
;
}
androidId
=
Settings
.
System
.
getString
(
activity
.
getContentResolver
(),
Settings
.
Secure
.
ANDROID_ID
);
save
(
activity
);
}
catch
(
Exception
e
)
{
Log
.
e
(
Constant
.
TAG
,
"getIMEI failed!"
,
e
);
}
}
private
static
boolean
restoreInfo
(
Context
context
)
{
if
(
imei
!=
null
&&
androidId
!=
null
)
{
return
true
;
}
SharedPreferences
sharedPreferences
=
context
.
getSharedPreferences
(
Constant
.
sharedPreferenceFile
,
Context
.
MODE_PRIVATE
);
String
imei
=
sharedPreferences
.
getString
(
"imei"
,
null
);
if
(
imei
==
null
)
{
return
false
;
}
DeviceInfoHolder
.
imei
=
imei
;
String
androidId
=
sharedPreferences
.
getString
(
"androidId"
,
null
);
if
(
androidId
==
null
)
{
return
false
;
}
DeviceInfoHolder
.
androidId
=
androidId
;
return
true
;
}
private
static
void
save
(
Context
context
)
{
SharedPreferences
sharedPreferences
=
context
.
getSharedPreferences
(
Constant
.
sharedPreferenceFile
,
Context
.
MODE_PRIVATE
);
SharedPreferences
.
Editor
edit
=
sharedPreferences
.
edit
();
edit
.
putString
(
"imei"
,
imei
);
edit
.
putString
(
"androidId"
,
androidId
);
edit
.
apply
();
}
public
static
String
getCachedImei
(
Context
context
)
{
restoreInfo
(
context
);
return
imei
;
}
public
static
String
getCachedAndroidId
(
Context
context
)
{
restoreInfo
(
context
);
return
androidId
;
}
}
app/src/main/java/com/virjar/g4proxy/utils/DeviceMessageUtil.java
View file @
c5491608
This diff is collapsed.
Click to expand it.
app/src/main/java/com/virjar/g4proxy/utils/MyApplication.java
deleted
100644 → 0
View file @
934b29df
package
com
.
virjar
.
g4proxy
.
utils
;
import
android.app.Application
;
import
android.content.Context
;
/**
* Created by liuzhaoce on 2019/4/12.
*/
public
class
MyApplication
extends
Application
{
private
static
Context
context
;
@Override
public
void
onCreate
()
{
// TODO Auto-generated method stub
super
.
onCreate
();
context
=
getApplicationContext
();
}
public
static
Context
getContext
()
{
return
context
;
}
}
\ No newline at end of file
app/src/main/java/top/wuhaojie/installerlibrary/AutoInstaller.java
View file @
c5491608
...
...
@@ -13,6 +13,7 @@ import android.provider.Settings;
import
android.support.v4.content.FileProvider
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.widget.Toast
;
import
com.tencent.mm.BuildConfig
;
...
...
@@ -175,6 +176,13 @@ public class AutoInstaller extends Handler {
}
}
public
void
autoConfigAccessibilitySetting
(
Context
context
)
{
if
(!
isAccessibilitySettingsOn
(
mContext
))
{
toAccessibilityService
();
Toast
.
makeText
(
context
,
"请打开辅助模式"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
private
boolean
permissionDenied
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
23
)
{
String
[]
permissions
=
{
...
...
@@ -194,7 +202,7 @@ public class AutoInstaller extends Handler {
private
void
toAccessibilityService
()
{
Intent
intent
=
new
Intent
(
Settings
.
ACTION_ACCESSIBILITY_SETTINGS
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
mContext
.
startActivity
(
intent
);
}
...
...
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