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.car.annotation.FutureFeature; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 import java.util.ArrayList; 23 import java.util.Collections; 24 import java.util.List; 25 26 /** 27 * The list of layers with subscribers. 28 * 29 * @hide 30 */ 31 @FutureFeature 32 public final class VmsSubscriptionState implements Parcelable { 33 private final int mSequenceNumber; 34 private final List<VmsLayer> mLayers; 35 36 /** 37 * Construct a dependency for layer on other layers. 38 */ VmsSubscriptionState(int sequenceNumber, List<VmsLayer> dependencies)39 public VmsSubscriptionState(int sequenceNumber, List<VmsLayer> dependencies) { 40 mSequenceNumber = sequenceNumber; 41 mLayers = Collections.unmodifiableList(dependencies); 42 } 43 getSequenceNumber()44 public int getSequenceNumber() { 45 return mSequenceNumber; 46 } 47 getLayers()48 public List<VmsLayer> getLayers() { 49 return mLayers; 50 } 51 52 @Override toString()53 public String toString() { 54 StringBuilder sb = new StringBuilder(); 55 sb.append("sequence number=").append(mSequenceNumber); 56 sb.append("; layers={"); 57 for(VmsLayer layer : mLayers) { 58 sb.append(layer).append(","); 59 } 60 sb.append("}"); 61 return sb.toString(); 62 } 63 64 public static final Parcelable.Creator<VmsSubscriptionState> CREATOR = new 65 Parcelable.Creator<VmsSubscriptionState>() { 66 public VmsSubscriptionState createFromParcel(Parcel in) { 67 return new VmsSubscriptionState(in); 68 } 69 public VmsSubscriptionState[] newArray(int size) { 70 return new VmsSubscriptionState[size]; 71 } 72 }; 73 74 @Override writeToParcel(Parcel out, int flags)75 public void writeToParcel(Parcel out, int flags) { 76 out.writeInt(mSequenceNumber); 77 out.writeParcelableList(mLayers, flags); 78 } 79 80 @Override describeContents()81 public int describeContents() { 82 return 0; 83 } 84 VmsSubscriptionState(Parcel in)85 private VmsSubscriptionState(Parcel in) { 86 mSequenceNumber = in.readInt(); 87 List<VmsLayer> layers = new ArrayList<>(); 88 in.readParcelableList(layers, VmsLayer.class.getClassLoader()); 89 mLayers = Collections.unmodifiableList(layers); 90 } 91 }