| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.telecom; |
| 18 |
|
| 19 |
import android.net.Uri; |
| 20 |
import android.os.Bundle; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
import java.util.ArrayList; |
| 25 |
import java.util.Collections; |
| 26 |
import java.util.List; |
| 27 |
|
| 28 |
import com.android.internal.telecom.IVideoProvider; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public final class ParcelableConference implements Parcelable { |
| 35 |
|
| 36 |
public static final class Builder { |
| 37 |
private final PhoneAccountHandle mPhoneAccount; |
| 38 |
private final int mState; |
| 39 |
private int mConnectionCapabilities; |
| 40 |
private int mConnectionProperties; |
| 41 |
private List<String> mConnectionIds = Collections.emptyList(); |
| 42 |
private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED; |
| 43 |
private IVideoProvider mVideoProvider; |
| 44 |
private int mVideoState = VideoProfile.STATE_AUDIO_ONLY; |
| 45 |
private StatusHints mStatusHints; |
| 46 |
private Bundle mExtras; |
| 47 |
private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED; |
| 48 |
private Uri mAddress; |
| 49 |
private int mAddressPresentation = TelecomManager.PRESENTATION_UNKNOWN; |
| 50 |
private String mCallerDisplayName; |
| 51 |
private int mCallerDisplayNamePresentation = TelecomManager.PRESENTATION_UNKNOWN;; |
| 52 |
private DisconnectCause mDisconnectCause; |
| 53 |
private boolean mRingbackRequested; |
| 54 |
private int mCallDirection = Call.Details.DIRECTION_UNKNOWN; |
| 55 |
|
| 56 |
public Builder( |
| 57 |
PhoneAccountHandle phoneAccount, |
| 58 |
int state) { |
| 59 |
mPhoneAccount = phoneAccount; |
| 60 |
mState = state; |
| 61 |
} |
| 62 |
|
| 63 |
public Builder setDisconnectCause(DisconnectCause cause) { |
| 64 |
mDisconnectCause = cause; |
| 65 |
return this; |
| 66 |
} |
| 67 |
|
| 68 |
public Builder setRingbackRequested(boolean requested) { |
| 69 |
mRingbackRequested = requested; |
| 70 |
return this; |
| 71 |
} |
| 72 |
|
| 73 |
public Builder setCallerDisplayName(String callerDisplayName, |
| 74 |
@TelecomManager.Presentation int callerDisplayNamePresentation) { |
| 75 |
mCallerDisplayName = callerDisplayName; |
| 76 |
mCallerDisplayNamePresentation = callerDisplayNamePresentation; |
| 77 |
return this; |
| 78 |
} |
| 79 |
|
| 80 |
public Builder setAddress(Uri address, |
| 81 |
@TelecomManager.Presentation int addressPresentation) { |
| 82 |
mAddress = address; |
| 83 |
mAddressPresentation = addressPresentation; |
| 84 |
return this; |
| 85 |
} |
| 86 |
|
| 87 |
public Builder setExtras(Bundle extras) { |
| 88 |
mExtras = extras; |
| 89 |
return this; |
| 90 |
} |
| 91 |
|
| 92 |
public Builder setStatusHints(StatusHints hints) { |
| 93 |
mStatusHints = hints; |
| 94 |
return this; |
| 95 |
} |
| 96 |
|
| 97 |
public Builder setConnectTimeMillis(long connectTimeMillis, long connectElapsedTimeMillis) { |
| 98 |
mConnectTimeMillis = connectTimeMillis; |
| 99 |
mConnectElapsedTimeMillis = connectElapsedTimeMillis; |
| 100 |
return this; |
| 101 |
} |
| 102 |
|
| 103 |
public Builder setVideoAttributes(IVideoProvider provider, |
| 104 |
@VideoProfile.VideoState int videoState) { |
| 105 |
mVideoProvider = provider; |
| 106 |
mVideoState = videoState; |
| 107 |
return this; |
| 108 |
} |
| 109 |
|
| 110 |
public Builder setConnectionIds(List<String> connectionIds) { |
| 111 |
mConnectionIds = connectionIds; |
| 112 |
return this; |
| 113 |
} |
| 114 |
|
| 115 |
public Builder setConnectionProperties(int properties) { |
| 116 |
mConnectionProperties = properties; |
| 117 |
return this; |
| 118 |
} |
| 119 |
|
| 120 |
public Builder setConnectionCapabilities(int capabilities) { |
| 121 |
mConnectionCapabilities = capabilities; |
| 122 |
return this; |
| 123 |
} |
| 124 |
|
| 125 |
public Builder setCallDirection(int callDirection) { |
| 126 |
mCallDirection = callDirection; |
| 127 |
return this; |
| 128 |
} |
| 129 |
|
| 130 |
public ParcelableConference build() { |
| 131 |
return new ParcelableConference(mPhoneAccount, mState, mConnectionCapabilities, |
| 132 |
mConnectionProperties, mConnectionIds, mVideoProvider, mVideoState, |
| 133 |
mConnectTimeMillis, mConnectElapsedTimeMillis, mStatusHints, mExtras, mAddress, |
| 134 |
mAddressPresentation, mCallerDisplayName, mCallerDisplayNamePresentation, |
| 135 |
mDisconnectCause, mRingbackRequested, mCallDirection); |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
private final PhoneAccountHandle mPhoneAccount; |
| 141 |
private final int mState; |
| 142 |
private final int mConnectionCapabilities; |
| 143 |
private final int mConnectionProperties; |
| 144 |
private final List<String> mConnectionIds; |
| 145 |
private final long mConnectTimeMillis; |
| 146 |
private final IVideoProvider mVideoProvider; |
| 147 |
private final int mVideoState; |
| 148 |
private final StatusHints mStatusHints; |
| 149 |
private final Bundle mExtras; |
| 150 |
private final long mConnectElapsedTimeMillis; |
| 151 |
private final Uri mAddress; |
| 152 |
private final int mAddressPresentation; |
| 153 |
private final String mCallerDisplayName; |
| 154 |
private final int mCallerDisplayNamePresentation; |
| 155 |
private final DisconnectCause mDisconnectCause; |
| 156 |
private final boolean mRingbackRequested; |
| 157 |
private final int mCallDirection; |
| 158 |
|
| 159 |
private ParcelableConference( |
| 160 |
PhoneAccountHandle phoneAccount, |
| 161 |
int state, |
| 162 |
int connectionCapabilities, |
| 163 |
int connectionProperties, |
| 164 |
List<String> connectionIds, |
| 165 |
IVideoProvider videoProvider, |
| 166 |
int videoState, |
| 167 |
long connectTimeMillis, |
| 168 |
long connectElapsedTimeMillis, |
| 169 |
StatusHints statusHints, |
| 170 |
Bundle extras, |
| 171 |
Uri address, |
| 172 |
int addressPresentation, |
| 173 |
String callerDisplayName, |
| 174 |
int callerDisplayNamePresentation, |
| 175 |
DisconnectCause disconnectCause, |
| 176 |
boolean ringbackRequested, |
| 177 |
int callDirection) { |
| 178 |
mPhoneAccount = phoneAccount; |
| 179 |
mState = state; |
| 180 |
mConnectionCapabilities = connectionCapabilities; |
| 181 |
mConnectionProperties = connectionProperties; |
| 182 |
mConnectionIds = connectionIds; |
| 183 |
mVideoProvider = videoProvider; |
| 184 |
mVideoState = videoState; |
| 185 |
mConnectTimeMillis = connectTimeMillis; |
| 186 |
mStatusHints = statusHints; |
| 187 |
mExtras = extras; |
| 188 |
mConnectElapsedTimeMillis = connectElapsedTimeMillis; |
| 189 |
mAddress = address; |
| 190 |
mAddressPresentation = addressPresentation; |
| 191 |
mCallerDisplayName = callerDisplayName; |
| 192 |
mCallerDisplayNamePresentation = callerDisplayNamePresentation; |
| 193 |
mDisconnectCause = disconnectCause; |
| 194 |
mRingbackRequested = ringbackRequested; |
| 195 |
mCallDirection = callDirection; |
| 196 |
} |
| 197 |
|
| 198 |
@Override |
| 199 |
public String toString() { |
| 200 |
return (new StringBuffer()) |
| 201 |
.append("account: ") |
| 202 |
.append(mPhoneAccount) |
| 203 |
.append(", state: ") |
| 204 |
.append(Connection.stateToString(mState)) |
| 205 |
.append(", capabilities: ") |
| 206 |
.append(Connection.capabilitiesToString(mConnectionCapabilities)) |
| 207 |
.append(", properties: ") |
| 208 |
.append(Connection.propertiesToString(mConnectionProperties)) |
| 209 |
.append(", connectTime: ") |
| 210 |
.append(mConnectTimeMillis) |
| 211 |
.append(", children: ") |
| 212 |
.append(mConnectionIds) |
| 213 |
.append(", VideoState: ") |
| 214 |
.append(mVideoState) |
| 215 |
.append(", VideoProvider: ") |
| 216 |
.append(mVideoProvider) |
| 217 |
.append(", isRingbackRequested: ") |
| 218 |
.append(mRingbackRequested) |
| 219 |
.append(", disconnectCause: ") |
| 220 |
.append(mDisconnectCause) |
| 221 |
.append(", callDirection: ") |
| 222 |
.append(mCallDirection) |
| 223 |
.toString(); |
| 224 |
} |
| 225 |
|
| 226 |
public PhoneAccountHandle getPhoneAccount() { |
| 227 |
return mPhoneAccount; |
| 228 |
} |
| 229 |
|
| 230 |
public int getState() { |
| 231 |
return mState; |
| 232 |
} |
| 233 |
|
| 234 |
public int getConnectionCapabilities() { |
| 235 |
return mConnectionCapabilities; |
| 236 |
} |
| 237 |
|
| 238 |
public int getConnectionProperties() { |
| 239 |
return mConnectionProperties; |
| 240 |
} |
| 241 |
|
| 242 |
public List<String> getConnectionIds() { |
| 243 |
return mConnectionIds; |
| 244 |
} |
| 245 |
|
| 246 |
public long getConnectTimeMillis() { |
| 247 |
return mConnectTimeMillis; |
| 248 |
} |
| 249 |
|
| 250 |
public long getConnectElapsedTimeMillis() { |
| 251 |
return mConnectElapsedTimeMillis; |
| 252 |
} |
| 253 |
|
| 254 |
public IVideoProvider getVideoProvider() { |
| 255 |
return mVideoProvider; |
| 256 |
} |
| 257 |
|
| 258 |
public int getVideoState() { |
| 259 |
return mVideoState; |
| 260 |
} |
| 261 |
|
| 262 |
public StatusHints getStatusHints() { |
| 263 |
return mStatusHints; |
| 264 |
} |
| 265 |
|
| 266 |
public Bundle getExtras() { |
| 267 |
return mExtras; |
| 268 |
} |
| 269 |
|
| 270 |
public Uri getHandle() { |
| 271 |
return mAddress; |
| 272 |
} |
| 273 |
|
| 274 |
public final DisconnectCause getDisconnectCause() { |
| 275 |
return mDisconnectCause; |
| 276 |
} |
| 277 |
|
| 278 |
public boolean isRingbackRequested() { |
| 279 |
return mRingbackRequested; |
| 280 |
} |
| 281 |
|
| 282 |
public int getHandlePresentation() { |
| 283 |
return mAddressPresentation; |
| 284 |
} |
| 285 |
|
| 286 |
public int getCallDirection() { |
| 287 |
return mCallDirection; |
| 288 |
} |
| 289 |
|
| 290 |
public static final @android.annotation.NonNull Parcelable.Creator<ParcelableConference> CREATOR = |
| 291 |
new Parcelable.Creator<ParcelableConference> () { |
| 292 |
@Override |
| 293 |
public ParcelableConference createFromParcel(Parcel source) { |
| 294 |
ClassLoader classLoader = ParcelableConference.class.getClassLoader(); |
| 295 |
PhoneAccountHandle phoneAccount = source.readParcelable(classLoader, android.telecom.PhoneAccountHandle.class); |
| 296 |
int state = source.readInt(); |
| 297 |
int capabilities = source.readInt(); |
| 298 |
List<String> connectionIds = new ArrayList<>(2); |
| 299 |
source.readList(connectionIds, classLoader, java.lang.String.class); |
| 300 |
long connectTimeMillis = source.readLong(); |
| 301 |
IVideoProvider videoCallProvider = |
| 302 |
IVideoProvider.Stub.asInterface(source.readStrongBinder()); |
| 303 |
int videoState = source.readInt(); |
| 304 |
StatusHints statusHints = source.readParcelable(classLoader, android.telecom.StatusHints.class); |
| 305 |
Bundle extras = source.readBundle(classLoader); |
| 306 |
int properties = source.readInt(); |
| 307 |
long connectElapsedTimeMillis = source.readLong(); |
| 308 |
Uri address = source.readParcelable(classLoader, android.net.Uri.class); |
| 309 |
int addressPresentation = source.readInt(); |
| 310 |
String callerDisplayName = source.readString(); |
| 311 |
int callerDisplayNamePresentation = source.readInt(); |
| 312 |
DisconnectCause disconnectCause = source.readParcelable(classLoader, android.telecom.DisconnectCause.class); |
| 313 |
boolean isRingbackRequested = source.readInt() == 1; |
| 314 |
int callDirection = source.readInt(); |
| 315 |
|
| 316 |
return new ParcelableConference(phoneAccount, state, capabilities, properties, |
| 317 |
connectionIds, videoCallProvider, videoState, connectTimeMillis, |
| 318 |
connectElapsedTimeMillis, statusHints, extras, address, addressPresentation, |
| 319 |
callerDisplayName, callerDisplayNamePresentation, disconnectCause, |
| 320 |
isRingbackRequested, callDirection); |
| 321 |
} |
| 322 |
|
| 323 |
@Override |
| 324 |
public ParcelableConference[] newArray(int size) { |
| 325 |
return new ParcelableConference[size]; |
| 326 |
} |
| 327 |
}; |
| 328 |
|
| 329 |
|
| 330 |
@Override |
| 331 |
public int describeContents() { |
| 332 |
return 0; |
| 333 |
} |
| 334 |
|
| 335 |
|
| 336 |
@Override |
| 337 |
public void writeToParcel(Parcel destination, int flags) { |
| 338 |
destination.writeParcelable(mPhoneAccount, 0); |
| 339 |
destination.writeInt(mState); |
| 340 |
destination.writeInt(mConnectionCapabilities); |
| 341 |
destination.writeList(mConnectionIds); |
| 342 |
destination.writeLong(mConnectTimeMillis); |
| 343 |
destination.writeStrongBinder( |
| 344 |
mVideoProvider != null ? mVideoProvider.asBinder() : null); |
| 345 |
destination.writeInt(mVideoState); |
| 346 |
destination.writeParcelable(mStatusHints, 0); |
| 347 |
destination.writeBundle(mExtras); |
| 348 |
destination.writeInt(mConnectionProperties); |
| 349 |
destination.writeLong(mConnectElapsedTimeMillis); |
| 350 |
destination.writeParcelable(mAddress, 0); |
| 351 |
destination.writeInt(mAddressPresentation); |
| 352 |
destination.writeString(mCallerDisplayName); |
| 353 |
destination.writeInt(mCallerDisplayNamePresentation); |
| 354 |
destination.writeParcelable(mDisconnectCause, 0); |
| 355 |
destination.writeInt(mRingbackRequested ? 1 : 0); |
| 356 |
destination.writeInt(mCallDirection); |
| 357 |
} |
| 358 |
} |