| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.telecom; |
| 18 |
|
| 19 |
import android.annotation.ElapsedRealtimeLong; |
| 20 |
import android.annotation.IntRange; |
| 21 |
import android.annotation.NonNull; |
| 22 |
import android.annotation.SystemApi; |
| 23 |
import android.os.Bundle; |
| 24 |
import android.os.Parcel; |
| 25 |
import android.os.Parcelable; |
| 26 |
|
| 27 |
import java.util.Objects; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
@SystemApi |
| 38 |
public final class BluetoothCallQualityReport implements Parcelable { |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public static final String EVENT_BLUETOOTH_CALL_QUALITY_REPORT = |
| 44 |
"android.telecom.event.BLUETOOTH_CALL_QUALITY_REPORT"; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public static final String EXTRA_BLUETOOTH_CALL_QUALITY_REPORT = |
| 50 |
"android.telecom.extra.BLUETOOTH_CALL_QUALITY_REPORT"; |
| 51 |
|
| 52 |
private final long mSentTimestampMillis; |
| 53 |
private final boolean mChoppyVoice; |
| 54 |
private final int mRssiDbm; |
| 55 |
private final int mSnrDb; |
| 56 |
private final int mRetransmittedPacketsCount; |
| 57 |
private final int mPacketsNotReceivedCount; |
| 58 |
private final int mNegativeAcknowledgementCount; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public @ElapsedRealtimeLong long getSentTimestampMillis() { |
| 65 |
return mSentTimestampMillis; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
public boolean isChoppyVoice() { |
| 74 |
return mChoppyVoice; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
public @IntRange(from = -127, to = 20) int getRssiDbm() { |
| 82 |
return mRssiDbm; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
public int getSnrDb() { |
| 90 |
return mSnrDb; |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public @IntRange(from = 0) int getRetransmittedPacketsCount() { |
| 98 |
return mRetransmittedPacketsCount; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
public @IntRange(from = 0) int getPacketsNotReceivedCount() { |
| 108 |
return mPacketsNotReceivedCount; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
public @IntRange(from = 0) int getNegativeAcknowledgementCount() { |
| 116 |
return mNegativeAcknowledgementCount; |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
@Override |
| 124 |
public int describeContents() { |
| 125 |
return 0; |
| 126 |
} |
| 127 |
|
| 128 |
@Override |
| 129 |
public void writeToParcel(@NonNull Parcel out, int flags) { |
| 130 |
out.writeLong(mSentTimestampMillis); |
| 131 |
out.writeBoolean(mChoppyVoice); |
| 132 |
out.writeInt(mRssiDbm); |
| 133 |
out.writeInt(mSnrDb); |
| 134 |
out.writeInt(mRetransmittedPacketsCount); |
| 135 |
out.writeInt(mPacketsNotReceivedCount); |
| 136 |
out.writeInt(mNegativeAcknowledgementCount); |
| 137 |
} |
| 138 |
|
| 139 |
public static final @android.annotation.NonNull Creator<BluetoothCallQualityReport> CREATOR = |
| 140 |
new Creator<BluetoothCallQualityReport>() { |
| 141 |
@Override |
| 142 |
public BluetoothCallQualityReport createFromParcel(Parcel in) { |
| 143 |
return new BluetoothCallQualityReport(in); |
| 144 |
} |
| 145 |
|
| 146 |
@Override |
| 147 |
public BluetoothCallQualityReport[] newArray(int size) { |
| 148 |
return new BluetoothCallQualityReport[size]; |
| 149 |
} |
| 150 |
}; |
| 151 |
|
| 152 |
@Override |
| 153 |
public boolean equals(Object o) { |
| 154 |
if (this == o) return true; |
| 155 |
if (o == null || getClass() != o.getClass()) return false; |
| 156 |
BluetoothCallQualityReport that = (BluetoothCallQualityReport) o; |
| 157 |
return mSentTimestampMillis == that.mSentTimestampMillis |
| 158 |
&& mChoppyVoice == that.mChoppyVoice && mRssiDbm == that.mRssiDbm |
| 159 |
&& mSnrDb == that.mSnrDb |
| 160 |
&& mRetransmittedPacketsCount == that.mRetransmittedPacketsCount |
| 161 |
&& mPacketsNotReceivedCount == that.mPacketsNotReceivedCount |
| 162 |
&& mNegativeAcknowledgementCount == that.mNegativeAcknowledgementCount; |
| 163 |
} |
| 164 |
|
| 165 |
@Override |
| 166 |
public int hashCode() { |
| 167 |
return Objects.hash(mSentTimestampMillis, mChoppyVoice, mRssiDbm, mSnrDb, |
| 168 |
mRetransmittedPacketsCount, mPacketsNotReceivedCount, |
| 169 |
mNegativeAcknowledgementCount); |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
public static final class Builder { |
| 176 |
private long mSentTimestampMillis; |
| 177 |
private boolean mChoppyVoice; |
| 178 |
private int mRssiDbm; |
| 179 |
private int mSnrDb; |
| 180 |
private int mRetransmittedPacketsCount; |
| 181 |
private int mPacketsNotReceivedCount; |
| 182 |
private int mNegativeAcknowledgementCount; |
| 183 |
|
| 184 |
public Builder() { } |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
public @NonNull Builder setSentTimestampMillis(long sentTimestampMillis) { |
| 191 |
mSentTimestampMillis = sentTimestampMillis; |
| 192 |
return this; |
| 193 |
} |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
public @NonNull Builder setChoppyVoice(boolean choppyVoice) { |
| 200 |
mChoppyVoice = choppyVoice; |
| 201 |
return this; |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
public @NonNull Builder setRssiDbm(int rssiDbm) { |
| 209 |
mRssiDbm = rssiDbm; |
| 210 |
return this; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
public @NonNull Builder setSnrDb(int snrDb) { |
| 218 |
mSnrDb = snrDb; |
| 219 |
return this; |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
public @NonNull Builder setRetransmittedPacketsCount( |
| 227 |
int retransmittedPacketsCount) { |
| 228 |
mRetransmittedPacketsCount = retransmittedPacketsCount; |
| 229 |
return this; |
| 230 |
} |
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
public @NonNull Builder setPacketsNotReceivedCount( |
| 237 |
int packetsNotReceivedCount) { |
| 238 |
mPacketsNotReceivedCount = packetsNotReceivedCount; |
| 239 |
return this; |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
public @NonNull Builder setNegativeAcknowledgementCount( |
| 247 |
int negativeAcknowledgementCount) { |
| 248 |
mNegativeAcknowledgementCount = negativeAcknowledgementCount; |
| 249 |
return this; |
| 250 |
} |
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
public @NonNull BluetoothCallQualityReport build() { |
| 257 |
return new BluetoothCallQualityReport(this); |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
private BluetoothCallQualityReport(Parcel in) { |
| 262 |
mSentTimestampMillis = in.readLong(); |
| 263 |
mChoppyVoice = in.readBoolean(); |
| 264 |
mRssiDbm = in.readInt(); |
| 265 |
mSnrDb = in.readInt(); |
| 266 |
mRetransmittedPacketsCount = in.readInt(); |
| 267 |
mPacketsNotReceivedCount = in.readInt(); |
| 268 |
mNegativeAcknowledgementCount = in.readInt(); |
| 269 |
} |
| 270 |
|
| 271 |
private BluetoothCallQualityReport(Builder builder) { |
| 272 |
mSentTimestampMillis = builder.mSentTimestampMillis; |
| 273 |
mChoppyVoice = builder.mChoppyVoice; |
| 274 |
mRssiDbm = builder.mRssiDbm; |
| 275 |
mSnrDb = builder.mSnrDb; |
| 276 |
mRetransmittedPacketsCount = builder.mRetransmittedPacketsCount; |
| 277 |
mPacketsNotReceivedCount = builder.mPacketsNotReceivedCount; |
| 278 |
mNegativeAcknowledgementCount = builder.mNegativeAcknowledgementCount; |
| 279 |
} |
| 280 |
} |