How to Manage and Audit App Operations on Android Using ADB appops

While the standard Android permissions framework exposes user-facing prompts for dangerous permissions (such as Location, Camera, and Microphone), the underlying Android platform enforces privacy controls through an internal system service known as App Operations (appops). AppOps tracks and gates over a hundred low-level hardware operations—including background clipboard access, notification posting, vibration, overlay drawing, and camera sensor capture. Testing how an application handles revoked permissions without crashing traditionally required navigating complex settings menus. Using Android Debug Bridge (ADB), developers can audit and manipulate AppOps directly from the command line.

In this guide, you will learn how AppOps differs from package permissions, query operational modes, simulate silent permission denials using the ignore mode, and reset app operations on Android using ADB.

Understanding AppOps Modes: Allow, Ignore, and Deny

When an application attempts an operation (such as reading the system clipboard or accessing fine location), the Android system checks the active AppOps mode for that operation and package:

  • allow: The application is permitted to execute the operation normally.
  • deny: The operating system rejects the operation and throws a SecurityException. If the application does not wrap the call in a try-catch block, the process crashes immediately.
  • ignore (Silent Denial): The operating system pretends the operation succeeded but returns mock or empty data. For example, reading contacts returns an empty cursor, location queries return null, and camera feeds return black frames. This allows users to protect privacy without breaking unstable legacy applications.
  • default: Reverts the operation mode to standard Android package manifest and runtime permission evaluations.

Connecting via ADB and Identifying App Operations

Ensure your device or emulator is connected with USB Debugging enabled:

adb devices

Android provides an extensive catalogue of standard operation names, including:

  • COARSE_LOCATION / FINE_LOCATION: Location sensor access.
  • CAMERA / RECORD_AUDIO: Camera hardware and microphone recording.
  • READ_CLIPBOARD: Accessing copied text and data buffers.
  • SYSTEM_ALERT_WINDOW: Drawing floating UI overlays over other applications.
  • POST_NOTIFICATION: Sending status bar notifications.

Auditing Active Operations for an Application

To inspect all operational states and access timestamps for a specific target package:

adb shell cmd appops get com.example.myapp

The command outputs each configured operation, its current mode, and historical usage metrics:

COARSE_LOCATION: allow; time=+2m30s ago; duration=1200ms
CAMERA: allow; time=+15m10s ago
READ_CLIPBOARD: allow; rejectTime=+1h20m ago
SYSTEM_ALERT_WINDOW: default

Notice the rejectTime attribute, which timestamps the exact moment an operation was rejected by the system.

Simulating Silent Permission Denial (Ignore Mode)

To evaluate whether your application handles missing location or camera access gracefully without crashing:

Set the location operation mode to ignore:

adb shell cmd appops set com.example.myapp FINE_LOCATION ignore

Now, launch the application and initiate a location lookup:

adb shell monkey -p com.example.myapp -c android.intent.category.LAUNCHER 1

Because the mode is set to ignore rather than deny, Android does not throw a SecurityException. Instead, the GPS callback receives null. Verify that your UI displays an informative message (e.g., “Location unavailable”) rather than freezing or encountering null pointer errors.

Hard-Denying Operations to Test Security Exceptions

To verify that your codebase properly handles explicit security rejections and catches SecurityException:

adb shell cmd appops set com.example.myapp CAMERA deny

Monitor logcat to observe how the application handles the hard exception:

adb logcat -s "MyCameraManager" "AndroidRuntime"

Testing Background Clipboard Access Restrictions

Starting with Android 10, background apps are prohibited from reading the system clipboard. To test how your app responds to clipboard access restrictions:

  1. Copy text to the Android clipboard:
    adb shell input text "ConfidentialToken123"
  2. Restrict clipboard access for the target app:
    adb shell cmd appops set com.example.myapp READ_CLIPBOARD ignore
  3. Send the application to the background:
    adb shell input keyevent KEYCODE_HOME
  4. Trigger your app’s background service. Confirm that attempting to read the clipboard yields an empty string without raising unhandled errors.

Resetting App Operations to Default Factory State

When automated regression testing is complete, restore all operation modes for the package back to default system permissions:

adb shell cmd appops reset com.example.myapp

Verify that the package is reset:

adb shell cmd appops get com.example.myapp

All operation modes return to their standard runtime evaluations, ensuring the device remains ready for standard interactive user testing.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.