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 // Hardcoded default DSDS capability. 34 public static final PhoneCapability DEFAULT_DSDS_CAPABILITY; 35 // Hardcoded default Single SIM single standby capability. 36 public static final PhoneCapability DEFAULT_SSSS_CAPABILITY; 37 38 static { 39 ModemInfo modemInfo1 = new ModemInfo(0, 0, true, true); 40 ModemInfo modemInfo2 = new ModemInfo(1, 0, true, true); 41 42 List<ModemInfo> logicalModemList = new ArrayList<>(); 43 logicalModemList.add(modemInfo1); 44 logicalModemList.add(modemInfo2); 45 DEFAULT_DSDS_CAPABILITY = new PhoneCapability(1, 1, 0, logicalModemList, false); 46 47 logicalModemList = new ArrayList<>(); 48 logicalModemList.add(modemInfo1); 49 DEFAULT_SSSS_CAPABILITY = new PhoneCapability(1, 1, 0, logicalModemList, false); 50 } 51 52 public final int maxActiveVoiceCalls; 53 public final int maxActiveData; 54 public final int max5G; 55 public final boolean validationBeforeSwitchSupported; 56 public final List<ModemInfo> logicalModemList; 57 PhoneCapability(int maxActiveVoiceCalls, int maxActiveData, int max5G, List<ModemInfo> logicalModemList, boolean validationBeforeSwitchSupported)58 public PhoneCapability(int maxActiveVoiceCalls, int maxActiveData, int max5G, 59 List<ModemInfo> logicalModemList, boolean validationBeforeSwitchSupported) { 60 this.maxActiveVoiceCalls = maxActiveVoiceCalls; 61 this.maxActiveData = maxActiveData; 62 this.max5G = max5G; 63 // Make sure it's not null. 64 this.logicalModemList = logicalModemList == null ? new ArrayList<>() : logicalModemList; 65 this.validationBeforeSwitchSupported = validationBeforeSwitchSupported; 66 } 67 68 @Override toString()69 public String toString() { 70 return "maxActiveVoiceCalls=" + maxActiveVoiceCalls + " maxActiveData=" + maxActiveData 71 + " max5G=" + max5G + "logicalModemList:" 72 + Arrays.toString(logicalModemList.toArray()); 73 } 74 PhoneCapability(Parcel in)75 private PhoneCapability(Parcel in) { 76 maxActiveVoiceCalls = in.readInt(); 77 maxActiveData = in.readInt(); 78 max5G = in.readInt(); 79 validationBeforeSwitchSupported = in.readBoolean(); 80 logicalModemList = new ArrayList<>(); 81 in.readList(logicalModemList, ModemInfo.class.getClassLoader()); 82 } 83 84 @Override hashCode()85 public int hashCode() { 86 return Objects.hash(maxActiveVoiceCalls, maxActiveData, max5G, logicalModemList, 87 validationBeforeSwitchSupported); 88 } 89 90 @Override equals(Object o)91 public boolean equals(Object o) { 92 if (o == null || !(o instanceof PhoneCapability) || hashCode() != o.hashCode()) { 93 return false; 94 } 95 96 if (this == o) { 97 return true; 98 } 99 100 PhoneCapability s = (PhoneCapability) o; 101 102 return (maxActiveVoiceCalls == s.maxActiveVoiceCalls 103 && maxActiveData == s.maxActiveData 104 && max5G == s.max5G 105 && validationBeforeSwitchSupported == s.validationBeforeSwitchSupported 106 && logicalModemList.equals(s.logicalModemList)); 107 } 108 109 /** 110 * {@link Parcelable#describeContents} 111 */ describeContents()112 public @Parcelable.ContentsFlags int describeContents() { 113 return 0; 114 } 115 116 /** 117 * {@link Parcelable#writeToParcel} 118 */ writeToParcel(Parcel dest, @Parcelable.WriteFlags int flags)119 public void writeToParcel(Parcel dest, @Parcelable.WriteFlags int flags) { 120 dest.writeInt(maxActiveVoiceCalls); 121 dest.writeInt(maxActiveData); 122 dest.writeInt(max5G); 123 dest.writeBoolean(validationBeforeSwitchSupported); 124 dest.writeList(logicalModemList); 125 } 126 127 public static final @android.annotation.NonNull Parcelable.Creator<PhoneCapability> CREATOR = new Parcelable.Creator() { 128 public PhoneCapability createFromParcel(Parcel in) { 129 return new PhoneCapability(in); 130 } 131 132 public PhoneCapability[] newArray(int size) { 133 return new PhoneCapability[size]; 134 } 135 }; 136 } 137