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.

Rizwan
  • 1,461
  • 12
  • 26
  • Seqrite requests for the activation of Device Administrator mode for its app in the user's mobile device; see page 38 at http://bitcast-b.bitgravity.com/quickheal/seqrite/documents/en/manuals/Seqrite_Mobile_Device_Management_MDM_Guide.pdf – ecle Dec 01 '15 at 06:51
  • My apps also requesting for Device Administrator mode, but setScreenCaptureDisabled of DevicePolicyManger class can be Called by a device/profile owner . I saw at http://stackoverflow.com/questions/21183328/how-to-make-my-app-a-device-owner that how to make my app device owner. But this is not a solution for my app. – Rizwan Dec 01 '15 at 07:02
  • Try to find solution here http://developer.android.com/guide/topics/admin/device-admin.html – ecle Dec 01 '15 at 07:20
  • I am already using Device Administration API policies in my app. It doesn't have Screenshot block policy in it. – Rizwan Dec 01 '15 at 07:34
  • Try to get some ideas from these test codes: https://android.googlesource.com/platform/cts/+/17aafef/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BaseDeviceOwnerTest.java and later apply the screenshot disabled check here https://android.googlesource.com/platform/cts/+/17aafef/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ScreenCaptureDisabledTest.java – ecle Dec 01 '15 at 07:45
  • 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. – Rizwan Dec 01 '15 at 07:49
  • How to become Device Owner app http://stackoverflow.com/questions/32763780/device-admin-api-how-to-be-a-device-owner – ecle Dec 01 '15 at 09:14
  • 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. – Rizwan Dec 01 '15 at 11:20
  • Actually, Google Play Store has a Private Channel for corporate users to manage mobile apps...https://support.google.com/a/answer/2494992?hl=en – ecle Dec 02 '15 at 01:07

2 Answers2

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.

Rizwan
  • 1,461
  • 12
  • 26
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.

zaitsman
  • 8,984
  • 6
  • 47
  • 79