feat: ресивер для автоматизации
This commit is contained in:
1 parent
709a0cd5e0
commit
d76386ee88
2 files changed
+32
No files matched your search
@@ -49,5 +49,14 @@
|
||||
android:value="Поддержание активного сетевого прокси-соединения через TURN-серверы для обхода ограничений сети." />
|
||||
</service>
|
||||
|
||||
<receiver
|
||||
android:name=".ProxyReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="com.freeturn.app.START_PROXY" />
|
||||
<action android:name="com.freeturn.app.STOP_PROXY" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.freeturn.app
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
class ProxyReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
when (intent.action) {
|
||||
"com.freeturn.app.START_PROXY" -> {
|
||||
ProxyService.clearLogs()
|
||||
ProxyService.startupResult.value = null
|
||||
val serviceIntent = Intent(context, ProxyService::class.java)
|
||||
context.startForegroundService(serviceIntent)
|
||||
}
|
||||
"com.freeturn.app.STOP_PROXY" -> {
|
||||
val serviceIntent = Intent(context, ProxyService::class.java)
|
||||
context.stopService(serviceIntent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user