Skip to content

Conversation

@Hamza417
Copy link
Owner

@Hamza417 Hamza417 commented Feb 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 1, 2026 09:06
Copy link
Contributor

Copilot AI left a 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")
Copy link

Copilot AI Feb 1, 2026

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).

Copilot uses AI. Check for mistakes.
Comment on lines +223 to +226
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()
Copy link

Copilot AI Feb 1, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +136 to +140
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 {
Copy link

Copilot AI Feb 1, 2026

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)).

Copilot uses AI. Check for mistakes.
Comment on lines +131 to +132
Log.d(TAG, "Found ${uniqueOperations.size} unique operations for $packageName")

Copy link

Copilot AI Feb 1, 2026

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).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant