Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
majora-adr
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
majora
majora-adr
Commits
19e78913
Commit
19e78913
authored
Sep 19, 2021
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重播前服务器mark
parent
7bb8aaea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
42 deletions
+50
-42
build.gradle
app/build.gradle
+3
-2
KeepAliveService.java
...src/main/java/com/virjar/majora/adr/KeepAliveService.java
+10
-1
Shell.java
app/src/main/java/com/virjar/majora/adr/Shell.java
+37
-39
No files found.
app/build.gradle
View file @
19e78913
...
...
@@ -7,9 +7,10 @@ android {
defaultConfig
{
applicationId
"com.virjar.majora.adr"
minSdkVersion
19
//noinspection ExpiredTargetSdkVersion
targetSdkVersion
23
versionCode
1
versionName
"1.
0
"
versionCode
2
versionName
"1.
2
"
archivesBaseName
=
"Majora_${versionName}"
.
replace
(
' '
,
'_'
)
}
...
...
app/src/main/java/com/virjar/majora/adr/KeepAliveService.java
View file @
19e78913
...
...
@@ -31,6 +31,7 @@ import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
public
class
KeepAliveService
extends
Service
{
private
static
boolean
start
=
false
;
private
static
MajoraClient
majoraClient
;
// 重播任务定时器
private
Timer
timer
=
new
Timer
(
"reDial"
);
...
...
@@ -108,6 +109,14 @@ public class KeepAliveService extends Service {
}
public
static
void
reDial
()
{
if
(
majoraClient
==
null
)
{
reDialInternal
();
}
else
{
majoraClient
.
prepareReDial
(
KeepAliveService:
:
reDialInternal
);
}
}
private
static
void
reDialInternal
()
{
try
{
Shell
.
doCmds
(
"settings put global airplane_mode_on 1 && am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true"
);
...
...
@@ -123,7 +132,7 @@ public class KeepAliveService extends Service {
SharedPreferences
spf
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
String
serverHost
=
spf
.
getString
(
"server_host"
,
"majora.virjar.com"
);
int
serverPort
=
NumberUtils
.
toInt
(
spf
.
getString
(
"server_port"
,
"5879"
),
5879
);
new
MajoraClient
(
serverHost
,
serverPort
,
ClientIdentifier
.
id
()).
startUp
(
);
majoraClient
=
new
MajoraClient
(
serverHost
,
serverPort
,
ClientIdentifier
.
id
()
);
}
// 5. Drawable----> Bitmap
...
...
app/src/main/java/com/virjar/majora/adr/Shell.java
View file @
19e78913
package
com
.
virjar
.
majora
.
adr
;
import
android.util.Log
;
import
com.virjar.majora.client.sdk.log.MajoraLogger
;
import
java.io.BufferedReader
;
...
...
@@ -15,49 +13,49 @@ import java.io.OutputStream;
public
class
Shell
{
public
static
void
doCmds
(
String
cmd
)
throws
Exception
{
MajoraLogger
.
getLogger
().
info
(
"doCmds:"
+
cmd
);
Process
process
=
null
;
String
result
=
""
;
DataOutputStream
os
=
null
;
DataInputStream
is
=
null
;
MajoraLogger
.
getLogger
().
info
(
"doCmds:"
+
cmd
);
Process
process
=
null
;
String
result
=
""
;
DataOutputStream
os
=
null
;
DataInputStream
is
=
null
;
try
{
process
=
Runtime
.
getRuntime
().
exec
(
"su"
);
os
=
new
DataOutputStream
(
process
.
getOutputStream
());
is
=
new
DataInputStream
(
process
.
getInputStream
());
os
.
writeBytes
(
cmd
+
"\n"
);
os
.
writeBytes
(
"exit\n"
);
os
.
flush
();
String
line
;
while
((
line
=
is
.
readLine
())
!=
null
)
{
result
+=
line
;
}
process
.
waitFor
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
os
!=
null
)
{
try
{
process
=
Runtime
.
getRuntime
().
exec
(
"su"
);
os
=
new
DataOutputStream
(
process
.
getOutputStream
());
is
=
new
DataInputStream
(
process
.
getInputStream
());
os
.
writeBytes
(
cmd
+
"\n"
);
os
.
writeBytes
(
"exit\n"
);
os
.
flush
();
String
line
=
null
;
while
((
line
=
is
.
readLine
())
!=
null
)
{
result
+=
line
;
}
process
.
waitFor
();
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
InterruptedException
e
)
{
}
}
if
(
is
!=
null
)
{
try
{
is
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
os
!=
null
)
{
try
{
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
is
!=
null
)
{
try
{
is
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
process
!=
null
)
{
process
.
destroy
();
}
}
MajoraLogger
.
getLogger
().
info
(
"doCmds result:"
+
result
);
}
if
(
process
!=
null
)
{
process
.
destroy
();
}
}
MajoraLogger
.
getLogger
().
info
(
"doCmds result:"
+
result
);
}
public
static
void
executeCmd
(
String
cmd
)
{
try
{
...
...
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