Printers for a disappearing print serivce incorrectly removed.
The code that removes printers for a disappearing print serivice was
using printer infos instead printer ids and also wrong map methods.
bug:10651739
Change-Id: Idb9ccdaad9a59b3b6d16b079b33afad56bc45255
diff --git a/core/java/android/print/IPrinterDiscoveryObserver.aidl b/core/java/android/print/IPrinterDiscoveryObserver.aidl
index 71198f7..b558011 100644
--- a/core/java/android/print/IPrinterDiscoveryObserver.aidl
+++ b/core/java/android/print/IPrinterDiscoveryObserver.aidl
@@ -16,7 +16,6 @@
package android.print;
-import android.print.IPrintClient;
import android.print.PrinterId;
import android.print.PrinterInfo;
diff --git a/services/java/com/android/server/print/UserState.java b/services/java/com/android/server/print/UserState.java
index 8fe979b..b37a0d9 100644
--- a/services/java/com/android/server/print/UserState.java
+++ b/services/java/com/android/server/print/UserState.java
@@ -779,21 +779,21 @@
return;
}
// Remove the printers for that service.
- List<PrinterInfo> removedPrinters = null;
+ List<PrinterId> removedPrinterIds = null;
final int printerCount = mPrinters.size();
for (int i = 0; i < printerCount; i++) {
- PrinterInfo printer = mPrinters.get(i);
- if (printer.getId().getServiceName().equals(serviceName)) {
- if (removedPrinters == null) {
- removedPrinters = new ArrayList<PrinterInfo>();
+ PrinterId printerId = mPrinters.keyAt(i);
+ if (printerId.getServiceName().equals(serviceName)) {
+ if (removedPrinterIds == null) {
+ removedPrinterIds = new ArrayList<PrinterId>();
}
- removedPrinters.add(printer);
+ removedPrinterIds.add(printerId);
}
}
- if (!removedPrinters.isEmpty()) {
+ if (!removedPrinterIds.isEmpty()) {
mHandler.obtainMessage(
SessionHandler.MSG_DISPATCH_PRINTERS_REMOVED,
- removedPrinters).sendToTarget();
+ removedPrinterIds).sendToTarget();
}
}