Adb / Revoke App Permission
Revoke App Permission
Revokes specified permissions from an application on the device.
adb shell pm revoke <package> <android.permission.CAMERA|android.permission.ACCESS_FINE_LOCATION|android.permission.READ_CONTACTS|...> adb shell pm revoke <package> <android.permission.CAMERA|android.permission.ACCESS_FINE_LOCATION|android.permission.READ_CONTACTS|...> #!/bin/bash
# Revoke App Permission
adb shell pm revoke {{package}} {{android.permission.CAMERA|android.permission.ACCESS_FINE_LOCATION|android.permission.READ_CONTACTS|...}} import subprocess
# Revoke App Permission
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"adb",
"shell",
"pm",
"revoke",
"<package>",
"<android.permission.CAMERA|android.permission.ACCESS_FINE_LOCATION|android.permission.READ_CONTACTS|...>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: adb not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
Necessary for security audits or when debugging unwanted behavior from an application.
Pro Tip
Perform revocation in an isolation environment to prevent user data integrity issues caused by abrupt permission loss.
Command Builder
Tune the command before you copy it
adb shell pm revoke <package> <android.permission.CAMERA|android.permission.ACCESS_FINE_LOCATION|android.permission.READ_CONTACTS|...> Terminal Output
Expected runtime feedback
PACKAGE_NAME: com.example.app
Permissions revoked:
- android.permission.CAMERA
- android.permission.ACCESS_FINE_LOCATION
Operation completed successfully. Anatomy of Output
Understanding the result
Success Revoke Status Indicates whether the permissions were successfully revoked.
Revoked permission: android.permission.ACCESS_FINE_LOCATION Revoked Permission Notification Confirms specific permissions revoked from the application.
Total Permissions Revoked: 1 Summary Count Total number of permissions revoked during operation.
Troubleshooting
Common pitfalls
adb shell pm revoke: Package not found
Solution: Verify the package name is correct and that the app is installed.
adb shell pm revoke: Permission <permission_name> is not a valid permission
Solution: Check for spelling and ensure the permission is applicable to the app.
adb shell pm revoke: Operation failed
Solution: Inspect device policies or user settings for related restrictions.
Command Breakdown
What each part is doing
-
adb - Base Command
- The executable that performs this operation. Here it runs Adb before the shell applies any redirect operators.
-
<package> - package
- The value supplied for package.
-
<android.permission.CAMERA|android.permission.ACCESS_FINE_LOCATION|android.permission.READ_CONTACTS|...> - android.permission.CAMERA|android.permission.ACCESS FINE LOCATION|android.permission.READ CONTACTS|...
- The value supplied for android.permission.CAMERA|android.permission.ACCESS FINE LOCATION|android.permission.READ CONTACTS|....
How To Run
Execution path
- Step 1
Run the command: `adb shell pm revoke com.example.app android.permission.CAMERA`
- Step 2
Verify permissions by running: `adb shell pm list packages -f -3`
Alternative Approaches
Comparable commands in other tools
Alternative programming tools for the same job.
go list std Go / List Packages Json go list -json time net/http Go / Show Package Documentation All Symbols go doc -all <encoding/json> Go / Show Package Documentation All Symbols Sources go doc -all -src <encoding/json> Dotnet / Package Dotnet Application Single File dotnet publish -r <runtime_identifier> -p:PublishSingleFile=true <path/to/project_file>