You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(platform-android): implement permission automation via adb
Add permission granting functionality for Android that uses adb to automatically grant a comprehensive set of common dangerous permissions when the permissions config flag is enabled. Works on both emulators and physical devices.
- Create android/permissions.ts with default permission list
- Add adb.grantPermissions() function to grant permissions via 'pm grant'
- Integrate permission granting in emulator and physical device instance setup
- Add comprehensive tests for permission granting scenarios
- Update permissions documentation to describe Android implementation
Copy file name to clipboardExpand all lines: website/src/docs/guides/permissions.mdx
+25-3Lines changed: 25 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,11 +25,13 @@ When `permissions` is `true`:
25
25
26
26
- On iOS simulators, Harness starts the XCTest agent and enables best-effort permission prompt auto-accept.
27
27
- On iOS physical devices, Harness also starts the XCTest agent when the runner is configured with `device.codeSign`.
28
-
- On Android, the shared config flag exists, but there is currently no dedicated Android permission automation implementation in the codebase.
28
+
- On Android emulators and physical devices, Harness uses `adb shell pm grant` to automatically grant a set of common permissions.
29
29
30
-
## What iOS Actually Automates
30
+
## Platform-Specific Implementation Details
31
31
32
-
The current iOS implementation does **not** pre-approve every permission up front.
32
+
### iOS
33
+
34
+
The iOS implementation does **not** pre-approve every permission up front.
33
35
Instead, it runs a best-effort watchdog that taps known positive system-prompt buttons such as:
34
36
35
37
-`Allow`
@@ -41,6 +43,26 @@ Instead, it runs a best-effort watchdog that taps known positive system-prompt b
41
43
42
44
Because this is button-based automation, it should be treated as a practical helper for common prompts rather than a guarantee that every permission dialog will be handled.
43
45
46
+
### Android
47
+
48
+
On Android, Harness pre-grants a comprehensive set of common dangerous permissions using `adb shell pm grant`. This approach:
49
+
50
+
- Grants permissions **proactively** before the app runs, avoiding permission dialogs during testing
51
+
- Works on both emulators and physical devices
52
+
- Includes location, camera, microphone, contacts, calendar, storage, SMS, and other common test permissions
53
+
- Uses the `pm grant` command which requires API 23+ or emulated environment support
54
+
55
+
The default set of granted permissions includes:
56
+
- Location (fine and coarse)
57
+
- Camera and microphone
58
+
- Contacts and calendar (read/write)
59
+
- Call log (read/write)
60
+
- Storage (read/write)
61
+
- Phone state and calling
62
+
- SMS (read/send/receive)
63
+
- Body sensors
64
+
- Network state and internet
65
+
44
66
## Performance Impact
45
67
46
68
Enabling `permissions` can make Harness heavier on iOS because it starts an additional XCTest agent session alongside the normal run.
0 commit comments