blob: 119f587e27c471fd1d1c7bd67415d06adfe96b1f [file] [log] [blame]
Malcolm Chene1623652018-08-08 20:27:45 -07001/*
2 * Copyright (C) 2018 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
17package android.telephony;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22import java.util.ArrayList;
23import java.util.Arrays;
24import java.util.List;
25import java.util.Objects;
26
27/**
28 * Define capability of a modem group. That is, the capabilities
29 * are shared between those modems defined by list of modem IDs.
30 * @hide
31 */
32public class PhoneCapability implements Parcelable {
33 public final int maxActiveVoiceCalls;
34 public final int maxActiveData;
35 public final int max5G;
Malcolm Chen990903b2019-01-24 10:56:01 -080036 public final boolean validationBeforeSwitchSupported;
Malcolm Chene1623652018-08-08 20:27:45 -070037 public final List<ModemInfo> logicalModemList;
38
39 public PhoneCapability(int maxActiveVoiceCalls, int maxActiveData, int max5G,
Malcolm Chen990903b2019-01-24 10:56:01 -080040 List<ModemInfo> logicalModemList, boolean validationBeforeSwitchSupported) {
Malcolm Chene1623652018-08-08 20:27:45 -070041 this.maxActiveVoiceCalls = maxActiveVoiceCalls;
42 this.maxActiveData = maxActiveData;
43 this.max5G = max5G;
44 // Make sure it's not null.
45 this.logicalModemList = logicalModemList == null ? new ArrayList<>() : logicalModemList;
Malcolm Chen990903b2019-01-24 10:56:01 -080046 this.validationBeforeSwitchSupported = validationBeforeSwitchSupported;
Malcolm Chene1623652018-08-08 20:27:45 -070047 }
48
49 @Override
50 public String toString() {
51 return "maxActiveVoiceCalls=" + maxActiveVoiceCalls + " maxActiveData=" + maxActiveData
52 + " max5G=" + max5G + "logicalModemList:"
53 + Arrays.toString(logicalModemList.toArray());
54 }
55
56 private PhoneCapability(Parcel in) {
57 maxActiveVoiceCalls = in.readInt();
58 maxActiveData = in.readInt();
59 max5G = in.readInt();
Malcolm Chen990903b2019-01-24 10:56:01 -080060 validationBeforeSwitchSupported = in.readBoolean();
Malcolm Chene1623652018-08-08 20:27:45 -070061 logicalModemList = new ArrayList<>();
62 in.readList(logicalModemList, ModemInfo.class.getClassLoader());
63 }
64
65 @Override
66 public int hashCode() {
Malcolm Chen990903b2019-01-24 10:56:01 -080067 return Objects.hash(maxActiveVoiceCalls, maxActiveData, max5G, logicalModemList,
68 validationBeforeSwitchSupported);
Malcolm Chene1623652018-08-08 20:27:45 -070069 }
70
71 @Override
72 public boolean equals(Object o) {
73 if (o == null || !(o instanceof PhoneCapability) || hashCode() != o.hashCode()) {
74 return false;
75 }
76
77 if (this == o) {
78 return true;
79 }
80
81 PhoneCapability s = (PhoneCapability) o;
82
83 return (maxActiveVoiceCalls == s.maxActiveVoiceCalls
84 && maxActiveData == s.maxActiveData
85 && max5G == s.max5G
Malcolm Chen990903b2019-01-24 10:56:01 -080086 && validationBeforeSwitchSupported == s.validationBeforeSwitchSupported
Malcolm Chene1623652018-08-08 20:27:45 -070087 && logicalModemList.equals(s.logicalModemList));
88 }
89
90 /**
91 * {@link Parcelable#describeContents}
92 */
93 public @Parcelable.ContentsFlags int describeContents() {
94 return 0;
95 }
96
97 /**
98 * {@link Parcelable#writeToParcel}
99 */
100 public void writeToParcel(Parcel dest, @Parcelable.WriteFlags int flags) {
101 dest.writeInt(maxActiveVoiceCalls);
102 dest.writeInt(maxActiveData);
103 dest.writeInt(max5G);
Malcolm Chen990903b2019-01-24 10:56:01 -0800104 dest.writeBoolean(validationBeforeSwitchSupported);
Malcolm Chene1623652018-08-08 20:27:45 -0700105 dest.writeList(logicalModemList);
106 }
107
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700108 public static final @android.annotation.NonNull Parcelable.Creator<PhoneCapability> CREATOR = new Parcelable.Creator() {
Malcolm Chene1623652018-08-08 20:27:45 -0700109 public PhoneCapability createFromParcel(Parcel in) {
110 return new PhoneCapability(in);
111 }
112
113 public PhoneCapability[] newArray(int size) {
114 return new PhoneCapability[size];
115 }
116 };
117}