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 describeContents()55 public int describeContents() { 56 return 0; 57 } 58 59 public static final Parcelable.Creator<BluetoothMasInstance> CREATOR = 60 new Parcelable.Creator<BluetoothMasInstance>() { 61 public BluetoothMasInstance createFromParcel(Parcel in) { 62 return new BluetoothMasInstance(in.readInt(), in.readString(), 63 in.readInt(), in.readInt()); 64 } 65 public BluetoothMasInstance[] newArray(int size) { 66 return new BluetoothMasInstance[size]; 67 } 68 }; 69 writeToParcel(Parcel out, int flags)70 public void writeToParcel(Parcel out, int flags) { 71 out.writeInt(mId); 72 out.writeString(mName); 73 out.writeInt(mChannel); 74 out.writeInt(mMsgTypes); 75 } 76 77 public static final class MessageType { 78 public static final int EMAIL = 0x01; 79 public static final int SMS_GSM = 0x02; 80 public static final int SMS_CDMA = 0x04; 81 public static final int MMS = 0x08; 82 } 83 getId()84 public int getId() { 85 return mId; 86 } 87 getName()88 public String getName() { 89 return mName; 90 } 91 getChannel()92 public int getChannel() { 93 return mChannel; 94 } 95 getMsgTypes()96 public int getMsgTypes() { 97 return mMsgTypes; 98 } 99 msgSupported(int msg)100 public boolean msgSupported(int msg) { 101 return (mMsgTypes & msg) != 0; 102 } 103 } 104