Skip to main content

Overview

PhoneClaw’s automation capabilities are powered by Android’s Accessibility Service, which provides programmatic access to UI elements across all apps on the device. This enables PhoneClaw to read screen content, find elements, and simulate user interactions.

What is an Accessibility Service?

Android Accessibility Services were designed to help users with disabilities interact with their devices. PhoneClaw leverages these same APIs for automation:
  • Screen Reading: Access all text and UI elements currently visible
  • UI Interaction: Click, type, scroll, and navigate programmatically
  • Global Access: Works across all apps (with permission)
  • Event Monitoring: Receive notifications when UI changes occur
User Permission Required: Accessibility Services require explicit user authorization in Android Settings → Accessibility. PhoneClaw cannot function without this permission.

Service Architecture

Service Lifecycle

From MyAccessibilityService.kt:45-63:
The service maintains a singleton instance that can be accessed from anywhere in the app. This allows ClawScript to trigger accessibility actions from JavaScript.

Core Capabilities

1. Simulating Clicks

PhoneClaw can click at specific screen coordinates using gestures:
JavaScript Usage:

2. Finding UI Elements

Accessibility Services can traverse the entire UI hierarchy:
JavaScript Usage:

3. Text Detection

Check if specific text appears on screen:
JavaScript Usage:

4. Text Input

Type into editable fields:
JavaScript Usage:

5. Scrolling & Swiping

JavaScript Usage:

Advanced Features

Element Finding by View ID

Target specific UI elements using Android resource IDs:
JavaScript Usage:

Extracting All Screen Text

JavaScript Usage:

App-Specific Automation

PhoneClaw includes specialized functions for popular apps:
JavaScript:

Permissions & Setup

1. Declare Service in AndroidManifest.xml

2. Configure Service Capabilities

res/xml/accessibility_service_config.xml

3. Check Permission Status

Best Practices

Performance Tips:
  • Always check if rootInActiveWindow is null before traversing
  • Recycle AccessibilityNodeInfo objects after use to prevent memory leaks
  • Use specific targeting (View IDs, content descriptions) instead of full tree traversal
  • Add delays between rapid UI interactions
Security Considerations:
  • Accessibility Services can access sensitive information (passwords, personal data)
  • Never log or transmit sensitive screen content
  • Respect user privacy and only automate with explicit consent
  • Be transparent about what data your automation accesses

Troubleshooting

Service Not Connected

Element Not Found

Click Not Working

If semantic clicks fail, fall back to coordinate-based clicks:

Next Steps

Vision Targeting

Combine accessibility with vision AI

ClawScript

JavaScript automation API reference