summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/print/UserState.java
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2013-09-23 18:48:34 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2013-09-23 23:41:12 -0700
commitb5f180608db6de123b54ae94de569ff1ebca705c (patch)
treea6e8f452458e30c3cf86d942131185c44cdc6e19 /services/java/com/android/server/print/UserState.java
parent89e1fec9af78b94cbafc21fe22a69213ae31a6fa (diff)
Multiple printer discovery session instances and other bugs.
1. The fused printers provider was dropping on the floor received printers if it was not active. It is in fact a loaded and if not active it should compute the printers and not deliver them until activated. This fixes an issue where opening the print dialog, then enabling a print service results in the printers reported by the service not showing up in the print dialog. 2. Printer discovery session was created twice which leads to incorrect behavior as the pint system is designed around the contract that there is a single printer discovery session per service at a time. This was possible due to an incorrect initialization of a member variable resulting in double session creation when the print service is connected. 3. When a print service is enabled during discovery we did not use the correct condition to start printer discovery resulting in starting it all the time even if not needed. Also if some of the printers that had to be tracked are reported by the service just enabled (typically historical printers) we did not ask the service to start tracking them. 4. Removed some logging. bug:10903343 Change-Id: I46c049471a4b099fc668df3aee2aaedc8d7786ac
Diffstat (limited to 'services/java/com/android/server/print/UserState.java')
-rw-r--r--services/java/com/android/server/print/UserState.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/services/java/com/android/server/print/UserState.java b/services/java/com/android/server/print/UserState.java
index fd4a3a48dbd8..8c2182732cea 100644
--- a/services/java/com/android/server/print/UserState.java
+++ b/services/java/com/android/server/print/UserState.java
@@ -1007,12 +1007,25 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks {
mHandler.obtainMessage(
SessionHandler.MSG_CREATE_PRINTER_DISCOVERY_SESSION,
service).sendToTarget();
- // If there are some observers that started discovery - tell the service.
- if (mDiscoveryObservers.getRegisteredCallbackCount() > 0) {
+ // Start printer discovery if necessary.
+ if (!mStartedPrinterDiscoveryTokens.isEmpty()) {
mHandler.obtainMessage(
SessionHandler.MSG_START_PRINTER_DISCOVERY,
service).sendToTarget();
}
+ // Start tracking printers if necessary
+ final int trackedPrinterCount = mStateTrackedPrinters.size();
+ for (int i = 0; i < trackedPrinterCount; i++) {
+ PrinterId printerId = mStateTrackedPrinters.get(i);
+ if (printerId.getServiceName().equals(service.getComponentName())) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = service;
+ args.arg2 = printerId;
+ mHandler.obtainMessage(SessionHandler
+ .MSG_START_PRINTER_STATE_TRACKING, args)
+ .sendToTarget();
+ }
+ }
}
public void dump(PrintWriter pw, String prefix) {