Reputation: 81
I'm trying to prevent from taking a screenshot in Crosswalk WebView. I have tried PrivacyScreenPlugin. This plugin works very good when I wasn't using Crosswalk plugin. However, if I added Crosswalk plugin, it only works at the app launch time.
For example, when I launch my app, I can not take a screenshot. However, if I show any other UI component (such as volume control, etc..), my app start allowing to take a screenshot.
I found this related question and one person mentioned that if I use Crosswalk, I need to modify PrivacyScreenPlugin/Crosswalk.
Here is what I tried:
In Crosswalk WebView plugin, XwalkWebViewEngine#init method.
cordova.getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
However, above code wasn't fix my issue.
And, I couldn't find a place to modify in PrivacyScreenPlugin.
I'm using following Android versions and plugins:
Any comment would be appreciated.
Upvotes: 2
Views: 1437
Reputation: 20512
This workaround worked for me. It basically digs to the SurfaceView that XWalkView creates and makes it secure:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
((SurfaceView)((FrameLayout)((FrameLayout) mXWalkView.getChildAt(0)).getChildAt(0)).getChildAt(0)).setSecure(true);
}
Looks ugly but worked like a charm.
Upvotes: 0