Don't fire 'changed' event if printer list is not updated

The printer list is tried to be updated when the network is changed
but the 'changed' event was fired even if the printer list is not
changed at all.

This CL suppresses events if the list is not changed.

Bug: 132840441
Test: run 'cts-tradefed run commandAndExit cts-dev --module
    CtsPrintTestCases --test android.print.cts.
    PrintDocumentAdapterContractTest#unexpectedLayoutCancel' 30 times
Change-Id: I9236e56ea9e19e37be29d6a1d0015ee0b2676460
This commit is contained in:
yoshiki iguchi
2019-05-22 11:32:46 +09:00
committed by Yoshiki Iguchi
parent 0f097d0dfa
commit 4465f55d92

View File

@@ -232,6 +232,11 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>>
// Add the new printers, i.e. what is left.
printers.addAll(discoveredPrinters.values());
// Do nothing if the printer list is not changed.
if (Objects.equals(mPrinters, printers)) {
return;
}
// Update the list of printers.
mPrinters.clear();
mPrinters.addAll(printers);