@@ -99,6 +99,38 @@ data class RawSubscription(
9999 appGroups.size + globalGroups.size
100100 }
101101
102+ val globalGroupAppGroupNameDisableMap by lazy {
103+ globalGroups.mapNotNull { g ->
104+ val n = g.disableIfAppGroupMatch
105+ if (n != null ) {
106+ val gName = if (n.isNotEmpty()) {
107+ n
108+ } else {
109+ g.name
110+ }
111+ g.key to apps.filter { a ->
112+ a.groups.any { ag ->
113+ ag.ignoreGlobalGroupMatch != true && ag.name.startsWith(gName)
114+ }
115+ }.map { it.id }.toHashSet()
116+ } else {
117+ null
118+ }
119+ }.toMap()
120+ }
121+
122+ fun getGlobalGroupInnerDisabled (globalGroup : RawGlobalGroup , appId : String ): Boolean {
123+ globalGroup.appIdEnable[appId]?.let {
124+ if (it == false ) return true
125+ }
126+ globalGroupAppGroupNameDisableMap[globalGroup.key]?.let {
127+ if (it.contains(appId)) {
128+ return true
129+ }
130+ }
131+ return false
132+ }
133+
102134 val numText by lazy {
103135 val appsSize = apps.size
104136 val appGroupsSize = appGroups.size
@@ -305,10 +337,11 @@ data class RawSubscription(
305337 override val matchAnyApp : Boolean? ,
306338 override val matchSystemApp : Boolean? ,
307339 override val matchLauncher : Boolean? ,
340+ val disableIfAppGroupMatch : String? ,
308341 override val rules : List <RawGlobalRule >,
309342 override val apps : List <RawGlobalApp >? ,
310343 ) : RawGroupProps, RawGlobalRuleProps {
311- val appIdEnable by lazy {
344+ val appIdEnable: Map < String , Boolean > by lazy {
312345 if (rules.all { r -> r.apps.isNullOrEmpty() }) {
313346 apps?.associate { a -> a.id to (a.enable ? : true ) } ? : emptyMap()
314347 } else {
@@ -417,6 +450,7 @@ data class RawSubscription(
417450 override val excludeVersionNames : List <String >? ,
418451 override val versionCodes : List <Long >? ,
419452 override val excludeVersionCodes : List <Long >? ,
453+ val ignoreGlobalGroupMatch : Boolean? ,
420454 ) : RawGroupProps, RawAppRuleProps {
421455 override val cacheMap by lazy { HashMap <String , Selector ?>() }
422456 override val errorDesc by lazy { getErrorDesc() }
@@ -606,11 +640,11 @@ data class RawSubscription(
606640 if (p.isString) {
607641 p.content
608642 } else {
609- error( " Element $p is not a string " )
643+ null
610644 }
611645 }
612646
613- else -> error( " Element $p is not a string " )
647+ else -> null
614648 }
615649
616650 private fun getLong (jsonObject : JsonObject ? = null, key : String ): Long? =
@@ -620,7 +654,7 @@ data class RawSubscription(
620654 p.long
621655 }
622656
623- else -> error( " Element $p is not a long " )
657+ else -> null
624658 }
625659
626660 private fun getInt (jsonObject : JsonObject ? = null, key : String ): Int? =
@@ -630,7 +664,7 @@ data class RawSubscription(
630664 p.int
631665 }
632666
633- else -> error( " Element $p is not a int " )
667+ else -> null
634668 }
635669
636670 private fun getBoolean (jsonObject : JsonObject ? = null, key : String ): Boolean? =
@@ -640,7 +674,7 @@ data class RawSubscription(
640674 p.boolean
641675 }
642676
643- else -> error( " Element $p is not a boolean " )
677+ else -> null
644678 }
645679
646680 private fun jsonToRuleRaw (rulesRawJson : JsonElement ): RawAppRule {
@@ -728,6 +762,7 @@ data class RawSubscription(
728762 excludeVersionNames = getStringIArray(jsonObject, " excludeVersionNames" ),
729763 priorityTime = getLong(jsonObject, " priorityTime" ),
730764 priorityActionMaximum = getInt(jsonObject, " priorityActionMaximum" ),
765+ ignoreGlobalGroupMatch = getBoolean(jsonObject, " ignoreGlobalGroupMatch" ),
731766 )
732767 }
733768
@@ -839,6 +874,7 @@ data class RawSubscription(
839874 forcedTime = getLong(jsonObject, " forcedTime" ),
840875 priorityTime = getLong(jsonObject, " priorityTime" ),
841876 priorityActionMaximum = getInt(jsonObject, " priorityActionMaximum" ),
877+ disableIfAppGroupMatch = getString(jsonObject, " disableIfAppGroupMatch" ),
842878 )
843879 }
844880
0 commit comments