public class CallStateObserver extends Object
The call service states include the call state, voice mailbox state, and unconditional call forwarding (CFU)
setting state. To monitor a specific type of updates, you must inherit this class and override the methods
corresponding to OBSERVE_flags in mask transferred by
DistributedCallManager#addObserver.
These methods will be invoked when the corresponding service state updates and the observer is added to monitor the
updates.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
CALL_STATE_IDLE |
Indicates that there is no ongoing call.
|
static int |
CALL_STATE_OFFHOOK |
Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call
ringing or waiting.
|
static int |
CALL_STATE_RINGING |
Indicates that an incoming call is ringing or waiting.
|
static int |
CALL_STATE_UNKNOWN |
Indicates an invalid state, which is used when the call state fails to be obtained.
|
static int |
OBSERVE_MASK_CALL_FORWARDING_UNCONDITIONAL_INDICATOR |
Indicates a mask that monitors CFU setting updates.
|
static int |
OBSERVE_MASK_CALL_STATE |
Indicates a mask that monitors call state updates.
|
static int |
OBSERVE_MASK_VOICE_MAIL_MESSAGE_INDICATOR |
Indicates a mask that monitors voice mailbox state updates.
|
| 构造器 | 说明 |
|---|---|
CallStateObserver() |
Creates an observer instance for receiving call service state updates in any slot.
|
CallStateObserver(int slot) |
Creates an observer instance for receiving call service state updates in a specified slot.
|
CallStateObserver(int slot,
EventRunner runner) |
Creates an observer instance for receiving call service state updates in a specified slot.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onCallStateUpdated(int state,
String number) |
Receives a call state change.
|
void |
onCfuIndicatorUpdated(boolean enable) |
Receives a CFU setting update.
|
void |
onVoiceMailMsgIndicatorUpdated(boolean isExist) |
Receives a voice mailbox state change.
|
public static final int CALL_STATE_IDLE
public static final int CALL_STATE_OFFHOOK
public static final int CALL_STATE_RINGING
public static final int CALL_STATE_UNKNOWN
public static final int OBSERVE_MASK_CALL_FORWARDING_UNCONDITIONAL_INDICATOR
Applications must have the ohos.permission.GET_TELEPHONY_STATE permission
to register this event.
public static final int OBSERVE_MASK_CALL_STATE
public static final int OBSERVE_MASK_VOICE_MAIL_MESSAGE_INDICATOR
Applications must have the ohos.permission.GET_TELEPHONY_STATE permission
to register this event.
public CallStateObserver()
throws IllegalArgumentException
IllegalArgumentException - Throws this exception if there is no EventRunner
that can process the callback.public CallStateObserver(int slot)
throws IllegalArgumentException
slot - Indicates the ID of the slot. The value 0 indicates slot 1,
and the value 1 indicates slot 2.IllegalArgumentException - Throws this exception if there is no EventRunner
that can process the callback.public CallStateObserver(int slot,
EventRunner runner)
throws IllegalArgumentException
EventRunner.slot - Indicates the ID of the slot. The value 0 indicates slot 1,
and the value 1 indicates slot 2.runner - Indicates the EventRunner to process the callback.IllegalArgumentException - Throws this exception if there is no EventRunner that can process the
callback.public void onVoiceMailMsgIndicatorUpdated(boolean isExist)
isExist - Specifies whether a voice mailbox message exists.
The value true indicates that a voice mailbox message exists,
and the value false indicates that no voice mailbox message exists.public void onCfuIndicatorUpdated(boolean enable)
enable - Specifies whether the CFU function is enabled.
The value true indicates that the CFU function is enabled,
and the value false indicates that the CFU function is disabled.public void onCallStateUpdated(int state,
String number)
state - Indicates the call state. The following call states are possible:
number - Indicates the called number. The value is an empty string if the application does not have
the ohos.permission#READ_CALL_LOG READ_CALL_LOG permission.