Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(adb): count requested permissions that the device marks restricted (#2359)
Jin15463bdbe605
diff --git a/src/adb/AdbProvider.test.ts b/src/adb/AdbProvider.test.tsindex b89ab9dfd..ae81353c7 100644--- a/src/adb/AdbProvider.test.ts+++ b/src/adb/AdbProvider.test.ts@@ -626,6 +626,34 @@ it("projects package details from dumpsys package output", async () => {});});+// Android 10 and 11 append ": restricted=true" to hard- and soft-restricted+// entries of the requested-permissions list (Settings.dumpPackageLPr).+it("counts requested permissions that the device marks as restricted", async () => {+ const { binary } = await writeAdbStub(+ shellStub({+ "dumpsys:package": `Packages:+ Package [com.example] (abcdef):+ userId=10234+ versionName=1.2.3+ requested permissions:+ android.permission.INTERNET+ android.permission.WRITE_EXTERNAL_STORAGE: restricted=true+ android.permission.CAMERA+ install permissions:+ android.permission.INTERNET: granted=true+`,+ }),+ );+ const result = await evidenceResult(providerOver(binary), {+ operation: "inspect_adb_package",+ input: { serial: "emulator-5554", package: "com.example" },+ });+ expect(result).toMatchObject({+ requested_permissions_count: 3,+ coverage: "complete",+ });+});+it("reports an uninstalled package from dumpsys refusal output", async () => {const { binary } = await writeAdbStub(shellStub({ "dumpsys:package": "Unable to find package: com.absent\n" }),diff --git a/src/adb/AdbShellOutput.ts b/src/adb/AdbShellOutput.tsindex f3323e7b2..726e6164d 100644--- a/src/adb/AdbShellOutput.ts+++ b/src/adb/AdbShellOutput.ts@@ -236,7 +236,11 @@ export const parseDumpsysPackageOutput = (inPermissions = true;continue;}- if (inPermissions && /^\s{2,}[A-Za-z0-9._]+$/.test(line)) {+ // Android 10 and 11 mark restricted entries as "NAME: restricted=true".+ if (+ inPermissions &&+ /^\s{2,}[A-Za-z0-9._]+(?:: restricted=true)?$/u.test(line)+ ) {permissions += 1;continue;}