Commit 525af62e authored by chenhuaqing's avatar chenhuaqing

code refinement

parent 80adb25b
...@@ -77,10 +77,11 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C ...@@ -77,10 +77,11 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C
val exitCode = exitChannel.receive() val exitCode = exitChannel.receive()
running = false running = false
when { when {
exitCode == OsConstants.ECONNREFUSED -> throw IOException("connection refused by server") exitCode == OsConstants.ECONNREFUSED -> throw IOException("请充值")
SystemClock.elapsedRealtime() - startTime < 1000 -> throw IOException( SystemClock.elapsedRealtime() - startTime < 1000 -> {
"$cmdName exits too fast (exit code: $exitCode)" Timber.e("$cmdName exits too fast (exit code: $exitCode)")
) throw IOException("网络错误 $exitCode")
}
exitCode == 128 + OsConstants.SIGKILL -> Timber.w("$cmdName was killed") exitCode == 128 + OsConstants.SIGKILL -> Timber.w("$cmdName was killed")
else -> Timber.w(IOException("$cmdName unexpectedly exits with code $exitCode")) else -> Timber.w(IOException("$cmdName unexpectedly exits with code $exitCode"))
} }
......
...@@ -32,7 +32,7 @@ import com.github.shadowsocks.utils.Key ...@@ -32,7 +32,7 @@ import com.github.shadowsocks.utils.Key
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@Database(entities = [Profile::class, KeyValuePair::class], version = 29) @Database(entities = [Profile::class, KeyValuePair::class], version = 30)
@TypeConverters(Profile.SubscriptionStatus::class) @TypeConverters(Profile.SubscriptionStatus::class)
abstract class PrivateDatabase : RoomDatabase() { abstract class PrivateDatabase : RoomDatabase() {
companion object { companion object {
...@@ -42,7 +42,8 @@ abstract class PrivateDatabase : RoomDatabase() { ...@@ -42,7 +42,8 @@ abstract class PrivateDatabase : RoomDatabase() {
Migration26, Migration26,
Migration27, Migration27,
Migration28, Migration28,
Migration29 Migration29,
Migration30
) )
allowMainThreadQueries() allowMainThreadQueries()
enableMultiInstanceInvalidation() enableMultiInstanceInvalidation()
...@@ -74,8 +75,18 @@ abstract class PrivateDatabase : RoomDatabase() { ...@@ -74,8 +75,18 @@ abstract class PrivateDatabase : RoomDatabase() {
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `metered` INTEGER NOT NULL DEFAULT 0") database.execSQL("ALTER TABLE `Profile` ADD COLUMN `metered` INTEGER NOT NULL DEFAULT 0")
} }
object Migration29 : Migration(28, 29) { object Migration29 : Migration(28, 29) {
override fun migrate(database: SupportSQLiteDatabase) = override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `subscription` INTEGER NOT NULL DEFAULT " + database.execSQL("ALTER TABLE `Profile` ADD COLUMN `subscription` INTEGER NOT NULL DEFAULT " +
Profile.SubscriptionStatus.UserConfigured.persistedValue) Profile.SubscriptionStatus.UserConfigured.persistedValue)
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `token` TEXT ")
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `authTimeout` INTEGER ")
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `beatsInterval` INTEGER ")
database.execSQL("ALTER TABLE `Profile` ADD COLUMN `retryLimit` INTEGER ")
}
}
object Migration30 : Migration(29, 30) {
override fun migrate(database: SupportSQLiteDatabase) {
}
} }
} }
...@@ -65,7 +65,7 @@ data class Profile( ...@@ -65,7 +65,7 @@ data class Profile(
var retryLimit: Int = 3, var retryLimit: Int = 3,
var route: String = "all", var route: String = "all",
var remoteDns: String = "dns.google", var remoteDns: String = "8.8.8.8",
var proxyApps: Boolean = false, var proxyApps: Boolean = false,
var bypass: Boolean = false, var bypass: Boolean = false,
var udpdns: Boolean = false, var udpdns: Boolean = false,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment