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