summaryrefslogtreecommitdiffstats
path: root/core/java/android/print
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2013-09-28 12:09:23 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2013-09-28 12:09:29 -0700
commitcfab2457f2c140a2356bb45ec25f51a0a5866556 (patch)
tree84b0c719b25746df0157573a398c2f706415d19f /core/java/android/print
parentc6568719671206e726f260fad390680f7fb0ee9e (diff)
downloadframeworks_base-cfab2457f2c140a2356bb45ec25f51a0a5866556.zip
frameworks_base-cfab2457f2c140a2356bb45ec25f51a0a5866556.tar.gz
frameworks_base-cfab2457f2c140a2356bb45ec25f51a0a5866556.tar.bz2
Printers in the list of printers change position.
While the logic was correct the array map that holds the list of pritners does not keep the position of the items constant. Switched to linked hash map which gives this guarantee. bug:10955751 Change-Id: Idbbe14d753e6a1ad1002f2289b10cb62d7f9f040
Diffstat (limited to 'core/java/android/print')
-rw-r--r--core/java/android/print/PrinterDiscoverySession.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/core/java/android/print/PrinterDiscoverySession.java b/core/java/android/print/PrinterDiscoverySession.java
index 6432a37..d32b71b 100644
--- a/core/java/android/print/PrinterDiscoverySession.java
+++ b/core/java/android/print/PrinterDiscoverySession.java
@@ -28,6 +28,7 @@ import android.util.Log;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.List;
/**
@@ -40,8 +41,8 @@ public final class PrinterDiscoverySession {
private static final int MSG_PRINTERS_ADDED = 1;
private static final int MSG_PRINTERS_REMOVED = 2;
- private final ArrayMap<PrinterId, PrinterInfo> mPrinters =
- new ArrayMap<PrinterId, PrinterInfo>();
+ private final LinkedHashMap<PrinterId, PrinterInfo> mPrinters =
+ new LinkedHashMap<PrinterId, PrinterInfo>();
private final IPrintManager mPrintManager;
@@ -218,9 +219,7 @@ public final class PrinterDiscoverySession {
}
// Update printers we already have.
- final int oldPrinterCount = mPrinters.size();
- for (int i = 0; i < oldPrinterCount; i++) {
- PrinterId oldPrinterId = mPrinters.keyAt(i);
+ for (PrinterId oldPrinterId : mPrinters.keySet()) {
PrinterInfo updatedPrinter = addedPrintersMap.remove(oldPrinterId);
if (updatedPrinter != null) {
mPrinters.put(oldPrinterId, updatedPrinter);