Merge "Update API docs for Telephony call state reporting." am: c2493ee1ee

am: 1ba28fec3f

Change-Id: I60014a59db60610746841840278adead80963db8
This commit is contained in:
Tyler Gunn
2018-03-14 17:22:06 +00:00
committed by android-build-merger
3 changed files with 56 additions and 24 deletions

View File

@@ -1265,7 +1265,7 @@ public class TelecomManager {
* @hide
*/
@SystemApi
public int getCallState() {
public @TelephonyManager.CallState int getCallState() {
try {
if (isServiceConnected()) {
return getTelecomService().getCallState();

View File

@@ -20,6 +20,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.telecom.TelecomManager;
import com.android.internal.telephony.IPhoneStateListener;
@@ -428,16 +429,20 @@ public class PhoneStateListener {
/**
* Callback invoked when device call state changes.
* <p>
* Reports the state of Telephony (mobile) calls on the device.
* <p>
* Note: The state returned here may differ from that returned by
* {@link TelephonyManager#getCallState()}. Receivers of this callback should be aware that
* calling {@link TelephonyManager#getCallState()} from within this callback may return a
* different state than the callback reports.
*
* @param state call state
* @param phoneNumber call phone number. If application does not have
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} permission, an empty
* string will be passed as an argument.
*
* @see TelephonyManager#CALL_STATE_IDLE
* @see TelephonyManager#CALL_STATE_RINGING
* @see TelephonyManager#CALL_STATE_OFFHOOK
*/
public void onCallStateChanged(int state, String phoneNumber) {
public void onCallStateChanged(@TelephonyManager.CallState int state, String phoneNumber) {
// default implementation empty
}

View File

@@ -3922,26 +3922,45 @@ public class TelephonyManager {
return IPhoneSubInfo.Stub.asInterface(ServiceManager.getService("iphonesubinfo"));
}
/** Device call state: No activity. */
/**
* Device call state: No activity.
*/
public static final int CALL_STATE_IDLE = 0;
/** Device call state: Ringing. A new call arrived and is
/**
* Device call state: Ringing. A new call arrived and is
* ringing or waiting. In the latter case, another call is
* already active. */
* already active.
*/
public static final int CALL_STATE_RINGING = 1;
/** Device call state: Off-hook. At least one call exists
* that is dialing, active, or on hold, and no calls are ringing
* or waiting. */
/**
* Device call state: Off-hook. At least one call exists
* that is dialing, active, or on hold, and no calls are ringing
* or waiting.
*/
public static final int CALL_STATE_OFFHOOK = 2;
/** @hide */
@IntDef(prefix = { "CALL_STATE_" }, value = {
CALL_STATE_IDLE,
CALL_STATE_RINGING,
CALL_STATE_OFFHOOK
})
@Retention(RetentionPolicy.SOURCE)
public @interface CallState{}
/**
* Returns one of the following constants that represents the current state of all
* phone calls.
* Returns the state of all calls on the device.
* <p>
* This method considers not only calls in the Telephony stack, but also calls via other
* {@link android.telecom.ConnectionService} implementations.
* <p>
* Note: The call state returned via this method may differ from what is reported by
* {@link PhoneStateListener#onCallStateChanged(int, String)}, as that callback only considers
* Telephony (mobile) calls.
*
* {@link TelephonyManager#CALL_STATE_RINGING}
* {@link TelephonyManager#CALL_STATE_OFFHOOK}
* {@link TelephonyManager#CALL_STATE_IDLE}
* @return the current call state.
*/
public int getCallState() {
public @CallState int getCallState() {
try {
ITelecomService telecom = getTelecomService();
if (telecom != null) {
@@ -3954,23 +3973,31 @@ public class TelephonyManager {
}
/**
* Returns a constant indicating the call state (cellular) on the device
* for a subscription.
* Returns the Telephony call state for calls on a specific subscription.
* <p>
* Note: This method considers ONLY telephony/mobile calls, where {@link #getCallState()}
* considers the state of calls from other {@link android.telecom.ConnectionService}
* implementations.
*
* @param subId whose call state is returned
* @param subId the subscription to check call state for.
* @hide
*/
public int getCallState(int subId) {
public @CallState int getCallState(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
return getCallStateForSlot(phoneId);
}
/**
* See getCallState.
* Returns the Telephony call state for calls on a specific SIM slot.
* <p>
* Note: This method considers ONLY telephony/mobile calls, where {@link #getCallState()}
* considers the state of calls from other {@link android.telecom.ConnectionService}
* implementations.
*
* @param slotIndex the SIM slot index to check call state for.
* @hide
*/
public int getCallStateForSlot(int slotIndex) {
public @CallState int getCallStateForSlot(int slotIndex) {
try {
ITelephony telephony = getITelephony();
if (telephony == null)