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.Objects; 23 24 /** 25 * Information of a single logical modem indicating 26 * its id, supported rats and whether it supports voice or data, etc. 27 * @hide 28 */ 29 public class ModemInfo implements Parcelable { 30 public final int modemId; 31 public final int rat; /* bitset */ 32 public final boolean isVoiceSupported; 33 public final boolean isDataSupported; 34 35 // TODO b/121394331: Clean up this class after V1_1.PhoneCapability cleanup. ModemInfo(int modemId)36 public ModemInfo(int modemId) { 37 this(modemId, 0, true, true); 38 } 39 ModemInfo(int modemId, int rat, boolean isVoiceSupported, boolean isDataSupported)40 public ModemInfo(int modemId, int rat, boolean isVoiceSupported, boolean isDataSupported) { 41 this.modemId = modemId; 42 this.rat = rat; 43 this.isVoiceSupported = isVoiceSupported; 44 this.isDataSupported = isDataSupported; 45 } 46 ModemInfo(Parcel in)47 public ModemInfo(Parcel in) { 48 modemId = in.readInt(); 49 rat = in.readInt(); 50 isVoiceSupported = in.readBoolean(); 51 isDataSupported = in.readBoolean(); 52 } 53 54 @Override toString()55 public String toString() { 56 return "modemId=" + modemId + " rat=" + rat + " isVoiceSupported:" + isVoiceSupported 57 + " isDataSupported:" + isDataSupported; 58 } 59 60 @Override hashCode()61 public int hashCode() { 62 return Objects.hash(modemId, rat, isVoiceSupported, isDataSupported); 63 } 64 65 @Override equals(Object o)66 public boolean equals(Object o) { 67 if (o == null || !(o instanceof ModemInfo) || hashCode() != o.hashCode()) { 68 return false; 69 } 70 71 if (this == o) { 72 return true; 73 } 74 75 ModemInfo s = (ModemInfo) o; 76 77 return (modemId == s.modemId 78 && rat == s.rat 79 && isVoiceSupported == s.isVoiceSupported 80 && isDataSupported == s.isDataSupported); 81 } 82 83 /** 84 * {@link Parcelable#describeContents} 85 */ describeContents()86 public @ContentsFlags int describeContents() { 87 return 0; 88 } 89 90 /** 91 * {@link Parcelable#writeToParcel} 92 */ writeToParcel(Parcel dest, @WriteFlags int flags)93 public void writeToParcel(Parcel dest, @WriteFlags int flags) { 94 dest.writeInt(modemId); 95 dest.writeInt(rat); 96 dest.writeBoolean(isVoiceSupported); 97 dest.writeBoolean(isDataSupported); 98 } 99 100 public static final @android.annotation.NonNull Parcelable.Creator<ModemInfo> CREATOR = new Parcelable.Creator() { 101 public ModemInfo createFromParcel(Parcel in) { 102 return new ModemInfo(in); 103 } 104 105 public ModemInfo[] newArray(int size) { 106 return new ModemInfo[size]; 107 } 108 }; 109 } 110