Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ReyunAdiTool
Project
Overview
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
daiwenjie
ReyunAdiTool
Commits
1efaf4c3
Commit
1efaf4c3
authored
Oct 17, 2022
by
LAPTOP-146U5DF5\28422
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了下载和上报的Host
parent
2af06a4e
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
400 additions
and
42 deletions
+400
-42
gradle.xml
.idea/gradle.xml
+1
-3
DoCommandService.java
...main/java/com/fear1ess/reyunaditool/DoCommandService.java
+1
-1
DoWorkThread.java
...src/main/java/com/fear1ess/reyunaditool/DoWorkThread.java
+3
-1
ExecuteCmdUtils.java
.../main/java/com/fear1ess/reyunaditool/ExecuteCmdUtils.java
+10
-0
MainActivity.java
...src/main/java/com/fear1ess/reyunaditool/MainActivity.java
+21
-5
NetWorkUtils.java
...src/main/java/com/fear1ess/reyunaditool/NetWorkUtils.java
+81
-20
ReBootBroadcastReceiver.java
...va/com/fear1ess/reyunaditool/ReBootBroadcastReceiver.java
+15
-0
Tool.java
app/src/main/java/com/fear1ess/reyunaditool/Tool.java
+109
-0
DownloadThread.java
...java/com/fear1ess/reyunaditool/thread/DownloadThread.java
+141
-6
InstallAndStartAppThread.java
...ear1ess/reyunaditool/thread/InstallAndStartAppThread.java
+9
-3
UploadAdsDataProceduce.java
.../fear1ess/reyunaditool/thread/UploadAdsDataProceduce.java
+2
-2
PushMsgUtils.java
...in/java/com/fear1ess/reyunaditool/utils/PushMsgUtils.java
+7
-1
No files found.
.idea/gradle.xml
View file @
1efaf4c3
...
...
@@ -4,7 +4,7 @@
<component
name=
"GradleSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
<option
name=
"testRunner"
value=
"
PLATFORM
"
/>
<option
name=
"testRunner"
value=
"
GRADLE
"
/>
<option
name=
"distributionType"
value=
"DEFAULT_WRAPPED"
/>
<option
name=
"externalProjectPath"
value=
"$PROJECT_DIR$"
/>
<option
name=
"gradleJvm"
value=
"1.8"
/>
...
...
@@ -14,8 +14,6 @@
<option
value=
"$PROJECT_DIR$/app"
/>
</set>
</option>
<option
name=
"resolveModulePerSourceSet"
value=
"false"
/>
<option
name=
"useQualifiedModuleNames"
value=
"true"
/>
</GradleProjectSettings>
</option>
</component>
...
...
app/src/main/java/com/fear1ess/reyunaditool/DoCommandService.java
View file @
1efaf4c3
...
...
@@ -52,7 +52,7 @@ public class DoCommandService extends Service {
private
Handler
mUiHandler
;
private
InstallAndStartAppThread
mInstallAndStartAppThread
;
p
rivate
DownloadThread
mDownloadAppThread
;
p
ublic
static
DownloadThread
mDownloadAppThread
;
private
Binder
mBinder
=
new
DoCommandBinder
();
...
...
app/src/main/java/com/fear1ess/reyunaditool/DoWorkThread.java
View file @
1efaf4c3
...
...
@@ -23,7 +23,9 @@ import static com.fear1ess.reyunaditool.NetWorkUtils.getDwonURL;
public
class
DoWorkThread
implements
Runnable
{
public
Handler
mainUiHandler
=
null
;
public
Context
appContext
=
null
;
public
static
String
getAppInfoUrlStr
=
"http://adfly-api.adinsights-global.com/get_app_res/?count=1&ua=android"
;
// public static String getAppInfoUrlStr = "http://adfly-api.adinsights-global.com/get_app_res/?count=1&ua=android";
public
static
String
getAppInfoUrlStr
=
"http://8.210.2.192/get_app_res/?count=1&ua=android"
;
public
static
String
postAppInfoUrlStr
=
"http://adfly-api.adinsights-global.com/get_app_res/?ua=android"
;
public
DoWorkThread
(
Context
cxt
,
Handler
handler
){
...
...
app/src/main/java/com/fear1ess/reyunaditool/ExecuteCmdUtils.java
View file @
1efaf4c3
...
...
@@ -66,6 +66,12 @@ public class ExecuteCmdUtils {
}
public
static
int
startApp
(
Context
appContext
,
String
packageName
)
{
try
{
if
(
packageName
==
null
){
return
0
;
}
MyLog
.
d
(
"startApp->启动:"
+
packageName
);
PackageManager
pm
=
appContext
.
getPackageManager
();
Intent
intent
=
pm
.
getLaunchIntentForPackage
(
packageName
);
if
(
intent
==
null
)
return
-
1
;
...
...
@@ -74,6 +80,10 @@ public class ExecuteCmdUtils {
String
className
=
cn
.
getClassName
();
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
appContext
.
startActivity
(
intent
);
}
catch
(
Exception
e
){
MyLog
.
error
(
e
.
toString
());
}
return
0
;
// Log.d(TAG, "startApp " + packageName);
// String cmd = "am start -n " + pkgName + "/" + className;
...
...
app/src/main/java/com/fear1ess/reyunaditool/MainActivity.java
View file @
1efaf4c3
...
...
@@ -51,10 +51,10 @@ public class MainActivity extends AppCompatActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
try
{
LocalService
.
m_comtext
=
getApplicationContext
();
RemoteService
.
m_comtext
=
getApplicationContext
();
startService
(
new
Intent
(
this
,
LocalService
.
class
));
//
startService(new Intent(this, LocalService.class));
AdiToolApp
app
=
(
AdiToolApp
)
getApplication
();
...
...
@@ -74,27 +74,37 @@ public class MainActivity extends AppCompatActivity {
requestPermissions
(
new
String
[]{
"android.permission.WRITE_EXTERNAL_STORAGE"
,
"android.permission.READ_EXTERNAL_STORAGE"
},
100
);
startForegroundService
(
new
Intent
(
MainActivity
.
this
,
DoCommandService
.
class
));
startBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
try
{
startBtn
.
setText
(
"Working"
);
startBtn
.
setEnabled
(
false
);
stopBtn
.
setEnabled
(
true
);
Context
cxt
=
AdiToolApp
.
getAppContext
();
startForegroundService
(
new
Intent
(
MainActivity
.
this
,
DoCommandService
.
class
));
}
catch
(
Exception
e
){
MyLog
.
d
(
"startBtn -> setOnClickListener :"
+
e
.
toString
());
}
}
});
stopBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
try
{
Context
cxt
=
AdiToolApp
.
getAppContext
();
stopService
(
new
Intent
(
cxt
,
DoCommandService
.
class
));
startBtn
.
setText
(
"Start"
);
startBtn
.
setEnabled
(
true
);
stopBtn
.
setEnabled
(
false
);
}
catch
(
Exception
e
){
MyLog
.
d
(
"stopBtn -> setOnClickListener :"
+
e
.
toString
());
}
}
});
...
...
@@ -134,6 +144,10 @@ public class MainActivity extends AppCompatActivity {
}
}
}).
start
();
}
catch
(
Exception
e
){
MyLog
.
d
(
"MainActivity -> onCreate "
+
e
.
toString
());
}
...
...
@@ -147,7 +161,9 @@ public class MainActivity extends AppCompatActivity {
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
()
.
build
();
Request
request
=
new
Request
.
Builder
()
.
url
(
"http://adfly-api.adinsights-global.com/get_app_res/?count=1&ua=android"
)
// .url("http://adfly-api.adinsights-global.com/get_app_res/?count=1&ua=android")
.
url
(
"http://8.210.2.192/get_app_res/?count=1&ua=android"
)
.
method
(
"GET"
,
null
)
.
build
();
try
{
...
...
app/src/main/java/com/fear1ess/reyunaditool/NetWorkUtils.java
View file @
1efaf4c3
...
...
@@ -136,32 +136,64 @@ public class NetWorkUtils {
out
.
write
(
postData
);
out
.
flush
();
}
String
fileName
=
huc
.
getHeaderField
(
"Content-Disposition"
);
if
(
fileName
==
null
){
callback
.
onDownloadPkgNameGetfailed
();
huc
.
disconnect
();
return
null
;
String
fileName
=
huc
.
getHeaderField
(
"pkg"
);
if
(
urlStr
.
contains
(
"get_apk"
)){
MyLog
.
d
(
"Content-Disposition: "
+
fileName
);
}
else
{
/*
测试代码
*/
fileName
=
""
;
}
String
pkgName
=
fileName
.
replace
(
"attachment; filename="
,
""
)
.
replace
(
".apk"
,
""
);
if
(
fileName
==
null
){
fileName
=
"error"
;
}
// if(fileName == null){
// callback.onDownloadPkgNameGetfailed();
// huc.disconnect();
//
// MyLog.d("没有获取到文件名");
// return null;
// }
String
pkgName
=
fileName
;
// String pkgName = fileName.replace("attachment; filename=","")
// .replace(".apk", "");
MyLog
.
d
(
"pkgName: "
+
pkgName
);
if
(
isDownload
){
callback
.
onDownloadPkgNameGetSuccess
(
pkgName
);
}
InputStream
is
=
huc
.
getInputStream
();
byte
[]
data
=
new
byte
[
8192
];
byte
[]
data
=
new
byte
[
1024
];
int
len
=
0
;
int
totalBytes
=
0
;
MyLog
.
d
(
"开始读取数据->开始"
+
huc
.
getContentLength
());
try
{
while
((
len
=
is
.
read
(
data
))
!=
-
1
){
os
.
write
(
data
,
0
,
len
);
totalBytes
+=
len
;
// MyLog.d("开始读取数据 "+totalBytes);
if
(
isDownload
){
if
(
fileName
!=
null
)
{
callback
.
onDownloadBytesUpdate
(
pkgName
,
totalBytes
);
}
}
}
}
catch
(
Exception
e
){
MyLog
.
d
(
"get-> "
+
e
.
toString
());
}
MyLog
.
d
(
"开始读取数据->结束 "
+
totalBytes
);
os
.
flush
();
byte
[]
resData
=
null
;
if
(
os
instanceof
ByteArrayOutputStream
)
{
resData
=
((
ByteArrayOutputStream
)
os
).
toByteArray
();
}
...
...
@@ -193,9 +225,13 @@ public class NetWorkUtils {
URL
getAppInfoUrl
=
null
;
Response
res
=
null
;
MyLog
.
d
(
"httpsReq ====== "
+
urlStr
);
long
start
=
System
.
currentTimeMillis
();
long
jiangge
=
60
*
30
;
HttpsURLConnection
huc
=
null
;
InputStream
is
=
null
;
try
{
getAppInfoUrl
=
new
URL
(
urlStr
);
HttpsURLConnection
huc
=
(
HttpsURLConnection
)
getAppInfoUrl
.
openConnection
();
huc
=
(
HttpsURLConnection
)
getAppInfoUrl
.
openConnection
();
if
(
postData
==
null
)
huc
.
setRequestMethod
(
"GET"
);
else
huc
.
setRequestMethod
(
"POST"
);
if
(
headers
!=
null
){
...
...
@@ -203,18 +239,23 @@ public class NetWorkUtils {
huc
.
setRequestProperty
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
huc
.
setConnectTimeout
(
5000
);
huc
.
setRequestProperty
(
"Connection"
,
"close"
);
huc
.
setConnectTimeout
(
10000
);
huc
.
setHostnameVerifier
(
new
TrustAllHostnamesVerifier
());
SSLContext
sc
=
SSLContext
.
getInstance
(
"TLS"
);
sc
.
init
(
null
,
new
TrustManager
[]{
new
TrustAllCertificateManager
()},
new
SecureRandom
());
huc
.
setSSLSocketFactory
(
sc
.
getSocketFactory
());
huc
.
connect
();
if
(
postData
!=
null
){
OutputStream
out
=
huc
.
getOutputStream
();
out
.
write
(
postData
);
out
.
flush
();
}
InputStream
is
=
huc
.
getInputStream
();
MyLog
.
d
(
"开始连接"
);
huc
.
connect
();
MyLog
.
d
(
"开始读取数据"
);
is
=
huc
.
getInputStream
();
byte
[]
data
=
new
byte
[
8192
];
// ByteArrayOutputStream bo = new ByteArrayOutputStream();
int
len
=
0
;
...
...
@@ -223,13 +264,18 @@ public class NetWorkUtils {
while
((
len
=
is
.
read
(
data
))
!=
-
1
){
os
.
write
(
data
,
0
,
len
);
sum
+=
len
;
if
(
sum
>
obj
){
MyLog
.
d
(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!! 读取的数据大于1G 放弃"
);
throw
new
Exception
(
"123123"
);
long
temp
=(
System
.
currentTimeMillis
()-
start
)/
1000
;
if
(
temp
%(
60
)==
0
){
MyLog
.
d
(
"读取APK的数据中 "
+
sum
);
}
if
(
temp
>
jiangge
){
os
.
close
();
MyLog
.
d
(
"读取超时了"
);
throw
new
Exception
(
"123"
);
}
// ++num;
}
MyLog
.
d
(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!! 读取的文件大小:"
+
sum
);
MyLog
.
d
(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!! 读取的文件大小:"
+
sum
+
" 时间:"
+(
System
.
currentTimeMillis
()-
start
)
);
os
.
flush
();
byte
[]
resData
=
null
;
if
(
os
instanceof
ByteArrayOutputStream
)
{
...
...
@@ -242,10 +288,10 @@ public class NetWorkUtils {
res
=
new
Response
(
huc
.
getResponseCode
(),
huc
.
getResponseMessage
(),
resData
,
fileName
);
os
.
close
();
is
.
close
();
huc
.
disconnect
();
//
huc.disconnect();
}
catch
(
Exception
e
)
{
MyLog
.
error
(
e
.
toString
());
}
}
finally
{
if
(
os
!=
null
){
try
{
os
.
close
();
...
...
@@ -253,6 +299,18 @@ public class NetWorkUtils {
e
.
printStackTrace
();
}
}
if
(
is
!=
null
){
try
{
is
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
huc
!=
null
){
huc
.
disconnect
();
}
}
MyLog
.
d
(
"发包结束:"
+
urlStr
);
return
res
;
...
...
@@ -261,14 +319,17 @@ public class NetWorkUtils {
//获取下载地址
public
static
String
getDwonURL
(){
String
result
=
null
;
try
{
JSONObject
jsonObject
=
null
;
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
()
.
build
();
Request
request
=
new
Request
.
Builder
()
.
url
(
getAppInfoUrlStr
)
// .url("http://adfly-api.adinsights-global.com/get_app_res/?count=1&ua=android")
.
url
(
"http://8.210.2.192/get_app_res/?count=1&ua=android"
)
.
method
(
"GET"
,
null
)
.
build
();
try
{
okhttp3
.
Response
response
=
client
.
newCall
(
request
).
execute
();
String
resp
=
new
String
(
response
.
body
().
bytes
());
jsonObject
=
new
JSONObject
(
resp
);
...
...
app/src/main/java/com/fear1ess/reyunaditool/ReBootBroadcastReceiver.java
View file @
1efaf4c3
...
...
@@ -12,9 +12,23 @@ public class ReBootBroadcastReceiver extends BroadcastReceiver {
// an Intent broadcast.
if
(
intent
.
getAction
().
equals
(
"android.intent.action.BOOT_COMPLETED"
))
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
MyLog
.
d
(
"准备重新启动APP!!!!!!!!!!!!!!"
);
try
{
Thread
.
sleep
(
5
*
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
MyLog
.
d
(
"启动:"
+
e
.
toString
());
}
MyLog
.
d
(
"开始重新启动APP!!!!!!!!!!!!!!"
);
Intent
i
=
new
Intent
(
context
,
MainActivity
.
class
);
i
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
context
.
startActivity
(
i
);
}
}).
start
();
}
}
}
\ No newline at end of file
app/src/main/java/com/fear1ess/reyunaditool/Tool.java
0 → 100644
View file @
1efaf4c3
package
com
.
fear1ess
.
reyunaditool
;
import
java.io.BufferedReader
;
import
java.io.DataOutputStream
;
import
java.io.File
;
import
java.io.InputStreamReader
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
public
class
Tool
{
public
static
void
sleep
(
int
sec
){
try
{
Thread
.
sleep
(
sec
*
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
public
static
void
renameFile
(
String
srcPath
,
String
reNamePath
){
File
fi
=
new
File
(
srcPath
);
File
fi2
=
new
File
(
reNamePath
);
fi
.
renameTo
(
fi2
);
}
public
static
ArrayList
<
String
>
rootCommand
(
String
command
)
{
MyLog
.
d
(
"执行命令:"
+
command
);
BufferedReader
successReader
=
null
;
BufferedReader
errorReader
=
null
;
StringBuilder
errorMsg
=
null
;
ArrayList
<
String
>
results
=
new
ArrayList
<
String
>();
Process
process
=
null
;
DataOutputStream
os
=
null
;
try
{
process
=
Runtime
.
getRuntime
().
exec
(
"su"
);
os
=
new
DataOutputStream
(
process
.
getOutputStream
());
os
.
writeBytes
(
command
+
"\n"
);
os
.
writeBytes
(
"exit\n"
);
os
.
flush
();
process
.
waitFor
();
//读取信息
errorMsg
=
new
StringBuilder
();
successReader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
errorReader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getErrorStream
()));
String
lineStr
;
results
.
add
(
"success"
);
//获取正常输出的信息
while
((
lineStr
=
successReader
.
readLine
())
!=
null
)
{
results
.
add
(
lineStr
);
}
//获取产生错误时的信息
while
((
lineStr
=
errorReader
.
readLine
())
!=
null
)
{
errorMsg
.
append
(
lineStr
);
}
if
(
errorMsg
.
toString
().
length
()
>
5
)
{
if
(
results
.
size
()>
0
){
results
.
clear
();
results
.
add
(
"failure"
);
}
// MyLog.d("执行命令:" + command + " 错误 信息是:" + errorMsg.toString());
results
.
add
(
errorMsg
.
toString
());
}
}
catch
(
Exception
e
)
{
return
null
;
}
finally
{
try
{
if
(
os
!=
null
)
{
os
.
close
();
}
process
.
destroy
();
}
catch
(
Exception
e
)
{
}
}
return
results
;
}
public
static
long
dateToStamp
(
String
s
)
{
long
res
=
0
;
//设置时间模版
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
date
=
null
;
try
{
date
=
simpleDateFormat
.
parse
(
s
);
if
(
date
!=
null
){
res
=
date
.
getTime
();
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
res
;
}
}
app/src/main/java/com/fear1ess/reyunaditool/thread/DownloadThread.java
View file @
1efaf4c3
...
...
@@ -3,6 +3,7 @@ package com.fear1ess.reyunaditool.thread;
import
android.content.Context
;
import
android.os.Handler
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
com.fear1ess.reyunaditool.AppInfo
;
...
...
@@ -10,6 +11,7 @@ import com.fear1ess.reyunaditool.DoCommandService;
import
com.fear1ess.reyunaditool.ExecuteCmdUtils
;
import
com.fear1ess.reyunaditool.MyLog
;
import
com.fear1ess.reyunaditool.NetWorkUtils
;
import
com.fear1ess.reyunaditool.Tool
;
import
com.fear1ess.reyunaditool.state.AppState
;
import
com.fear1ess.reyunaditool.utils.PushMsgUtils
;
...
...
@@ -18,6 +20,7 @@ import org.json.JSONObject;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
...
...
@@ -39,7 +42,7 @@ public class DownloadThread extends Thread {
public
static
String
TAG
=
"reyunaditool_log"
;
// public static String downloadAppUrlStr = "http://adfly-api.adinsights-global.com/get_app_res/?count=1&ua=and";
public
static
String
downloadAppUrlStr
=
"http://
101.32.45.4
/get_app_res/?count=1&ua=android"
;
public
static
String
downloadAppUrlStr
=
"http://
8.210.2.192
/get_app_res/?count=1&ua=android"
;
static
{
File
fi
=
new
File
(
downloadDir
);
...
...
@@ -102,29 +105,37 @@ public class DownloadThread extends Thread {
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
MyLog
.
d
(
"开始获取下载连接: "
);
MyLog
.
d
(
"开始获取下载连接
1
: "
);
String
url
=
getDwonURL
();
// String url="http://adinsights-new.oss-cn-huhehaote.aliyuncs.com/ad_union%2Fpackage%2Fpackage_79b00e464f57b8a3ea88926d1b3f9a91.apk?OSSAccessKeyId=LTAI4G7uVtsTvSYaa1ekxQoF&Expires=1656672566&Signature=%2FLw%2Bo1mTLTYDh%2FDFQaLuMIr8c8w%3D";
MyLog
.
d
(
"获取到的下载地址: "
+
url
);
setNetWorkCallback
();
String
ts
=
String
.
valueOf
(
System
.
currentTimeMillis
());
String
downloadPath
=
downloadDir
+
"/"
+
"rycache_"
+
ts
+
".apk"
;
String
pkgName
=
downloadApp
(
url
,
downloadPath
);
String
biaozhi
=
downloadApp
(
url
,
downloadPath
);
// String pkgName = downloadApp(downloadAppUrlStr, downloadPath);
MyLog
.
d
(
"下载获取的包名:"
+
pkgName
);
MyLog
.
d
(
"下载获取的包名:"
+
biaozhi
+
" 下载地址:"
+
downloadPath
);
String
pkgName
=
null
;
pkgName
=
getPackageName
(
downloadPath
,
pkgName
);
// MyLog.d("下载获取的包名->重新获取包名======== "+pkgName);
if
(
pkgName
==
null
)
{
ExecuteCmdUtils
.
deletePkg
(
downloadPath
);
MyLog
.
d
(
"删除包信息..开始等待5分钟.."
);
try
{
sleep
(
5
*
60
*
1000
);
sleep
(
1
*
60
*
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
continue
;
}
String
newPath
=
downloadDir
+
"/"
+
pkgName
+
".apk"
;
renameFile
(
downloadPath
,
newPath
);
uploadDownLoadSuccessData
(
pkgName
);
uploadDownLoadSuccessData
(
biaozhi
);
try
{
mAppInfoQueue
.
put
(
new
AppInfo
(
pkgName
,
newPath
));
...
...
@@ -137,6 +148,129 @@ public class DownloadThread extends Thread {
}
}
public
String
getPackageName
(
String
downloadPath
,
String
pkgName
){
String
result_pkg
=
null
;
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
String
code
=
installApp
(
downloadPath
);
MyLog
.
d
(
"getPackageName-> "
+
code
);
if
(
code
==
null
){
return
code
;
}
else
if
(
code
.
contains
(
"INSTALL_FAILED_ALREADY_EXISTS"
)){
int
start
=
code
.
indexOf
(
"re-install"
)+
11
;
int
end
=
code
.
indexOf
(
"without first"
);
result_pkg
=
code
.
substring
(
start
,
end
).
trim
();
MyLog
.
d
(
"getPackageName-> 返回的 "
+
result_pkg
);
break
;
}
}
// ArrayList<String> after_name=getAppPackageName();
//
// MyLog.d("getPackageName -> after_name "+after_name.size());
// for (int i = 0; i < after_name.size(); i++) {
// String item=after_name.get(i);
// MyLog.d("getPackageName -> after_name "+item);
// if (!before_name.contains(item)){
// MyLog.d("获取到的APP 包名: "+item);
// result_pkg=item;
// break;
// }
// }
return
result_pkg
;
}
public
String
installApp
(
String
downloadPath
){
String
cmd
=
"pm install "
+
downloadPath
;
ArrayList
<
String
>
result
=
Tool
.
rootCommand
(
cmd
);
if
(
result
==
null
)
return
null
;
String
type
=
result
.
get
(
0
);
if
(
type
.
equals
(
"success"
)){
MyLog
.
d
(
"installApp->安装APP: "
+
downloadPath
+
" -> 成功"
);
return
"success:"
;
}
String
errorMsg
=
result
.
get
(
1
);
if
(
errorMsg
.
contains
(
"INSTALL_FAILED_ALREADY_EXISTS"
)){
return
errorMsg
;
}
else
{
MyLog
.
d
(
"installApp->安装APP: "
+
downloadPath
+
" -> 失败 : "
+
errorMsg
);
return
null
;
}
}
public
void
deleApp
(){
ArrayList
<
String
>
result
=
getAppPackageName
();
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++)
{
String
pkgName
=
result
.
get
(
i
);
ExecuteCmdUtils
.
finishApp
(
pkgName
);
MyLog
.
d
(
"deleApp-> "
+
pkgName
+
" result: "
+
uninstallApp
(
pkgName
));
;
}
}
public
boolean
uninstallApp
(
String
packageName
){
String
cmd
=
"pm uninstall "
+
packageName
;
ArrayList
<
String
>
result
=
Tool
.
rootCommand
(
cmd
);
if
(
result
==
null
)
return
false
;
String
type
=
result
.
get
(
0
);
MyLog
.
d
(
"uninstallapp->卸载APP:"
+
type
);
if
(
type
.
equals
(
"success"
)){
MyLog
.
d
(
"uninstallapp->卸载APP: "
+
packageName
+
" -> 成功"
);
return
true
;
}
MyLog
.
d
(
"uninstallapp->卸载APP: "
+
packageName
+
" -> 失败"
);
return
result
!=
null
;
}
public
ArrayList
<
String
>
getAppPackageName
(){
ArrayList
<
String
>
result
=
new
ArrayList
<>();
ArrayList
<
String
>
arrayList
=
Tool
.
rootCommand
(
"ls /data/app -l"
);
for
(
int
i
=
2
;
i
<
arrayList
.
size
();
i
++)
{
String
item
=
arrayList
.
get
(
i
);
try
{
// d("getPackageName-> 获取的包名1:"+item);
String
[]
strings
=
item
.
split
(
" "
);
String
str
=
strings
[
7
];
// d("getPackageName-> 获取的包名1:"+str);
str
=
str
.
split
(
"-"
)[
0
];
// d("getPackageName-> 获取的包名2:"+str);
item
=
str
;
if
((!
item
.
contains
(
"com.google"
))
&&(!
item
.
contains
(
"com.topjohnwu.magisk"
))
&&(!
item
.
contains
(
"com.fear1ess"
))
&&(!
item
.
contains
(
"com.magic"
))
//
&&(!
item
.
contains
(
"org.meowcat.edxposed.manager"
))
&&(!
item
.
contains
(
"bin.mt.plus"
))
// &&(!item.contains("org.meowcat.edxposed.manager"))
){
result
.
add
(
str
.
trim
());
MyLog
.
d
(
"getPackageName-> 获取的包名1:"
+
item
);
}
}
catch
(
Exception
e
){
MyLog
.
d
(
e
.
toString
());
item
=
"error"
;
};
}
if
(
result
.
size
()>
2
){
result
.
remove
(
0
);
result
.
remove
(
1
);
}
return
result
;
}
public
void
uploadDownLoadSuccessData
(
String
pkgName
)
{
Log
.
d
(
TAG
,
"start upload download success data..."
);
ExecutorService
es
=
Executors
.
newSingleThreadExecutor
();
...
...
@@ -144,6 +278,7 @@ public class DownloadThread extends Thread {
try
{
jo
.
put
(
"app_id"
,
pkgName
);
jo
.
put
(
"download_success"
,
1
);
MyLog
.
d
(
"uploadDownLoadSuccessData-> "
+
jo
.
toString
());
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
...
...
app/src/main/java/com/fear1ess/reyunaditool/thread/InstallAndStartAppThread.java
View file @
1efaf4c3
...
...
@@ -15,7 +15,9 @@ import com.fear1ess.reyunaditool.AppInfo;
import
com.fear1ess.reyunaditool.DoCommandService
;
import
com.fear1ess.reyunaditool.ExecuteCmdUtils
;
import
com.fear1ess.reyunaditool.MainActivity
;
import
com.fear1ess.reyunaditool.MyLog
;
import
com.fear1ess.reyunaditool.NetWorkUtils
;
import
com.fear1ess.reyunaditool.Tool
;
import
com.fear1ess.reyunaditool.cmd.OperateCmd
;
import
com.fear1ess.reyunaditool.state.AppState
;
import
com.fear1ess.reyunaditool.utils.PushMsgUtils
;
...
...
@@ -24,6 +26,7 @@ import org.json.JSONException;
import
org.json.JSONObject
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
...
...
@@ -43,8 +46,8 @@ public class InstallAndStartAppThread extends Thread {
private
volatile
boolean
mNeedWait
=
false
;
private
volatile
boolean
needRunning
=
true
;
public
static
String
postAppInfoUrlStr
=
"http://adfly-api.adinsights-global.com/get_app_res/?ua=android"
;
//
public static String postAppInfoUrlStr = "http://adfly-api.adinsights-global.com/get_app_res/?ua=android";
public
static
String
postAppInfoUrlStr
=
"http://8.210.2.192/get_app_res/?ua=android"
;
public
HandleAppHandler
hah
;
public
InstallAndStartAppThread
(
DownloadThread
dt
,
Context
cxt
,
Handler
uiHandler
,
DoCommandService
service
)
{
...
...
@@ -124,6 +127,7 @@ public class InstallAndStartAppThread extends Thread {
public
synchronized
void
installAndStartNewApp
()
{
AppInfo
appInfo
=
null
;
try
{
// deleApp();
while
(
true
){
//启动APP本身
// Message message=new Message();
...
...
@@ -145,7 +149,7 @@ public class InstallAndStartAppThread extends Thread {
if
(!
isAppExists
(
mPkgName
)){
int
res
=
ExecuteCmdUtils
.
installApp
(
mDownloadPath
);
if
(
res
==
0
){
Log
.
d
(
TAG
,
"install app "
+
mPkgName
+
"success!"
);
Log
.
d
(
TAG
,
"install app "
+
mPkgName
+
"success!"
);
;
}
else
{
mService
.
uploadErrorApkData
(
"install failed"
);
Log
.
e
(
TAG
,
"install app "
+
mPkgName
+
" failed!"
);
...
...
@@ -204,6 +208,8 @@ public class InstallAndStartAppThread extends Thread {
public
class
HandleAppHandler
extends
Handler
{
@Override
...
...
app/src/main/java/com/fear1ess/reyunaditool/thread/UploadAdsDataProceduce.java
View file @
1efaf4c3
...
...
@@ -6,8 +6,8 @@ import com.fear1ess.reyunaditool.NetWorkUtils;
public
class
UploadAdsDataProceduce
implements
Runnable
{
public
static
String
TAG
=
"reyunaditool_log"
;
public
static
String
postAppInfoUrlStr
=
"http://101.32.45.4
/get_app_res/?ua=android"
;
// public static String postAppInfoUrlStr = "http://adfly-api.adinsights-global.com
/get_app_res/?ua=android";
public
static
String
postAppInfoUrlStr
=
"http://8.210.2.192/get_app_res/?ua=android"
;
public
String
mData
;
public
UploadAdsDataProceduce
(
String
str
)
{
...
...
app/src/main/java/com/fear1ess/reyunaditool/utils/PushMsgUtils.java
View file @
1efaf4c3
...
...
@@ -13,6 +13,7 @@ import android.util.Base64;
import
com.fear1ess.reyunaditool.AdiToolApp
;
import
com.fear1ess.reyunaditool.AppInfo
;
import
com.fear1ess.reyunaditool.MyLog
;
import
com.fear1ess.reyunaditool.cmd.WSConnectCmd.ServerCmd
;
import
org.json.JSONException
;
...
...
@@ -96,7 +97,7 @@ public class PushMsgUtils {
}
public
static
ApplicationInfo
getApplicationInfo
(
String
pkgName
){
PackageManager
pm
=
AdiToolApp
.
getAppContext
().
getPackageManager
();
try
{
PackageManager
pm
=
AdiToolApp
.
getAppContext
().
getPackageManager
();
List
<
ApplicationInfo
>
packageInfos
=
pm
.
getInstalledApplications
(
0
);
for
(
ApplicationInfo
ai
:
packageInfos
)
{
if
(
pkgName
.
equals
(
ai
.
packageName
))
return
ai
;
...
...
@@ -105,6 +106,11 @@ public class PushMsgUtils {
String appName = appInfo.loadLabel(pm).toString();
appInfos.add(new AppInfo(pkgName,appName,icon));*/
}
}
catch
(
Exception
e
){
MyLog
.
d
(
"getApplicationInfo -> "
+
e
.
toString
());
}
return
null
;
}
}
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