IClashService
This commit is contained in:
3 files changed
+5
-4
No files matched your search
@@ -6,7 +6,7 @@ import com.github.kr328.clash.IClashObserver;
|
||||
interface IClashService {
|
||||
void start();
|
||||
void stop();
|
||||
void registerObserver(String id, in IClashObserver observer);
|
||||
void registerObserver(String id, boolean notifyCurrent, in IClashObserver observer);
|
||||
void unregisterObserver(String id);
|
||||
void loadProfile(in Uri path);
|
||||
void startTunDevice(in ParcelFileDescriptor fd, int mtu);
|
||||
|
||||
@@ -31,13 +31,14 @@ class ClashService : Service() {
|
||||
private val observers = mutableMapOf<String, IClashObserver>()
|
||||
|
||||
private inner class ClashServiceImpl : IClashService.Stub() {
|
||||
override fun registerObserver(id: String?, observer: IClashObserver?) {
|
||||
override fun registerObserver(id: String?, notifyCurrent: Boolean, observer: IClashObserver?) {
|
||||
if (id == null || observer == null)
|
||||
throw RemoteException()
|
||||
|
||||
observers[id] = observer
|
||||
|
||||
observer.onStatusChanged(ClashStatus(status))
|
||||
if ( notifyCurrent )
|
||||
observer.onStatusChanged(ClashStatus(status))
|
||||
|
||||
observer.asBinder().linkToDeath({
|
||||
observers.remove(id)
|
||||
|
||||
@@ -33,7 +33,7 @@ class TunService : VpnService() {
|
||||
val clash = IClashService.Stub.asInterface(service) ?: throw NullPointerException()
|
||||
|
||||
clash.start()
|
||||
clash.registerObserver("tun", object: IClashObserver.Stub() {
|
||||
clash.registerObserver("tun", false, object: IClashObserver.Stub() {
|
||||
override fun onStatusChanged(status: ClashStatus?) {
|
||||
if ( status == null )
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user