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 shellsu → 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 using OP_<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.

  • 1
    Okay, so I realized that something else is going on (it is not matching the received <OP> to null) in the line I linked about the source code.
    – Firelord
    Commented Feb 17, 2016 at 0:26
  • 1
    Looks like it might possibly be that 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
    Commented Feb 17, 2016 at 0:54
  • Nope, no effect.
    – Firelord
    Commented Feb 17, 2016 at 0:56
  • Even then, does it actually totally prevent the Android System from drawing over other apps? It probably does what the string says it should do - prevent Android from showing alert dialogs. Commented Feb 17, 2016 at 12:11
  • @TamoghnaChowdhury Try it, you would come to know that it does.
    – Firelord
    Commented Feb 17, 2016 at 12:12


You must log in to answer this question.

Browse other questions tagged .