-
-
Notifications
You must be signed in to change notification settings - Fork 84
AppOps Parse Fix #466
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
base: master
Are you sure you want to change the base?
AppOps Parse Fix #466
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adjusts AppOps parsing to better separate UID-scoped vs package-scoped modes and improve handling of ambiguous appops get output.
Changes:
- Extracts unique operation names from
appops get <package>output. - Queries each operation individually via
appops get <package> <op>and parses UID/package scope separately. - Adds helper functions (
extractUniqueOperations,parseIndividualOperation) to encapsulate parsing logic.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| uidAppOp.scope = AppOpScope.UID | ||
| ops.add(uidAppOp) | ||
| } | ||
| val opOutput = runAndGetOutput("appops get $packageName $queryOperation") |
Copilot
AI
Feb 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getOps() now executes appops get <package> <op> once per unique operation (inside a loop). This can be a large number of root/Shizuku shell invocations and may significantly slow loading. Consider parsing UID/package scope from the single appops get <package> output, or otherwise reducing/ batching these calls (e.g., only falling back to per-op queries when the combined output can’t be disambiguated).
| val parts = line.split(":".toRegex(), limit = 2) | ||
| if (parts.size >= 2 && parts[0].trim() == operation) { | ||
| val valuesPart = parts[1].trim() | ||
| packageModeValue = valuesPart.split(";").firstOrNull()?.trim() |
Copilot
AI
Feb 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseIndividualOperation() matches package-scoped lines only when parts[0].trim() == operation, but getOps() may query using a different token (queryOperation, e.g., numeric code extracted from MIUIOP(10008)). If the appops get ... <op> output prefixes the line with the numeric code, this check will skip parsing the package-scoped mode. Consider matching against both representations (original name and extracted numeric), or passing queryOperation into this function and accepting either.
| val queryOperation = if (operation.contains("(") && operation.endsWith(")")) { | ||
| val extracted = operation.substringAfter("(").substringBefore(")") | ||
| // Verify it's numeric, otherwise use original | ||
| if (extracted.toIntOrNull() != null) extracted else operation | ||
| } else { |
Copilot
AI
Feb 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OEM op normalization logic (extracting numeric code from NAME(number) with substringAfter/Before and toIntOrNull) is duplicated here and in getStateChangeCommand(). To avoid drift and keep behavior consistent between get and set, consider extracting this into a small private helper (e.g., toAppOpsCliToken(opName)).
| Log.d(TAG, "Found ${uniqueOperations.size} unique operations for $packageName") | ||
|
|
Copilot
AI
Feb 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new Log.d(TAG, ...) statements added around app-ops parsing (including per-scope logs) can be very noisy and may impact performance, especially since runAndGetOutput() already logs every output line. Consider removing these or gating them behind a debug flag (e.g., BuildConfig.DEBUG).
No description provided.