Conversation
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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") | ||
|
|
There was a problem hiding this comment.
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).
# Conflicts: # app/src/main/java/app/simple/inure/viewmodels/viewers/OperationsViewModel.kt
81aeb43 to
4d35a2d
Compare
No description provided.