Android Mobile Device Management: Disable screenshots capture across all apps
Asked Answered
D

2

6

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.

Danyluk answered 1/12, 2015 at 6:6 Comment(9)
Seqrite requests for the activation of Device Administrator mode for its app in the user's mobile device; see page 38 at bitcast-b.bitgravity.com/quickheal/seqrite/documents/en/manuals/…Carton
My apps also requesting for Device Administrator mode, but setScreenCaptureDisabled of DevicePolicyManger class can be Called by a device/profile owner . I saw at #21183828 that how to make my app device owner. But this is not a solution for my app.Danyluk
Try to find solution here developer.android.com/guide/topics/admin/device-admin.htmlCarton
I am already using Device Administration API policies in my app. It doesn't have Screenshot block policy in it.Danyluk
Try to get some ideas from these test codes: android.googlesource.com/platform/cts/+/17aafef/hostsidetests/… and later apply the screenshot disabled check here android.googlesource.com/platform/cts/+/17aafef/hostsidetests/…Carton
Above tests are for device owner app. It is checking assertTrue(mDevicePolicyManager.isDeviceOwnerApp(PACKAGE_NAME)). But my app is not device owner, so I don't think this will help.Danyluk
How to become Device Owner app #32764280Carton
Thanks bro for your help. But I can't use NFC or adb shell method to activate device owner because thia app will go to normal user through app store and they can not do these procedures. I need some api or intent which can do this but didn't find so far.Danyluk
Actually, Google Play Store has a Private Channel for corporate users to manage mobile apps...support.google.com/a/answer/2494992?hl=enCarton
D
1

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.

Danyluk answered 29/12, 2015 at 12:6 Comment(3)
Thanks, but would you mine to put the complete code? what is vm? the root view of the activity? does this code run into a started service?Hyacinth
wm = WindowManagerMainsail
TYPE_SYSTEM_OVERLAY is depreactaed nowWellington
C
0

To kick off device owner, you need to wipe the device and NFC bump it or have the user select DO from the menu (5.1 and above only). Unless you use things like Motorola or KNOX APIs (which are platform specific) you are out of luck with general Android.

Cicely answered 24/12, 2015 at 13:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.