|
|
@ -16,6 +16,7 @@ import android.os.IBinder;
|
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.v7.widget.SwitchCompat;
|
|
|
|
import android.support.v7.widget.SwitchCompat;
|
|
|
|
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.KeyEvent;
|
|
|
@ -25,17 +26,13 @@ import android.widget.CompoundButton;
|
|
|
|
import android.widget.Switch;
|
|
|
|
import android.widget.Switch;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
|
|
import com.moandjiezana.toml.Toml;
|
|
|
|
import com.xypower.common.FilesUtils;
|
|
|
|
import com.moandjiezana.toml.TomlWriter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.Closeable;
|
|
|
|
import java.io.Closeable;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity {
|
|
|
|
public class MainActivity extends AppCompatActivity {
|
|
|
@ -46,6 +43,9 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
private ShellService mService;
|
|
|
|
private ShellService mService;
|
|
|
|
private boolean mBound;
|
|
|
|
private boolean mBound;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String MICRO_KEY_SERVER = "%%SERVER%%";
|
|
|
|
|
|
|
|
private static final String MICRO_KEY_PORT = "%%PORT%%";
|
|
|
|
|
|
|
|
|
|
|
|
Handler mHandler;
|
|
|
|
Handler mHandler;
|
|
|
|
|
|
|
|
|
|
|
|
private String mServer = "61.169.135.146";
|
|
|
|
private String mServer = "61.169.135.146";
|
|
|
@ -85,7 +85,26 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(titleText, "titleText");
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(titleText, "titleText");
|
|
|
|
titleText.setText((CharSequence)("frp for Android - " + versionName + "/0.58.0"));
|
|
|
|
titleText.setText((CharSequence)("frp for Android - " + versionName + "/0.58.0"));
|
|
|
|
|
|
|
|
|
|
|
|
checkConfig();
|
|
|
|
int startFrp = 0;
|
|
|
|
|
|
|
|
int autoClose = 0;
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
|
|
|
String server = intent.getStringExtra("server");
|
|
|
|
|
|
|
|
mPort = intent.getIntExtra("port", 7000);
|
|
|
|
|
|
|
|
startFrp = intent.getIntExtra("startFrp", 0);
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(server)) {
|
|
|
|
|
|
|
|
mServer = server;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (startFrp != 0) {
|
|
|
|
|
|
|
|
Log.i(TAG, "Will start server");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
autoClose = intent.getIntExtra("autoClose", 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkConfig(mServer, mPort);
|
|
|
|
checkNotificationPermission();
|
|
|
|
checkNotificationPermission();
|
|
|
|
createBGNotificationChannel();
|
|
|
|
createBGNotificationChannel();
|
|
|
|
|
|
|
|
|
|
|
@ -100,7 +119,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
MainActivity.this.stopShell();
|
|
|
|
MainActivity.this.stopShell();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
@ -125,33 +143,17 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
|
|
this.setListener();
|
|
|
|
this.setListener();
|
|
|
|
|
|
|
|
|
|
|
|
int startFrp = 0;
|
|
|
|
state_switch.setChecked(mBound || (startFrp != 0));
|
|
|
|
{
|
|
|
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
|
|
|
String server = intent.getStringExtra("server");
|
|
|
|
|
|
|
|
mPort = intent.getIntExtra("port", 7000);
|
|
|
|
|
|
|
|
startFrp = intent.getIntExtra("startFrp", 0);
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(server)) {
|
|
|
|
|
|
|
|
mServer = server;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (startFrp != 0) {
|
|
|
|
|
|
|
|
Log.i(TAG, "Will start server");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int autoClose = intent.getIntExtra("autoClose", 0);
|
|
|
|
if (autoClose != 0) {
|
|
|
|
if (autoClose != 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
MainActivity.this.finish();
|
|
|
|
MainActivity.this.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 2000);
|
|
|
|
}, 2000);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
state_switch.setChecked(mBound || (startFrp != 0));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private final void setListener() {
|
|
|
|
private final void setListener() {
|
|
|
@ -190,7 +192,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public final void checkConfig() {
|
|
|
|
public final void checkConfig(String server, int port) {
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var12, "resources");
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var12, "resources");
|
|
|
|
AssetManager assetmanager = getResources().getAssets();
|
|
|
|
AssetManager assetmanager = getResources().getAssets();
|
|
|
|
|
|
|
|
|
|
|
@ -199,35 +201,19 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
confFile.mkdirs();
|
|
|
|
confFile.mkdirs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
File file = new File(new File(getDataDir(), "conf"), "config.toml");
|
|
|
|
File file = new File(new File(getDataDir(), "conf"), "config.toml");
|
|
|
|
FileOutputStream fileOutputStream = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
fileOutputStream = new FileOutputStream(file);
|
|
|
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fileOutputStream == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer configContent = new StringBuffer();
|
|
|
|
InputStream inputStream = null;
|
|
|
|
InputStream inputStream = null;
|
|
|
|
byte[] bytes = new byte[256];
|
|
|
|
|
|
|
|
int bytesRead = -1;
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
inputStream = assetmanager.open("config.toml");
|
|
|
|
inputStream = assetmanager.open("config.toml");
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var10001, "assetmanager.open((BuildConfig.ConfigFileName))");
|
|
|
|
String content = FilesUtils.readTextFile(inputStream);
|
|
|
|
while ((bytesRead = inputStream.read(bytes)) != -1) {
|
|
|
|
content = content.replaceAll(MICRO_KEY_SERVER, server);
|
|
|
|
if (bytesRead > 0) {
|
|
|
|
content = content.replaceAll(MICRO_KEY_PORT, Integer.toString(port));
|
|
|
|
fileOutputStream.write(bytes, 0, bytesRead);
|
|
|
|
|
|
|
|
}
|
|
|
|
FilesUtils.writeTextFile(file.getAbsolutePath(), content);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unit var11 = Unit.INSTANCE;
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
ex.printStackTrace();
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
closeFinally(fileOutputStream);
|
|
|
|
|
|
|
|
closeFinally(inputStream);
|
|
|
|
closeFinally(inputStream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|