Expose and update the call forward/waiting APIs

Expose the call forwarding and call waiting APIs, update their
documentation, and convert them to async APIs due to their dependence on
network communication.

Fixes: 168655869
Test: atest android.telephony.cts.TelephonyManagerTest
Change-Id: Ic20bc99314c8538a3f75f6af9c37bc4d30781825
Merged-In: Ic20bc99314c8538a3f75f6af9c37bc4d30781825
This commit is contained in:
Hall Liu
2020-09-18 19:03:33 -07:00
parent 9caec78557
commit 8410239d72
7 changed files with 359 additions and 213 deletions

View File

@@ -10543,6 +10543,26 @@ package android.telephony {
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallAttributes> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallAttributes> CREATOR;
} }
public final class CallForwardingInfo implements android.os.Parcelable {
ctor public CallForwardingInfo(boolean, int, @Nullable String, int);
method public int describeContents();
method @Nullable public String getNumber();
method public int getReason();
method public int getTimeoutSeconds();
method public boolean isEnabled();
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallForwardingInfo> CREATOR;
field public static final int ERROR_FDN_CHECK_FAILURE = 2; // 0x2
field public static final int ERROR_NOT_SUPPORTED = 3; // 0x3
field public static final int ERROR_UNKNOWN = 1; // 0x1
field public static final int REASON_ALL = 4; // 0x4
field public static final int REASON_ALL_CONDITIONAL = 5; // 0x5
field public static final int REASON_BUSY = 1; // 0x1
field public static final int REASON_NOT_REACHABLE = 3; // 0x3
field public static final int REASON_NO_REPLY = 2; // 0x2
field public static final int REASON_UNCONDITIONAL = 0; // 0x0
field public static final int SUCCESS = 0; // 0x0
}
public final class CallQuality implements android.os.Parcelable { public final class CallQuality implements android.os.Parcelable {
ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int); ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int);
ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean); ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean);
@@ -11183,6 +11203,8 @@ package android.telephony {
method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getAllowedNetworkTypes(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getAllowedNetworkTypes();
method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getAndUpdateDefaultRespondViaMessageApplication(); method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getAndUpdateDefaultRespondViaMessageApplication();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallForwarding(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CallForwardingInfoCallback);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallWaitingStatus(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int);
@@ -11260,6 +11282,8 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) public void resetSettings(); method @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) public void resetSettings();
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCallForwarding(@NonNull android.telephony.CallForwardingInfo, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCallWaitingStatus(boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int);
@@ -11297,6 +11321,10 @@ package android.telephony {
field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED"; field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED";
field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED"; field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED";
field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED"; field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED";
field public static final int CALL_WAITING_STATUS_DISABLED = 2; // 0x2
field public static final int CALL_WAITING_STATUS_ENABLED = 1; // 0x1
field public static final int CALL_WAITING_STATUS_NOT_SUPPORTED = 4; // 0x4
field public static final int CALL_WAITING_STATUS_UNKNOWN_ERROR = 3; // 0x3
field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe
field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1 field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1
field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0 field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0
@@ -11351,6 +11379,11 @@ package android.telephony {
field public static final int SRVCC_STATE_HANDOVER_STARTED = 0; // 0x0 field public static final int SRVCC_STATE_HANDOVER_STARTED = 0; // 0x0
} }
public static interface TelephonyManager.CallForwardingInfoCallback {
method public void onCallForwardingInfoAvailable(@NonNull android.telephony.CallForwardingInfo);
method public void onError(int);
}
public final class UiccAccessRule implements android.os.Parcelable { public final class UiccAccessRule implements android.os.Parcelable {
ctor public UiccAccessRule(byte[], @Nullable String, long); ctor public UiccAccessRule(byte[], @Nullable String, long);
method public int describeContents(); method public int describeContents();

View File

@@ -9425,6 +9425,26 @@ package android.telephony {
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallAttributes> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallAttributes> CREATOR;
} }
public final class CallForwardingInfo implements android.os.Parcelable {
ctor public CallForwardingInfo(boolean, int, @Nullable String, int);
method public int describeContents();
method @Nullable public String getNumber();
method public int getReason();
method public int getTimeoutSeconds();
method public boolean isEnabled();
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallForwardingInfo> CREATOR;
field public static final int ERROR_FDN_CHECK_FAILURE = 2; // 0x2
field public static final int ERROR_NOT_SUPPORTED = 3; // 0x3
field public static final int ERROR_UNKNOWN = 1; // 0x1
field public static final int REASON_ALL = 4; // 0x4
field public static final int REASON_ALL_CONDITIONAL = 5; // 0x5
field public static final int REASON_BUSY = 1; // 0x1
field public static final int REASON_NOT_REACHABLE = 3; // 0x3
field public static final int REASON_NO_REPLY = 2; // 0x2
field public static final int REASON_UNCONDITIONAL = 0; // 0x0
field public static final int SUCCESS = 0; // 0x0
}
public final class CallQuality implements android.os.Parcelable { public final class CallQuality implements android.os.Parcelable {
ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int); ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int);
ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean); ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean);
@@ -10065,6 +10085,8 @@ package android.telephony {
method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getAllowedNetworkTypes(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getAllowedNetworkTypes();
method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getAndUpdateDefaultRespondViaMessageApplication(); method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getAndUpdateDefaultRespondViaMessageApplication();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallForwarding(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CallForwardingInfoCallback);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallWaitingStatus(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int);
@@ -10142,6 +10164,8 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) public void resetSettings(); method @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) public void resetSettings();
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCallForwarding(@NonNull android.telephony.CallForwardingInfo, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCallWaitingStatus(boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int);
@@ -10179,6 +10203,10 @@ package android.telephony {
field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED"; field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED";
field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED"; field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED";
field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED"; field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED";
field public static final int CALL_WAITING_STATUS_DISABLED = 2; // 0x2
field public static final int CALL_WAITING_STATUS_ENABLED = 1; // 0x1
field public static final int CALL_WAITING_STATUS_NOT_SUPPORTED = 4; // 0x4
field public static final int CALL_WAITING_STATUS_UNKNOWN_ERROR = 3; // 0x3
field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe
field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1 field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1
field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0 field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0
@@ -10233,6 +10261,11 @@ package android.telephony {
field public static final int SRVCC_STATE_HANDOVER_STARTED = 0; // 0x0 field public static final int SRVCC_STATE_HANDOVER_STARTED = 0; // 0x0
} }
public static interface TelephonyManager.CallForwardingInfoCallback {
method public void onCallForwardingInfoAvailable(@NonNull android.telephony.CallForwardingInfo);
method public void onError(int);
}
public final class UiccAccessRule implements android.os.Parcelable { public final class UiccAccessRule implements android.os.Parcelable {
ctor public UiccAccessRule(byte[], @Nullable String, long); ctor public UiccAccessRule(byte[], @Nullable String, long);
method public int describeContents(); method public int describeContents();

View File

@@ -27,6 +27,26 @@ package android.telephony {
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallAttributes> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallAttributes> CREATOR;
} }
public final class CallForwardingInfo implements android.os.Parcelable {
ctor public CallForwardingInfo(boolean, int, @Nullable String, int);
method public int describeContents();
method @Nullable public String getNumber();
method public int getReason();
method public int getTimeoutSeconds();
method public boolean isEnabled();
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallForwardingInfo> CREATOR;
field public static final int ERROR_FDN_CHECK_FAILURE = 2; // 0x2
field public static final int ERROR_NOT_SUPPORTED = 3; // 0x3
field public static final int ERROR_UNKNOWN = 1; // 0x1
field public static final int REASON_ALL = 4; // 0x4
field public static final int REASON_ALL_CONDITIONAL = 5; // 0x5
field public static final int REASON_BUSY = 1; // 0x1
field public static final int REASON_NOT_REACHABLE = 3; // 0x3
field public static final int REASON_NO_REPLY = 2; // 0x2
field public static final int REASON_UNCONDITIONAL = 0; // 0x0
field public static final int SUCCESS = 0; // 0x0
}
public final class CallQuality implements android.os.Parcelable { public final class CallQuality implements android.os.Parcelable {
ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int); ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int);
ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean); ctor public CallQuality(int, int, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean);
@@ -640,6 +660,8 @@ package android.telephony {
method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getAllowedNetworkTypes(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getAllowedNetworkTypes();
method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getAndUpdateDefaultRespondViaMessageApplication(); method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getAndUpdateDefaultRespondViaMessageApplication();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallForwarding(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CallForwardingInfoCallback);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallWaitingStatus(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int);
@@ -718,6 +740,8 @@ package android.telephony {
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCallForwarding(@NonNull android.telephony.CallForwardingInfo, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCallWaitingStatus(boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int);
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataEnabled(int, boolean); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataEnabled(int, boolean);
@@ -754,6 +778,10 @@ package android.telephony {
field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED"; field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED";
field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED"; field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED";
field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED"; field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED";
field public static final int CALL_WAITING_STATUS_DISABLED = 2; // 0x2
field public static final int CALL_WAITING_STATUS_ENABLED = 1; // 0x1
field public static final int CALL_WAITING_STATUS_NOT_SUPPORTED = 4; // 0x4
field public static final int CALL_WAITING_STATUS_UNKNOWN_ERROR = 3; // 0x3
field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe
field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1 field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1
field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0 field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0
@@ -808,6 +836,11 @@ package android.telephony {
field public static final int SRVCC_STATE_HANDOVER_STARTED = 0; // 0x0 field public static final int SRVCC_STATE_HANDOVER_STARTED = 0; // 0x0
} }
public static interface TelephonyManager.CallForwardingInfoCallback {
method public void onCallForwardingInfoAvailable(@NonNull android.telephony.CallForwardingInfo);
method public void onError(int);
}
public final class UiccAccessRule implements android.os.Parcelable { public final class UiccAccessRule implements android.os.Parcelable {
ctor public UiccAccessRule(byte[], @Nullable String, long); ctor public UiccAccessRule(byte[], @Nullable String, long);
method public int describeContents(); method public int describeContents();

View File

@@ -20,6 +20,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
@@ -33,50 +34,35 @@ import java.util.Objects;
* Defines the call forwarding information. * Defines the call forwarding information.
* @hide * @hide
*/ */
@SystemApi
public final class CallForwardingInfo implements Parcelable { public final class CallForwardingInfo implements Parcelable {
private static final String TAG = "CallForwardingInfo"; private static final String TAG = "CallForwardingInfo";
/** /**
* Indicates the call forwarding status is inactive. * Indicates that the operation was successful.
*
* @hide
*/ */
public static final int STATUS_INACTIVE = 0; public static final int SUCCESS = 0;
/** /**
* Indicates the call forwarding status is active. * Indicates that setting or retrieving the call forwarding info failed with an unknown error.
*
* @hide
*/ */
public static final int STATUS_ACTIVE = 1; public static final int ERROR_UNKNOWN = 1;
/** /**
* Indicates the call forwarding could not be enabled because the recipient is not on * Indicates that call forwarding is not enabled because the recipient is not on a
* Fixed Dialing Number (FDN) list. * Fixed Dialing Number (FDN) list.
*
* @hide
*/ */
public static final int STATUS_FDN_CHECK_FAILURE = 2; public static final int ERROR_FDN_CHECK_FAILURE = 2;
/** /**
* Indicates the call forwarding status is with an unknown error. * Indicates that call forwarding is not supported on the network at this time.
*
* @hide
*/ */
public static final int STATUS_UNKNOWN_ERROR = 3; public static final int ERROR_NOT_SUPPORTED = 3;
/** /**
* Indicates the call forwarding is not supported (e.g. called via CDMA). * Indicates that call forwarding reason is "unconditional".
*
* @hide
*/
public static final int STATUS_NOT_SUPPORTED = 4;
/**
* Indicates the call forwarding reason is "unconditional".
* Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number * Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number
* and conditions +CCFC * and conditions +CCFC
* @hide
*/ */
public static final int REASON_UNCONDITIONAL = 0; public static final int REASON_UNCONDITIONAL = 0;
@@ -84,7 +70,6 @@ public final class CallForwardingInfo implements Parcelable {
* Indicates the call forwarding status is "busy". * Indicates the call forwarding status is "busy".
* Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number * Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number
* and conditions +CCFC * and conditions +CCFC
* @hide
*/ */
public static final int REASON_BUSY = 1; public static final int REASON_BUSY = 1;
@@ -92,7 +77,6 @@ public final class CallForwardingInfo implements Parcelable {
* Indicates the call forwarding reason is "no reply". * Indicates the call forwarding reason is "no reply".
* Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number * Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number
* and conditions +CCFC * and conditions +CCFC
* @hide
*/ */
public static final int REASON_NO_REPLY = 2; public static final int REASON_NO_REPLY = 2;
@@ -100,7 +84,6 @@ public final class CallForwardingInfo implements Parcelable {
* Indicates the call forwarding reason is "not reachable". * Indicates the call forwarding reason is "not reachable".
* Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number * Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number
* and conditions +CCFC * and conditions +CCFC
* @hide
*/ */
public static final int REASON_NOT_REACHABLE = 3; public static final int REASON_NOT_REACHABLE = 3;
@@ -109,7 +92,6 @@ public final class CallForwardingInfo implements Parcelable {
* simultaneously (unconditional, busy, no reply, and not reachable). * simultaneously (unconditional, busy, no reply, and not reachable).
* Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number * Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number
* and conditions +CCFC * and conditions +CCFC
* @hide
*/ */
public static final int REASON_ALL = 4; public static final int REASON_ALL = 4;
@@ -118,26 +100,25 @@ public final class CallForwardingInfo implements Parcelable {
* forwarding reasons simultaneously (busy, no reply, and not reachable). * forwarding reasons simultaneously (busy, no reply, and not reachable).
* Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number * Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number
* and conditions +CCFC * and conditions +CCFC
* @hide
*/ */
public static final int REASON_ALL_CONDITIONAL = 5; public static final int REASON_ALL_CONDITIONAL = 5;
/** /**
* Call forwarding function status * Call forwarding errors
* @hide
*/ */
@IntDef(prefix = { "STATUS_" }, value = { @IntDef(prefix = { "ERROR_" }, value = {
STATUS_ACTIVE, ERROR_UNKNOWN,
STATUS_INACTIVE, ERROR_NOT_SUPPORTED,
STATUS_UNKNOWN_ERROR, ERROR_FDN_CHECK_FAILURE
STATUS_NOT_SUPPORTED,
STATUS_FDN_CHECK_FAILURE
}) })
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface CallForwardingStatus { public @interface CallForwardingError{
} }
/** /**
* Call forwarding reason types * Call forwarding reason types
* @hide
*/ */
@IntDef(flag = true, prefix = { "REASON_" }, value = { @IntDef(flag = true, prefix = { "REASON_" }, value = {
REASON_UNCONDITIONAL, REASON_UNCONDITIONAL,
@@ -152,9 +133,9 @@ public final class CallForwardingInfo implements Parcelable {
} }
/** /**
* The call forwarding status. * Whether call forwarding is enabled for this reason.
*/ */
private int mStatus; private boolean mEnabled;
/** /**
* The call forwarding reason indicates the condition under which calls will be forwarded. * The call forwarding reason indicates the condition under which calls will be forwarded.
@@ -178,39 +159,35 @@ public final class CallForwardingInfo implements Parcelable {
/** /**
* Construct a CallForwardingInfo. * Construct a CallForwardingInfo.
* *
* @param status the call forwarding status * @param enabled Whether to enable call forwarding for the reason specified
* in {@link #getReason()}.
* @param reason the call forwarding reason * @param reason the call forwarding reason
* @param number the phone number to which calls will be forwarded * @param number the phone number to which calls will be forwarded
* @param timeSeconds the timeout (in seconds) before the forwarding is attempted * @param timeSeconds the timeout (in seconds) before the forwarding is attempted
* @hide
*/ */
public CallForwardingInfo(@CallForwardingStatus int status, @CallForwardingReason int reason, public CallForwardingInfo(boolean enabled, @CallForwardingReason int reason,
@Nullable String number, int timeSeconds) { @Nullable String number, int timeSeconds) {
mStatus = status; mEnabled = enabled;
mReason = reason; mReason = reason;
mNumber = number; mNumber = number;
mTimeSeconds = timeSeconds; mTimeSeconds = timeSeconds;
} }
/** /**
* Returns the call forwarding status. * Whether call forwarding is enabled for the reason from {@link #getReason()}.
* *
* @return the call forwarding status. * @return {@code true} if enabled, {@code false} otherwise.
*
* @hide
*/ */
public @CallForwardingStatus int getStatus() { public boolean isEnabled() {
return mStatus; return mEnabled;
} }
/** /**
* Returns the call forwarding reason. The call forwarding reason indicates the condition * Returns the call forwarding reason. The call forwarding reason indicates the condition
* under which calls will be forwarded. For example, {@link #REASON_NO_REPLY} indicates * under which calls will be forwarded. For example, {@link #REASON_NO_REPLY} indicates
* that calls will be forward to {@link #getNumber()} when the user fails to answer the call. * that calls will be forwarded when the user fails to answer the call.
* *
* @return the call forwarding reason. * @return the call forwarding reason.
*
* @hide
*/ */
public @CallForwardingReason int getReason() { public @CallForwardingReason int getReason() {
return mReason; return mReason;
@@ -220,9 +197,7 @@ public final class CallForwardingInfo implements Parcelable {
* Returns the phone number to which calls will be forwarded. * Returns the phone number to which calls will be forwarded.
* *
* @return the number calls will be forwarded to, or {@code null} if call forwarding * @return the number calls will be forwarded to, or {@code null} if call forwarding
* is being disabled. * is disabled.
*
* @hide
*/ */
@Nullable @Nullable
public String getNumber() { public String getNumber() {
@@ -230,16 +205,14 @@ public final class CallForwardingInfo implements Parcelable {
} }
/** /**
* Gets the timeout (in seconds) before the forwarding is attempted. For example, * Gets the timeout (in seconds) before forwarding is attempted. For example,
* if {@link #REASON_NO_REPLY} is the call forwarding reason, the device will wait this * if {@link #REASON_NO_REPLY} is the call forwarding reason, the device will wait this
* duration of time before forwarding the call to {@link #getNumber()}. * duration of time before forwarding the call to the number returned by {@link #getNumber()}.
* *
* Reference: 3GPP TS 27.007 version 10.3.0 Release 10 * Reference: 3GPP TS 27.007 version 10.3.0 Release 10
* 7.11 Call forwarding number and conditions +CCFC * 7.11 Call forwarding number and conditions +CCFC
* *
* @return the timeout (in seconds) before the forwarding is attempted. * @return the timeout (in seconds) before the forwarding is attempted.
*
* @hide
*/ */
@SuppressLint("MethodNameUnits") @SuppressLint("MethodNameUnits")
public int getTimeoutSeconds() { public int getTimeoutSeconds() {
@@ -257,14 +230,14 @@ public final class CallForwardingInfo implements Parcelable {
@Override @Override
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeString(mNumber); out.writeString(mNumber);
out.writeInt(mStatus); out.writeBoolean(mEnabled);
out.writeInt(mReason); out.writeInt(mReason);
out.writeInt(mTimeSeconds); out.writeInt(mTimeSeconds);
} }
private CallForwardingInfo(Parcel in) { private CallForwardingInfo(Parcel in) {
mNumber = in.readString(); mNumber = in.readString();
mStatus = in.readInt(); mEnabled = in.readBoolean();
mReason = in.readInt(); mReason = in.readInt();
mTimeSeconds = in.readInt(); mTimeSeconds = in.readInt();
} }
@@ -281,7 +254,7 @@ public final class CallForwardingInfo implements Parcelable {
} }
CallForwardingInfo other = (CallForwardingInfo) o; CallForwardingInfo other = (CallForwardingInfo) o;
return mStatus == other.mStatus return mEnabled == other.mEnabled
&& mNumber == other.mNumber && mNumber == other.mNumber
&& mReason == other.mReason && mReason == other.mReason
&& mTimeSeconds == other.mTimeSeconds; && mTimeSeconds == other.mTimeSeconds;
@@ -292,7 +265,7 @@ public final class CallForwardingInfo implements Parcelable {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(mStatus, mNumber, mReason, mTimeSeconds); return Objects.hash(mEnabled, mNumber, mReason, mTimeSeconds);
} }
public static final @NonNull Parcelable.Creator<CallForwardingInfo> CREATOR = public static final @NonNull Parcelable.Creator<CallForwardingInfo> CREATOR =
@@ -313,7 +286,7 @@ public final class CallForwardingInfo implements Parcelable {
*/ */
@Override @Override
public String toString() { public String toString() {
return "[CallForwardingInfo: status=" + mStatus return "[CallForwardingInfo: enabled=" + mEnabled
+ ", reason= " + mReason + ", reason= " + mReason
+ ", timeSec= " + mTimeSeconds + " seconds" + ", timeSec= " + mTimeSeconds + " seconds"
+ ", number=" + Rlog.pii(TAG, mNumber) + "]"; + ", number=" + Rlog.pii(TAG, mNumber) + "]";

View File

@@ -96,6 +96,8 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.CellNetworkScanResult; import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.IBooleanConsumer; import com.android.internal.telephony.IBooleanConsumer;
import com.android.internal.telephony.ICallForwardingInfoCallback;
import com.android.internal.telephony.IIntegerConsumer;
import com.android.internal.telephony.INumberVerificationCallback; import com.android.internal.telephony.INumberVerificationCallback;
import com.android.internal.telephony.IOns; import com.android.internal.telephony.IOns;
import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.IPhoneSubInfo;
@@ -12746,195 +12748,304 @@ public class TelephonyManager {
} }
/** /**
* Gets the voice call forwarding info {@link CallForwardingInfo}, given the call forward * Callback to be used with {@link #getCallForwarding}
* reason. * @hide
*/
@SystemApi
public interface CallForwardingInfoCallback {
/**
* Called when the call forwarding info is successfully retrieved from the network.
* @param info information about how calls are forwarded
*/
void onCallForwardingInfoAvailable(@NonNull CallForwardingInfo info);
/**
* Called when there was an error retrieving the call forwarding information.
* @param error
*/
void onError(@CallForwardingInfo.CallForwardingError int error);
}
/**
* Gets the voice call forwarding info for a given call forwarding reason.
* *
* @param callForwardingReason the call forwarding reasons * This method queries the network for the currently set call forwarding configuration for the
* provided call forwarding reason. When the network has provided its response, the result will
* be supplied via the provided {@link Executor} on the provided
* {@link CallForwardingInfoCallback}.
*
* @param callForwardingReason the call forwarding reason to query.
* @param executor The executor on which to execute the callback once the result is ready.
* @param callback The callback the results should be delivered on.
* *
* @throws IllegalArgumentException if callForwardingReason is not any of * @throws IllegalArgumentException if callForwardingReason is not any of
* {@link CallForwardingInfo.REASON_UNCONDITIONAL}, {@link CallForwardingInfo.REASON_BUSY}, * {@link CallForwardingInfo#REASON_UNCONDITIONAL}, {@link CallForwardingInfo#REASON_BUSY},
* {@link CallForwardingInfo.REASON_NO_REPLY}, {@link CallForwardingInfo.REASON_NOT_REACHABLE}, * {@link CallForwardingInfo#REASON_NO_REPLY}, {@link CallForwardingInfo#REASON_NOT_REACHABLE},
* {@link CallForwardingInfo.REASON_ALL}, {@link CallForwardingInfo.REASON_ALL_CONDITIONAL} * {@link CallForwardingInfo#REASON_ALL}, or {@link CallForwardingInfo#REASON_ALL_CONDITIONAL}
*
* @return {@link CallForwardingInfo} with the status {@link CallForwardingInfo#STATUS_ACTIVE}
* or {@link CallForwardingInfo#STATUS_INACTIVE} and the target phone number to forward calls
* to, if it's available. Otherwise, it will return a {@link CallForwardingInfo} with status
* {@link CallForwardingInfo#STATUS_UNKNOWN_ERROR},
* {@link CallForwardingInfo#STATUS_NOT_SUPPORTED},
* or {@link CallForwardingInfo#STATUS_FDN_CHECK_FAILURE} depending on the situation.
* *
* @hide * @hide
*/ */
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@NonNull @SystemApi
public CallForwardingInfo getCallForwarding(@CallForwardingReason int callForwardingReason) { public void getCallForwarding(@CallForwardingReason int callForwardingReason,
@NonNull Executor executor, @NonNull CallForwardingInfoCallback callback) {
if (callForwardingReason < CallForwardingInfo.REASON_UNCONDITIONAL if (callForwardingReason < CallForwardingInfo.REASON_UNCONDITIONAL
|| callForwardingReason > CallForwardingInfo.REASON_ALL_CONDITIONAL) { || callForwardingReason > CallForwardingInfo.REASON_ALL_CONDITIONAL) {
throw new IllegalArgumentException("callForwardingReason is out of range"); throw new IllegalArgumentException("callForwardingReason is out of range");
} }
ICallForwardingInfoCallback internalCallback = new ICallForwardingInfoCallback.Stub() {
@Override
public void onCallForwardingInfoAvailable(CallForwardingInfo info) {
executor.execute(() ->
Binder.withCleanCallingIdentity(() ->
callback.onCallForwardingInfoAvailable(info)));
}
@Override
public void onError(int error) {
executor.execute(() ->
Binder.withCleanCallingIdentity(() ->
callback.onError(error)));
}
};
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
if (telephony != null) { if (telephony != null) {
return telephony.getCallForwarding(getSubId(), callForwardingReason); telephony.getCallForwarding(getSubId(), callForwardingReason, internalCallback);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
Rlog.e(TAG, "getCallForwarding RemoteException", ex); Rlog.e(TAG, "getCallForwarding RemoteException", ex);
} catch (NullPointerException ex) { ex.rethrowAsRuntimeException();
Rlog.e(TAG, "getCallForwarding NPE", ex);
} }
return new CallForwardingInfo(
CallForwardingInfo.STATUS_UNKNOWN_ERROR, 0 /* reason */, null /* number */,
0 /* timeout */);
} }
/** /**
* Sets the voice call forwarding info including status (enable/disable), call forwarding * Sets voice call forwarding behavior as described by the provided {@link CallForwardingInfo}.
* reason, the number to forward, and the timeout before the forwarding is attempted.
* *
* @param callForwardingInfo {@link CallForwardingInfo} to setup the call forwarding. * This method will enable call forwarding if the provided {@link CallForwardingInfo} returns
* Enabling if {@link CallForwardingInfo#getStatus()} returns * {@code true} from its {@link CallForwardingInfo#isEnabled()} method, and disables call
* {@link CallForwardingInfo#STATUS_ACTIVE}; Disabling if * forwarding otherwise.
* {@link CallForwardingInfo#getStatus()} returns {@link CallForwardingInfo#STATUS_INACTIVE}.
* *
* @throws IllegalArgumentException if any of the following for parameter callForwardingInfo: * If you wish to be notified about the results of this operation, provide an {@link Executor}
* 0) it is {@code null}. * and {@link Consumer<Integer>} to be notified asynchronously when the operation completes.
* 1) {@link CallForwardingInfo#getStatus()} returns neither
* {@link CallForwardingInfo#STATUS_ACTIVE} nor {@link CallForwardingInfo#STATUS_INACTIVE}.
* 2) {@link CallForwardingInfo#getReason()} is not any of
* {@link CallForwardingInfo.REASON_UNCONDITIONAL}, {@link CallForwardingInfo.REASON_BUSY},
* {@link CallForwardingInfo.REASON_NO_REPLY}, {@link CallForwardingInfo.REASON_NOT_REACHABLE},
* {@link CallForwardingInfo.REASON_ALL}, {@link CallForwardingInfo.REASON_ALL_CONDITIONAL}
* 3) {@link CallForwardingInfo#getNumber()} returns {@code null}.
* 4) {@link CallForwardingInfo#getTimeoutSeconds()} doesn't return a positive value.
* *
* @return {@code true} to indicate it was set successfully; {@code false} otherwise. * @param callForwardingInfo Info about whether calls should be forwarded and where they
* should be forwarded to.
* @param executor The executor on which the listener will be called. Must be non-null if
* {@code listener} is non-null.
* @param resultListener Asynchronous listener that'll be called when the operation completes.
* Called with {@link CallForwardingInfo#SUCCESS} if the operation
* succeeded and an error code from {@link CallForwardingInfo}
* if it failed.
* *
* @throws IllegalArgumentException if any of the following are true for the parameter
* callForwardingInfo:
* <ul>
* <li>it is {@code null}.</li>
* <li>{@link CallForwardingInfo#getReason()} is not any of:
* <ul>
* <li>{@link CallForwardingInfo#REASON_UNCONDITIONAL}</li>
* <li>{@link CallForwardingInfo#REASON_BUSY}</li>
* <li>{@link CallForwardingInfo#REASON_NO_REPLY}</li>
* <li>{@link CallForwardingInfo#REASON_NOT_REACHABLE}</li>
* <li>{@link CallForwardingInfo#REASON_ALL}</li>
* <li>{@link CallForwardingInfo#REASON_ALL_CONDITIONAL}</li>
* </ul>
* <li>{@link CallForwardingInfo#getNumber()} returns {@code null} when enabling call
* forwarding</li>
* <li>{@link CallForwardingInfo#getTimeoutSeconds()} returns a non-positive value when
* enabling call forwarding</li>
* </ul>
* @hide * @hide
*/ */
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean setCallForwarding(@NonNull CallForwardingInfo callForwardingInfo) { @SystemApi
public void setCallForwarding(@NonNull CallForwardingInfo callForwardingInfo,
@Nullable @CallbackExecutor Executor executor,
@Nullable @CallForwardingInfo.CallForwardingError Consumer<Integer> resultListener) {
if (callForwardingInfo == null) { if (callForwardingInfo == null) {
throw new IllegalArgumentException("callForwardingInfo is null"); throw new IllegalArgumentException("callForwardingInfo is null");
} }
int callForwardingStatus = callForwardingInfo.getStatus();
if (callForwardingStatus != CallForwardingInfo.STATUS_ACTIVE
&& callForwardingStatus != CallForwardingInfo.STATUS_INACTIVE) {
throw new IllegalArgumentException(
"callForwardingStatus is neither active nor inactive");
}
int callForwardingReason = callForwardingInfo.getReason(); int callForwardingReason = callForwardingInfo.getReason();
if (callForwardingReason < CallForwardingInfo.REASON_UNCONDITIONAL if (callForwardingReason < CallForwardingInfo.REASON_UNCONDITIONAL
|| callForwardingReason > CallForwardingInfo.REASON_ALL_CONDITIONAL) { || callForwardingReason > CallForwardingInfo.REASON_ALL_CONDITIONAL) {
throw new IllegalArgumentException("callForwardingReason is out of range"); throw new IllegalArgumentException("callForwardingReason is out of range");
} }
if (callForwardingInfo.getNumber() == null) { if (callForwardingInfo.isEnabled()) {
throw new IllegalArgumentException("callForwarding number is null"); if (callForwardingInfo.getNumber() == null) {
throw new IllegalArgumentException("callForwarding number is null");
}
if (callForwardingInfo.getTimeoutSeconds() <= 0) {
throw new IllegalArgumentException("callForwarding timeout isn't positive");
}
} }
if (callForwardingInfo.getTimeoutSeconds() <= 0) { if (resultListener != null) {
throw new IllegalArgumentException("callForwarding timeout isn't positive"); Objects.requireNonNull(executor);
} }
IIntegerConsumer internalCallback = new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() ->
Binder.withCleanCallingIdentity(() -> resultListener.accept(result)));
}
};
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
if (telephony != null) { if (telephony != null) {
return telephony.setCallForwarding(getSubId(), callForwardingInfo); telephony.setCallForwarding(getSubId(), callForwardingInfo, internalCallback);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
Rlog.e(TAG, "setCallForwarding RemoteException", ex); Rlog.e(TAG, "setCallForwarding RemoteException", ex);
ex.rethrowAsRuntimeException();
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
Rlog.e(TAG, "setCallForwarding NPE", ex); Rlog.e(TAG, "setCallForwarding NPE", ex);
throw ex;
} }
return false;
} }
/** /**
* Indicates the call waiting status is active. * Indicates that call waiting is enabled.
* *
* @hide * @hide
*/ */
public static final int CALL_WAITING_STATUS_ACTIVE = 1; @SystemApi
public static final int CALL_WAITING_STATUS_ENABLED = 1;
/** /**
* Indicates the call waiting status is inactive. * Indicates that call waiting is disabled.
* *
* @hide * @hide
*/ */
public static final int CALL_WAITING_STATUS_INACTIVE = 2; @SystemApi
public static final int CALL_WAITING_STATUS_DISABLED = 2;
/** /**
* Indicates the call waiting status is with an unknown error. * Indicates there was an unknown error retrieving the call waiting status.
* *
* @hide * @hide
*/ */
@SystemApi
public static final int CALL_WAITING_STATUS_UNKNOWN_ERROR = 3; public static final int CALL_WAITING_STATUS_UNKNOWN_ERROR = 3;
/** /**
* Indicates the call waiting is not supported (e.g. called via CDMA). * Indicates the call waiting is not supported on the current network.
* *
* @hide * @hide
*/ */
@SystemApi
public static final int CALL_WAITING_STATUS_NOT_SUPPORTED = 4; public static final int CALL_WAITING_STATUS_NOT_SUPPORTED = 4;
/** /**
* Call waiting function status
*
* @hide * @hide
*/ */
@IntDef(prefix = { "CALL_WAITING_STATUS_" }, value = { @IntDef(prefix = { "CALL_WAITING_STATUS_" }, value = {
CALL_WAITING_STATUS_ACTIVE, CALL_WAITING_STATUS_ENABLED,
CALL_WAITING_STATUS_INACTIVE, CALL_WAITING_STATUS_DISABLED,
CALL_WAITING_STATUS_NOT_SUPPORTED, CALL_WAITING_STATUS_UNKNOWN_ERROR,
CALL_WAITING_STATUS_UNKNOWN_ERROR CALL_WAITING_STATUS_NOT_SUPPORTED,
}) })
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface CallWaitingStatus { public @interface CallWaitingStatus {
} }
/** /**
* Gets the status of voice call waiting function. Call waiting function enables the waiting * Retrieves the call waiting status of this device from the network.
* for the incoming call when it reaches the user who is busy to make another call and allows
* users to decide whether to switch to the incoming call.
* *
* @return the status of call waiting function. * When call waiting is enabled, an incoming call that arrives when the user is already on
* an active call will be held in a waiting state while the user is notified instead of being
* rejected with a busy signal.
*
* @param executor The executor on which the result listener will be called.
* @param resultListener A {@link Consumer} that will be called with the result fetched
* from the network. The result will be one of:
* <ul>
* <li>{@link #CALL_WAITING_STATUS_ENABLED}}</li>
* <li>{@link #CALL_WAITING_STATUS_DISABLED}}</li>
* <li>{@link #CALL_WAITING_STATUS_UNKNOWN_ERROR}}</li>
* <li>{@link #CALL_WAITING_STATUS_NOT_SUPPORTED}}</li>
* </ul>
* @hide * @hide
*/ */
@SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public @CallWaitingStatus int getCallWaitingStatus() { public void getCallWaitingStatus(@NonNull Executor executor,
@NonNull @CallWaitingStatus Consumer<Integer> resultListener) {
Objects.requireNonNull(executor);
Objects.requireNonNull(resultListener);
IIntegerConsumer internalCallback = new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() -> Binder.withCleanCallingIdentity(
() -> resultListener.accept(result)));
}
};
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
if (telephony != null) { if (telephony != null) {
return telephony.getCallWaitingStatus(getSubId()); telephony.getCallWaitingStatus(getSubId(), internalCallback);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
Rlog.e(TAG, "getCallWaitingStatus RemoteException", ex); Rlog.e(TAG, "getCallWaitingStatus RemoteException", ex);
ex.rethrowAsRuntimeException();
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
Rlog.e(TAG, "getCallWaitingStatus NPE", ex); Rlog.e(TAG, "getCallWaitingStatus NPE", ex);
throw ex;
} }
return CALL_WAITING_STATUS_UNKNOWN_ERROR;
} }
/** /**
* Sets the status for voice call waiting function. Call waiting function enables the waiting * Sets the call waiting status of this device with the network.
* for the incoming call when it reaches the user who is busy to make another call and allows
* users to decide whether to switch to the incoming call.
* *
* @param isEnable {@code true} to enable; {@code false} to disable. * If you wish to be notified about the results of this operation, provide an {@link Executor}
* @return {@code true} to indicate it was set successfully; {@code false} otherwise. * and {@link Consumer<Integer>} to be notified asynchronously when the operation completes.
* *
* @see #getCallWaitingStatus for a description of the call waiting functionality.
*
* @param enabled {@code true} to enable; {@code false} to disable.
* @param executor The executor on which the listener will be called. Must be non-null if
* {@code listener} is non-null.
* @param resultListener Asynchronous listener that'll be called when the operation completes.
* Called with the new call waiting status (either
* {@link #CALL_WAITING_STATUS_ENABLED} or
* {@link #CALL_WAITING_STATUS_DISABLED} if the operation succeeded and
* {@link #CALL_WAITING_STATUS_NOT_SUPPORTED} or
* {@link #CALL_WAITING_STATUS_UNKNOWN_ERROR} if it failed.
* @hide * @hide
*/ */
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean setCallWaitingStatus(boolean isEnable) { public void setCallWaitingStatus(boolean enabled, @Nullable Executor executor,
@Nullable Consumer<Integer> resultListener) {
if (resultListener != null) {
Objects.requireNonNull(executor);
}
IIntegerConsumer internalCallback = new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() ->
Binder.withCleanCallingIdentity(() -> resultListener.accept(result)));
}
};
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
if (telephony != null) { if (telephony != null) {
return telephony.setCallWaitingStatus(getSubId(), isEnable); telephony.setCallWaitingStatus(getSubId(), enabled, internalCallback);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
Rlog.e(TAG, "setCallWaitingStatus RemoteException", ex); Rlog.e(TAG, "setCallWaitingStatus RemoteException", ex);
ex.rethrowAsRuntimeException();
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
Rlog.e(TAG, "setCallWaitingStatus NPE", ex); Rlog.e(TAG, "setCallWaitingStatus NPE", ex);
throw ex;
} }
return false;
} }
/** /**

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2020 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 com.android.internal.telephony;
import android.telephony.CallForwardingInfo;
// Callback interface for the getCallForwarding API in TelephonyManager.
oneway interface ICallForwardingInfoCallback {
void onCallForwardingInfoAvailable(in CallForwardingInfo info);
void onError(int error);
}

View File

@@ -58,6 +58,7 @@ import android.telephony.ims.aidl.IImsRegistrationCallback;
import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.internal.telephony.CellNetworkScanResult; import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.IBooleanConsumer; import com.android.internal.telephony.IBooleanConsumer;
import com.android.internal.telephony.ICallForwardingInfoCallback;
import com.android.internal.telephony.IIntegerConsumer; import com.android.internal.telephony.IIntegerConsumer;
import com.android.internal.telephony.INumberVerificationCallback; import com.android.internal.telephony.INumberVerificationCallback;
import com.android.internal.telephony.OperatorInfo; import com.android.internal.telephony.OperatorInfo;
@@ -1639,78 +1640,15 @@ interface ITelephony {
*/ */
void carrierActionResetAll(int subId); void carrierActionResetAll(int subId);
/** void getCallForwarding(int subId, int callForwardingReason,
* Gets the voice call forwarding info {@link CallForwardingInfo}, given the call forward ICallForwardingInfoCallback callback);
* reason.
*
* @param callForwardingReason the call forwarding reasons which are the bitwise-OR combination
* of the following constants:
* <ol>
* <li>{@link CallForwardingInfo#REASON_BUSY} </li>
* <li>{@link CallForwardingInfo#REASON_NO_REPLY} </li>
* <li>{@link CallForwardingInfo#REASON_NOT_REACHABLE} </li>
* </ol>
*
* @throws IllegalArgumentException if callForwardingReason is not a bitwise-OR combination
* of {@link CallForwardingInfo.REASON_BUSY}, {@link CallForwardingInfo.REASON_BUSY},
* {@link CallForwardingInfo.REASON_NOT_REACHABLE}
*
* @return {@link CallForwardingInfo} with the status {@link CallForwardingInfo#STATUS_ACTIVE}
* or {@link CallForwardingInfo#STATUS_INACTIVE} and the target phone number to forward calls
* to, if it's available. Otherwise, it will return a {@link CallForwardingInfo} with status
* {@link CallForwardingInfo#STATUS_NOT_SUPPORTED} or
* {@link CallForwardingInfo#STATUS_FDN_CHECK_FAILURE} depending on the situation.
*
* @hide
*/
CallForwardingInfo getCallForwarding(int subId, int callForwardingReason);
/** void setCallForwarding(int subId, in CallForwardingInfo callForwardingInfo,
* Sets the voice call forwarding info including status (enable/disable), call forwarding IIntegerConsumer callback);
* reason, the number to forward, and the timeout before the forwarding is attempted.
*
* @param callForwardingInfo {@link CallForwardingInfo} to setup the call forwarding.
* Enabling if {@link CallForwardingInfo#getStatus()} returns
* {@link CallForwardingInfo#STATUS_ACTIVE}; Disabling if
* {@link CallForwardingInfo#getStatus()} returns {@link CallForwardingInfo#STATUS_INACTIVE}.
*
* @throws IllegalArgumentException if any of the following:
* 0) callForwardingInfo is null.
* 1) {@link CallForwardingInfo#getStatus()} for callForwardingInfo returns neither
* {@link CallForwardingInfo#STATUS_ACTIVE} nor {@link CallForwardingInfo#STATUS_INACTIVE}.
* 2) {@link CallForwardingInfo#getReason()} for callForwardingInfo doesn't return the
* bitwise-OR combination of {@link CallForwardingInfo.REASON_BUSY},
* {@link CallForwardingInfo.REASON_BUSY}, {@link CallForwardingInfo.REASON_NOT_REACHABLE}
* 3) {@link CallForwardingInfo#getNumber()} for callForwardingInfo returns null.
* 4) {@link CallForwardingInfo#getTimeout()} for callForwardingInfo returns nagetive value.
*
* @return {@code true} to indicate it was set successfully; {@code false} otherwise.
*
* @hide
*/
boolean setCallForwarding(int subId, in CallForwardingInfo callForwardingInfo);
/** void getCallWaitingStatus(int subId, IIntegerConsumer callback);
* Gets the status of voice call waiting function. Call waiting function enables the waiting
* for the incoming call when it reaches the user who is busy to make another call and allows
* users to decide whether to switch to the incoming call.
*
* @return the status of call waiting function.
* @hide
*/
int getCallWaitingStatus(int subId);
/** void setCallWaitingStatus(int subId, boolean enabled, IIntegerConsumer callback);
* Sets the status for voice call waiting function. Call waiting function enables the waiting
* for the incoming call when it reaches the user who is busy to make another call and allows
* users to decide whether to switch to the incoming call.
*
* @param isEnable {@code true} to enable; {@code false} to disable.
* @return {@code true} to indicate it was set successfully; {@code false} otherwise.
*
* @hide
*/
boolean setCallWaitingStatus(int subId, boolean isEnable);
/** /**
* Policy control of data connection. Usually used when data limit is passed. * Policy control of data connection. Usually used when data limit is passed.