Disable screenshot capture in all applications

I am making an MDM application in which I have to block the screenshot on all applications on the device. I know using

 getWindow().setFlags(LayoutParams.FLAG_SECURE,LayoutParams.FLAG_SECURE)

I can disable screen capture in my applications, but I want to disable screen capture in all applications installed on the device. previously I used File observer to lock the screen capture, it found that any image was added to the Screenshot folder, it deletes this image. But with Android M, they do not allow you to monitor files. I have searched a lot, but have not received any solution. But many Android apps like quick cure seqrite MDM prevents screen capture in Android M too, it should be.

I found the setScreenCaptureDisabled api in the DevicePolicyManger class, which can disable screen capture, but it can only be called by the device owner’s applications.

Please help me if anyone knows how to lock screen capture.

+4
source share
2 answers

I got a solution using logs, blocking screen capture in seqrite application. In case of activation of the screen lock, they started the service on which they displayed a floating window

  WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                    WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_SECURE,
                    PixelFormat.TRANSPARENT);
                params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                params.gravity = Gravity.CENTER;
                mView = new LinearLayout(ctx);
                View  btn = new View(ctx);
                mView.addView(btn);
                wm.addView(mView, params);

Here I use the secure flag, which blocks screen capture in all applications. Because it is a window at the top that blocks screen capture.

0
source

, , NFC - ( 5.1 ). , Motorola KNOX API ( ), Android.

0

Source: https://habr.com/ru/post/1618068/


All Articles