• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 package com.android.bluetooth.hfp;
17 
18 import java.util.Objects;
19 
20 /**
21  * A blob of data representing an overall call state on the phone
22  */
23 class HeadsetCallState extends HeadsetMessageObject {
24     /**
25      * Number of active calls
26      */
27     int mNumActive;
28     /**
29      * Number of held calls
30      */
31     int mNumHeld;
32     /**
33      * Current call setup state as defined in bthf_call_state_t of bt_hf.h or
34      * {@link com.android.server.telecom.BluetoothPhoneServiceImpl} or {@link HeadsetHalConstants}
35      */
36     int mCallState;
37     /**
38      * Currently active call's phone number
39      */
40     String mNumber;
41     /**
42      * Phone number type
43      */
44     int mType;
45 
HeadsetCallState(int numActive, int numHeld, int callState, String number, int type)46     HeadsetCallState(int numActive, int numHeld, int callState, String number, int type) {
47         mNumActive = numActive;
48         mNumHeld = numHeld;
49         mCallState = callState;
50         mNumber = number;
51         mType = type;
52     }
53 
54     @Override
buildString(StringBuilder builder)55     public void buildString(StringBuilder builder) {
56         if (builder == null) {
57             return;
58         }
59         builder.append(this.getClass().getSimpleName())
60                 .append("[numActive=")
61                 .append(mNumActive)
62                 .append(", numHeld=")
63                 .append(mNumHeld)
64                 .append(", callState=")
65                 .append(mCallState)
66                 .append(", number=");
67         if (mNumber == null) {
68             builder.append("null");
69         } else {
70             builder.append("***");
71         }
72         builder.append(mNumber).append(", type=").append(mType).append("]");
73     }
74 
75     @Override
equals(Object object)76     public boolean equals(Object object) {
77         if (this == object) {
78             return true;
79         }
80         if (!(object instanceof HeadsetCallState)) {
81             return false;
82         }
83         HeadsetCallState that = (HeadsetCallState) object;
84         return mNumActive == that.mNumActive && mNumHeld == that.mNumHeld
85                 && mCallState == that.mCallState && Objects.equals(mNumber, that.mNumber)
86                 && mType == that.mType;
87     }
88 
89     @Override
hashCode()90     public int hashCode() {
91         return Objects.hash(mNumActive, mNumHeld, mCallState, mNumber, mType);
92     }
93 }
94