fix load profile return nil invalid selected

This commit is contained in:
Kr328 committed 2019-12-02 00:21:36 +08:00
1 parent e8a48c0f0d
commit 32828a6ee9
3 files changed
+5 -6

No files matched your search

+2
View File
@@ -33,6 +33,8 @@ func handleProfileReload(client *net.UnixConn) {
InvalidSelected []string `json:"invalidSelected"`
}
response.InvalidSelected = make([]string, 0)
defer func() {
buf, _ := json.Marshal(&response)
@@ -2,8 +2,6 @@ package com.github.kr328.clash.core
import android.content.Context
import android.net.LocalSocket
import android.util.Log
import com.github.kr328.clash.core.Constants.TAG
import com.github.kr328.clash.core.event.BandwidthEvent
import com.github.kr328.clash.core.event.LogEvent
import com.github.kr328.clash.core.event.ProcessEvent
@@ -11,9 +9,9 @@ import com.github.kr328.clash.core.event.SpeedEvent
import com.github.kr328.clash.core.model.LoadProfilePacket
import com.github.kr328.clash.core.model.RawProxyPacket
import com.github.kr328.clash.core.model.SetProxyPacket
import com.github.kr328.clash.core.utils.Log
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import org.json.JSONObject
import java.io.File
import java.io.FileDescriptor
import java.io.IOException
@@ -53,8 +51,7 @@ class Clash(
LoadProfilePacket.Request(file.absolutePath, selected)))
val result = Json(JsonConfiguration.Stable)
.parse(LoadProfilePacket.Response.serializer(),
input.readString())
.parse(LoadProfilePacket.Response.serializer(), input.readString())
if (result.error.isNotEmpty()) {
throw IOException(result.error)
@@ -244,7 +244,7 @@ class ClashService : Service(), IClashEventObserver, ClashEventService.Master,
profileService.removeCurrentProfileProxy(remove)
notification.setProfile(active.name)
} catch (e: IOException) {
} catch (e: Exception) {
clash.process.stop()
Log.w("Load profile failure", e)
}