|
|
@ -15,6 +15,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.text.TextUtils;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.Button;
|
|
|
@ -22,9 +23,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.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.FileNotFoundException;
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
@ -38,6 +43,9 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
private ShellService mService;
|
|
|
|
private ShellService mService;
|
|
|
|
private boolean mBound;
|
|
|
|
private boolean mBound;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String mServer = "61.169.135.146";
|
|
|
|
|
|
|
|
private int mPort = 7000;
|
|
|
|
|
|
|
|
|
|
|
|
private final ServiceConnection connection = new ServiceConnection() {
|
|
|
|
private final ServiceConnection connection = new ServiceConnection() {
|
|
|
|
public void onServiceConnected(@NotNull ComponentName className, @NotNull IBinder service) {
|
|
|
|
public void onServiceConnected(@NotNull ComponentName className, @NotNull IBinder service) {
|
|
|
|
// Intrinsics.checkNotNullParameter(className, "className");
|
|
|
|
// Intrinsics.checkNotNullParameter(className, "className");
|
|
|
@ -69,15 +77,15 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
TextView titleText = (TextView)this.findViewById(R.id.titleText);
|
|
|
|
TextView titleText = (TextView)this.findViewById(R.id.titleText);
|
|
|
|
// 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"));
|
|
|
|
this.checkConfig();
|
|
|
|
|
|
|
|
this.checkNotificationPermission();
|
|
|
|
checkConfig();
|
|
|
|
this.createBGNotificationChannel();
|
|
|
|
checkNotificationPermission();
|
|
|
|
this.mBound = this.isServiceRunning(ShellService.class);
|
|
|
|
createBGNotificationChannel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mBound = isServiceRunning(ShellService.class);
|
|
|
|
state_switch = (Switch)this.findViewById(R.id.state_switch);
|
|
|
|
state_switch = (Switch)this.findViewById(R.id.state_switch);
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var10001, "findViewById<SwitchCompat>(R.id.state_switch)");
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var10001, "findViewById<SwitchCompat>(R.id.state_switch)");
|
|
|
|
|
|
|
|
|
|
|
|
state_switch.setChecked(this.mBound);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state_switch.setOnCheckedChangeListener((CompoundButton.OnCheckedChangeListener)(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
state_switch.setOnCheckedChangeListener((CompoundButton.OnCheckedChangeListener)(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
public final void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
public final void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
if (isChecked) {
|
|
|
|
if (isChecked) {
|
|
|
@ -89,7 +97,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final SharedPreferences editor = this.getSharedPreferences("data", 0);
|
|
|
|
final SharedPreferences editor = this.getSharedPreferences("data", 0);
|
|
|
|
auto_start_switch = (Switch) this.findViewById(R.id.auto_start_switch);
|
|
|
|
auto_start_switch = (Switch) this.findViewById(R.id.auto_start_switch);
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var10001, "findViewById<SwitchCompat>(R.id.auto_start_switch)");
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var10001, "findViewById<SwitchCompat>(R.id.auto_start_switch)");
|
|
|
@ -103,12 +110,26 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
editorx.apply();
|
|
|
|
editorx.apply();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
if (this.mBound) {
|
|
|
|
|
|
|
|
|
|
|
|
if (mBound) {
|
|
|
|
Intent intent = new Intent((Context)this, ShellService.class);
|
|
|
|
Intent intent = new Intent((Context)this, ShellService.class);
|
|
|
|
this.bindService(intent, (ServiceConnection)this.connection, 1);
|
|
|
|
this.bindService(intent, (ServiceConnection)this.connection, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.setListener();
|
|
|
|
this.setListener();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int 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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state_switch.setChecked(mBound || (startFrp != 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private final void setListener() {
|
|
|
|
private final void setListener() {
|
|
|
@ -150,11 +171,19 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
public final void checkConfig() {
|
|
|
|
public final void checkConfig() {
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var12, "resources");
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var12, "resources");
|
|
|
|
AssetManager assetmanager = getResources().getAssets();
|
|
|
|
AssetManager assetmanager = getResources().getAssets();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File confFile = new File(getDataDir(), "conf");
|
|
|
|
|
|
|
|
if (!confFile.exists()) {
|
|
|
|
|
|
|
|
confFile.mkdirs();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
File file = new File(new File(getDataDir(), "conf"), "config.toml");
|
|
|
|
FileOutputStream fileOutputStream = null;
|
|
|
|
FileOutputStream fileOutputStream = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
fileOutputStream = this.openFileOutput("config.toml", 0);
|
|
|
|
fileOutputStream = new FileOutputStream(file);
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fileOutputStream == null) {
|
|
|
|
if (fileOutputStream == null) {
|
|
|
@ -163,13 +192,15 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
|
|
InputStream inputStream = null;
|
|
|
|
InputStream inputStream = null;
|
|
|
|
byte[] bytes = new byte[256];
|
|
|
|
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))");
|
|
|
|
// Intrinsics.checkNotNullExpressionValue(var10001, "assetmanager.open((BuildConfig.ConfigFileName))");
|
|
|
|
int bytesRead = inputStream.read(bytes);
|
|
|
|
while ((bytesRead = inputStream.read(bytes)) != -1) {
|
|
|
|
if (bytesRead > 0) {
|
|
|
|
if (bytesRead > 0) {
|
|
|
|
fileOutputStream.write(bytes, 0, bytesRead);
|
|
|
|
fileOutputStream.write(bytes, 0, bytesRead);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// Unit var11 = Unit.INSTANCE;
|
|
|
|
// Unit var11 = Unit.INSTANCE;
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
ex.printStackTrace();
|
|
|
@ -178,6 +209,20 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
closeFinally(inputStream);
|
|
|
|
closeFinally(inputStream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// Toml toml = new Toml();
|
|
|
|
|
|
|
|
// File file = new File(getDataDir(), "config.toml");
|
|
|
|
|
|
|
|
// toml.read(file);
|
|
|
|
|
|
|
|
// int aa = 0;
|
|
|
|
|
|
|
|
// String someValue = toml.getString("someKey");
|
|
|
|
|
|
|
|
// Date someDate = toml.getDate("someTable.someDate");
|
|
|
|
|
|
|
|
// MyClass myClass = toml.to(MyClass.class);
|
|
|
|
|
|
|
|
// TomlWriter.Builder tomlBuilder = new TomlWriter.Builder();
|
|
|
|
|
|
|
|
// tomlBuilder.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static final void closeFinally(Closeable closable) {
|
|
|
|
private static final void closeFinally(Closeable closable) {
|
|
|
|