blob: 4459e2c44bdcf7d62046bd98e0cbdf2f3a956918 [file] [log] [blame]
Hemant Gupta8949bfb2013-08-16 14:57:55 +05301/*
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
17package android.bluetooth;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/** @hide */
23public 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
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
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
45 public int hashCode() {
46 return mId + (mChannel << 8) + (mMsgTypes << 16);
47 }
48
49 @Override
50 public String toString() {
51 return Integer.toString(mId) + ":" + mName + ":" + mChannel + ":" +
52 Integer.toHexString(mMsgTypes);
53 }
54
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
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
84 public int getId() {
85 return mId;
86 }
87
88 public String getName() {
89 return mName;
90 }
91
92 public int getChannel() {
93 return mChannel;
94 }
95
96 public int getMsgTypes() {
97 return mMsgTypes;
98 }
99
100 public boolean msgSupported(int msg) {
101 return (mMsgTypes & msg) != 0;
102 }
103}