fix(android): let permission all change nothing on an app that declares no permissions

Merged
IM
7d ago
+120-17

Summary

On Android, settings permission <grant|deny|reset> all --app <pkg> failed with COMMAND_FAILED: Could not read declared permissions for an app that declares no permissions. Android prints no requested permissions: section for such a package, so a client that sets all before each launch could not launch it.

Now a dump counts as declaring nothing only when it reaches the acting user's empty runtime permissions: block and has no install permissions: section. all then changes nothing and warns. Unreadable dumps still refuse before any pm call, as do named targets. A shared-user-id package has no per-user runtime block, so it still refuses, as before.

4 files. No linked issue.

Validation

  • Head ce216dc47 (device run on 6c1e3207d), base 854bba6c5.
  • check:affected --run --head ce216dc47 (exactCommit: true): format, lint, typecheck, layering, fallow, build and vitest-related pass.
    • unit: 21198 pass, 1 fails: upload-http-deadline.test.ts ("did not complete in 3s"). It fails the same way on a clean 854bba6c5 checkout on this macOS host.
    • Checks skipped after it pass alone: test:integration:provider (308), check:command-docs, check:doc-links, check:doc-prose.
  • Pixel 9 AVD, Android 16 (API 36), source 6c1e3207d, node bin/agent-device.mjs settings permission <action> <target> --app <pkg> --platform android --serial emulator-5554. On com.callstack.agentdevice.imehelper, which declares no permissions:
    • Base (0.21.40): COMMAND_FAILED.
    • Head: grant, deny and reset all return permissions: [] and a warning.
    • Head: grant camera fails before pm.
  • On an app that declares permissions, reset all then grant all works as before.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.