• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 /** @hide */
25 public final class BluetoothMasInstance implements Parcelable {
26     private final int mId;
27     private final String mName;
28     private final int mChannel;
29     private final int mMsgTypes;
30 
BluetoothMasInstance(int id, String name, int channel, int msgTypes)31     public BluetoothMasInstance(int id, String name, int channel, int msgTypes) {
32         mId = id;
33         mName = name;
34         mChannel = channel;
35         mMsgTypes = msgTypes;
36     }
37 
38     @Override
equals(@ullable Object o)39     public boolean equals(@Nullable Object o) {
40         if (o instanceof BluetoothMasInstance) {
41             return mId == ((BluetoothMasInstance) o).mId;
42         }
43         return false;
44     }
45 
46     @Override
hashCode()47     public int hashCode() {
48         return mId + (mChannel << 8) + (mMsgTypes << 16);
49     }
50 
51     @Override
toString()52     public String toString() {
53         return Integer.toString(mId) + ":" + mName + ":" + mChannel + ":"
54                 + Integer.toHexString(mMsgTypes);
55     }
56 
57     @Override
describeContents()58     public int describeContents() {
59         return 0;
60     }
61 
62     public static final @NonNull Creator<BluetoothMasInstance> CREATOR = new Creator<>() {
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     /** @hide */
82     public static final class MessageType {
83         public static final int EMAIL = 0x01;
84         public static final int SMS_GSM = 0x02;
85         public static final int SMS_CDMA = 0x04;
86         public static final int MMS = 0x08;
87     }
88 
getId()89     public int getId() {
90         return mId;
91     }
92 
getName()93     public String getName() {
94         return mName;
95     }
96 
getChannel()97     public int getChannel() {
98         return mChannel;
99     }
100 
getMsgTypes()101     public int getMsgTypes() {
102         return mMsgTypes;
103     }
104 
105     /** @hide */
msgSupported(int msg)106     public boolean msgSupported(int msg) {
107         return (mMsgTypes & msg) != 0;
108     }
109 }
110