forked from sysapps/telephony
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
3281 lines (3261 loc) · 123 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>
Web Telephony API
</title>
<script src='https://www.w3.org/Tools/respec/respec-w3c-common' class=
'remove'>
</script>
<script class="remove">
/*Respec configuration*/
var respecConfig = {
specStatus: "ED",
shortName: "telephony",
noLegacyStyle: false,
publishDate: "",
previousPublishDate: "",
previousMaturity: "",
edDraftURI: "http://www.w3.org/2012/sysapps/telephony/",
// lcEnd: "",
crEnd: "",
editors: [
{ name: "Marcos Cáceres", company: "Mozilla",
companyURL: "http://www.tid.es/" },
{ name: "José M. Cantera", company: "Telefónica",
companyURL: "http://www.tid.es/" },
{ name: "Eduardo Fullea", company: "Telefónica",
companyURL: "http://www.tid.es/" },
{ name: "Zoltan Kis", company: "Intel",
companyURL: "http://www.intel.com/" }
],
inlineCSS: true,
noIDLIn: true,
extraCSS: ["../ReSpec.js/css/respec.css"],
wg: "System Applications Working Group",
wgURI: "http://www.w3.org/2012/sysapps/",
wgPublicList: "public-sysapps",
wgPatentURI: "http://www.w3.org/2004/01/pp-impl/58119/status",
otherLinks: [{
key: "Repository",
data: [{
value: "We are on Github.",
href: "https://github.com/sysapps/telephony"
}, {
value: "File a bug.",
href: "https://github.com/sysapps/telephony/issues"
}, {
value: "Commit history.",
href: "https://github.com/sysapps/telephony/commits/gh-pages"
}
]
}]
};
</script>
<style>
/*HTML5 Tidy screws up if this line is missing.*/
figure{
display: block;
width: auto;
margin: 2em auto;
text-align: center;
}
figcaption{
display: block;
margin-top: 1em;
}
</style>
</head>
<body>
<!-- - - - - - - - - - - - - - - Abstract - - - - - - - - - - - - - - - - - -->
<section id="abstract">
<p>
This specification defines an API to manage telephone calls. A typical
use case of the <cite>Web Telephony API</cite> is the implementation of
a 'Dialer' application supporting multiparty calls and multiple
telephony services. A minimal structure for call history items is also
defined.
</p>
</section>
<!-- - - - - - - - - - - Status of this document - - - - - - - - - - - - - -->
<section id="sotd">
<p>
Implementors should be aware that this specification is not stable.
<strong>Implementors who are not taking part in the discussions are
likely to find the specification changing out from under them in
incompatible ways.</strong> Vendors interested in implementing this
specification before it eventually reaches the Candidate Recommendation
stage should join the aforementioned mailing lists and take part in the
discussions.
</p>
<p>
Significant changes to this document since last publication are
documented in the <a href="#Changes">Changes section</a>.
</p>
</section>
<!-- - - - - - - - - - - - - - Introduction - - - - - - - - - - - - - - - -->
<section class="informative">
<h2>
Introduction
</h2>
<p>
The <cite>Web Telephony API</cite> allows applications to manage
interaction with telephony call signaling, but does not handle audio
channels management.
</p>
<p>
An example of making a telephony call is provided below:
</p>
<pre class="example highlight">
var telCall = navigator.telephony.dial('+1234567890');
telCall.onactive = function(e) {
window.console.log('Connected!');
}
telCall.ondisconnected = function(e) {
window.console.log('Disconnected!');
// update call history
}
telCall.onerror = function(e) {
window.console.error(e);
}
</pre>
<p>
The use cases for this specification are collected in the <a href=
'http://www.w3.org/wiki/System_Applications_WG:_Telephony_API'>wiki
page</a> of this API.
</p>
<p>
The following specifications have been used for designing the <cite>Web
Telephony API</cite>: for <abbr title=
"Global System for Mobile Communications">GSM</abbr> the [[!GSM-CALL]]
suite, for IMS/SIP the [[!IMS]] suite, for <abbr title=
"Extensible Messaging and Presence Protocol ">XMPP</abbr> the
[[!JINGLE]] specification. The same API would work also for
<abbr title="Session Initiation Protocol">SIP</abbr> and <abbr title=
"Extensible Messaging and Presence Protocol ">XMPP</abbr> calls, except
multiparty call handling, which is modeled after the cellular
multiparty calls.
</p>
<p>
Future versions of this specification may add <abbr title=
"Session Initiation Protocol">SIP</abbr> and <abbr title=
"Extensible Messaging and Presence Protocol ">XMPP</abbr> conference
support.
</p>
</section>
<!-- - - - - - - - - - - - - - Conformance - - - - - - - - - - - - - - - - -->
<section id="conformance">
<p>
This specification defines conformance criteria that apply to a single
product: the <dfn>user agent</dfn> that implements the interfaces that
it contains.
</p>
<p>
Implementations that use ECMAScript to implement the APIs defined in
this specification MUST implement them in a manner consistent with the
ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]],
as this specification uses that specification and terminology.
</p>
</section>
<!-- - - - - - - - - - - - - - Terminology - - - - - - - - - - - - - - - - -->
<section>
<h2>
Terminology
</h2>
<p>
The <dfn><code><a href=
"http://dev.w3.org/html5/spec/webappapis.html#eventhandler">EventHandler</a></code></dfn>
interface represents a callback used for <a href=
"http://www.w3.org/html/wg/drafts/html/master/webappapis.html#event-handlers">
event handlers</a> as defined in [[!HTML5]].
</p>
<p>
The concepts <dfn><a href=
"http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">queue a
task</a></dfn> and <dfn><a href=
"http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire
a simple event</a></dfn> are defined in [[!HTML5]]. The <a href=
"http://www.whatwg.org/specs/web-apps/current-work/#task-source">task
source</a> for all <a href=
"http://www.whatwg.org/specs/web-apps/current-work/#queue-a-task">tasks
queued</a> in this specification is the <dfn>Telephony task
source</dfn>.
</p>
<p>
The terms <dfn><a href=
"http://dev.w3.org/html5/spec/webappapis.html#event-handlers">event
handler</a></dfn> and <dfn><a href=
"http://dev.w3.org/html5/spec/webappapis.html#event-handler-event-type">
event handler event types</a></dfn> are defined in [[!HTML5]].
</p>
<p>
The <dfn><a href=
"http://dom.spec.whatwg.org/#event"><code>Event</code></a></dfn>
interface and the the <dfn><a href=
"http://dom.spec.whatwg.org/#promise"><code>Promise</code></a></dfn>
interface as well as the concept of a <a href=
"http://dom.spec.whatwg.org/#concept-resolver"><dfn>resolver</dfn></a>
are defined in [[!DOM4]].
</p>
<p>
An <dfn>active call</dfn> is a <a>TelephonyCall</a> in the
<a>active</a> state representing a connected call which is bound to the
media input and output devices (e.g. microphone, speaker, tone
generator). Note that a call on <a>hold</a> is also active from a call
signaling point of view, but not bound to media input and output
devices.
</p>
<p>
A <dfn>telephony service</dfn> exposes telephony functionality
associated to a subscriber identity registered with a telephony service
provider. For example, in cellular telephony a telephony service is
associated to a SIM card (Subscriber Identity Module). When making a
call, the identity (e.g. SIM card, associated to an Integrated Circuit
Card Identifier, ICC-ID) is always provided, either explicitly in the
function call, or by using a <a>default telephony service</a> in the
implementation. The device can receive phone calls from any active
telephony service, even simultaneously, in which case the user agent
arbitrates the calls either by a policy, or by the user by choosing
which call to accept. A telephony service can use different protocols
for telephony signaling and media (e.g. GSM, CDMA, VoLTE, etc.) with
the same identity. Since call states can differ depending on the
protocol, the telephony call objects contain information which
identifies the service and the protocol used for making the call.
</p>
<p>
A <dfn>default telephony service</dfn> is the <a>telephony service</a>
that is set as default for telephony operations by the implementation.
</p>
<p>
A <dfn>telephony service id</dfn> uniquely identifies a <a>telephony
service</a> together with a user identity in the system. For SIM cards,
this can include the ICC-ID as service identifier. However, the MSISDN
MUST NOT be used as telephony service id.
</p>
<p>
A <dfn>multiparty call</dfn> (also referred to as <dfn>conference
call</dfn>) is a telephony call with multiple remote party
participants, which is controlled as a single call, i.e. can be put on
hold, activated, disconnected with all participants. Other calls can be
joined with a multiparty call. This version supports GSM multiparty
calls and CDMA 3-way calls.
</p>
<p>
A <dfn>conference id</dfn> uniquely identifies a <a>multiparty call</a>
in the system and in call history.
</p>
<p>
A <dfn>remote party id</dfn> uniquely identifies a participant (a.k.a.
remote party) in a telephony call in the given <a>telephony
service</a>, such as a phone number.
</p>
</section>
<!-- - - - - - - - - - - - Security and privacy - - - - - - - - - - - - - - -->
<section>
<h2>
Security and privacy considerations
</h2>
<div class="issue">
<p>
To be improved. See <a href=
"https://github.com/sysapps/telephony/issues/26">bug 26</a>.
</p>
</div>
<p>
This API provides access to a potentially dangerous and valuable
feature of a device. As a result, misuse of the API would have a large
cost to users and other system stakeholders. This API should,
therefore, not be implemented without careful consideration of security
and privacy issues.
</p>
<p>
This section provides a limited overview of security and privacy
considerations relevant for this API. It includes a set of threats to
users and other stakeholders, as well as requirements for mitigating
them.
</p>
<p>
However, this section cannot cover all of the potential threats, nor
can it reflect the context in which a conformant implementation may be
operating. As a result, this security section should be considered only
the starting point for implementers.
</p>
<section>
<h3>
Threats
</h3>
<p>
The following list of threats should be considered by the
implementer. Note that these are not given in any order.
</p>
<ul>
<li>The API could be used by a malicious application to deny other
system applications access to the device's telephony services,
creating an availability problem. This is a safety, as well as
security, concern.
</li>
<li>The API could be used by a malicious application as part of a
distributed denial of service attack, making frequent calls to a
remote call system such as an emergency response number.
</li>
<li>The API could be used by an application to list the telephone
numbers that the end user has called and is, at any time, calling.
This information ought to be considered private, and could also be
used as part of a social engineering attack, or for identity theft.
</li>
<li>The API could be used to make unwanted calls to premium-rate
telephone numbers. A malicious application could use this to earn
money at the user's expense. Similarly, this API could be misused to
enrol the user into a premium-rate calling service, which would then
charge the end user when calls are received.
</li>
<li>The API could be used to make unwanted advertising calls, in a
similar manner to spam email campaigns. When combined with access to
the user's contact list, this would be both expensive and embarassing
for the user, and could result in their telephony service being
terminated by the network operator.
</li>
<li>The API could be used by a malicious application to make
telephone calls impersonating the end user, or as part of a process
to defeat a two-factor authentication system.
</li>
<li>A poorly implemented application could misuse this API to make
unnecessary or unexpected calls, costing the user money or
embarassing them.
</li>
<li>This API could be used to call a number other than the one that
the user was expecting, routing calls to an unknown
man-in-the-middle. This could be used to eavesdrop on the user. When
used in combination with recordings from the microphone, this API
could be used to covertly survey the end user.
</li>
<li>This API could be used to send USSD messages to the service
provider and invoke functions such as wiping the handset or accessing
security settings.
</li>
<li>The API could be misused to access the user's voicemail
recordings.
</li>
<li>The API could be misused as part of a DDoS attack on an operator
or service provider, flooding the network with calls at certain
times.
</li>
<li>The API could cost the end user money by making outgoing calls
when the user is roaming, or on an expensive network.
</li>
</ul>
</section>
<section>
<h3>
Mitigations
</h3>
<p>
The following mechanisms may be employed to help an implementer
mitigate the threats outlined in the previous section.
</p>
<ul>
<li>The user agent should only expose this API to <em>privileged</em>
applications, as defined in the <a href=
"http://www.w3.org/TR/runtime/">Runtime and Security Model</a>.
</li>
<li>The user agent should only expose this API to applications which
were distributed by an institution that the handset recognises as a
valid source. For example, the API might only be accessible to
applications distributed by the handset manufacturer.
</li>
<li>All applications with access to this API should be reviewed
before they are made available. A mechanism for remote update of
applications with access to this API should be provided to allow for
identified security issues to be fixed.
</li>
<li>The user agent should maintain the integrity of any application
with access to this API when initially downloaded, as well as when it
is stored offline.
</li>
<li>The user agent should only expose this API to downloaded, offline
applications which are not modifiable by external web servers. A
restrictive content security policy should be used to enforce that
application with external content (such as scripts) cannot access
this API.
</li>
<li>The API implementation should have different behaviour when used
with premium-rate numbers. Accessing premium-rate numbers may require
an additional permission to be listed in the manifest, a different
(or additional) warning to be displayed to users, or place an
additional requirement on the valid distributors of the application.
It is up to the implementing user agent to identify whether a remote
party identifier is premium-rate or not.
</li>
<li>The API implementation should have different behaviour when the
user is roaming on a network with a different (less favourable)
service-level agreement. For example, presenting a different warning
to the user, or denying access to this API from certain applications
altogether.
</li>
<li>User consent must be captured when a call is made. For example,
the user must press a 'dial' button, or equivalent, before the call
is placed. The user must also be shown the recipients of the call,
and the numbers that have and will be dialled as part of placing it.
</li>
<li>It should be obvious, visually, when a call is being invoked, is
in progress, and has ended. This should be visible to the end user
and it must not be possible for applications to hide or obscure this
indicator.
</li>
<li>The user agent should introduce rate limiting to prevent an
application from making too many calls in too short a period of time.
</li>
</ul>
</section>
<section>
<h3>
User interaction guidelines
</h3>
<p>
TODO
</p>
</section>
</section>
<!-- - - - - - - - - - - Extended interface Navigator - - - - - - - - - - - -->
<section>
<h2>
Extensions to <code>Navigator</code> object
</h2>
<p>
The <a>TelephonyManager</a> interface is exposed on [[!HTML]]'s
<a href="http://www.whatwg.org/specs/web-apps/current-work/#dom-navigator">
<code>Navigator</code></a> object.
</p>
<dl title="partial interface Navigator" class="idl">
<dt>
readonly attribute TelephonyManager telephony
</dt>
<dd>
When getting, the user agent MUST return the <a>TelephonyManager</a>
object, which provides the ability to interface with the <a>telephony
service</a> of the device.
</dd>
</dl>
</section>
<!-- - - - - - - - - - - - Interface TelephonyManager - - - - - - - - - - - -->
<section>
<h2>
<a>TelephonyManager</a> Interface
</h2>
<p>
The <a>TelephonyManager</a> interface provides access to telephony
functionality, and manages the lifecycle of the <a>Call</a> objects.
</p>
<dl title="interface TelephonyManager : EventTarget" class="idl">
<dt>
readonly attribute Call? activeCall
</dt>
<dd>
When getting, the user agent MUST return a <a>Call</a> object
representing the <a>active call</a>. If there is no active
<a>Call</a> return <code>null</code>.
</dd>
<dt>
readonly attribute Call[] calls
</dt>
<dd>
When getting, the user agent MUST return an array, which can be
empty, of <a>Call</a> objects managed by this objects. Note that
<a>TelephonyCall</a> objects belonging to a multiparty call are
managed by the corresponding <a>ConferenceCall</a> object and MUST
NOT be also present in this array.
</dd>
<dt>
readonly attribute DOMString[] emergencyNumbers
</dt>
<dd>
When getting, the user agent MUST return an array, which can be
empty, of telephone numbers for the emergency services in the current
geographical area.
</dd>
<dt>
readonly attribute DOMString[] serviceIds
</dt>
<dd>
When getting, the user agent MUST return an array, which can be
empty, of <a>telephony service id</a>'s.
</dd>
<dt>
readonly attribute DOMString defaultServiceId
</dt>
<dd>
When getting, the user agent MUST return the <a>DOMString</a> that
represents the id of the <a>default telephony service</a>.
</dd>
<dt>
Promise changeDefaultService(DOMString serviceID)
</dt>
<dd>
Provides a means to change the <a>default telephony service</a> used
by the user agent. When invoked, the user agent runs the <a>steps to
update the default service</a>.
<dl class='parameters'>
<dt>
DOMString serviceID
</dt>
<dd>
A <a>service id</a> for a <a>telephony service</a> known to the
user agent.
</dd>
</dl>
</dd>
<dt>
TelephonyCall dial ()
</dt>
<dd>
Initiates a new telephony call. Returns a <a>TelephonyCall</a>
object, which will manage the asynchronous call signaling events.
<dl class='parameters'>
<dt>
DOMString remoteParty
</dt>
<dd>
Represents the destination number of the call.
</dd>
<dt>
optional DialParams params
</dt>
<dd>
If set, represents the optional parameters of the call, including
the telephony service to be used, and whether caller ID is hidden
</dd>
</dl>
</dd>
<dt>
Promise sendTones()
</dt>
<dd>
This method asynchronously emits a [[!DTMF]] tone sequence with the
platform default or specified duration and delay, in the platform
default or the specified telephony service. A
<a><code>Promise</code></a> object will be returned in order to
notify the result of the request.
<dl class='parameters'>
<dt>
DOMString tones
</dt>
<dd>
Represents the sequence of [[!DTMF]] tones to be emitted. Its
value can be any sequence of the following characters (0-9; A-D;
*; #).
</dd>
<dt>
optional ToneParams params
</dt>
<dd>
If set, represents the <a>telephony service id</a> to be used,
the tone duration and the delay (gap) before a tone. If not set,
implementations MUST use default values for these.
</dd>
</dl>
</dd>
<dt>
Promise startTone()
</dt>
<dd>
This method starts emitting a [[!DTMF]] tone with the platform
default or specified delay, in the platform default or the specified
telephony service. A <a><code>Promise</code></a> object will be
returned in order to notify the result of the request.
<dl class='parameters'>
<dt>
DOMString tone
</dt>
<dd>
Represents the [[!DTMF]] tone. Its value can be any of the
following characters: 0-9; A-D; *; #.
</dd>
<dt>
optional ToneParams params
</dt>
<dd>
If set, represents the <a>telephony service id</a> to be used,
and the delay before a tone. The <a>duration</a> member is
ignored. If not set, implementations MUST use default values for
telephony service and delay.
</dd>
</dl>
</dd>
<dt>
Promise stopTone(optional DOMString serviceId)
</dt>
<dd>
This method stops emitting a [[!DTMF]] tone in the default or the
specified telephony service. A <a><code>Promise</code></a> object
will be returned in order to notify the result of the request.
</dd>
<dt class="no-docs">
attribute EventHandler onincoming
</dt>
<dd>
Whenever there is a new call in <a>incoming</a> or <a>waiting</a>
state, the <a>user agent</a> MUST <a>queue a task</a> to fire an
event named <a>incoming</a> of type <a>TelephonyEvent</a>. The
<a>call</a> attribute of the event MUST be set to the
<a>TelephonyCall</a> object controlling the incoming call.
</dd>
<dt class="no-docs">
attribute EventHandler oncallschanged
</dt>
<dd>
Whenever a call is added to or removed from the <a>calls</a> array,
the <a>user agent</a> MUST <a>queue a task</a> to <a>fire a simple
event</a> named <code>callschanged</code>.
</dd>
<dt class="no-docs">
attribute EventHandler onserviceadded
</dt>
<dd>
The <a>serviceadded</a> event of type <a>TelephonyServiceEvent</a>
MUST be fired whenever a new <a>telephony service</a> is enabled in
the system. The <a>serviceId</a> attribute of the event MUST contain
the <a>telephony service id</a> of the new service. Note that
compliant implementations may not be reporting such events when they
occur (e.g. OTA SIM update or hot-swappable SIM cards).
</dd>
<dt class="no-docs">
attribute EventHandler onserviceremoved
</dt>
<dd>
The <a>serviceremoved</a> event of type <a>TelephonyServiceEvent</a>
MUST be fired when an existing <a>telephony service</a> is disabled
in the system. The <a>serviceId</a> attribute of the event MUST
contain the <a>telephony service id</a> of the disabled service.
</dd>
<dt>
attribute EventHandler onservicechanged
</dt>
<dd>
Handles a change of <a>default telephony service</a> from one to
another.
</dd>
</dl>
<section>
<h2>
Event handlers
</h2>
<p>
The following are the <a>event handlers</a> (and their corresponding
<a>event types</a>) that MUST be supported as attributes by the
<a>TelephonyManager</a> object.
</p>
<table class="simple">
<thead>
<tr>
<th>
event handler
</th>
<th>
event name
</th>
<th>
event type
</th>
<th>
short description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<dfn><code>onincoming</code></dfn>
</td>
<td>
<dfn><code>incoming</code></dfn>
</td>
<td>
<a>TelephonyEvent</a>
</td>
<td>
handles incoming and waiting calls
</td>
</tr>
<tr>
<td>
<dfn><code>oncallschanged</code></dfn>
</td>
<td>
<dfn><code>callschanged</code></dfn>
</td>
<td>
<a><code>Event</code></a>
</td>
<td>
handles change in the <a>calls</a> array
</td>
</tr>
<tr>
<td>
<dfn><code>onserviceadded</code></dfn>
</td>
<td>
<dfn><code>serviceadded</code></dfn>
</td>
<td>
<a>TelephonyServiceEvent</a>
</td>
<td>
handles a new enabled telephony service
</td>
</tr>
<tr>
<td>
<dfn><code>onserviceremoved</code></dfn>
</td>
<td>
<dfn><code>serviceremoved</code></dfn>
</td>
<td>
<a>TelephonyServiceEvent</a>
</td>
<td>
handles a disabled telephony service
</td>
</tr>
<tr>
<td>
<dfn><code>onservicechanged</code></dfn>
</td>
<td>
<dfn><code>servicechanged</code></dfn>
</td>
<td>
<a>TelephonyServiceEvent</a>
</td>
<td>
handles the change of default telephony service.
</td>
</tr>
</tbody>
</table>
</section>
<section id="telephonymanager-steps">
<h3>
Steps
</h3>
<p>
The <a>TelephonyManager</a> object MUST <a>queue a task</a>
<dfn><var>TCallControl</var></dfn> for each <a>TelephonyCall</a> or
<a>ConferenceCall</a> object it manages, which MUST listen to any
event that results in changing the call, and upon such events, follow
the steps described in this specification.
</p>
<p>
The <dfn>steps to update the default service</dfn> are as follows:
</p>
<ol>
<li>Let <var>potential service</var> be the first argument passed to
this operation.
</li>
<li>Let <var>promise</var> be a new <a><code>Promise</code></a>
object and <var>resolver</var> its associated resolver.
</li>
<li>Return <var>promise</var> and continue the following steps
asynchronously.
</li>
<li>If <var>potential service</var> does not exactly match the
identifier of any <a>telephony service</a> known to the user agent,
run the following sub-steps and terminate this algorithm:
<ol>
<li>Let <var>error</var> be a new <a href=
"http://dom.spec.whatwg.org/#domerror">DOMError</a> object whose
name is "<a href=
"http://dom.spec.whatwg.org/#notfounderror">NotFoundError</a>".
</li>
<li>Invoke <var>resolver</var>'s reject(value) method with <var>
error</var> as the value argument.
</li>
</ol>
</li>
<li>If <var>potential service</var> exactly matches the service id of
the current default telephony service, run the following sub-steps
and terminate this algorithm:
<ol>
<li>Invoke <var>resolver</var>'s accept(value) method with <var>
potential service</var> as the value argument.
</li>
</ol>
</li>
<li>Otherwise, run the <a>steps to change the default service</a>,
with <var>potential service</var> as the <a>telephony service id</a>,
and <var>promise</var> as the <a><code>Promise</code></a>.
</li>
</ol>
<p>
The <dfn>steps to change the default service</dfn> are given by the
following algorithm. This abstract operation takes as an argument a
<a>telephony service id</a> and an optional
<a><code>Promise</code></a>.
</p>
<ol>
<li>Make a platform/system specific request to the underlying system
to change from the current default telephony service to the one
identified by <var>service id</var>.
</li>
<li>Possibly wait indefinately.
</li>
<li>If it's not possible (for whatever reason: timeout, security,
etc.) to change the default telephony service, and if
<var>promise</var> was passed, run the following sub steps and
terminate this algorithm:
<ol>
<li>Let <var>error</var> be a new DOMError object whose name is
"NoModificationAllowedError".
</li>
<li>Call <var>resolver</var>'s reject(value) method with
<var>error</var> as the value argument.
</li>
</ol>
</li>
<li>Otherwise, <a>queue a task</a> to:
<ol>
<li>Change the <a>defaultServiceId</a> attribute to the
<a>telephony service id</a> of the new <a>default telephony
service</a>.
</li>
<li>If <a><code>Promise</code></a> was passed, invoke
<var>resolver</var>'s accept(value) method with the id of the new
default service as value argument.
</li>
<li>
<a>Fire a simple event</a> named <code>servicechange</code> at
the <a>telephony</a> attribute of the navigator object.
</li>
</ol>
</li>
</ol>
<p>
The <a>dial</a> method when invoked MUST run the following steps:
</p>
<ol id="steps-dial">
<li>Create a new <a>TelephonyCall</a> object, referred as
<var>telCall</var> in these steps.
</li>
<li>Set the <a>remoteParty</a> attribute of <var>telCall</var> to the
<a>remote party id</a> specified in the <a>remoteParty</a> parameter.
</li>
<li>If <a>calls</a> array already contains a <a>TelephonyCall</a>
object with identical <a>remoteParty</a> attribute, then an
<code>InvalidModificationError</code> MUST be thrown.
</li>
<li>Otherwise, make a request to the telephony system to dial in the
<a>remote party id</a> passed in the <var>remoteParty</var>
parameter. Note that the value can be also an emergency number.
According to the value of the <code>hideCallerId</code> in the <code>
params</code> parameter, the own number is requested to be either
displayed, hidden or otherwise the default system configuration to
this regard is requested to be followed. The call MUST be made
using the <a>telephony service</a> specified in the
<code>service</code> member of the <code>params</code> arguement.
If not specified, then the implementation MUST use the <a>default
telephony service</a>. Even if there is no SIM card and no other
telephony services are available, but emergency calls are known to
be possible (e.g. because a cellular modem is present), it is
considered as a default service with only emergency call
capability, and the implementation MUST define a <a>telephony
service id</a> for it. When not even emergency calls are possible
(e.g. it is a purely IP based implementation and there is no
cellular modem), the implementation MAY use empty string for
default <a>telephony service id</a>, but it is encouraged that a
default service is created, with the methods throwing a
<code>NotSupported</code> error.
</li>
<li>If the request is successful, then
<ol>
<li>Set the <code>state</code> of <var>telCall</var> to
<code>"dialing"</code> value.
</li>
<li>Add <var>telCall</var> to the <a>calls</a> array.
</li>
<li>
<a>Queue a task</a> to <a>fire a simple event</a> named
<code>statechange</code> at the <var>telCall</var> object.
</li>
<li>
<a>Queue a task</a> to <a>fire a simple event</a> named
<code>dialing</code> at the <var>telCall</var> object.
</li>
<li>and finally return to the caller and <a>queue a task</a> <a>
<var>TCallControl</var></a> to monitor call flow progress.
</li>
</ol>
</li>
<li>If during further steps for call connection there is an error,
execute the <a>error steps</a> for <var>telCall</var>.
</li>
</ol>
<p>
The <code>sendTones</code> method when invoked MUST run the following
steps:
</p>
<ol id="steps-sendtones">
<li>If the <a>ToneParams</a> parameter specifies the <a>serviceId</a>
to be used, then validate and use that value, otherwise use the
<a>default telephony service</a> for sending the tones.
</li>
<li>If the <a>ToneParams</a> parameter specifies the tone
<code>duration</code>, then validate and use that value, otherwise
use a default value.
</li>
<li>If the <a>ToneParams</a> parameter specifies the tone
<code>gap</code>, then validate and use that value, otherwise use a
default value.
</li>
<li>Request from the telephony system to send the specified tones.
</li>
<li>Let <var>promise</var> be a new <a><code>Promise</code></a>
object and <var>resolver</var> its associated
<a><code>resolver</code></a>.
</li>
<li>Return <var>promise</var> to the caller and continue the
following steps asynchronously.
</li>
<li>If the request to the telephony system is successful, or if the
telephony system does not support feedback about the result of the
request, invoke <var>resolver</var>'s <code>accept()</code> method
with no arguments.
</li>
<li>If the request to the telephony system is unsuccessful, invoke
<var>resolver</var>'s <code>reject()</code> method, with no
arguments.
</li>
</ol>
<p>
The <code>startTone</code> method when invoked MUST run the following
steps:
</p>
<ol id="steps-starttone">
<li>If the platform does not support long press [[!DTMF]] tones,
throw a <code>NotSupported</code> error and finish these steps. In
this case applications may then use the <code>sendTones</code> method
for sending [[!DTMF]].
</li>
<li>If the <a>ToneParams</a> parameter specifies the <a>serviceId</a>
to be used, then validate and use that value, otherwise use the
<a>default telephony service</a> for sending the tones.
</li>
<li>If the <a>ToneParams</a> parameter specifies the tone
<code>duration</code>, then ignore that value.
</li>
<li>If the <a>ToneParams</a> parameter specifies the tone
<code>gap</code>, meaning the delay before sending the tone, then
validate and use that value, otherwise use a default value.
</li>
<li>Request from the telephony system to start sending the specified
tone. The tone SHOULD play until the <code>stopTone</code> method is
called.
</li>
<li>Let <var>promise</var> be a new <a><code>Promise</code></a>
object and <var>resolver</var> its associated
<a><code>resolver</code></a>.
</li>
<li>Return <var>promise</var> to the caller and continue the
following steps asynchronously.
</li>
<li>If the request to the telephony system is successful, or if the
telephony system does not support feedback about the result of the
request, invoke <var>resolver</var>'s <code>accept()</code> method
with no arguments.
</li>
<li>If the request to the telephony system is unsuccessful, invoke
<var>resolver</var>'s <code>reject()</code> method, with no
arguments.
</li>
</ol>
<p>
The <a>stopTone</a> method when invoked MUST run the following steps:
</p>
<ol id="steps-stoptone">
<li>If the platform does not support long press [[!DTMF]] tones,
throw a <code>NotSupported</code> error.
</li>
<li>If the provided parameters are invalid, or there is no tone
playing on the specified telephony service, throw an
<code>InvalidStateError</code> error.
</li>
<li>Otherwise, request from the telephony system to stop sending the
specified tone.
</li>
<li>Let <var>promise</var> be a new <a><code>Promise</code></a>
object and <var>resolver</var> its associated
<a><code>resolver</code></a>.
</li>
<li>Return <var>promise</var> to the caller and continue the
following steps asynchronously.
</li>
<li>If the request to the telephony system is successful, or if the
telephony system does not support feedback about the result of the
request, invoke <var>resolver</var>'s <code>accept()</code> method
with no arguments.
</li>