diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2013-08-11 12:29:39 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2013-08-11 14:40:05 -0700 |
commit | 798bed6cc7d273e72b0253288605db9cd2b57740 (patch) | |
tree | b4278847c40cf910b69773c6205395ada02543ed /packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java | |
parent | 5893a97cbf398ca3e1bff5444454343d94e25a4c (diff) | |
download | frameworks_base-798bed6cc7d273e72b0253288605db9cd2b57740.zip frameworks_base-798bed6cc7d273e72b0253288605db9cd2b57740.tar.gz frameworks_base-798bed6cc7d273e72b0253288605db9cd2b57740.tar.bz2 |
Refinement of the print service APIs.
1. Factored out the printer discovery APIs of a print service in a
dedicated session object that is created by the print service on
demand. This ensures that added/removed/updated printers from
one session do not interfere with another session.
2. Updated the app facing APIs to pass in a document info along
with a printed file. Also exposed the print file adapter so
apps that create a temporary file for printing can intercept
when it is read by the system so the file can be deleted.
3. Updated the print service documentation.
Change-Id: I3473d586c26d8bda1cf7e2bdacb441aa9df982ed
Diffstat (limited to 'packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java')
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java b/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java index e5153e7..4fab4f8 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java +++ b/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java @@ -32,10 +32,9 @@ import android.print.IPrintDocumentAdapter; import android.print.IPrintSpooler; import android.print.IPrintSpoolerCallbacks; import android.print.IPrintSpoolerClient; -import android.print.IPrinterDiscoveryObserver; +import android.print.IPrinterDiscoverySessionObserver; import android.print.PrintAttributes; import android.print.PrintJobInfo; -import android.print.PrinterId; import android.util.Log; import android.util.Slog; @@ -167,20 +166,11 @@ public final class PrintSpoolerService extends Service { printJob).sendToTarget(); } - public void onReqeustUpdatePrinters(List<PrinterId> printers) { - mHandler.obtainMessage(MyHandler.MSG_ON_REQUEST_UPDATE_PRINTERS, - printers).sendToTarget(); - } - - public void startPrinterDiscovery(IPrinterDiscoveryObserver observer) { - mHandler.obtainMessage(MyHandler.MSG_ON_START_PRINTER_DISCOVERY, + public void createPrinterDiscoverySession(IPrinterDiscoverySessionObserver observer) { + mHandler.obtainMessage(MyHandler.MSG_CREATE_PRINTER_DISCOVERY_SESSION, observer).sendToTarget(); } - public void stopPrinterDiscovery() { - mHandler.sendEmptyMessage(MyHandler.MSG_ON_STOP_PRINTER_DISCOVERY); - } - public void onAllPrintJobsForServiceHandled(ComponentName service) { mHandler.obtainMessage(MyHandler.MSG_ON_ALL_PRINT_JOBS_FOR_SERIVICE_HANDLED, service).sendToTarget(); @@ -193,12 +183,10 @@ public final class PrintSpoolerService extends Service { private final class MyHandler extends Handler { public static final int MSG_SET_CLIENT = 1; public static final int MSG_START_PRINT_JOB_CONFIG_ACTIVITY = 2; - public static final int MSG_ON_START_PRINTER_DISCOVERY = 3; - public static final int MSG_ON_STOP_PRINTER_DISCOVERY = 4; + public static final int MSG_CREATE_PRINTER_DISCOVERY_SESSION = 3; public static final int MSG_ON_PRINT_JOB_QUEUED = 5; public static final int MSG_ON_ALL_PRINT_JOBS_FOR_SERIVICE_HANDLED = 6; public static final int MSG_ON_ALL_PRINT_JOBS_HANDLED = 7; - public static final int MSG_ON_REQUEST_UPDATE_PRINTERS = 8; public static final int MSG_CHECK_ALL_PRINTJOBS_HANDLED = 9; public MyHandler(Looper looper) { @@ -206,7 +194,6 @@ public final class PrintSpoolerService extends Service { } @Override - @SuppressWarnings("unchecked") public void handleMessage(Message message) { switch (message.what) { case MSG_SET_CLIENT: { @@ -233,23 +220,14 @@ public final class PrintSpoolerService extends Service { } } break; - case MSG_ON_START_PRINTER_DISCOVERY: { - IPrinterDiscoveryObserver observer = (IPrinterDiscoveryObserver) message.obj; - if (mClient != null) { - try { - mClient.onStartPrinterDiscovery(observer); - } catch (RemoteException re) { - Log.e(LOG_TAG, "Error notifying start printer discovery.", re); - } - } - } break; - - case MSG_ON_STOP_PRINTER_DISCOVERY: { + case MSG_CREATE_PRINTER_DISCOVERY_SESSION: { + IPrinterDiscoverySessionObserver observer = + (IPrinterDiscoverySessionObserver) message.obj; if (mClient != null) { try { - mClient.onStopPrinterDiscovery(); + mClient.createPrinterDiscoverySession(observer); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error notifying stop printer discovery.", re); + Log.e(LOG_TAG, "Error creating printer discovery session.", re); } } } break; @@ -287,17 +265,6 @@ public final class PrintSpoolerService extends Service { } } break; - case MSG_ON_REQUEST_UPDATE_PRINTERS: { - List<PrinterId> printerIds = (List<PrinterId>) message.obj; - if (mClient != null) { - try { - mClient.onRequestUpdatePrinters(printerIds); - } catch (RemoteException re) { - Slog.e(LOG_TAG, "Error requesting to update pritners.", re); - } - } - } break; - case MSG_CHECK_ALL_PRINTJOBS_HANDLED: { PrintSpooler spooler = PrintSpooler.peekInstance(); if (spooler != null) { |