1 /** 2 * Copyright 2021 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.telephony.data; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 import java.util.ArrayList; 25 import java.util.List; 26 import java.util.Objects; 27 28 /** 29 * Represents a slicing configuration 30 */ 31 public final class NetworkSlicingConfig implements Parcelable { 32 private final List<UrspRule> mUrspRules; 33 private final List<NetworkSliceInfo> mSliceInfo; 34 NetworkSlicingConfig()35 public NetworkSlicingConfig() { 36 mUrspRules = new ArrayList<>(); 37 mSliceInfo = new ArrayList<>(); 38 } 39 40 /** @hide */ NetworkSlicingConfig(List<UrspRule> urspRules, List<NetworkSliceInfo> sliceInfo)41 public NetworkSlicingConfig(List<UrspRule> urspRules, List<NetworkSliceInfo> sliceInfo) { 42 this(); 43 mUrspRules.addAll(urspRules); 44 mSliceInfo.addAll(sliceInfo); 45 } 46 47 /** @hide */ NetworkSlicingConfig(Parcel p)48 public NetworkSlicingConfig(Parcel p) { 49 mUrspRules = p.createTypedArrayList(UrspRule.CREATOR); 50 mSliceInfo = p.createTypedArrayList(NetworkSliceInfo.CREATOR); 51 } 52 53 /** 54 * This list contains the current URSP rules. Empty list represents that no rules are 55 * configured. 56 * @return the current URSP rules for this slicing configuration. 57 */ getUrspRules()58 public @NonNull List<UrspRule> getUrspRules() { 59 return mUrspRules; 60 } 61 62 /** 63 * @return the list of all slices for this slicing configuration. 64 */ getSliceInfo()65 public @NonNull List<NetworkSliceInfo> getSliceInfo() { 66 return mSliceInfo; 67 } 68 69 @Override writeToParcel(@onNull Parcel dest, int flags)70 public void writeToParcel(@NonNull Parcel dest, int flags) { 71 dest.writeTypedList(mUrspRules, flags); 72 dest.writeTypedList(mSliceInfo, flags); 73 } 74 75 public static final @NonNull Parcelable.Creator<NetworkSlicingConfig> CREATOR = 76 new Parcelable.Creator<NetworkSlicingConfig>() { 77 @Override 78 public NetworkSlicingConfig createFromParcel(Parcel source) { 79 return new NetworkSlicingConfig(source); 80 } 81 82 @Override 83 public NetworkSlicingConfig[] newArray(int size) { 84 return new NetworkSlicingConfig[size]; 85 } 86 }; 87 88 @Override describeContents()89 public int describeContents() { 90 return 0; 91 } 92 93 @Override equals(@ullable Object o)94 public boolean equals(@Nullable Object o) { 95 if (this == o) return true; 96 if (o == null || getClass() != o.getClass()) return false; 97 NetworkSlicingConfig that = (NetworkSlicingConfig) o; 98 return mUrspRules.size() == that.mUrspRules.size() 99 && mUrspRules.containsAll(that.mUrspRules) 100 && mSliceInfo.size() == that.mSliceInfo.size() 101 && mSliceInfo.containsAll(that.mSliceInfo); 102 } 103 104 @Override hashCode()105 public int hashCode() { 106 return Objects.hash(mUrspRules, mSliceInfo); 107 } 108 109 @Override toString()110 public String toString() { 111 return "{.urspRules = " + mUrspRules + ", .sliceInfo = " + mSliceInfo + "}"; 112 } 113 } 114