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