| 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.IntDef; |
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
import java.lang.annotation.Retention; |
| 25 |
import java.lang.annotation.RetentionPolicy; |
| 26 |
import java.util.Objects; |
| 27 |
|
| 28 |
public final class PhoneAccountSuggestion implements Parcelable { |
| 29 |
|
| 30 |
|
| 31 |
@Retention(RetentionPolicy.SOURCE) |
| 32 |
@IntDef(value = {REASON_NONE, REASON_INTRA_CARRIER, REASON_FREQUENT, |
| 33 |
REASON_USER_SET, REASON_OTHER}, prefix = { "REASON_" }) |
| 34 |
public @interface SuggestionReason {} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public static final int REASON_NONE = 0; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public static final int REASON_INTRA_CARRIER = 1; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public static final int REASON_FREQUENT = 2; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
public static final int REASON_USER_SET = 3; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
public static final int REASON_OTHER = 4; |
| 64 |
|
| 65 |
private PhoneAccountHandle mHandle; |
| 66 |
private int mReason; |
| 67 |
private boolean mShouldAutoSelect; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
public PhoneAccountSuggestion(@NonNull PhoneAccountHandle handle, @SuggestionReason int reason, |
| 80 |
boolean shouldAutoSelect) { |
| 81 |
this.mHandle = handle; |
| 82 |
this.mReason = reason; |
| 83 |
this.mShouldAutoSelect = shouldAutoSelect; |
| 84 |
} |
| 85 |
|
| 86 |
private PhoneAccountSuggestion(Parcel in) { |
| 87 |
mHandle = in.readParcelable(PhoneAccountHandle.class.getClassLoader(), android.telecom.PhoneAccountHandle.class); |
| 88 |
mReason = in.readInt(); |
| 89 |
mShouldAutoSelect = in.readByte() != 0; |
| 90 |
} |
| 91 |
|
| 92 |
public static final @android.annotation.NonNull Creator<PhoneAccountSuggestion> CREATOR = |
| 93 |
new Creator<PhoneAccountSuggestion>() { |
| 94 |
@Override |
| 95 |
public PhoneAccountSuggestion createFromParcel(Parcel in) { |
| 96 |
return new PhoneAccountSuggestion(in); |
| 97 |
} |
| 98 |
|
| 99 |
@Override |
| 100 |
public PhoneAccountSuggestion[] newArray(int size) { |
| 101 |
return new PhoneAccountSuggestion[size]; |
| 102 |
} |
| 103 |
}; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
@NonNull public PhoneAccountHandle getPhoneAccountHandle() { |
| 109 |
return mHandle; |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
public @SuggestionReason int getReason() { |
| 116 |
return mReason; |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
public boolean shouldAutoSelect() { |
| 126 |
return mShouldAutoSelect; |
| 127 |
} |
| 128 |
|
| 129 |
@Override |
| 130 |
public int describeContents() { |
| 131 |
return 0; |
| 132 |
} |
| 133 |
|
| 134 |
@Override |
| 135 |
public void writeToParcel(Parcel dest, int flags) { |
| 136 |
dest.writeParcelable(mHandle, flags); |
| 137 |
dest.writeInt(mReason); |
| 138 |
dest.writeByte((byte) (mShouldAutoSelect ? 1 : 0)); |
| 139 |
} |
| 140 |
|
| 141 |
@Override |
| 142 |
public boolean equals(Object o) { |
| 143 |
if (this == o) return true; |
| 144 |
if (o == null || getClass() != o.getClass()) return false; |
| 145 |
PhoneAccountSuggestion that = (PhoneAccountSuggestion) o; |
| 146 |
return mReason == that.mReason |
| 147 |
&& mShouldAutoSelect == that.mShouldAutoSelect |
| 148 |
&& Objects.equals(mHandle, that.mHandle); |
| 149 |
} |
| 150 |
|
| 151 |
@Override |
| 152 |
public int hashCode() { |
| 153 |
return Objects.hash(mHandle, mReason, mShouldAutoSelect); |
| 154 |
} |
| 155 |
} |