Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ACS based cache deletion on HyperOS 2.0 #1544

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import eu.darken.sdmse.common.datastore.PreferenceScreenData
import eu.darken.sdmse.common.datastore.PreferenceStoreMapper
import eu.darken.sdmse.common.datastore.createValue
import eu.darken.sdmse.common.datastore.valueBlocking
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.device.RomType
import eu.darken.sdmse.main.core.GeneralSettings
import javax.inject.Inject
import javax.inject.Singleton
Expand Down Expand Up @@ -63,13 +61,6 @@ class AppCleanerSettings @Inject constructor(
// Amounts to common folders created by default
val minCacheSizeBytes = dataStore.createValue<Long>("skip.mincachesize.bytes", MIN_CACHE_SIZE_DEFAULT)


init {
// TODO Remove in a later version
val oldValue = dataStore.createValue("automation.romtype.detection", RomType.AUTO, moshi).valueBlocking
generalSettings.romTypeDetection.valueBlocking = oldValue
}

override val mapper = PreferenceStoreMapper(
includeSystemAppsEnabled,
includeRunningAppsEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ClearCacheModule @AssistedInject constructor(
private fun getPriotizedSpecGenerators(): List<AppCleanerSpecGenerator> = specGenerators
.get()
.also { log(TAG) { "${it.size} step generators are available" } }
.onEach { log(TAG, VERBOSE) { "Loaded: $it" } }
.onEach { log(TAG, VERBOSE) { "Loaded: $it (${it.tag})" } }
.sortedByDescending { generator: AppCleanerSpecGenerator ->
when (generator) {
is MIUISpecs -> 190
Expand Down Expand Up @@ -192,10 +192,10 @@ class ClearCacheModule @AssistedInject constructor(

val specGenerator = getPriotizedSpecGenerators().firstOrNull { it.isResponsible(pkg) }
?: getPriotizedSpecGenerators().single { it is AOSPSpecs }
log(TAG) { "Using spec generator: $specGenerator" }
log(TAG) { "Using spec generator: ${specGenerator.tag}" }

val spec = specGenerator.getClearCache(pkg)
log(TAG) { "Generated spec for ${pkg.id} is $spec" }
log(TAG) { "Generated spec for ${pkg.id} is ${spec.tag}" }

when (spec) {
is AutomationSpec.Explorer -> processExplorerSpec(pkg, spec)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class AlcatelSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {

override val tag: String = TAG

override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ open class AndroidTVSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class AOSPSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ColorOSSpecs @Inject constructor(


override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class FlymeSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class HonorSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class HuaweiSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class LGESpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class MIUISpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class NubiaSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class OnePlusSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class RealmeSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class SamsungSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class VivoSpecs @Inject constructor(
}

override suspend fun getClearCache(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import eu.darken.sdmse.common.pkgs.features.Installed
import eu.darken.sdmse.common.pkgs.toPkgId
import eu.darken.sdmse.common.progress.withProgress
import eu.darken.sdmse.main.core.GeneralSettings
import java.util.*
import javax.inject.Inject

@Reusable
Expand All @@ -61,6 +60,7 @@ open class AndroidTVSpecs @Inject constructor(
}

override suspend fun getForceStop(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import eu.darken.sdmse.common.pkgs.features.Installed
import eu.darken.sdmse.common.pkgs.toPkgId
import eu.darken.sdmse.common.progress.withProgress
import eu.darken.sdmse.main.core.GeneralSettings
import java.util.*
import javax.inject.Inject

@Reusable
Expand All @@ -58,6 +57,7 @@ class AOSPSpecs @Inject constructor(
}

override suspend fun getForceStop(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class MIUISpecs @Inject constructor(
}

override suspend fun getForceStop(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import eu.darken.sdmse.common.pkgs.features.Installed
import eu.darken.sdmse.common.pkgs.toPkgId
import eu.darken.sdmse.common.progress.withProgress
import eu.darken.sdmse.main.core.GeneralSettings
import java.util.*
import javax.inject.Inject

@Reusable
Expand All @@ -60,6 +59,7 @@ class SamsungSpecs @Inject constructor(
}

override suspend fun getForceStop(pkg: Installed): AutomationSpec = object : AutomationSpec.Explorer {
override val tag: String = TAG
override suspend fun createPlan(): suspend AutomationExplorer.Context.() -> Unit = {
mainPlan(pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AutomationExplorer @AssistedInject constructor(
}

suspend fun process(spec: AutomationSpec.Explorer) {
log(TAG) { "process(): $spec" }
log(TAG) { "process(): ${spec.tag}" }

var attempts = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package eu.darken.sdmse.automation.core.specs
import java.time.Duration

sealed interface AutomationSpec {
val tag: String
interface Explorer : AutomationSpec {

val executionTimeout: Duration
get() = Duration.ofSeconds(20)

Expand Down
Loading