aboutsummaryrefslogtreecommitdiff
path: root/car-lib
diff options
context:
space:
mode:
authorAsaf Rosenfeld <asafro@google.com>2017-06-30 18:20:08 -0700
committerAsaf Rosenfeld <asafro@google.com>2017-07-05 22:38:41 -0700
commitf9be20bbf15014d1d6ad58a21304fb8fdaa06b6d (patch)
tree8fc383d2315de7331a2f200ed0e4053354625e27 /car-lib
parentf91b5eaf2231a61689127d2b887894cde21f6110 (diff)
downloadCar-f9be20bbf15014d1d6ad58a21304fb8fdaa06b6d.tar.gz
Updating Routing and subscription state to support subscription to layer from specific publisher
Test: Added tests and all tests pass Change-Id: Ic914f67f2281eb2a1d90512c5c80d5a63a159446
Diffstat (limited to 'car-lib')
-rw-r--r--car-lib/src/android/car/vms/VmsSubscriptionState.java57
1 files changed, 41 insertions, 16 deletions
diff --git a/car-lib/src/android/car/vms/VmsSubscriptionState.java b/car-lib/src/android/car/vms/VmsSubscriptionState.java
index 0e36fb1f30..0e7e4fab51 100644
--- a/car-lib/src/android/car/vms/VmsSubscriptionState.java
+++ b/car-lib/src/android/car/vms/VmsSubscriptionState.java
@@ -19,9 +19,13 @@ package android.car.vms;
import android.car.annotation.FutureFeature;
import android.os.Parcel;
import android.os.Parcelable;
+
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+
/**
* The list of layers with subscribers.
@@ -31,30 +35,44 @@ import java.util.List;
@FutureFeature
public final class VmsSubscriptionState implements Parcelable {
private final int mSequenceNumber;
- private final List<VmsLayer> mLayers;
+ private final Set<VmsLayer> mLayers;
+ private final Set<VmsAssociatedLayer> mSubscribedLayersFromPublishers;
/**
- * Construct a dependency for layer on other layers.
+ * Construcs a summary of the state of the current subscriptions for publishers to consume
+ * and adjust which layers that the are publishing.
*/
- public VmsSubscriptionState(int sequenceNumber, List<VmsLayer> dependencies) {
+ public VmsSubscriptionState(int sequenceNumber,
+ Set<VmsLayer> subscribedLayers,
+ Set<VmsAssociatedLayer> layersFromPublishers) {
mSequenceNumber = sequenceNumber;
- mLayers = Collections.unmodifiableList(dependencies);
+ mLayers = Collections.unmodifiableSet(subscribedLayers);
+ mSubscribedLayersFromPublishers = Collections.unmodifiableSet(layersFromPublishers);
}
public int getSequenceNumber() {
return mSequenceNumber;
}
- public List<VmsLayer> getLayers() {
+ public Set<VmsLayer> getSubscribedLayersFromAll() {
return mLayers;
}
+ public Set<VmsAssociatedLayer> getSubscribedLayersFromPublishers() {
+ return mSubscribedLayersFromPublishers;
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("sequence number=").append(mSequenceNumber);
sb.append("; layers={");
- for(VmsLayer layer : mLayers) {
+ for (VmsLayer layer : mLayers) {
+ sb.append(layer).append(",");
+ }
+ sb.append("}");
+ sb.append("; associatedLayers={");
+ for (VmsAssociatedLayer layer : mSubscribedLayersFromPublishers) {
sb.append(layer).append(",");
}
sb.append("}");
@@ -62,19 +80,21 @@ public final class VmsSubscriptionState implements Parcelable {
}
public static final Parcelable.Creator<VmsSubscriptionState> CREATOR = new
- Parcelable.Creator<VmsSubscriptionState>() {
- public VmsSubscriptionState createFromParcel(Parcel in) {
- return new VmsSubscriptionState(in);
- }
- public VmsSubscriptionState[] newArray(int size) {
- return new VmsSubscriptionState[size];
- }
- };
+ Parcelable.Creator<VmsSubscriptionState>() {
+ public VmsSubscriptionState createFromParcel(Parcel in) {
+ return new VmsSubscriptionState(in);
+ }
+
+ public VmsSubscriptionState[] newArray(int size) {
+ return new VmsSubscriptionState[size];
+ }
+ };
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mSequenceNumber);
- out.writeParcelableList(mLayers, flags);
+ out.writeParcelableList(new ArrayList(mLayers), flags);
+ out.writeParcelableList(new ArrayList(mSubscribedLayersFromPublishers), flags);
}
@Override
@@ -84,8 +104,13 @@ public final class VmsSubscriptionState implements Parcelable {
private VmsSubscriptionState(Parcel in) {
mSequenceNumber = in.readInt();
+
List<VmsLayer> layers = new ArrayList<>();
in.readParcelableList(layers, VmsLayer.class.getClassLoader());
- mLayers = Collections.unmodifiableList(layers);
+ mLayers = Collections.unmodifiableSet(new HashSet(layers));
+
+ List<VmsAssociatedLayer> associatedLayers = new ArrayList<>();
+ in.readParcelableList(associatedLayers, VmsAssociatedLayer.class.getClassLoader());
+ mSubscribedLayersFromPublishers = Collections.unmodifiableSet(new HashSet(associatedLayers));
}
} \ No newline at end of file