1 /* 2 * Copyright (C) 2014 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.bluetooth; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 /** @hide */ 25 @SuppressWarnings("InconsistentHashCode") // TODO(b/314811467) 26 public final class BluetoothMasInstance implements Parcelable { 27 private final int mId; 28 private final String mName; 29 private final int mChannel; 30 private final int mMsgTypes; 31 BluetoothMasInstance(int id, String name, int channel, int msgTypes)32 public BluetoothMasInstance(int id, String name, int channel, int msgTypes) { 33 mId = id; 34 mName = name; 35 mChannel = channel; 36 mMsgTypes = msgTypes; 37 } 38 39 @Override equals(@ullable Object o)40 public boolean equals(@Nullable Object o) { 41 if (o instanceof BluetoothMasInstance) { 42 return mId == ((BluetoothMasInstance) o).mId; 43 } 44 return false; 45 } 46 47 @Override hashCode()48 public int hashCode() { 49 return mId + (mChannel << 8) + (mMsgTypes << 16); 50 } 51 52 @Override toString()53 public String toString() { 54 return Integer.toString(mId) 55 + ":" 56 + mName 57 + ":" 58 + mChannel 59 + ":" 60 + Integer.toHexString(mMsgTypes); 61 } 62 63 @Override describeContents()64 public int describeContents() { 65 return 0; 66 } 67 68 public static final @NonNull Creator<BluetoothMasInstance> CREATOR = 69 new Creator<>() { 70 public BluetoothMasInstance createFromParcel(Parcel in) { 71 return new BluetoothMasInstance( 72 in.readInt(), in.readString(), in.readInt(), in.readInt()); 73 } 74 75 public BluetoothMasInstance[] newArray(int size) { 76 return new BluetoothMasInstance[size]; 77 } 78 }; 79 80 @Override writeToParcel(Parcel out, int flags)81 public void writeToParcel(Parcel out, int flags) { 82 out.writeInt(mId); 83 out.writeString(mName); 84 out.writeInt(mChannel); 85 out.writeInt(mMsgTypes); 86 } 87 88 /** @hide */ 89 public static final class MessageType { 90 public static final int EMAIL = 0x01; 91 public static final int SMS_GSM = 0x02; 92 public static final int SMS_CDMA = 0x04; 93 public static final int MMS = 0x08; 94 } 95 getId()96 public int getId() { 97 return mId; 98 } 99 getName()100 public String getName() { 101 return mName; 102 } 103 getChannel()104 public int getChannel() { 105 return mChannel; 106 } 107 getMsgTypes()108 public int getMsgTypes() { 109 return mMsgTypes; 110 } 111 112 /** @hide */ msgSupported(int msg)113 public boolean msgSupported(int msg) { 114 return (mMsgTypes & msg) != 0; 115 } 116 } 117