blob: cea5beeda81a17d71a3f4d90e6f0a9d66e794f6d [file] [log] [blame]
Hall Liu066612a2018-11-20 15:32:33 -08001package android.telecom;
2
3import android.annotation.IntDef;
4import android.annotation.SystemApi;
5import android.os.Parcel;
6import android.os.Parcelable;
7
8import java.lang.annotation.Retention;
9import java.lang.annotation.RetentionPolicy;
10
11public final class PhoneAccountSuggestion implements Parcelable {
12
13 /** @hide */
14 @Retention(RetentionPolicy.SOURCE)
15 @IntDef(value = {REASON_NONE, REASON_INTRA_CARRIER, REASON_FREQUENT,
16 REASON_USER_SET, REASON_OTHER}, prefix = { "REASON_" })
17 public @interface SuggestionReason {}
18
19 public static final int REASON_NONE = 0;
20 public static final int REASON_INTRA_CARRIER = 1;
21 public static final int REASON_FREQUENT = 2;
22 public static final int REASON_USER_SET = 3;
23 public static final int REASON_OTHER = 4;
24
25 private PhoneAccountHandle mHandle;
26 private int mReason;
27 private boolean mShouldAutoSelect;
28
29 /**
30 * @hide
31 */
32 @SystemApi
33 public PhoneAccountSuggestion(PhoneAccountHandle handle, @SuggestionReason int reason,
34 boolean shouldAutoSelect) {
35 this.mHandle = handle;
36 this.mReason = reason;
37 this.mShouldAutoSelect = shouldAutoSelect;
38 }
39
40 private PhoneAccountSuggestion(Parcel in) {
41 mHandle = in.readParcelable(PhoneAccountHandle.class.getClassLoader());
42 mReason = in.readInt();
43 mShouldAutoSelect = in.readByte() != 0;
44 }
45
46 public static final Creator<PhoneAccountSuggestion> CREATOR =
47 new Creator<PhoneAccountSuggestion>() {
48 @Override
49 public PhoneAccountSuggestion createFromParcel(Parcel in) {
50 return new PhoneAccountSuggestion(in);
51 }
52
53 @Override
54 public PhoneAccountSuggestion[] newArray(int size) {
55 return new PhoneAccountSuggestion[size];
56 }
57 };
58
59 public PhoneAccountHandle getHandle() {
60 return mHandle;
61 }
62
63 public @SuggestionReason int getReason() {
64 return mReason;
65 }
66
67 public boolean shouldAutoSelect() {
68 return mShouldAutoSelect;
69 }
70
71 @Override
72 public int describeContents() {
73 return 0;
74 }
75
76 @Override
77 public void writeToParcel(Parcel dest, int flags) {
78 dest.writeParcelable(mHandle, flags);
79 dest.writeInt(mReason);
80 dest.writeByte((byte) (mShouldAutoSelect ? 1 : 0));
81 }
82}