Refactor how the print dialog activity is started.

1. Before the print job activity was started asyncronously with
   respect to the print call on to the print manager. This was
   creating a situation where the starting activity may finish
   before the print dialog appears which may lead to an orphaned
   print document adapter with no data to print (as the UI is
   is gone), or strange behaviors where the print dialog starts
   on as a separate task.

   To address this the pending intent for starting the print
   dialog is not started by the print spooler since we cannot
   call into it synchronously as we have to start its process
   and bind to the spooler service which leads to jankyness in
   the client app. Now the pending intent is created by the
   print manager service in the synchronous print call so
   from an app's perspective calling print starts the activity.

   The side effect of this design is that the print dialog
   activity may start before the system is bound to the spooler
   service. In such a case the print activity cannot start
   poking the print spooler state as the system registers
   callback to observe the spooler state. To address this
   the print spooler activity disables the UI and also binds
   to the spooler service which happenes immediately after it
   is started. As soon as the print dialog binds to the
   service it starts the UI.

2. Fixed an bug in the printer adapter of the print dialog that
   was leading to a crash if the only item in the adater is the
   all pritners option and it is selected.

3. Piping the package name that started the printing so we can
   pass it to the storage UI as a hint to open the last location
   the app used.

bug:11127269

Change-Id: Ia93820bdae0b0e7600a0930b1f10d9708bd86b68
diff --git a/packages/PrintSpooler/AndroidManifest.xml b/packages/PrintSpooler/AndroidManifest.xml
index 1e6954e..7eea3e9 100644
--- a/packages/PrintSpooler/AndroidManifest.xml
+++ b/packages/PrintSpooler/AndroidManifest.xml
@@ -58,8 +58,13 @@
         <activity
             android:name=".PrintJobConfigActivity"
             android:configChanges="orientation|screenSize"
-            android:exported="false"
+            android:permission="android.permission.BIND_PRINT_SPOOLER_SERVICE"
             android:theme="@style/PrintJobConfigActivityTheme">
+            <intent-filter>
+                <action android:name="android.print.PRINT_DILAOG" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="printjob" android:pathPattern="*" />
+            </intent-filter>
         </activity>
 
         <activity