• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.car.vms;
18 
19 import android.annotation.SystemApi;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 
24 import java.util.Set;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.HashSet;
28 import java.util.Collections;
29 
30 import java.util.Objects;
31 
32 /**
33  * VMS Layers that can be subscribed to by VMS clients.
34  *
35  * @hide
36  */
37 @SystemApi
38 public final class VmsAvailableLayers implements Parcelable {
39 
40     // A sequence number.
41     private final int mSeq;
42 
43     // The list of AssociatedLayers
44     private final Set<VmsAssociatedLayer> mAssociatedLayers;
45 
VmsAvailableLayers(Set<VmsAssociatedLayer> associatedLayers, int sequence)46     public VmsAvailableLayers(Set<VmsAssociatedLayer> associatedLayers, int sequence) {
47         mSeq = sequence;
48 
49         mAssociatedLayers = Collections.unmodifiableSet(associatedLayers);
50     }
51 
getSequence()52     public int getSequence() {
53         return mSeq;
54     }
55 
getAssociatedLayers()56     public Set<VmsAssociatedLayer> getAssociatedLayers() {
57         return mAssociatedLayers;
58     }
59 
60     @Override
toString()61     public String toString() {
62         return "VmsAvailableLayers{ seq: " +
63                 mSeq +
64                 ", AssociatedLayers: " +
65                 mAssociatedLayers +
66                 "}";
67     }
68 
69 
70     // Parcelable related methods.
71     public static final Parcelable.Creator<VmsAvailableLayers> CREATOR = new
72             Parcelable.Creator<VmsAvailableLayers>() {
73                 public VmsAvailableLayers createFromParcel(Parcel in) {
74                     return new VmsAvailableLayers(in);
75                 }
76 
77                 public VmsAvailableLayers[] newArray(int size) {
78                     return new VmsAvailableLayers[size];
79                 }
80             };
81 
82     @Override
writeToParcel(Parcel out, int flags)83     public void writeToParcel(Parcel out, int flags) {
84         out.writeInt(mSeq);
85         out.writeParcelableList(new ArrayList(mAssociatedLayers), flags);
86     }
87 
88     @Override
equals(Object o)89     public boolean equals(Object o) {
90         if (!(o instanceof VmsAvailableLayers)) {
91             return false;
92         }
93         VmsAvailableLayers p = (VmsAvailableLayers) o;
94         return Objects.equals(p.mAssociatedLayers, mAssociatedLayers) &&
95                 p.mSeq == mSeq;
96     }
97 
98     @Override
describeContents()99     public int describeContents() {
100         return 0;
101     }
102 
VmsAvailableLayers(Parcel in)103     private VmsAvailableLayers(Parcel in) {
104         mSeq = in.readInt();
105 
106         List<VmsAssociatedLayer> associatedLayers = new ArrayList<>();
107         in.readParcelableList(associatedLayers, VmsAssociatedLayer.class.getClassLoader());
108         mAssociatedLayers = Collections.unmodifiableSet(new HashSet(associatedLayers));
109     }
110 }