@Test public void testMergeSpecs() { Uri uri = Uri.parse("content: assertEquals(Collections.emptySet(), mCompatPinnedList.getSpecs(uri)); mCompatPinnedList.addPin(uri, "my_pkg", new ArraySet<>(Arrays.asList(FIRST_SPECS))); assertSetEquals(new ArraySet<>(Arrays.asList(FIRST_SPECS)), mCompatPinnedList.getSpecs(uri)); mCompatPinnedList.addPin(uri, "my_pkg2", new ArraySet<>(Arrays.asList(SECOND_SPECS))); assertSetEquals(new ArraySet<>(Arrays.asList(new SliceSpec[]{ new SliceSpec("spec2", 1), new SliceSpec("spec3", 2), new SliceSpec("spec4", 1), })), mCompatPinnedList.getSpecs(uri)); }
private static ArraySet<SliceSpec> mergeSpecs(ArraySet<SliceSpec> specs, Set<SliceSpec> supportedSpecs) { for (int i = 0; i < specs.size(); i++) { SliceSpec s = specs.valueAt(i); SliceSpec other = findSpec(supportedSpecs, s.getType()); if (other == null) { specs.removeAt(i--); } else if (other.getRevision() < s.getRevision()) { specs.removeAt(i--); specs.add(other); } } return specs; }
CompatPinnedList { private static ArraySet<SliceSpec> mergeSpecs(ArraySet<SliceSpec> specs, Set<SliceSpec> supportedSpecs) { for (int i = 0; i < specs.size(); i++) { SliceSpec s = specs.valueAt(i); SliceSpec other = findSpec(supportedSpecs, s.getType()); if (other == null) { specs.removeAt(i--); } else if (other.getRevision() < s.getRevision()) { specs.removeAt(i--); specs.add(other); } } return specs; } }
CompatPinnedList { private static ArraySet<SliceSpec> mergeSpecs(ArraySet<SliceSpec> specs, Set<SliceSpec> supportedSpecs) { for (int i = 0; i < specs.size(); i++) { SliceSpec s = specs.valueAt(i); SliceSpec other = findSpec(supportedSpecs, s.getType()); if (other == null) { specs.removeAt(i--); } else if (other.getRevision() < s.getRevision()) { specs.removeAt(i--); specs.add(other); } } return specs; } CompatPinnedList(Context context, String prefsName); }
CompatPinnedList { private static ArraySet<SliceSpec> mergeSpecs(ArraySet<SliceSpec> specs, Set<SliceSpec> supportedSpecs) { for (int i = 0; i < specs.size(); i++) { SliceSpec s = specs.valueAt(i); SliceSpec other = findSpec(supportedSpecs, s.getType()); if (other == null) { specs.removeAt(i--); } else if (other.getRevision() < s.getRevision()) { specs.removeAt(i--); specs.add(other); } } return specs; } CompatPinnedList(Context context, String prefsName); List<Uri> getPinnedSlices(); synchronized ArraySet<SliceSpec> getSpecs(Uri uri); synchronized boolean addPin(Uri uri, String pkg, Set<SliceSpec> specs); synchronized boolean removePin(Uri uri, String pkg); }
CompatPinnedList { private static ArraySet<SliceSpec> mergeSpecs(ArraySet<SliceSpec> specs, Set<SliceSpec> supportedSpecs) { for (int i = 0; i < specs.size(); i++) { SliceSpec s = specs.valueAt(i); SliceSpec other = findSpec(supportedSpecs, s.getType()); if (other == null) { specs.removeAt(i--); } else if (other.getRevision() < s.getRevision()) { specs.removeAt(i--); specs.add(other); } } return specs; } CompatPinnedList(Context context, String prefsName); List<Uri> getPinnedSlices(); synchronized ArraySet<SliceSpec> getSpecs(Uri uri); synchronized boolean addPin(Uri uri, String pkg, Set<SliceSpec> specs); synchronized boolean removePin(Uri uri, String pkg);  }