The Privacy Screen Plugin for Cordova / PhoneGap
Today I made a thing. The Privacy Screen Plugin.
Some backstory: both iOS (as of iOS 7) and Android have app switchers that display a screenshot of your app. This is a lovely feature for most apps, but if your app displays sensitive information, this is a possible privacy risk.
My apps using the "Zero-knowledge" JavaScript library Crypton, as well as those for my primary day-job at SpiderOak, are privacy focussed. This means that we treat data displayed in these apps as sensitive and... well... private. Therefore, I had tried many times, quite unsuccessfully, to "black out" my apps when displayed in these "app switchers" on iOS and Android.
The problem was that I was trying to do this using variations on the pause and resume events available in Cordova / PhoneGap. These events can be very handy, and I already use them for other purposes, but for this use case they don't fire fast or early enough. The screenshots of my apps were getting taken before any DOM changes I might make in the pause event occured. I had basically given up on this thinking that a cross-platform plugin to do this would be way too big of a pain.
It came up again in conversation with SpiderOak's "security guy" Tomâs Touceda, and I decided to take the plunge and see how hard it would be. I had grand plans of covering the screen with an all black native view or something. I knew how to do that in iOS, assuming I could hook into the native applicationWillResignActive or similar. The issue was Android, of course. My native Android dev skills are way weaker than my Objective-C and iOS, particularly in the area of LayoutManagers and other view stuff.
Luckily, after about 15 minutes of ye olde Googling, I found FLAG_SECURE!
Well, between that and a recent Cordova dev email thread mentioning method swizzling (omg, that term... pfah!), I had a real idea for how to get started. I also found a great StackOverflow post that suggested just hiding the window.
I don't like having to use plugins, but I really enjoy writing them, strangely. So a couple of hours later, I had a real working plugin on two platforms.
Have a look, raise an issue, or fork away here: https://github.com/devgeeks/PrivacyScreenPlugin.










