Interface CallBridge
Internal service-provider interface implemented by each platform port to
carry the com.codename1.call API onto the native call stacks: Apple's
CallKit and PushKit, and Android's ConnectionService, TelecomManager
and CallScreeningService.
Application code never touches this interface. It is obtained by the
com.codename1.call packages from
com.codename1.ui.Display#getCallBridge(), and the base implementation
returns null -- which is why the public API degrades to a well-behaved
NOT_SUPPORTED on ports that implement nothing, and why application code
needs no platform if statements.
Everything here is primitives, strings and byte arrays
A port may be Objective-C reached through ParparVM, where constructing a
Java object is expensive and easy to get wrong. So no method on this
interface takes or returns a framework type: enums cross as their
ordinals, capability sets cross as bit masks, and structured records
cross as tab-delimited strings built by
com.codename1.impl.call.CallWire.
Asynchrony is by request id, and every operation must answer
Operations that can fail take a requestId allocated by the caller and
answer exactly once by calling the matching deliver... entry point on
the public class. An operation that never answers is worse than one
that fails: the caller holds an AsyncResource that will never settle
and has no way to find out. A port that cannot start something must still
report the failure. This bites harder here than elsewhere, because both
platforms have a documented "the system refused your call" path --
Telecom's onCreateIncomingConnectionFailed and the NSError handed to
CallKit's report completion -- that is easy to leave unwired, and an
unwired refusal looks exactly like a call that is still ringing.
Unsolicited events -- the user answering, the system taking the audio -- carry the call id they belong to instead of a request id. Every entry point may be called from any thread; they marshal to the EDT themselves.
The up direction has a deadline too
A system-originated action must be answered with completeAction(long, boolean) within
a few seconds or the platform times it out and the system UI and the app
disagree about the call, silently. The facade guarantees an answer the
same way this interface guarantees one downward.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intgetCallCapabilities()bit: caller identification can be installed.static final intgetCallCapabilities()bit: the system offers a keypad and delivers DTMF digits.static final intReserved.static final intgetCallCapabilities()bit: calls can be held and resumed.static final intgetCallCapabilities()bit: the app can SET the system mute state.static final intgetCallCapabilities()bit: outgoing calls can be reported.static final intReserved.static final intgetCallCapabilities()bit: incoming calls can be screened or blocked.static final intgetCallCapabilities()bit: the platform draws a system call UI.static final intgetCallCapabilities()bit: video calls are supported.static final intgetCallCapabilities()bit: the app can be woken by a VoIP push.static final intrequestPermissions(int, int)bit: camera access, for video calls.static final intrequestPermissions(int, int)bit: the grant needed to own calls --MANAGE_OWN_CALLSon Android.static final intrequestPermissions(int, int)bit: microphone access.static final intrequestPermissions(int, int)bit: permission to post notifications, which Android needs to show a call in the shade.static final intrequestPermissions(int, int)bit: the call-screening role. -
Method Summary
Modifier and TypeMethodDescriptionbooleancompleteAction(long actionToken, boolean fulfilled) Answers a system-originated action delivered withactionToken.voidconfigureProvider(int requestId, String configWire) Installs the calling identity: the name the system shows, the ringtone, whether video is offered.voiddrainPendingCalls(int requestId) Delivers every call reported natively but not yet seen by Java, then answers once with the count.voidThis side is ending the call.intThe ordinal of the currentcom.codename1.call.session.CallAudioRoute.intThe ordinal of the currentcom.codename1.call.CallAvailability-- whether a call could be rung right now, which is a different question from whether the platform supports calling.intTheCAPABILITY_*bit mask this port supports.voidgetDirectoryStatus(int requestId) Answers with aCallWire-encoded status record.intThePERMISSION_*bit mask currently granted.booleanWhether this port can report calls to a system call UI at all.booleanWhether this port can install caller identification or blocking.booleanWhether this port can be woken by a VoIP push.voidregisterVoipPush(int requestId) Registers for VoIP pushes, answering with the token.voidreloadDirectory(int requestId) Asks the system to re-read the directory source.voidreportCallEnded(String callId, int endReasonOrdinal, long timestampMs) The far end ended the call.voidreportIncomingCall(int requestId, String callId, String handleWire, String displayName, int capabilityBits, boolean hasVideo) Reports a new incoming call and starts it ringing.voidreportIncomingConnected(String callId, long timestampMs) The incoming call is connected.voidreportOutgoingCall(int requestId, String callId, String handleWire, String displayName, int capabilityBits, boolean hasVideo) Reports a new outgoing call the app is placing.voidreportOutgoingConnected(String callId, long timestampMs) The outgoing call is connected.voidreportOutgoingStartedConnecting(String callId, long timestampMs) The outgoing call has begun connecting.voidrequestPermissions(int requestId, int permissionBits) Requests thePERMISSION_*bits inpermissionBits, answering with the granted mask.voidrequestScreeningRole(int requestId) Asks the user for the call-screening role.voidSends DTMF digits.voidsetAudioRoute(int requestId, int routeOrdinal) Asks for a route by ordinal.voidsetCallGroup(int requestId, String callId, String otherCallId) GroupscallIdwithotherCallId, or ungroups it when that is null.voidsetDirectorySource(int requestId, String filePath) Installs the caller-identification and blocking data atfilePath.voidHolds or resumes a call.voidsetJavaReady(boolean ready) Tells the port whether application code is listening yet.voidMutes or unmutes a call.voidshowAudioRoutePicker(int requestId, String callId) Shows the system's audio route picker.voidunregisterVoipPush(int requestId) Stops VoIP push delivery.voidupdateCall(String callId, String handleWire, String displayName, int capabilityBits, boolean hasVideo) Updates the display of a call already reported.
-
Field Details
-
CAPABILITY_SYSTEM_UI
static final int CAPABILITY_SYSTEM_UIgetCallCapabilities()bit: the platform draws a system call UI.- See Also:
-
CAPABILITY_OUTGOING
static final int CAPABILITY_OUTGOINGgetCallCapabilities()bit: outgoing calls can be reported.- See Also:
-
CAPABILITY_HOLD
static final int CAPABILITY_HOLDgetCallCapabilities()bit: calls can be held and resumed.- See Also:
-
CAPABILITY_MUTE
static final int CAPABILITY_MUTEgetCallCapabilities()bit: the app can SET the system mute state.About
setMuted(int, String, boolean)only. Hearing what the user does with the system's own mute control is not gated by this and arrives everywhere, throughCalls.deliverMuteChanged; Android reports that and offers no way to drive it, so it does not set this bit.- See Also:
-
CAPABILITY_DTMF
static final int CAPABILITY_DTMFgetCallCapabilities()bit: the system offers a keypad and delivers DTMF digits.- See Also:
-
CAPABILITY_GROUPING
static final int CAPABILITY_GROUPINGReserved. No port sets this. Neither platform lets an app put two of its own calls into a conference: CallKit's
CXSetGroupCallActiontravels system to app and has no app-initiated counterpart, and Telecom conferences self-managed calls only through aConnectionServiceconference this port does not build. Soalways answers NOT_SUPPORTED. The constant isinvalid reference
CallSession#groupWithkept so the bit values do not shift if that changes.
- See Also:
-
CAPABILITY_VIDEO
-
CAPABILITY_VOIP_PUSH
static final int CAPABILITY_VOIP_PUSHgetCallCapabilities()bit: the app can be woken by a VoIP push.- See Also:
-
CAPABILITY_DIRECTORY
static final int CAPABILITY_DIRECTORYgetCallCapabilities()bit: caller identification can be installed.- See Also:
-
CAPABILITY_SCREENING
static final int CAPABILITY_SCREENINGgetCallCapabilities()bit: incoming calls can be screened or blocked.- See Also:
-
CAPABILITY_ROUTE_PICKER
static final int CAPABILITY_ROUTE_PICKERReserved. No port sets this. Neither platform has a system audio route picker an app can present for a call -- iOS offersAVRoutePickerView, a view the app places itself, and Android offers nothing -- soshowAudioRoutePicker(int, String)always answers NOT_SUPPORTED. The constant is kept so the bit values do not shift if that changes.- See Also:
-
PERMISSION_MANAGE_CALLS
static final int PERMISSION_MANAGE_CALLSrequestPermissions(int, int)bit: the grant needed to own calls --MANAGE_OWN_CALLSon Android. Implicit on iOS.- See Also:
-
PERMISSION_MICROPHONE
static final int PERMISSION_MICROPHONErequestPermissions(int, int)bit: microphone access.- See Also:
-
PERMISSION_CAMERA
static final int PERMISSION_CAMERArequestPermissions(int, int)bit: camera access, for video calls.- See Also:
-
PERMISSION_NOTIFICATIONS
static final int PERMISSION_NOTIFICATIONSrequestPermissions(int, int)bit: permission to post notifications, which Android needs to show a call in the shade.- See Also:
-
PERMISSION_SCREENING_ROLE
static final int PERMISSION_SCREENING_ROLErequestPermissions(int, int)bit: the call-screening role.- See Also:
-
-
Method Details
-
isCallSupported
boolean isCallSupported()Whether this port can report calls to a system call UI at all. -
isVoipPushSupported
boolean isVoipPushSupported()Whether this port can be woken by a VoIP push. -
isDirectorySupported
boolean isDirectorySupported()Whether this port can install caller identification or blocking. -
getCallCapabilities
int getCallCapabilities()TheCAPABILITY_*bit mask this port supports. -
getCallAvailability
int getCallAvailability()The ordinal of the currentcom.codename1.call.CallAvailability-- whether a call could be rung right now, which is a different question from whether the platform supports calling. -
getGrantedPermissions
int getGrantedPermissions()ThePERMISSION_*bit mask currently granted. -
requestPermissions
void requestPermissions(int requestId, int permissionBits) Requests thePERMISSION_*bits inpermissionBits, answering with the granted mask. -
configureProvider
Installs the calling identity: the name the system shows, the ringtone, whether video is offered.
configWireis aCallWire-encoded record.On Android this registers the
PhoneAccount; until it has run,TelecomManager.addNewIncomingCallis a silent no-op, which is why this is a separate step rather than something inferred from the first report. -
reportIncomingCall
-
reportOutgoingCall
-
reportOutgoingStartedConnecting
The outgoing call has begun connecting.timestampMsis wall clock. -
reportOutgoingConnected
The outgoing call is connected. -
reportIncomingConnected
The incoming call is connected. -
updateCall
-
reportCallEnded
The far end ended the call.endReasonOrdinalis acom.codename1.call.CallEndReasonordinal and becomes what the system writes in the call log. -
endCall
This side is ending the call. -
setHeld
Holds or resumes a call. -
setMuted
Mutes or unmutes a call. -
sendDtmf
-
setCallGroup
-
getAudioRoute
int getAudioRoute()The ordinal of the currentcom.codename1.call.session.CallAudioRoute. -
setAudioRoute
void setAudioRoute(int requestId, int routeOrdinal) Asks for a route by ordinal. -
showAudioRoutePicker
Shows the system's audio route picker. -
completeAction
boolean completeAction(long actionToken, boolean fulfilled) Answers a system-originated action delivered with
actionToken.The token is opaque and allocated by the port. Exactly one call per token; a second is ignored rather than treated as an error, because the facade's safety net and the application may both answer and the race between them is not worth making the application think about.
Returns
whether the platform still held this action. A
falsesays the platform gave up on it -- a CallKit timeout, a Telecom connection torn down underneath it -- and the caller must not apply the local effect, because the system is no longer going to carry the action out. -
registerVoipPush
void registerVoipPush(int requestId) Registers for VoIP pushes, answering with the token. -
unregisterVoipPush
void unregisterVoipPush(int requestId) Stops VoIP push delivery. -
setJavaReady
void setJavaReady(boolean ready) Tells the port whether application code is listening yet.
Until this is true the port must hold pushed calls rather than delivering them, because on iOS the system call is reported by native code before any application code has run.
-
drainPendingCalls
void drainPendingCalls(int requestId) Delivers every call reported natively but not yet seen by Java, then answers once with the count. -
setDirectorySource
Installs the caller-identification and blocking data at
filePath.A path rather than an array: the list routinely runs to hundreds of thousands of numbers, and on iOS the process that reads it is a separate extension, so the data has to be on disk in a shared container whatever this API looked like.
-
reloadDirectory
void reloadDirectory(int requestId) Asks the system to re-read the directory source. -
getDirectoryStatus
void getDirectoryStatus(int requestId) Answers with aCallWire-encoded status record. -
requestScreeningRole
void requestScreeningRole(int requestId) Asks the user for the call-screening role.
-