Repository navigation
AppOps: warn before modifying AppOps for shared system UIDs (#2030) - #2073
Open
AndrewWangDev wants to merge 1 commit into
Open
AndrewWangDev wants to merge 1 commit into
AndrewWangDev wants to merge 1 commit into
Conversation
…rAkon#2030) In Android M (API 23)+, AppOpsManagerCompat.setMode delegates to setUidMode. While consistent with Android's UID security domain, modifying AppOps on an app that shares a core system UID (e.g. UID 1000 with the system framework) can inadvertently strip permissions like GET_USAGE_STATS globally, causing system stability issues. This commit introduces a tiered confirmation dialog before executing dangerous AppOps modifications: - For apps sharing a system UID (< 10000), a high-visibility warning dialog is displayed highlighting the affected system packages. - For non-system shared UIDs, a general multi-package notice is shown. - Adds comprehensive unit tests and multi-language support (English and Simplified Chinese). Resolves: MuntashirAkon#2030 Signed-off-by: Andrew Wang Dev <me@andrewwangdev.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Please check before submitting a PR
Describe the feature or issue
In Android 6.0+ (API 23+),
AppOpsManagerCompat.setModedelegates toAppOpsManager.setUidMode. Since Android enforces AppOps boundaries per UID rather than per package, changing or resetting AppOps for an application that shares a UID with core system packages (most notablyandroid.uid.system/ UID 1000, which includes Settings, System UI, and core framework components) modifies those permissions globally across all packages sharing that UID.For example, inadvertently revoking or resetting
GET_USAGE_STATSon a vendor system tool sharing UID 1000 can cause the Android Settings app or system services to crash immediately with aSecurityException.Related Issues
Resolves #2030
Describe the solution you've implemented
Introduced
UidWarningHelperand added tiered confirmation dialogs before executing dangerous AppOps modifications:Warning Strategy:
ic_caution) detailing the critical risk to system stability and explicitly enumerates the affected co-located packages.Intercepted Operations:
mSharedUidWarningDismissed) avoids redundant prompts within the same session.Lifecycle, Concurrency & Performance Guards:
ContextThemeWrapper/ContextWrapperto retrieve the underlyingActivity, with explicitisFinishing()andisDestroyed()checks.checkedUids) and early-break traversal once a critical system UID is encountered.AppDetailsViewModel.getUid(), avoiding false UID 0 (root) detections.Tests & Localization:
UidWarningHelperTestcovering boundary conditions, destroyed activities, non-activity contexts, and multi-user resolution.Describe alternatives you've considered
Additional context
./gradlew :app:testDebugUnitTest --tests io.github.muntashirakon.AppManager.utils.UidWarningHelperTest(9/9 passed)../gradlew :app:lintDebug../gradlew assembleDebug.