Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 54
ADFA-3826 Whitelist some StrictMode errors for Mediatek, Xiaomi and MIUI devices#1259
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
Merged
hal-eisen-adfa
merged 4 commits into
stage
from
ADFA-3826-StrictMode-violations-pre-permissionsApr 28, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eb63891
Whitelist some StrictMode errors for Mediatek, Xiaomi and MIUI devices
hal-eisen-adfa 71d9b8d
Tighten up the whitelist rules to reduce maintenance risk
hal-eisen-adfa d6231d4
Merge branch 'stage' into ADFA-3826-StrictMode-violations-pre-permiss…
hal-eisen-adfa 1eb825a
Refine whitelist rules to be more narrowly targeted
hal-eisen-adfa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110 app/src/androidTest/kotlin/com/itsaky/androidide/app/strictmode/WhitelistRulesTest.kt
This file contains hidden or 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
89 changes: 89 additions & 0 deletions
89 app/src/main/java/com/itsaky/androidide/app/strictmode/WhitelistEngine.kt
This file contains hidden or 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,7 +1,9 @@ | ||
| package com.itsaky.androidide.app.strictmode | ||
| import android.os.strictmode.DiskReadViolation | ||
| import android.os.strictmode.DiskWriteViolation | ||
| import androidx.annotation.VisibleForTesting | ||
| import com.itsaky.androidide.app.strictmode.FrameMatcher.Companion.anyOf | ||
| import com.itsaky.androidide.app.strictmode.FrameMatcher.Companion.classAndMethod | ||
| import android.os.strictmode.Violation as StrictModeViolation | ||
| @@ -220,6 +222,93 @@ object WhitelistEngine { | ||
| classAndMethod("com.itsaky.androidide.activities.OnboardingActivity", "checkToolsIsInstalled"), | ||
| ) | ||
| } | ||
| rule { | ||
| ofType<DiskReadViolation>() | ||
| allow( | ||
| """ | ||
| On MediaTek devices, BoostFwk's 'Util.isGameApp' is invoked from ScrollIdentify | ||
| (via OverScroller's BoostFwkManagerImpl.perfHint) when a RecyclerView/ViewPager2 | ||
| is initialized. It checks for a file's existence, resulting in a DiskReadViolation. | ||
| Since we can't control when BoostFwk performs scenario detection, we allow this | ||
| violation. | ||
| """.trimIndent(), | ||
| ) | ||
| matchAdjacentFrames( | ||
| classAndMethod("java.io.File", "exists"), | ||
| classAndMethod("com.mediatek.boostfwk.utils.Util", "isGameApp"), | ||
| classAndMethod("com.mediatek.boostfwk.utils.TasksUtil", "isGameAPP"), | ||
| classAndMethod("com.mediatek.boostfwk.identify.scroll.ScrollIdentify", "checkAppType"), | ||
| ) | ||
| } | ||
| rule { | ||
| ofType<DiskReadViolation>() | ||
| allow( | ||
| """ | ||
| On MediaTek devices, AsyncDrawableCache hooks into Resources.loadDrawable and | ||
| synchronously commits to a SharedPreferences-backed cache. This is triggered by | ||
| routine layout inflation and produces a DiskReadViolation. We anchor this rule | ||
| with a java.io disk-access frame at the top and the SharedPreferencesImpl | ||
| commit frame immediately adjacent to the vendor chain, so it only fires on the | ||
| actual prefs-write path inside this vendor caching code. | ||
| """.trimIndent(), | ||
| ) | ||
| matchAdjacentFramesInOrder( | ||
| listOf( | ||
| listOf( | ||
| anyOf( | ||
| classAndMethod("java.io.File", "exists"), | ||
| classAndMethod("java.io.FileInputStream", "<init>"), | ||
| classAndMethod("java.io.FileOutputStream", "<init>"), | ||
| classAndMethod("java.io.RandomAccessFile", "<init>"), | ||
| classAndMethod("android.system.Os", "stat"), | ||
| ), | ||
| ), | ||
| listOf( | ||
| classAndMethod("android.app.SharedPreferencesImpl\$EditorImpl", "commit"), | ||
| classAndMethod("com.mediatek.res.AsyncDrawableCache", "storeDrawableId"), | ||
| classAndMethod("com.mediatek.res.AsyncDrawableCache", "putCacheList"), | ||
| classAndMethod("com.mediatek.res.ResOptExtImpl", "putCacheList"), | ||
| ), | ||
| ), | ||
| ) | ||
| } | ||
| rule { | ||
| ofType<DiskWriteViolation>() | ||
| allow( | ||
| """ | ||
| On MediaTek devices, AsyncDrawableCache hooks into Resources.loadDrawable and | ||
| synchronously commits to a SharedPreferences-backed cache. The same path also | ||
| produces a DiskWriteViolation when the prefs file is written. We anchor this | ||
| rule with a concrete write-path frame at the top and the SharedPreferencesImpl | ||
| commit frame immediately adjacent to the vendor chain, so it only fires on the | ||
| actual prefs-write path inside this vendor caching code. | ||
| """.trimIndent(), | ||
| ) | ||
| matchAdjacentFramesInOrder( | ||
| listOf( | ||
| listOf( | ||
| anyOf( | ||
| classAndMethod("java.io.FileOutputStream", "<init>"), | ||
| classAndMethod("java.io.FileOutputStream", "write"), | ||
| classAndMethod("java.io.File", "delete"), | ||
| classAndMethod("android.system.Os", "chmod"), | ||
| ), | ||
| ), | ||
| listOf( | ||
| classAndMethod("android.app.SharedPreferencesImpl\$EditorImpl", "commit"), | ||
| classAndMethod("com.mediatek.res.AsyncDrawableCache", "storeDrawableId"), | ||
| classAndMethod("com.mediatek.res.AsyncDrawableCache", "putCacheList"), | ||
| classAndMethod("com.mediatek.res.ResOptExtImpl", "putCacheList"), | ||
| ), | ||
| ), | ||
| ) | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| /** | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.