https://code.google.com/p/android/issues/detail?id=196597
-
Compile in Android Studio
-
Execute the following instructions:
adb install app/build/outputs/apk/app-debug.apk
adb shell am start -S 'com.android.settings/.Settings\$DeviceAdminSettingsActivity'
You should be able to register/unregister the sample app as device administrator.
Now execute this to briefly allow/deny SYSTEM_ALERT_WINDOW.
adb shell appops set sample.androidissue196597 SYSTEM_ALERT_WINDOW allow
adb shell appops set sample.androidissue196597 SYSTEM_ALERT_WINDOW deny
adb shell am start -S 'com.android.settings/.Settings\$DeviceAdminSettingsActivity'
Now you will get a force-close of the system settings app.