Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.telephony; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | |
| 22 | import java.util.ArrayList; |
| 23 | import java.util.Arrays; |
| 24 | import java.util.List; |
| 25 | import 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 | */ |
| 32 | public class PhoneCapability implements Parcelable { |
| 33 | public final int maxActiveVoiceCalls; |
| 34 | public final int maxActiveData; |
| 35 | public final int max5G; |
Malcolm Chen | 990903b | 2019-01-24 10:56:01 -0800 | [diff] [blame] | 36 | public final boolean validationBeforeSwitchSupported; |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 37 | public final List<ModemInfo> logicalModemList; |
| 38 | |
| 39 | public PhoneCapability(int maxActiveVoiceCalls, int maxActiveData, int max5G, |
Malcolm Chen | 990903b | 2019-01-24 10:56:01 -0800 | [diff] [blame] | 40 | List<ModemInfo> logicalModemList, boolean validationBeforeSwitchSupported) { |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 41 | 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 Chen | 990903b | 2019-01-24 10:56:01 -0800 | [diff] [blame] | 46 | this.validationBeforeSwitchSupported = validationBeforeSwitchSupported; |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 47 | } |
| 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 Chen | 990903b | 2019-01-24 10:56:01 -0800 | [diff] [blame] | 60 | validationBeforeSwitchSupported = in.readBoolean(); |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 61 | logicalModemList = new ArrayList<>(); |
| 62 | in.readList(logicalModemList, ModemInfo.class.getClassLoader()); |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public int hashCode() { |
Malcolm Chen | 990903b | 2019-01-24 10:56:01 -0800 | [diff] [blame] | 67 | return Objects.hash(maxActiveVoiceCalls, maxActiveData, max5G, logicalModemList, |
| 68 | validationBeforeSwitchSupported); |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 69 | } |
| 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 Chen | 990903b | 2019-01-24 10:56:01 -0800 | [diff] [blame] | 86 | && validationBeforeSwitchSupported == s.validationBeforeSwitchSupported |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 87 | && 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 Chen | 990903b | 2019-01-24 10:56:01 -0800 | [diff] [blame] | 104 | dest.writeBoolean(validationBeforeSwitchSupported); |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 105 | dest.writeList(logicalModemList); |
| 106 | } |
| 107 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 108 | public static final @android.annotation.NonNull Parcelable.Creator<PhoneCapability> CREATOR = new Parcelable.Creator() { |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 109 | 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 | } |