First of all, the following command works perfectly fine on Android 5.1.1 (CM, PA and Tesla ROM builds):
adb shell su -c 'appops set android SYSTEM_ALERT_WINDOW deny'
The said command blocks Android System (android
) to draw over other apps (show overlay).
The same command on execution in COS12 (Android 5.0.2) throws the command's usage and the error:
Error: Unknown operation string: SYSTEM_ALERT_WINDOW
(SYSTEM_ALERT_WINDOW henceforth as <OP> here)
Per the info in the source code of AppOpsManager.java, the error should show up when <OP>
is null which it is not in my opinion.
Series of failed attempts
- I tried with multiple types of operations with no avail, both in uppercase and lowercase characters.
- I also unsuccessfully tried with interactive shell session, that is,
adb shell
→su
→ command. - I replaced single quotes with double quotes and also attempted with enclosing
<OP>
with double quotes. - I hopelessly tried
android:system_alert_window
as<OP>
too. Same goes for usingOP_<OP>
as<OP>
. - While I didn't need to change the SELinux status to Permissive in CM12.1, I did set it to Permissive and tried aforesaid steps with no success.
- Tried for a change: I thought App Ops by nowsky and App Ops [Root] by Droid Mate might help but they simply showed what Privacy Guard of CM gives.
- I edited
/data/system/appops.xml
and reflected the changes found in the same file for CM12.1. Since I was not clear on what I was doing, it partially worked. - There is the system service
appops
and I've no idea how to make good use of it.
So, what is wrong in my command and how do I make it work?
My original goal
The problem posted here can be solved by that first command in all of my Android 5.1.1 builds. (There may be side-effects of it.) Now I need to find a way to port my solution on Android 5.0.2 build.
Note: the device is OnePlus One.
Update: I've now tested the command on stock Android 5.0 (running on Nexus 6) and the situation remains same.
SYSTEM_ALERT_WINDOW
Is the wrong string for the API. Android 5.0 is API 21 and Android 5.1 is API 22. I am just curious but try
OPSTR_SYSTEM_ALERT_WINDOW
Instead.
– Bo Lawson Feb 17 '16 at 00:54