1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.Annotation.NetworkType;
import java.util.Objects;
/**
* Contains information about a call's attributes as passed up from the HAL. If there are multiple
* ongoing calls, the CallAttributes will pertain to the call in the foreground.
* @hide
*/
@SystemApi
public final class CallAttributes implements Parcelable {
private PreciseCallState mPreciseCallState;
@NetworkType
private int mNetworkType; // TelephonyManager.NETWORK_TYPE_* ints
private CallQuality mCallQuality;
public CallAttributes(@NonNull PreciseCallState state, @NetworkType int networkType,
@NonNull CallQuality callQuality) {
this.mPreciseCallState = state;
this.mNetworkType = networkType;
this.mCallQuality = callQuality;
}
@NonNull
@Override
public String toString() {
return "mPreciseCallState=" + mPreciseCallState + " mNetworkType=" + mNetworkType
+ " mCallQuality=" + mCallQuality;
}
private CallAttributes(Parcel in) {
this.mPreciseCallState = in.readParcelable(PreciseCallState.class.getClassLoader());
this.mNetworkType = in.readInt();
this.mCallQuality = in.readParcelable(CallQuality.class.getClassLoader());
}
// getters
/**
* Returns the {@link PreciseCallState} of the call.
*/
@NonNull
public PreciseCallState getPreciseCallState() {
return mPreciseCallState;
}
/**
* Returns the {@link TelephonyManager#NetworkType} of the call.
*
* @see TelephonyManager#NETWORK_TYPE_UNKNOWN
* @see TelephonyManager#NETWORK_TYPE_GPRS
* @see TelephonyManager#NETWORK_TYPE_EDGE
* @see TelephonyManager#NETWORK_TYPE_UMTS
* @see TelephonyManager#NETWORK_TYPE_CDMA
* @see TelephonyManager#NETWORK_TYPE_EVDO_0
* @see TelephonyManager#NETWORK_TYPE_EVDO_A
* @see TelephonyManager#NETWORK_TYPE_1xRTT
* @see TelephonyManager#NETWORK_TYPE_HSDPA
* @see TelephonyManager#NETWORK_TYPE_HSUPA
* @see TelephonyManager#NETWORK_TYPE_HSPA
* @see TelephonyManager#NETWORK_TYPE_IDEN
* @see TelephonyManager#NETWORK_TYPE_EVDO_B
* @see TelephonyManager#NETWORK_TYPE_LTE
* @see TelephonyManager#NETWORK_TYPE_EHRPD
* @see TelephonyManager#NETWORK_TYPE_HSPAP
* @see TelephonyManager#NETWORK_TYPE_GSM
* @see TelephonyManager#NETWORK_TYPE_TD_SCDMA
* @see TelephonyManager#NETWORK_TYPE_IWLAN
* @see TelephonyManager#NETWORK_TYPE_LTE_CA
* @see TelephonyManager#NETWORK_TYPE_NR
*/
@NetworkType
public int getNetworkType() {
return mNetworkType;
}
/**
* Returns the {#link CallQuality} of the call.
*/
@NonNull
public CallQuality getCallQuality() {
return mCallQuality;
}
@Override
public int hashCode() {
return Objects.hash(mPreciseCallState, mNetworkType, mCallQuality);
}
@Override
public boolean equals(@Nullable Object o) {
if (o == null || !(o instanceof CallAttributes) || hashCode() != o.hashCode()) {
return false;
}
if (this == o) {
return true;
}
CallAttributes s = (CallAttributes) o;
return (Objects.equals(mPreciseCallState, s.mPreciseCallState)
&& mNetworkType == s.mNetworkType
&& Objects.equals(mCallQuality, s.mCallQuality));
}
/**
* {@link Parcelable#describeContents}
*/
public int describeContents() {
return 0;
}
/**
* {@link Parcelable#writeToParcel}
*/
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(mPreciseCallState, flags);
dest.writeInt(mNetworkType);
dest.writeParcelable(mCallQuality, flags);
}
public static final @android.annotation.NonNull Parcelable.Creator<CallAttributes> CREATOR = new Parcelable.Creator() {
public CallAttributes createFromParcel(Parcel in) {
return new CallAttributes(in);
}
public CallAttributes[] newArray(int size) {
return new CallAttributes[size];
}
};
}
|