From 066612a910cce4f4fd2f6ba83f31a7264bbef16b Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Tue, 20 Nov 2018 15:32:33 -0800 Subject: Add PhoneAccountSuggestion class Add parcelable data class for the phone acct suggestion feature. Test: TBD Bug: 111455117 Change-Id: I6d5368133abfc076ccb2e6ddfff70de8b6a56e8f --- api/current.txt | 14 ++++ api/system-current.txt | 4 ++ .../android/telecom/PhoneAccountSuggestion.java | 82 ++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 telecomm/java/android/telecom/PhoneAccountSuggestion.java diff --git a/api/current.txt b/api/current.txt index 3580fa520f22..420e029c500f 100755 --- a/api/current.txt +++ b/api/current.txt @@ -41683,6 +41683,20 @@ package android.telecom { field public static final android.os.Parcelable.Creator CREATOR; } + public final class PhoneAccountSuggestion implements android.os.Parcelable { + method public int describeContents(); + method public android.telecom.PhoneAccountHandle getHandle(); + method public int getReason(); + method public boolean shouldAutoSelect(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator CREATOR; + field public static final int REASON_FREQUENT = 2; // 0x2 + field public static final int REASON_INTRA_CARRIER = 1; // 0x1 + field public static final int REASON_NONE = 0; // 0x0 + field public static final int REASON_OTHER = 4; // 0x4 + field public static final int REASON_USER_SET = 3; // 0x3 + } + public final class RemoteConference { method public void disconnect(); method public java.util.List getConferenceableConnections(); diff --git a/api/system-current.txt b/api/system-current.txt index 4aaed7a83ffb..83fd41119a25 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5022,6 +5022,10 @@ package android.telecom { field public static final int CAPABILITY_MULTI_USER = 32; // 0x20 } + public final class PhoneAccountSuggestion implements android.os.Parcelable { + ctor public PhoneAccountSuggestion(android.telecom.PhoneAccountHandle, int, boolean); + } + public final class RemoteConference { method public deprecated void setAudioState(android.telecom.AudioState); } diff --git a/telecomm/java/android/telecom/PhoneAccountSuggestion.java b/telecomm/java/android/telecom/PhoneAccountSuggestion.java new file mode 100644 index 000000000000..cea5beeda81a --- /dev/null +++ b/telecomm/java/android/telecom/PhoneAccountSuggestion.java @@ -0,0 +1,82 @@ +package android.telecom; + +import android.annotation.IntDef; +import android.annotation.SystemApi; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +public final class PhoneAccountSuggestion implements Parcelable { + + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(value = {REASON_NONE, REASON_INTRA_CARRIER, REASON_FREQUENT, + REASON_USER_SET, REASON_OTHER}, prefix = { "REASON_" }) + public @interface SuggestionReason {} + + public static final int REASON_NONE = 0; + public static final int REASON_INTRA_CARRIER = 1; + public static final int REASON_FREQUENT = 2; + public static final int REASON_USER_SET = 3; + public static final int REASON_OTHER = 4; + + private PhoneAccountHandle mHandle; + private int mReason; + private boolean mShouldAutoSelect; + + /** + * @hide + */ + @SystemApi + public PhoneAccountSuggestion(PhoneAccountHandle handle, @SuggestionReason int reason, + boolean shouldAutoSelect) { + this.mHandle = handle; + this.mReason = reason; + this.mShouldAutoSelect = shouldAutoSelect; + } + + private PhoneAccountSuggestion(Parcel in) { + mHandle = in.readParcelable(PhoneAccountHandle.class.getClassLoader()); + mReason = in.readInt(); + mShouldAutoSelect = in.readByte() != 0; + } + + public static final Creator CREATOR = + new Creator() { + @Override + public PhoneAccountSuggestion createFromParcel(Parcel in) { + return new PhoneAccountSuggestion(in); + } + + @Override + public PhoneAccountSuggestion[] newArray(int size) { + return new PhoneAccountSuggestion[size]; + } + }; + + public PhoneAccountHandle getHandle() { + return mHandle; + } + + public @SuggestionReason int getReason() { + return mReason; + } + + public boolean shouldAutoSelect() { + return mShouldAutoSelect; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeParcelable(mHandle, flags); + dest.writeInt(mReason); + dest.writeByte((byte) (mShouldAutoSelect ? 1 : 0)); + } +} -- cgit v1.2.3-59-g8ed1b From 34d9e24008ccdc5e294a5897c92c062e3eea8298 Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Wed, 21 Nov 2018 17:05:58 -0800 Subject: Add docs and more annotations Add docs to some constants in PhoneAccountSuggestion and add @TestApi annotations to enable CTS testing for the new APIs. Test: compiles Bug: 111455117 Change-Id: I2b55a411ff4f0da37eefa0996f7316ea53bca41d --- api/current.txt | 5 +- api/test-current.txt | 4 ++ telecomm/java/android/telecom/Call.java | 11 +++++ .../android/telecom/PhoneAccountSuggestion.java | 55 +++++++++++++++++++++- 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/api/current.txt b/api/current.txt index 420e029c500f..5e8fa194e98c 100755 --- a/api/current.txt +++ b/api/current.txt @@ -41111,8 +41111,9 @@ package android.telecom { method public void swapConference(); method public void unhold(); method public void unregisterCallback(android.telecom.Call.Callback); - field public static final java.lang.String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts"; + field public static final deprecated java.lang.String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts"; field public static final java.lang.String EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS = "android.telecom.extra.LAST_EMERGENCY_CALLBACK_TIME_MILLIS"; + field public static final java.lang.String EXTRA_SUGGESTED_PHONE_ACCOUNTS = "android.telecom.extra.SUGGESTED_PHONE_ACCOUNTS"; field public static final int STATE_ACTIVE = 4; // 0x4 field public static final int STATE_CONNECTING = 9; // 0x9 field public static final int STATE_DIALING = 1; // 0x1 @@ -41685,7 +41686,7 @@ package android.telecom { public final class PhoneAccountSuggestion implements android.os.Parcelable { method public int describeContents(); - method public android.telecom.PhoneAccountHandle getHandle(); + method public android.telecom.PhoneAccountHandle getPhoneAccountHandle(); method public int getReason(); method public boolean shouldAutoSelect(); method public void writeToParcel(android.os.Parcel, int); diff --git a/api/test-current.txt b/api/test-current.txt index 8466ef037142..b5b128a94727 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -963,6 +963,10 @@ package android.telecom { ctor public CallAudioState(boolean, int, int, android.bluetooth.BluetoothDevice, java.util.Collection); } + public final class PhoneAccountSuggestion implements android.os.Parcelable { + ctor public PhoneAccountSuggestion(android.telecom.PhoneAccountHandle, int, boolean); + } + } package android.telephony { diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index cef998651cfe..bf0ffb94b252 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -123,9 +123,20 @@ public final class Call { * The key to retrieve the optional {@code PhoneAccount}s Telecom can bundle with its Call * extras. Used to pass the phone accounts to display on the front end to the user in order to * select phone accounts to (for example) place a call. + * @deprecated Use the list from {@link #EXTRA_SUGGESTED_PHONE_ACCOUNTS} instead. */ + @Deprecated public static final String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts"; + /** + * Key for extra used to pass along a list of {@link PhoneAccountSuggestion}s to the in-call + * UI when a call enters the {@link #STATE_SELECT_PHONE_ACCOUNT} state. The list included here + * will have the same length and be in the same order as the list passed with + * {@link #AVAILABLE_PHONE_ACCOUNTS}. + */ + public static final String EXTRA_SUGGESTED_PHONE_ACCOUNTS = + "android.telecom.extra.SUGGESTED_PHONE_ACCOUNTS"; + /** * Extra key used to indicate the time (in milliseconds since midnight, January 1, 1970 UTC) * when the last outgoing emergency call was made. This is used to identify potential emergency diff --git a/telecomm/java/android/telecom/PhoneAccountSuggestion.java b/telecomm/java/android/telecom/PhoneAccountSuggestion.java index cea5beeda81a..4e6a178c8170 100644 --- a/telecomm/java/android/telecom/PhoneAccountSuggestion.java +++ b/telecomm/java/android/telecom/PhoneAccountSuggestion.java @@ -1,7 +1,24 @@ +/* + * 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.telecom; import android.annotation.IntDef; import android.annotation.SystemApi; +import android.annotation.TestApi; import android.os.Parcel; import android.os.Parcelable; @@ -16,10 +33,33 @@ public final class PhoneAccountSuggestion implements Parcelable { REASON_USER_SET, REASON_OTHER}, prefix = { "REASON_" }) public @interface SuggestionReason {} + /** + * Indicates that this account is not suggested for use, but is still available. + */ public static final int REASON_NONE = 0; + + /** + * Indicates that the {@link PhoneAccountHandle} is suggested because the number we're calling + * is on the same carrier, and therefore may have lower rates. + */ public static final int REASON_INTRA_CARRIER = 1; + + /** + * Indicates that the {@link PhoneAccountHandle} is suggested because the user uses it + * frequently for the number that we are calling. + */ public static final int REASON_FREQUENT = 2; + + /** + * Indicates that the {@link PhoneAccountHandle} is suggested because the user explicitly + * specified that it be used for the number we are calling. + */ public static final int REASON_USER_SET = 3; + + /** + * Indicates that the {@link PhoneAccountHandle} is suggested for a reason not otherwise + * enumerated here. + */ public static final int REASON_OTHER = 4; private PhoneAccountHandle mHandle; @@ -30,6 +70,7 @@ public final class PhoneAccountSuggestion implements Parcelable { * @hide */ @SystemApi + @TestApi public PhoneAccountSuggestion(PhoneAccountHandle handle, @SuggestionReason int reason, boolean shouldAutoSelect) { this.mHandle = handle; @@ -56,14 +97,26 @@ public final class PhoneAccountSuggestion implements Parcelable { } }; - public PhoneAccountHandle getHandle() { + /** + * @return The {@link PhoneAccountHandle} for this suggestion. + */ + public PhoneAccountHandle getPhoneAccountHandle() { return mHandle; } + /** + * @return The reason for this suggestion + */ public @SuggestionReason int getReason() { return mReason; } + /** + * Suggests whether the dialer should automatically place the call using this account without + * user interaction. This may be set on multiple {@link PhoneAccountSuggestion}s, and the dialer + * is free to choose which one to use. + * @return {@code true} if the hint is to auto-select, {@code false} otherwise. + */ public boolean shouldAutoSelect() { return mShouldAutoSelect; } -- cgit v1.2.3-59-g8ed1b