summaryrefslogtreecommitdiffstats
path: root/media/java/android/media/ToneGenerator.java
blob: 08c49e75ed1e411b2cab3ed0e3f6070b6a6a7b57 (plain)
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
/*
 * Copyright (C) 2008 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 android.media;



/**
 * This class provides methods to play DTMF tones (ITU-T Recommendation Q.23),
 * call supervisory tones (3GPP TS 22.001, CEPT) and proprietary tones (3GPP TS 31.111).
 * Depending on call state and routing options, tones are mixed to the downlink audio
 * or output to the speaker phone or headset.
 * This API is not for generating tones over the uplink audio path.
 */
public class ToneGenerator
{

    /* Values for toneType parameter of ToneGenerator() constructor */
    /*
     * List of all available tones: These constants must be kept consistant with
     * the enum in ToneGenerator C++ class.     */

    /**
     * Default value for an unknown or unspecified tone.
     * @hide
     */
    public static final int TONE_UNKNOWN = -1;

    /**
     * DTMF tone for key 0: 1336Hz, 941Hz, continuous</p>
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_0 = 0;
    /**
     * DTMF tone for key 1: 1209Hz, 697Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_1 = 1;
    /**
     * DTMF tone for key 2: 1336Hz, 697Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_2 = 2;
    /**
     * DTMF tone for key 3: 1477Hz, 697Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_3 = 3;
    /**
     * DTMF tone for key 4: 1209Hz, 770Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_4 = 4;
    /**
     * DTMF tone for key 5: 1336Hz, 770Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_5 = 5;
    /**
     * DTMF tone for key 6: 1477Hz, 770Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_6 = 6;
    /**
     * DTMF tone for key 7: 1209Hz, 852Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_7 = 7;
    /**
     * DTMF tone for key 8: 1336Hz, 852Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_8 = 8;
    /**
     * DTMF tone for key 9: 1477Hz, 852Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_9 = 9;
    /**
     * DTMF tone for key *: 1209Hz, 941Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_S = 10;
    /**
     * DTMF tone for key #: 1477Hz, 941Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_P = 11;
    /**
     * DTMF tone for key A: 1633Hz, 697Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_A = 12;
    /**
     * DTMF tone for key B: 1633Hz, 770Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_B = 13;
    /**
     * DTMF tone for key C: 1633Hz, 852Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_C = 14;
    /**
     * DTMF tone for key D: 1633Hz, 941Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_DTMF_D = 15;
    /**
     * Call supervisory tone, Dial tone:
     *      CEPT:           425Hz, continuous
     *      ANSI (IS-95):   350Hz+440Hz, continuous
     *      JAPAN:          400Hz, continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_DIAL = 16;
    /**
     * Call supervisory tone, Busy:
     *      CEPT:           425Hz, 500ms ON, 500ms OFF...
     *      ANSI (IS-95):   480Hz+620Hz, 500ms ON, 500ms OFF...
     *      JAPAN:          400Hz, 500ms ON, 500ms OFF...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_BUSY = 17;
    /**
     * Call supervisory tone, Congestion:
     *      CEPT, JAPAN:    425Hz, 200ms ON, 200ms OFF...
     *      ANSI (IS-95):   480Hz+620Hz, 250ms ON, 250ms OFF...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_CONGESTION = 18;
    /**
     * Call supervisory tone, Radio path acknowlegment :
     *      CEPT, ANSI:    425Hz, 200ms ON
     *      JAPAN:         400Hz, 1s ON, 2s OFF...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_RADIO_ACK = 19;
    /**
     * Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_RADIO_NOTAVAIL = 20;
    /**
     * Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_ERROR = 21;
    /**
     * Call supervisory tone, Call Waiting:
     *      CEPT, JAPAN:    425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF...
     *      ANSI (IS-95):   440 Hz, 300 ms ON, 9.7 s OFF,
     *                      (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...)
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_CALL_WAITING = 22;
    /**
     * Call supervisory tone, Ring Tone:
     *      CEPT, JAPAN:    425Hz, 1s ON, 4s OFF...
     *      ANSI (IS-95):   440Hz + 480Hz, 2s ON, 4s OFF...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_RINGTONE = 23;
    /**
     * Proprietary tone, general beep: 400Hz+1200Hz, 35ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_PROP_BEEP = 24;
    /**
     * Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_PROP_ACK = 25;
    /**
     * Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_PROP_NACK = 26;
    /**
     * Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int  TONE_PROP_PROMPT = 27;
    /**
     * Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_PROP_BEEP2 = 28;
    /**
     * Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones,
     * each on for 250 ms
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_INTERCEPT = 29;
    /**
     * Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_INTERCEPT_ABBREV = 30;
    /**
     * Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_CONGESTION_ABBREV = 31;
    /**
     * Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone
     * repeated 3 times in a 100 ms on, 100 ms off cycle
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_CONFIRM = 32;
    /**
     * Call supervisory tone (IS-95), pip tone: four bursts of 480 Hz tone (0.1 s on, 0.1 s off).
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_SUP_PIP = 33;
    /**
     *  CDMA Dial tone : 425Hz  continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_DIAL_TONE_LITE = 34;
    /**
     * CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_NETWORK_USA_RINGBACK = 35;
    /**
     *  CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_INTERCEPT = 36;
    /**
     * CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_ABBR_INTERCEPT = 37;
    /**
     * CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_REORDER = 38;
    /**
     *
     * CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_ABBR_REORDER = 39;
    /**
     * CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_NETWORK_BUSY = 40;
    /**
     * CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_CONFIRM = 41;
    /**
     *
     * CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_ANSWER = 42;
    /**
     *
     * CDMA Network Callwaiting tone: 440Hz 300ms ON
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_NETWORK_CALLWAITING = 43;
    /**
     * CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_PIP = 44;
    /**
     *  ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times,
     *  2091 32ms ON, 2556 48ms ON, 4s OFF
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL = 45;
    /**
     *  ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times,
     * 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} times,
     * 2091Hz 32ms ON, 4s OFF.
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP = 46;
    /**
     * ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times
     * 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times,
     * 2091Hz 16ms ON, 200ms OFF
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI = 47;
    /**
     * ISDN Call sign PAT3 tone: silent tone
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT3 = 48;
    /**
     * ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times
     * 2091Hz 20ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING = 49;
    /**
     *
     * ISDN Pat5 tone: silent tone
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT5 = 50;
    /**
     *
     * ISDN Pat6 tone: silent tone
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT6 = 51;
    /**
     * ISDN Pat7 tone: silent tone
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT7 = 52;
    /**
     * TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times
     * 4000ms OFF, Repeat ....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_L = 53;
    /**
     * TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times
     * 4000ms OFF, Repeat ....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_L = 54;
    /**
     * TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times,
     * 4000ms OFF, Repeat ....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_L = 55;
    /**
     * CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times,
     * 400ms OFF, repeat ....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_SS = 56;
    /**
     * CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times,
     * 400ms OFF, repeat ....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_SS = 57;
    /**
     * CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times,
     * 400ms OFF, repeat ....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_SS = 58;
    /**
     * CDMA HIGH SSL tone: {3700Hz 25ms, 4000Hz 25ms} 8 times,
     * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 8 times,
     * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 16 times,
     * 4000ms OFF, repeat ...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_SSL = 59;
    /**
     * CDMA MED SSL tone: {2600Hz 25ms, 2900Hz 25ms} 8 times,
     * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 8 times,
     * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 16 times,
     * 4000ms OFF, repeat ...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_SSL = 60;
    /**
     * CDMA LOW SSL tone: {1300Hz 25ms, 1450Hz 25ms} 8 times,
     * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 8 times,
     * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 16 times,
     * 4000ms OFF, repeat ...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_SSL = 61;
    /**
     * CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times,
     * 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times,
     * 3000ms OFF, repeat ....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_SS_2 = 62;
    /**
     * CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times,
     * 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times,
     * 3000ms OFF, repeat ....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_SS_2 = 63;
    /**
     * CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times,
     * 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times,
     * 3000ms OFF, repeat ....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_SS_2 = 64;
    /**
     *  CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times,
     *  500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF,
     *  {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_SLS = 65;
    /**
     *  CDMA MED  SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times,
     *  500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF,
     *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT
     *
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_SLS = 66;
    /**
     *  CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times,
     *  500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF,
     *  {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_SLS = 67;
    /**
     *  CDMA HIGH S X4 tone: {3700Hz 25ms, 4000Hz 25ms} 10 times,
     *  500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF,
     *  {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF,
     *  {3700Hz 25ms, 4000Hz 25ms} 10 times, 2500ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_S_X4 = 68;
    /**
     *  CDMA MED S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times,
     *  500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF,
     *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF,
     *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_S_X4 = 69;
    /**
     *  CDMA LOW  S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times,
     *  500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF,
     *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF,
     *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....
     *
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_S_X4 = 70;
    /**
     * CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times,
     * 2000ms OFF,  REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_PBX_L = 71;
    /**
     *  CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times,
     * 2000ms OFF,  REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_PBX_L = 72;
    /**
     * CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times,
     * 2000ms OFF,  REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_PBX_L = 73;
    /**
     * CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times
     * 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times,
     * 2000ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_PBX_SS = 74;
    /**
     * CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times
     * 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times,
     * 2000ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_PBX_SS = 75;
    /**
     * CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times
     * 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times,
     * 2000ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_PBX_SS = 76;
    /**
     * CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times
     * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF,
     * {3700Hz 25ms, 4000Hz 25ms} 16 times, 1000ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_PBX_SSL = 77;
    /**
     * CDMA MED PBX SSL tone:{2600Hz 25ms, 2900Hz 25ms} 8 times
     * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF,
     * {2600Hz 25ms, 2900Hz 25ms} 16 times, 1000ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_PBX_SSL = 78;
    /**
     * CDMA LOW PBX SSL tone:{1300Hz 25ms, 1450Hz 25ms} 8 times
     * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF,
     * {1300Hz 25ms, 1450Hz 25ms} 16 times, 1000ms OFF, REPEAT....
     *
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_PBX_SSL = 79;
    /**
     * CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times
     * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 200ms OFF,
     * {3700Hz 25ms, 4000Hz 25ms} 8 times, 1000ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_PBX_SLS = 80;
    /**
     * CDMA HIGH PBX SLS tone:{2600Hz 25ms, 2900Hz 25ms} 8 times
     * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 200ms OFF,
     * {2600Hz 25ms, 2900Hz 25ms} 8 times, 1000ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_PBX_SLS = 81;
    /**
     * CDMA HIGH PBX SLS tone:{1300Hz 25ms, 1450Hz 25ms} 8 times
     * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 200ms OFF,
     * {1300Hz 25ms, 1450Hz 25ms} 8 times, 1000ms OFF, REPEAT....
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_PBX_SLS = 82;
    /**
     * CDMA HIGH PBX X S4 tone: {3700Hz 25ms 4000Hz 25ms} 8 times,
     * 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF,
     * {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF,
     * {3700Hz 25ms 4000Hz 25ms} 8 times, 800ms OFF, REPEAT...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_HIGH_PBX_S_X4 = 83;
    /**
     * CDMA MED PBX X S4 tone: {2600Hz 25ms 2900Hz 25ms} 8 times,
     * 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF,
     * {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF,
     * {2600Hz 25ms 2900Hz 25ms} 8 times, 800ms OFF, REPEAT...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_MED_PBX_S_X4 = 84;
    /**
     * CDMA LOW PBX X S4 tone: {1300Hz 25ms 1450Hz 25ms} 8 times,
     * 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF,
     * {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF,
     * {1300Hz 25ms 1450Hz 25ms} 8 times, 800ms OFF, REPEAT...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_LOW_PBX_S_X4 = 85;
    /**
     * CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON
     * 622Hz 62ms ON, 1109Hz 62ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_ALERT_NETWORK_LITE = 86;
    /**
     * CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times,
     * 1245 62ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_ALERT_AUTOREDIAL_LITE = 87;
    /**
     * CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_ONE_MIN_BEEP = 88;
    /**
     *
     * CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_KEYPAD_VOLUME_KEY_LITE = 89;
    /**
     * CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_PRESSHOLDKEY_LITE = 90;
    /**
     * CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms,
     * 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_ALERT_INCALL_LITE = 91;
    /**
     * CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times
     * 4990ms OFF, REPEAT...
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_EMERGENCY_RINGBACK = 92;
    /**
     * CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_ALERT_CALL_GUARD = 93;
    /**
     * CDMA SOFT ERROR LITE  tone: 1047Hz 125ms ON, 370Hz 125ms
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_SOFT_ERROR_LITE = 94;
    /**
     * CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_CALLDROP_LITE = 95;
    /**
     * CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF.
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_NETWORK_BUSY_ONE_SHOT = 96;
    /**
     * CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON
     * @see #ToneGenerator(int, int)
     */
    public static final int    TONE_CDMA_ABBR_ALERT = 97;
    /**
     * CDMA_SIGNAL_OFF - silent tone
     *
     * @see #ToneGenerator(int, int)
     */
    public static final int TONE_CDMA_SIGNAL_OFF = 98;
    /**
     * SUPERVISORY_CH - 440Hz
     *
     * @hide #ToneGenerator(int, int)
     */
    public static final int TONE_SUPERVISORY_CH = 100;
    /**
     * HOLD_RECALL - 440Hz
     *
     * @hide #ToneGenerator(int, int)
     */
    public static final int TONE_HOLD_RECALL = 99;

    /** Maximum volume, for use with {@link #ToneGenerator(int,int)} */
    public static final int MAX_VOLUME = 100;
    /** Minimum volume setting, for use with {@link #ToneGenerator(int,int)} */
    public static final int MIN_VOLUME = 0;

    /**
     * ToneGenerator class contructor specifying output stream type and volume.
     *
     * @param streamType The streame type used for tone playback (e.g. STREAM_MUSIC).
     * @param volume     The volume of the tone, given in percentage of maximum volume (from 0-100).
     *
     */
    public ToneGenerator(int streamType, int volume) {
        native_setup(streamType, volume);
    }

    /**
     * This method starts the playback of a tone of the specified type.
     * only one tone can play at a time: if a tone is playing while this method is called,
     * this tone is stopped and replaced by the one requested.
     * @param toneType   The type of tone generated chosen from the following list:
     * <ul>
     * <li>{@link #TONE_DTMF_0}
     * <li>{@link #TONE_DTMF_1}
     * <li>{@link #TONE_DTMF_2}
     * <li>{@link #TONE_DTMF_3}
     * <li>{@link #TONE_DTMF_4}
     * <li>{@link #TONE_DTMF_5}
     * <li>{@link #TONE_DTMF_6}
     * <li>{@link #TONE_DTMF_7}
     * <li>{@link #TONE_DTMF_8}
     * <li>{@link #TONE_DTMF_9}
     * <li>{@link #TONE_DTMF_A}
     * <li>{@link #TONE_DTMF_B}
     * <li>{@link #TONE_DTMF_C}
     * <li>{@link #TONE_DTMF_D}
     * <li>{@link #TONE_SUP_DIAL}
     * <li>{@link #TONE_SUP_BUSY}
     * <li>{@link #TONE_SUP_CONGESTION}
     * <li>{@link #TONE_SUP_RADIO_ACK}
     * <li>{@link #TONE_SUP_RADIO_NOTAVAIL}
     * <li>{@link #TONE_SUP_ERROR}
     * <li>{@link #TONE_SUP_CALL_WAITING}
     * <li>{@link #TONE_SUP_RINGTONE}
     * <li>{@link #TONE_PROP_BEEP}
     * <li>{@link #TONE_PROP_ACK}
     * <li>{@link #TONE_PROP_NACK}
     * <li>{@link #TONE_PROP_PROMPT}
     * <li>{@link #TONE_PROP_BEEP2}
     * <li>{@link #TONE_SUP_INTERCEPT}
     * <li>{@link #TONE_SUP_INTERCEPT_ABBREV}
     * <li>{@link #TONE_SUP_CONGESTION_ABBREV}
     * <li>{@link #TONE_SUP_CONFIRM}
     * <li>{@link #TONE_SUP_PIP}
     * <li>{@link #TONE_CDMA_DIAL_TONE_LITE}
     * <li>{@link #TONE_CDMA_NETWORK_USA_RINGBACK}
     * <li>{@link #TONE_CDMA_INTERCEPT}
     * <li>{@link #TONE_CDMA_ABBR_INTERCEPT}
     * <li>{@link #TONE_CDMA_REORDER}
     * <li>{@link #TONE_CDMA_ABBR_REORDER}
     * <li>{@link #TONE_CDMA_NETWORK_BUSY}
     * <li>{@link #TONE_CDMA_CONFIRM}
     * <li>{@link #TONE_CDMA_ANSWER}
     * <li>{@link #TONE_CDMA_NETWORK_CALLWAITING}
     * <li>{@link #TONE_CDMA_PIP}
     * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL}
     * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP}
     * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI}
     * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT3}
     * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING}
     * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT5}
     * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT6}
     * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT7}
     * <li>{@link #TONE_CDMA_HIGH_L}
     * <li>{@link #TONE_CDMA_MED_L}
     * <li>{@link #TONE_CDMA_LOW_L}
     * <li>{@link #TONE_CDMA_HIGH_SS}
     * <li>{@link #TONE_CDMA_MED_SS}
     * <li>{@link #TONE_CDMA_LOW_SS}
     * <li>{@link #TONE_CDMA_HIGH_SSL}
     * <li>{@link #TONE_CDMA_MED_SSL}
     * <li>{@link #TONE_CDMA_LOW_SSL}
     * <li>{@link #TONE_CDMA_HIGH_SS_2}
     * <li>{@link #TONE_CDMA_MED_SS_2}
     * <li>{@link #TONE_CDMA_LOW_SS_2}
     * <li>{@link #TONE_CDMA_HIGH_SLS}
     * <li>{@link #TONE_CDMA_MED_SLS}
     * <li>{@link #TONE_CDMA_LOW_SLS}
     * <li>{@link #TONE_CDMA_HIGH_S_X4}
     * <li>{@link #TONE_CDMA_MED_S_X4}
     * <li>{@link #TONE_CDMA_LOW_S_X4}
     * <li>{@link #TONE_CDMA_HIGH_PBX_L}
     * <li>{@link #TONE_CDMA_MED_PBX_L}
     * <li>{@link #TONE_CDMA_LOW_PBX_L}
     * <li>{@link #TONE_CDMA_HIGH_PBX_SS}
     * <li>{@link #TONE_CDMA_MED_PBX_SS}
     * <li>{@link #TONE_CDMA_LOW_PBX_SS}
     * <li>{@link #TONE_CDMA_HIGH_PBX_SSL}
     * <li>{@link #TONE_CDMA_MED_PBX_SSL}
     * <li>{@link #TONE_CDMA_LOW_PBX_SSL}
     * <li>{@link #TONE_CDMA_HIGH_PBX_SLS}
     * <li>{@link #TONE_CDMA_MED_PBX_SLS}
     * <li>{@link #TONE_CDMA_LOW_PBX_SLS}
     * <li>{@link #TONE_CDMA_HIGH_PBX_S_X4}
     * <li>{@link #TONE_CDMA_MED_PBX_S_X4}
     * <li>{@link #TONE_CDMA_LOW_PBX_S_X4}
     * <li>{@link #TONE_CDMA_ALERT_NETWORK_LITE}
     * <li>{@link #TONE_CDMA_ALERT_AUTOREDIAL_LITE}
     * <li>{@link #TONE_CDMA_ONE_MIN_BEEP}
     * <li>{@link #TONE_CDMA_KEYPAD_VOLUME_KEY_LITE}
     * <li>{@link #TONE_CDMA_PRESSHOLDKEY_LITE}
     * <li>{@link #TONE_CDMA_ALERT_INCALL_LITE}
     * <li>{@link #TONE_CDMA_EMERGENCY_RINGBACK}
     * <li>{@link #TONE_CDMA_ALERT_CALL_GUARD}
     * <li>{@link #TONE_CDMA_SOFT_ERROR_LITE}
     * <li>{@link #TONE_CDMA_CALLDROP_LITE}
     * <li>{@link #TONE_CDMA_NETWORK_BUSY_ONE_SHOT}
     * <li>{@link #TONE_CDMA_ABBR_ALERT}
     * <li>{@link #TONE_CDMA_SIGNAL_OFF}
     * </ul>
     * @see #ToneGenerator(int, int)
    */
    public boolean startTone(int toneType) {
        return startTone(toneType, -1);
    }

    /**
     * This method starts the playback of a tone of the specified type for the specified duration.
     * @param toneType   The type of tone generated @see {@link #startTone(int)}.
     * @param durationMs  The tone duration in milliseconds. If the tone is limited in time by definition,
     * the actual duration will be the minimum of durationMs and the defined tone duration. Setting durationMs to -1,
     * is equivalent to calling {@link #startTone(int)}.
    */
    public native boolean startTone(int toneType, int durationMs);

    /**
     * This method stops the tone currently playing playback.
     * @see #ToneGenerator(int, int)
     */
    public native void stopTone();

    /**
     * Releases resources associated with this ToneGenerator object. It is good
     * practice to call this method when you're done using the ToneGenerator.
     */
    public native void release();

    private native final void native_setup(int streamType, int volume);

    private native final void native_finalize();

    /**
    * Returns the audio session ID.
    *
    * @return the ID of the audio session this ToneGenerator belongs to or 0 if an error
    * occured.
    */
    public native final int getAudioSessionId();

    @Override
    protected void finalize() { native_finalize(); }

    @SuppressWarnings("unused")
    private long mNativeContext; // accessed by native methods
}