Skip to content

Commit 6f0e750

Browse files
committed
chore(db): remove vestigial neko plugin protocol remnant (schema v11)
1 parent 23f69ce commit 6f0e750

7 files changed

Lines changed: 18 additions & 133 deletions

File tree

app/src/main/java/io/nekohasekai/sagernet/database/ProxyEntity.kt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import moe.matsuri.nb4a.proxy.anytls.AnyTLSSettingsActivity
4646
import moe.matsuri.nb4a.proxy.anytls.toUri
4747
import moe.matsuri.nb4a.proxy.config.ConfigBean
4848
import moe.matsuri.nb4a.proxy.config.ConfigSettingActivity
49-
import moe.matsuri.nb4a.proxy.neko.*
5049
import moe.matsuri.nb4a.proxy.shadowtls.ShadowTLSBean
5150
import moe.matsuri.nb4a.proxy.shadowtls.ShadowTLSSettingsActivity
5251
import io.nekohasekai.sagernet.fmt.masterdnsvpn.toUri as toMasterDnsVpnUri
@@ -84,7 +83,6 @@ data class ProxyEntity(
8483
var shadowTLSBean: ShadowTLSBean? = null,
8584
var anyTLSBean: AnyTLSBean? = null,
8685
var chainBean: ChainBean? = null,
87-
var nekoBean: NekoBean? = null,
8886
var configBean: ConfigBean? = null,
8987
var snellBean: SnellBean? = null,
9088
var masterDnsVpnBean: MasterDnsVpnBean? = null,
@@ -121,6 +119,9 @@ data class ProxyEntity(
121119
const val TYPE_OLCRTC = 27
122120

123121
const val TYPE_CONFIG = 998
122+
123+
// 999 was the Matsuri "Neko Plugin" protocol (removed). Reserved: do not
124+
// reuse the id; rows with this type are purged by the v11 migration.
124125
const val TYPE_NEKO = 999
125126

126127
const val TYPE_CHAIN = 8
@@ -205,7 +206,6 @@ data class ProxyEntity(
205206
TYPE_SHADOWTLS -> shadowTLSBean = KryoConverters.shadowTLSDeserialize(byteArray)
206207
TYPE_ANYTLS -> anyTLSBean = KryoConverters.anyTLSDeserialize(byteArray)
207208
TYPE_CHAIN -> chainBean = KryoConverters.chainDeserialize(byteArray)
208-
TYPE_NEKO -> nekoBean = KryoConverters.nekoDeserialize(byteArray)
209209
TYPE_CONFIG -> configBean = KryoConverters.configDeserialize(byteArray)
210210
TYPE_SNELL -> snellBean = KryoConverters.snellDeserialize(byteArray)
211211
TYPE_MASTERDNSVPN -> masterDnsVpnBean = KryoConverters.masterDnsVpnDeserialize(byteArray)
@@ -232,7 +232,6 @@ data class ProxyEntity(
232232
TYPE_SHADOWTLS -> "ShadowTLS"
233233
TYPE_ANYTLS -> "AnyTLS"
234234
TYPE_CHAIN -> chainName
235-
TYPE_NEKO -> nekoBean!!.displayType()
236235
TYPE_CONFIG -> configBean!!.displayType()
237236
TYPE_SNELL -> "Snell"
238237
TYPE_MASTERDNSVPN -> "MasterDnsVPN"
@@ -263,7 +262,6 @@ data class ProxyEntity(
263262
TYPE_SHADOWTLS -> shadowTLSBean
264263
TYPE_ANYTLS -> anyTLSBean
265264
TYPE_CHAIN -> chainBean
266-
TYPE_NEKO -> nekoBean
267265
TYPE_CONFIG -> configBean
268266
TYPE_SNELL -> snellBean
269267
TYPE_MASTERDNSVPN -> masterDnsVpnBean
@@ -286,7 +284,6 @@ data class ProxyEntity(
286284
is WireGuardBean -> false
287285
is AmneziaWGBean -> false
288286
is ShadowTLSBean -> false
289-
is NekoBean -> false
290287
is ConfigBean -> false
291288
else -> true
292289
}
@@ -309,7 +306,6 @@ data class ProxyEntity(
309306
is SnellBean -> toUri()
310307
is MasterDnsVpnBean -> toMasterDnsVpnUri()
311308
is OlcrtcBean -> toOlcrtcUri()
312-
is NekoBean -> ""
313309
else -> toUniversalLink()
314310
}
315311
}
@@ -363,7 +359,6 @@ data class ProxyEntity(
363359
TYPE_MASTERDNSVPN -> true
364360
TYPE_OLCRTC -> true
365361
TYPE_HYSTERIA -> !hysteriaBean!!.canUseSingBox()
366-
TYPE_NEKO -> true
367362
else -> false
368363
}
369364
}
@@ -466,7 +461,6 @@ data class ProxyEntity(
466461
anyTLSBean = null
467462
chainBean = null
468463
configBean = null
469-
nekoBean = null
470464
snellBean = null
471465
masterDnsVpnBean = null
472466
olcrtcBean = null
@@ -577,11 +571,6 @@ data class ProxyEntity(
577571
chainBean = bean
578572
}
579573

580-
is NekoBean -> {
581-
type = TYPE_NEKO
582-
nekoBean = bean
583-
}
584-
585574
is ConfigBean -> {
586575
type = TYPE_CONFIG
587576
configBean = bean

app/src/main/java/io/nekohasekai/sagernet/database/SagerDatabase.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ package io.nekohasekai.sagernet.database
22

33
import androidx.room.AutoMigration
44
import androidx.room.Database
5+
import androidx.room.DeleteColumn
56
import androidx.room.Room
67
import androidx.room.RoomDatabase
78
import androidx.room.TypeConverters
9+
import androidx.room.migration.AutoMigrationSpec
10+
import androidx.sqlite.db.SupportSQLiteDatabase
811
import io.nekohasekai.sagernet.Key
912
import io.nekohasekai.sagernet.SagerNet
1013
import io.nekohasekai.sagernet.fmt.KryoConverters
1114
import io.nekohasekai.sagernet.fmt.gson.GsonConverters
1215

1316
@Database(
1417
entities = [ProxyGroup::class, ProxyEntity::class, RuleEntity::class],
15-
version = 10,
18+
version = 11,
1619
autoMigrations = [
1720
AutoMigration(from = 3, to = 4),
1821
AutoMigration(from = 4, to = 5),
@@ -21,11 +24,21 @@ import io.nekohasekai.sagernet.fmt.gson.GsonConverters
2124
AutoMigration(from = 7, to = 8),
2225
AutoMigration(from = 8, to = 9),
2326
AutoMigration(from = 9, to = 10),
27+
AutoMigration(from = 10, to = 11, spec = SagerDatabase.RemoveNekoColumn::class),
2428
],
2529
)
2630
@TypeConverters(value = [KryoConverters::class, GsonConverters::class])
2731
abstract class SagerDatabase : RoomDatabase() {
2832

33+
@DeleteColumn(tableName = "proxy_entities", columnName = "nekoBean")
34+
class RemoveNekoColumn : AutoMigrationSpec {
35+
override fun onPostMigrate(db: SupportSQLiteDatabase) {
36+
// Legacy neko-plugin rows are non-functional placeholders; without the
37+
// bean column they could no longer even render. Purge them.
38+
db.execSQL("DELETE FROM proxy_entities WHERE type = 999")
39+
}
40+
}
41+
2942
companion object {
3043
val instance by lazy {
3144
SagerNet.application.getDatabasePath(Key.DB_PROFILE).parentFile?.mkdirs()

app/src/main/java/io/nekohasekai/sagernet/fmt/KryoConverters.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import io.nekohasekai.sagernet.ktx.KryosKt;
3333
import io.nekohasekai.sagernet.ktx.Logs;
3434
import moe.matsuri.nb4a.proxy.config.ConfigBean;
35-
import moe.matsuri.nb4a.proxy.neko.NekoBean;
3635
import moe.matsuri.nb4a.utils.JavaUtil;
3736

3837
public class KryoConverters {
@@ -220,12 +219,6 @@ public static ChainBean chainDeserialize(byte[] bytes) {
220219
return deserialize(new ChainBean(), bytes);
221220
}
222221

223-
@TypeConverter
224-
public static NekoBean nekoDeserialize(byte[] bytes) {
225-
if (JavaUtil.isEmpty(bytes)) return null;
226-
return deserialize(new NekoBean(), bytes);
227-
}
228-
229222
@TypeConverter
230223
public static SubscriptionBean subscriptionDeserialize(byte[] bytes) {
231224
if (JavaUtil.isEmpty(bytes)) return null;

app/src/main/java/io/nekohasekai/sagernet/fmt/TypeMap.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ object TypeMap : HashMap<String, Int>() {
2323
this["snell"] = ProxyEntity.TYPE_SNELL
2424
this["masterdnsvpn"] = ProxyEntity.TYPE_MASTERDNSVPN
2525
this["olcrtc"] = ProxyEntity.TYPE_OLCRTC
26-
this["neko"] = ProxyEntity.TYPE_NEKO
2726
this["config"] = ProxyEntity.TYPE_CONFIG
2827
}
2928

app/src/main/java/io/nekohasekai/sagernet/ui/ConfigurationFragment.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,10 +1831,6 @@ class ConfigurationFragment @JvmOverloads constructor(
18311831
}
18321832
}
18331833

1834-
if (proxyEntity.nekoBean != null) {
1835-
popup.menu.removeItem(R.id.action_group_configuration)
1836-
}
1837-
18381834
popup.setOnMenuItemClickListener(this)
18391835
popup.show()
18401836
}
@@ -2078,12 +2074,6 @@ class ConfigurationFragment @JvmOverloads constructor(
20782074
doubleColumnMenuButton.isGone = true
20792075
}
20802076

2081-
proxyEntity.nekoBean?.apply {
2082-
if (!isDoubleColumn) {
2083-
shareLayout.isGone = true
2084-
}
2085-
}
2086-
20872077
runOnDefaultDispatcher {
20882078
val selected = (selectedItem?.id ?: DataStore.selectedProxy) == proxyEntity.id
20892079
val started =

app/src/main/java/moe/matsuri/nb4a/Protocols.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package moe.matsuri.nb4a
22

33
import android.content.Context
44
import io.nekohasekai.sagernet.R
5-
import io.nekohasekai.sagernet.database.ProxyEntity.Companion.TYPE_NEKO
65
import io.nekohasekai.sagernet.fmt.AbstractBean
76
import io.nekohasekai.sagernet.ktx.app
87
import io.nekohasekai.sagernet.ktx.getColorAttr
@@ -42,10 +41,7 @@ object Protocols {
4241
// Display
4342

4443
fun Context.getProtocolColor(type: Int): Int {
45-
return when (type) {
46-
TYPE_NEKO -> getColorAttr(android.R.attr.textColorPrimary)
47-
else -> getColorAttr(R.attr.protocolColor)
48-
}
44+
return getColorAttr(R.attr.protocolColor)
4945
}
5046

5147
// Test

app/src/main/java/moe/matsuri/nb4a/proxy/neko/NekoBean.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)