diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1039d8b..f9c6cbd 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,6 +5,8 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/io/github/acedroidx/frp/AutoStartBroadReceiver.kt b/app/src/main/java/io/github/acedroidx/frp/AutoStartBroadReceiver.kt
new file mode 100644
index 0000000..d776918
--- /dev/null
+++ b/app/src/main/java/io/github/acedroidx/frp/AutoStartBroadReceiver.kt
@@ -0,0 +1,23 @@
+package io.github.acedroidx.frp
+
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import androidx.appcompat.app.AppCompatActivity
+
+class AutoStartBroadReceiver : BroadcastReceiver() {
+ private val ACTION = "android.intent.action.BOOT_COMPLETED"
+ override fun onReceive(context: Context, intent: Intent) {
+ //开机启动
+ val editor = context.getSharedPreferences("data", AppCompatActivity.MODE_PRIVATE)
+ val auto_start = editor.getBoolean("auto_start", false)
+ if (ACTION == intent.action && auto_start) {
+ //开机启动
+ val mainIntent = Intent(context, MainActivity::class.java)
+ mainIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ context.startActivity(mainIntent)
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/acedroidx/frp/MainActivity.kt b/app/src/main/java/io/github/acedroidx/frp/MainActivity.kt
index fd32b2d..f7db176 100644
--- a/app/src/main/java/io/github/acedroidx/frp/MainActivity.kt
+++ b/app/src/main/java/io/github/acedroidx/frp/MainActivity.kt
@@ -1,6 +1,8 @@
package io.github.acedroidx.frp
-import android.app.*
+import android.app.ActivityManager
+import android.app.NotificationChannel
+import android.app.NotificationManager
import android.content.ComponentName
import android.content.Context
import android.content.Intent
@@ -23,6 +25,7 @@ class MainActivity : AppCompatActivity() {
val configname = "config.ini"
private lateinit var state_switch: SwitchCompat
+ private lateinit var auto_start_switch: SwitchCompat
private lateinit var mService: ShellService
private var mBound: Boolean = false
@@ -60,6 +63,15 @@ class MainActivity : AppCompatActivity() {
state_switch = findViewById(R.id.state_switch)
state_switch.isChecked = mBound
state_switch.setOnCheckedChangeListener { buttonView, isChecked -> if (isChecked) (startShell()) else (stopShell()) }
+ val editor = getSharedPreferences("data", AppCompatActivity.MODE_PRIVATE)
+ auto_start_switch = findViewById(R.id.auto_start_switch)
+ auto_start_switch.isChecked = editor.getBoolean("auto_start", false)
+ if (auto_start_switch.isChecked) (startShell())
+ auto_start_switch.setOnCheckedChangeListener { buttonView, isChecked ->
+ val editor = editor.edit()
+ editor.putBoolean("auto_start", isChecked)
+ editor.apply();
+ }
if (mBound) {
val intent = Intent(this, ShellService::class.java)
bindService(intent, connection, Context.BIND_AUTO_CREATE)
@@ -151,8 +163,7 @@ class MainActivity : AppCompatActivity() {
}
private fun isServiceRunning(serviceClass: Class<*>): Boolean {
- val manager =
- getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
+ val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
for (service in manager.getRunningServices(Int.MAX_VALUE)) {
if (serviceClass.name == service.service.className) {
return true
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index b19da0b..5ed2b32 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -30,6 +30,12 @@
android:layout_height="wrap_content"
android:text="切换开关" />
+
+
+