Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Mobile Device Management: Disable screenshots capture across all apps

I am making an MDM app in which I have to block screen shot across all apps in device. I know using

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

I can disable screen capture in my apps activities, but I want to disable screen capture in all apps installed into device. Previously I was using File observer to block screen capture, it was detecting if any image has been added to Screenshot folder, it was deleting that image. But from Android M,they are not allowing file observer. I have search alot but didn't get any solution. But many android apps like quick heal's seqrite MDM is preventing screen capture in android M too, so there must be some way.

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

Please help me if any one know the way to block screen capture.

like image 459
Rizwan Avatar asked Dec 01 '15 06:12

Rizwan


1 Answers

I got the solution by using logs while blocking screen capture in seqrite app. In case of screen blocking activated they started a service on which they were showing 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 am using flag secure which is blocking capturing of screen across all applications. Because this window is at top which is blocking screen capture.

like image 137
Rizwan Avatar answered Oct 14 '22 18:10

Rizwan