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
10384643
Commit
10384643
authored
Aug 17, 2021
by
LAPTOP-146U5DF5\28422
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
5545c985
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
135 additions
and
8 deletions
+135
-8
DoCommandService.java
...main/java/com/fear1ess/reyunaditool/DoCommandService.java
+5
-3
LocalService.java
...src/main/java/com/fear1ess/reyunaditool/LocalService.java
+1
-1
MainActivity.java
...src/main/java/com/fear1ess/reyunaditool/MainActivity.java
+83
-1
MyLog.java
app/src/main/java/com/fear1ess/reyunaditool/MyLog.java
+21
-0
InstallAndStartAppThread.java
...ear1ess/reyunaditool/thread/InstallAndStartAppThread.java
+19
-3
activity_main.xml
app/src/main/res/layout/activity_main.xml
+6
-0
No files found.
app/src/main/java/com/fear1ess/reyunaditool/DoCommandService.java
View file @
10384643
...
...
@@ -166,13 +166,15 @@ public class DoCommandService extends Service {
isUploadAdsData
=
true
;
}
public
void
uploadErrorApkData
()
{
public
void
uploadErrorApkData
(
String
type
)
{
Log
.
d
(
TAG
,
"start upload empty ads data..."
);
ExecutorService
es
=
Executors
.
newSingleThreadExecutor
();
JSONObject
jo
=
new
JSONObject
();
try
{
jo
.
put
(
"app_id"
,
mCurPkgName
);
jo
.
put
(
"apk_error"
,
1
);
// jo.put("app_id", mCurPkgName);
jo
.
put
(
"apk_error"
,
"包名:"
+
mCurPkgName
+
" 客户端:"
+
MainActivity
.
m_Android_ID
+
" error_type:"
+
type
);
// jo.put("user", );
// jo.put("error_type",type);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
...
...
app/src/main/java/com/fear1ess/reyunaditool/LocalService.java
View file @
10384643
...
...
@@ -39,7 +39,7 @@ public class LocalService extends Service {
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
Log
.
d
(
"myTest"
,
"onStartCommand: 本地服务启动"
);
//
Log.d("myTest", "onStartCommand: 本地服务启动");
startService
(
new
Intent
(
LocalService
.
this
,
RemoteService
.
class
));
bindService
(
new
Intent
(
this
,
RemoteService
.
class
),
connection
,
Context
.
BIND_IMPORTANT
);
return
START_STICKY
;
...
...
app/src/main/java/com/fear1ess/reyunaditool/MainActivity.java
View file @
10384643
...
...
@@ -12,16 +12,31 @@ import android.os.Build;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.provider.Settings
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
java.lang.ref.WeakReference
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
static
com
.
fear1ess
.
reyunaditool
.
ExecuteCmdUtils
.
executeCmd
;
public
class
MainActivity
extends
AppCompatActivity
{
public
static
String
m_Android_ID
=
""
;
public
static
Button
m_startBtn
=
null
;
public
static
Button
m_stopBtn
=
null
;
public
static
String
m_myPackageName
=
""
;
public
static
Context
m_context
=
null
;
//保持屏幕常量的表示
public
static
boolean
m_isShow
=
false
;
//
// public static Handler m_handler=new MainActivityHandler();
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
O
)
@Override
...
...
@@ -36,9 +51,18 @@ public class MainActivity extends AppCompatActivity {
AdiToolApp
app
=
(
AdiToolApp
)
getApplication
();
Button
startBtn
=
findViewById
(
R
.
id
.
start_btn
);
m_startBtn
=
startBtn
;
Button
stopBtn
=
findViewById
(
R
.
id
.
stop_btn
);
m_stopBtn
=
stopBtn
;
stopBtn
.
setEnabled
(
false
);
TextView
textView
=
findViewById
(
R
.
id
.
user_ID
);
m_Android_ID
=
Settings
.
System
.
getString
(
getContentResolver
(),
Settings
.
System
.
ANDROID_ID
);
String
user
=
"当前APP的Android ID: "
+
m_Android_ID
;
textView
.
setText
(
user
);
m_myPackageName
=
getPackageName
();
m_context
=
getApplicationContext
();
requestPermissions
(
new
String
[]{
"android.permission.WRITE_EXTERNAL_STORAGE"
,
"android.permission.READ_EXTERNAL_STORAGE"
},
100
);
...
...
@@ -70,6 +94,7 @@ public class MainActivity extends AppCompatActivity {
public
void
run
()
{
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -81,17 +106,43 @@ public class MainActivity extends AppCompatActivity {
});
}
}.
start
();
m_isShow
=
false
;
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
while
(
true
){
try
{
// Log.d("myTest","保持屏幕常量状态中");
Thread
.
sleep
(
60
*
1000
);
executeCmd
(
"ls"
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
if
(
m_isShow
){
break
;
}
}
}
}).
start
();
}
public
static
class
MainActivityHandler
extends
Handler
{
public
static
final
int
NETWORK_ERROR
=
0
;
public
static
final
int
StartMySlef
=
11
;
private
WeakReference
<
Activity
>
mActivityWeakRef
=
null
;
public
MainActivityHandler
(
Activity
activity
){
mActivityWeakRef
=
new
WeakReference
<>(
activity
);
}
// public MainActivityHandler() {
//
// }
@Override
public
void
handleMessage
(
@NonNull
Message
msg
)
{
switch
(
msg
.
what
){
...
...
@@ -100,9 +151,39 @@ public class MainActivity extends AppCompatActivity {
Toast
t
=
Toast
.
makeText
(
mActivityWeakRef
.
get
(),
errText
,
Toast
.
LENGTH_SHORT
);
t
.
show
();
break
;
case
StartMySlef:
startMySelf
();
break
;
default
:
break
;
}
}
}
@Override
protected
void
onStop
()
{
super
.
onStop
();
try
{
if
(
m_isShow
){
startMySelf
();
}
// Toast.makeText(MainActivity.m_context,"开始卸载APP",Toast.LENGTH_LONG).show();
}
catch
(
Exception
e
){
}
}
public
static
void
startMySelf
(){
try
{
int
result
=
ExecuteCmdUtils
.
startApp
(
MainActivity
.
m_context
,
MainActivity
.
m_myPackageName
);
if
(
result
==-
1
){
MyLog
.
error
(
"启动Activity结果失败"
);
}
else
{
MyLog
.
error
(
"启动Activity结果成功"
);
}
}
catch
(
Exception
e
){
MyLog
.
error
(
e
.
toString
());
}
}
}
\ No newline at end of file
app/src/main/java/com/fear1ess/reyunaditool/MyLog.java
0 → 100644
View file @
10384643
package
com
.
fear1ess
.
reyunaditool
;
import
android.util.Log
;
public
class
MyLog
{
private
static
final
String
TAG
=
"MyTest"
;
public
static
boolean
is_Open
=
false
;
public
static
void
d
(
Object
object
){
if
(
is_Open
){
synchronized
(
object
){
Log
.
d
(
TAG
,
""
+
object
);
}
}
}
public
static
void
error
(
Object
object
){
synchronized
(
object
){
Log
.
d
(
TAG
,
"异常:"
+
object
);
}
}
}
app/src/main/java/com/fear1ess/reyunaditool/thread/InstallAndStartAppThread.java
View file @
10384643
...
...
@@ -6,6 +6,7 @@ import android.content.pm.PackageManager;
import
android.os.Handler
;
import
android.os.Message
;
import
android.util.Log
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
...
...
@@ -13,6 +14,7 @@ import com.fear1ess.reyunaditool.AdiToolApp;
import
com.fear1ess.reyunaditool.AppInfo
;
import
com.fear1ess.reyunaditool.DoCommandService
;
import
com.fear1ess.reyunaditool.ExecuteCmdUtils
;
import
com.fear1ess.reyunaditool.MainActivity
;
import
com.fear1ess.reyunaditool.NetWorkUtils
;
import
com.fear1ess.reyunaditool.cmd.OperateCmd
;
import
com.fear1ess.reyunaditool.state.AppState
;
...
...
@@ -26,6 +28,9 @@ import java.util.List;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
//import static com.fear1ess.reyunaditool.MainActivity.m_handler;
import
static
com
.
fear1ess
.
reyunaditool
.
MainActivity
.
startMySelf
;
public
class
InstallAndStartAppThread
extends
Thread
{
public
static
String
TAG
=
"reyunaditool_log"
;
...
...
@@ -71,19 +76,24 @@ public class InstallAndStartAppThread extends Thread {
@Override
public
void
run
()
{
while
(
needRunning
){
try
{
startMySelf
();
mService
.
isUploadAdsData
=
false
;
installAndStartNewApp
();
sleep
(
60
*
1000
);
if
(
mService
.
isUploadAdsData
==
false
){
mService
.
uploadErrorApkData
();
mService
.
uploadErrorApkData
(
"上传广告数据失败"
);
}
removeApp
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
mNeedWait
=
true
;
startMySelf
();
}
/*
...
...
@@ -115,6 +125,10 @@ public class InstallAndStartAppThread extends Thread {
AppInfo
appInfo
=
null
;
try
{
while
(
true
){
//启动APP本身
// Message message=new Message();
// message.what=1;
// m_handler.sendMessage(message);
Thread
.
sleep
(
2000
);
appInfo
=
mDownloadThread
.
mAppInfoQueue
.
take
();
...
...
@@ -133,7 +147,7 @@ public class InstallAndStartAppThread extends Thread {
if
(
res
==
0
){
Log
.
d
(
TAG
,
"install app "
+
mPkgName
+
"success!"
);
}
else
{
mService
.
uploadErrorApkData
();
mService
.
uploadErrorApkData
(
"install failed"
);
Log
.
e
(
TAG
,
"install app "
+
mPkgName
+
" failed!"
);
if
(
ExecuteCmdUtils
.
deletePkg
(
mDownloadPath
)
!=
0
){
Log
.
e
(
TAG
,
"delete pkg "
+
mDownloadPath
+
" failed!"
);
...
...
@@ -159,7 +173,7 @@ public class InstallAndStartAppThread extends Thread {
if
(
ExecuteCmdUtils
.
startApp
(
appContext
,
mPkgName
)
!=
0
){
Log
.
e
(
TAG
,
"start app "
+
mPkgName
+
" failed!"
);
mService
.
uploadErrorApkData
();
mService
.
uploadErrorApkData
(
"启动APP失败"
);
msg
=
PushMsgUtils
.
createPushMsg
(
mPkgName
,
null
,
null
,
AppState
.
APP_INSTALL_FAILED
);
mService
.
sendMsgToClient
(
msg
);
...
...
@@ -171,6 +185,8 @@ public class InstallAndStartAppThread extends Thread {
}
continue
;
}
//启动APP成功
MainActivity
.
m_isShow
=
true
;
//send checking msg
msg
=
PushMsgUtils
.
createPushMsg
(
mPkgName
,
null
,
null
,
...
...
app/src/main/res/layout/activity_main.xml
View file @
10384643
...
...
@@ -21,5 +21,10 @@
android:text=
"Stop"
android:id=
"@+id/stop_btn"
>
</Button>
<TextView
android:id=
"@+id/user_ID"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
</TextView>
</LinearLayout>
\ No newline at end of file
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