Monday, May 7, 2018

The History of Printing on Android and how the Mopria Alliance made it better

Prior to the debut of Android 8.0 Oreo's Default Print Service, printing documents on Android was easier said than done. Google's mobile operating system didn't gain native printer support until Android 4.4 KitKat, and with the exception of third-party solutions from the likes of Samsung, setting up a printer required vendor-specific plugins and drivers. But thanks to the Mopria Alliance, a consortium of smartphone and printer manufacturers, Android's compatibility with printers has improved by leaps and bounds. Android Oreo supports an astounding 97 percent of the printers on the market—over 100 million—plus features such as duplex printing, Wi-Fi Direct printing, orientation, and paper size adjustment.

But just what does the Mopria Alliance have to do with mobile printing, and what's in store for future versions of Android? Here's a brief history of the Android print framework, and a preview of improvements in the pipeline.

Printing on Android with Android 4.4 KitKat

Android KitKat print menu.

Early versions of Android didn't natively support printing. Printing a document, image, or anything else from a pre-KitKat Android smartphone or tablet required downloading a third-party tool such as Google Cloud Print, pulling up the document in another app, and using Android's Share menu to pass it to the aforementioned tool. Needless to say, it wasn't an elegant solution—especially compared to Apple's AirPrint and other up-and-coming competitors.

Android's printer service needed a makeover, and Google got around to it in 2013. Android 4.4 KitKat marked the debut of APIs for managing printers and a native Android printing platform. The nascent Android Print Framework had a UI with drop-down menus for printer and page selection, and a print manager that passed printing requests from apps to available printer services.

Printer manufacturers weren't constricted to the new print manager, of course. They could use the APIs to develop their own print services and distribute them through Google Play, and many did, including HP, Canon, Epson, and Brother. App developers, meanwhile, had the freedom to add print actions to apps or implement the new print APIs to create, cancel, and check the status of ongoing print jobs.

Here's how Android's print stack worked back then (and how it still works today, largely): When a user fired off a print job from within an app, the app made API calls to the Android Print Framework, which in turn made calls to a print service. (One of those API calls was to Google's PDF renderer, which generated a paginated PDF version of the file to be printed.) The print service then completed a handshake with the printer, which began the printing process.

Unfortunately, KitKat's new printing platform was the very definition of bare bones. Android 5.0 Lollipop improved on it with a Material Design-inspired menu with a print preview and drop-down selectors for paper size, color, orientation, and page range. And Android 7.0 Nougat brought with it new API calls that surfaced the status of print jobs, allowing apps to display indicators of printing progress. (In previous versions of Android, it wasn't immediately apparent.) But Android's print stack didn't come into its own until Oreo.

Improvements in printing on Android 8.0 Oreo thanks to the Mopria Alliance

The Mopria Alliance, a global non-profit mobile printing standards body, might not have much in the way of brand recognition, but it's hardly the new kid on the block. In the five years since its founding, it has recruited printer and productivity heavyweights including Adobe, Konica Minolta, Qualcomm, Lexmark, Kyocera, Dell, and Toshiba, all of which have committed to supporting core printing technologies, features, and services across mobile devices.

Brent Richtsmeier, chairman of the Mopria Alliance Steering Committee, told XDA-Developers that Mopria's technology is installed on over 750 million devices different mobile devices, and that it delivers 1.4 million pages to printers every day. "As the world becomes more connected […] it's very clear that everything is interconnected and more mobile, but people still need to print," Mr. Richtsmeier said.

To that end, Mopria teamed up with Android OEMs such as Samsung—a founding member of the Mopria Alliance—ZTE, Huawei, and Amazon to ship tablets and smartphones with the Mopria Print Library (MLP), Mopria's suite of developer tools. One fruit of its labor is the Samsung Print Service, a mobile printing tool for the Android Print Framework that comes pre-installed on the Samsung Galaxy S4, S5, S6, S7, S8, and S9. (Mr. Richtsmeier says that it has approximately 400 million monthly active users.) Another is ZTE's Axon 7 and Axon 7 Max, which shipped in China preloaded with the Mopria Print Service.

Simultaneously, Mopria embarked on a collaboration with Google to merge its technologies with the Android Open Source Project (AOSP) codebase. In the years following the release of KitKat, it contributed thousands of lines of code culminating in Android Oreo's new and improved Default Print Service.

The Default Print Service in Android 8.0 Oreo supports standard print settings such as color adjustment, media type selection, and copying. It's free and easy to use, but also doesn't preclude developers from creating their own Mopria-certified products.

Going the custom route is relatively easy, according to Mr. Richtsmeier. Joining the Mopria Alliance is the first step—a small licensing fee's involved. Then, developers have a couple of options: (1) Compile the Mopria Library with their own code, (2) use the codebase that Mopria licenses to all members of the Mopria Alliance, or (3) use Mopria's existing AOSP code to write a custom solution.

Once the code is in place, next comes the testing. Mopria Alliance members have access to toolsets for compliance testing, including automated device-specific and printer tests. Once the necessary tests have been run and the data collected, the results must be sent off to a Mopria engineer, who reviews them to ensure that the code behaves as expected and checks all the necessary boxes. If all goes well, the app's deemed Mopria-certified.

The Future of Printing on Android

Android's printing platform has come a long way since the pre-KitKat era, when janky workarounds (usually involving the Share menu) were the only way to print something—short of transferring files to a printer-connected PC, of course.

That said, Android Oreo's Default Print Service conspicuously lacks enterprise features such as punching, folding, stapling, PIN authentication, or accounting features. It also doesn't support "share to print"—there's no easy way to print something from Android's Share menu. (Mr. Richtsmeier blames the latter problem with a bug in Android's WebView class a year ago, which delayed implementation.)

Android Printing Mopria

Feature difference between Android Oreo's Default Print Service and the Mopria app. Source: Mopria.

Third-party print services such as Mopria's own standalone Mopria Print Service, which is available for free from the Google Play Store, help to fill the functionality gap, adding features such as input tray selection, Bluetooth printing, ad hoc Wi-Fi printing, and direct USB-OTG printing. But that's not much consolation for users in countries with spotty internet infrastructure, or where the Google Play Store isn't available.

Mopria Print Service (Free, Google Play) →

Signs of improvement are on the horizon, thankfully, as Android P will be bridging the feature gap somewhat.

Several commits in the Android Gerrit submitted late last year by Mopria developers point to support for IPPS-only printers. IPPS is an HTTPS-based secure implementation of the Internet Printing Protocol (IPP) that allows apps to send print jobs, query print job status, and more with internet-connected printers.

And in January, Mopria developers began laying the groundwork for another nice-to-have: Wi-Fi Direct printing. Currently, the Default Print Service on Android supports only local wireless infrastructure connections through a router or hotspot, but new commits add support for connections directly between Android smartphones and tablets and Wi-Fi Direct-compatible printers. With Wi-Fi Direct, there's no pairing required, and unlike Wi-Fi hotspots, some printers don't even require a password.

Mr. Richtsmeier said that Mopria developers have also supplied code for manually adding printers.

"There have been studies done that show that eighty percent of millennials, who make up the majority of the workforce, do their jobs with mobile technology, but that only 33 percent of them say that those mobile technologies are meeting their needs," Mr. Richtsmeier said, "and printing is something people look at as a key thing that happens in the office. Mopria is trying to fill that gap [and] meet [those] needs."

from xda-developers