-
-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automation: Improve reliability one Android 14 devices (OnePlus & Redmi)
Stop using the root from accessibility events as fallback. Delayed event emission can lead to an out-dated (and later recycled) root being used by the step-process. Error behavior: * Click event from app 1 is emitted when SD Maid starts processing app 2 * windowRoot of app 2 is not ready yet * SD Maid starts using fallback root from the last event (the click event from app 2) * The fallback root is no longer valid, as it corresponds to the settings screen from app 1 * SD Maids keeps retrying and the fallback root is at some point recycled * SD Maid keeps trying to crawl an empty root nodef Fixes #1124 Might fix #1016
- Loading branch information
Showing
8 changed files
with
48 additions
and
46 deletions.
There are no files selected for viewing
24 changes: 23 additions & 1 deletion
24
app/src/main/java/eu/darken/sdmse/automation/core/AutomationExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,27 @@ | ||
package eu.darken.sdmse.automation.core | ||
|
||
import android.view.accessibility.AccessibilityNodeInfo | ||
import eu.darken.sdmse.common.debug.Bugs | ||
import eu.darken.sdmse.common.debug.logging.Logging.Priority.VERBOSE | ||
import eu.darken.sdmse.common.debug.logging.log | ||
import kotlinx.coroutines.CancellationException | ||
import kotlinx.coroutines.currentCoroutineContext | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.isActive | ||
|
||
suspend fun AutomationManager.canUseAcsNow(): Boolean = useAcs.first() | ||
suspend fun AutomationManager.canUseAcsNow(): Boolean = useAcs.first() | ||
|
||
suspend fun AutomationHost.waitForWindowRoot(delayMs: Long = 200): AccessibilityNodeInfo { | ||
var root: AccessibilityNodeInfo? = null | ||
|
||
while (currentCoroutineContext().isActive) { | ||
root = windowRoot() | ||
if (root != null) break | ||
|
||
if (Bugs.isDebug) log(VERBOSE) { "Waiting for windowRoot..." } | ||
delay(delayMs) | ||
} | ||
|
||
return root ?: throw CancellationException("Cancelled while waiting for windowRoot") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
app/src/main/java/eu/darken/sdmse/automation/core/errors/AutomationException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package eu.darken.sdmse.automation.core.errors | ||
|
||
open class AutomationException(message: String?, cause: Throwable?) : Exception(message, cause) { | ||
open class AutomationException( | ||
message: String? = null, | ||
cause: Throwable? = null | ||
) : Exception(message, cause) { | ||
constructor(message: String?) : this(message, null) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters