blob: 7a31328eaf02c4c6e4a4d28a60596b1f775e609e [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) {
Jack Hea355e5e2017-08-22 16:06:54 -070039 return mId == ((BluetoothMasInstance) o).mId;
Hemant Gupta8949bfb2013-08-16 14:57:55 +053040 }
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() {
Jack He2992cd02017-08-22 21:21:23 -070051 return Integer.toString(mId) + ":" + mName + ":" + mChannel + ":"
52 + Integer.toHexString(mMsgTypes);
Hemant Gupta8949bfb2013-08-16 14:57:55 +053053 }
54
Jack He2992cd02017-08-22 21:21:23 -070055 @Override
Hemant Gupta8949bfb2013-08-16 14:57:55 +053056 public int describeContents() {
57 return 0;
58 }
59
60 public static final Parcelable.Creator<BluetoothMasInstance> CREATOR =
61 new Parcelable.Creator<BluetoothMasInstance>() {
Jack Hea355e5e2017-08-22 16:06:54 -070062 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 };
Hemant Gupta8949bfb2013-08-16 14:57:55 +053071
Jack He2992cd02017-08-22 21:21:23 -070072 @Override
Hemant Gupta8949bfb2013-08-16 14:57:55 +053073 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 {
Jack Hea355e5e2017-08-22 16:06:54 -070081 public static final int EMAIL = 0x01;
82 public static final int SMS_GSM = 0x02;
Hemant Gupta8949bfb2013-08-16 14:57:55 +053083 public static final int SMS_CDMA = 0x04;
Jack Hea355e5e2017-08-22 16:06:54 -070084 public static final int MMS = 0x08;
Hemant Gupta8949bfb2013-08-16 14:57:55 +053085 }
86
87 public int getId() {
88 return mId;
89 }
90
91 public String getName() {
92 return mName;
93 }
94
95 public int getChannel() {
96 return mChannel;
97 }
98
99 public int getMsgTypes() {
100 return mMsgTypes;
101 }
102
103 public boolean msgSupported(int msg) {
104 return (mMsgTypes & msg) != 0;
105 }
106}