service refactored
This commit is contained in:
5 files changed
+33
-3
No files matched your search
@@ -7,16 +7,22 @@
|
||||
<application>
|
||||
<service
|
||||
android:name="ClashService"
|
||||
android:label="@string/clash_service_label"
|
||||
android:exported="false"
|
||||
android:process=":clash" />
|
||||
android:process=":background" />
|
||||
<service
|
||||
android:name="TunService"
|
||||
android:label="@string/tun_service_label"
|
||||
android:exported="false"
|
||||
android:process=":clash"
|
||||
android:process=":background"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.VpnService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service android:name=".ClashManagerService"
|
||||
android:label="@string/clash_manager_service_label"
|
||||
android:exported="false"
|
||||
android:process=":background" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.github.kr328.clash.service;
|
||||
|
||||
import com.github.kr328.clash.service.IClashProfileManager;
|
||||
import com.github.kr328.clash.service.ipc.IPCParcelables;
|
||||
import com.github.kr328.clash.core.model.Packet;
|
||||
|
||||
interface IClashManager {
|
||||
// Profile
|
||||
IClashProfileManager getProfileManager();
|
||||
|
||||
// Control
|
||||
boolean setSelectProxy(String proxy, String selected);
|
||||
ParcelableCompletedFuture startHealthCheck(String group);
|
||||
|
||||
@@ -5,12 +5,17 @@ import androidx.core.content.edit
|
||||
import com.github.kr328.clash.core.Clash
|
||||
import com.github.kr328.clash.core.model.General
|
||||
import com.github.kr328.clash.core.model.ProxyGroup
|
||||
import com.github.kr328.clash.service.data.ClashDatabase
|
||||
import com.github.kr328.clash.service.ipc.ParcelableCompletedFuture
|
||||
import com.github.kr328.clash.service.ipc.ParcelablePipe
|
||||
|
||||
class ClashManager(context: Context) : IClashManager.Stub() {
|
||||
class ClashManager(private val context: Context) : IClashManager.Stub() {
|
||||
private val settings = context.getSharedPreferences("service", Context.MODE_PRIVATE)
|
||||
|
||||
override fun getProfileManager(): IClashProfileManager {
|
||||
return ClashProfileManager(context, ClashDatabase.getInstance(context))
|
||||
}
|
||||
|
||||
override fun queryAllProxies(): Array<ProxyGroup> {
|
||||
return Clash.queryProxyGroups().toTypedArray()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.github.kr328.clash.service
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.os.IBinder
|
||||
|
||||
class ClashManagerService : Service() {
|
||||
override fun onBind(intent: Intent?): IBinder? {
|
||||
return ClashManager(this)
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,8 @@
|
||||
|
||||
<!-- from https://github.com/shadowsocks/shadowsocks-android/blob/master/core/src/main/res/values/strings.xml -->
|
||||
<string name="clash_notification_content">"%1$s↑\t%2$s↓"</string>
|
||||
|
||||
<string name="clash_service_label">Clash Core Service</string>
|
||||
<string name="tun_service_label">Tun Device Service</string>
|
||||
<string name="clash_manager_service_label">Clash Manager Service</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user