Commit 19e78913 authored by Administrator's avatar Administrator

重播前服务器mark

parent 7bb8aaea
......@@ -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(' ', '_')
}
......
......@@ -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
......
package com.virjar.majora.adr;
import android.util.Log;
import com.virjar.majora.client.sdk.log.MajoraLogger;
import java.io.BufferedReader;
......@@ -27,7 +25,7 @@ public class Shell {
os.writeBytes(cmd + "\n");
os.writeBytes("exit\n");
os.flush();
String line = null;
String line;
while ((line = is.readLine()) != null) {
result += line;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment