1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.media;
18 
19 import android.compat.annotation.UnsupportedAppUsage;
20 
21 
22 
23 /**
24  * This class provides methods to play DTMF tones (ITU-T Recommendation Q.23),
25  * call supervisory tones (3GPP TS 22.001, CEPT) and proprietary tones (3GPP TS 31.111).
26  * Depending on call state and routing options, tones are mixed to the downlink audio
27  * or output to the speaker phone or headset.
28  * This API is not for generating tones over the uplink audio path.
29  */
30 public class ToneGenerator
31 {
32 
33     /* Values for toneType parameter of ToneGenerator() constructor */
34     /*
35      * List of all available tones: These constants must be kept consistant with
36      * the enum in ToneGenerator C++ class.     */
37 
38     /**
39      * Default value for an unknown or unspecified tone.
40      * @hide
41      */
42     public static final int TONE_UNKNOWN = -1;
43 
44     /**
45      * DTMF tone for key 0: 1336Hz, 941Hz, continuous</p>
46      *
47      * @see #ToneGenerator(int, int)
48      */
49     public static final int TONE_DTMF_0 = 0;
50     /**
51      * DTMF tone for key 1: 1209Hz, 697Hz, continuous
52      *
53      * @see #ToneGenerator(int, int)
54      */
55     public static final int TONE_DTMF_1 = 1;
56     /**
57      * DTMF tone for key 2: 1336Hz, 697Hz, continuous
58      *
59      * @see #ToneGenerator(int, int)
60      */
61     public static final int TONE_DTMF_2 = 2;
62     /**
63      * DTMF tone for key 3: 1477Hz, 697Hz, continuous
64      *
65      * @see #ToneGenerator(int, int)
66      */
67     public static final int TONE_DTMF_3 = 3;
68     /**
69      * DTMF tone for key 4: 1209Hz, 770Hz, continuous
70      *
71      * @see #ToneGenerator(int, int)
72      */
73     public static final int TONE_DTMF_4 = 4;
74     /**
75      * DTMF tone for key 5: 1336Hz, 770Hz, continuous
76      *
77      * @see #ToneGenerator(int, int)
78      */
79     public static final int TONE_DTMF_5 = 5;
80     /**
81      * DTMF tone for key 6: 1477Hz, 770Hz, continuous
82      *
83      * @see #ToneGenerator(int, int)
84      */
85     public static final int TONE_DTMF_6 = 6;
86     /**
87      * DTMF tone for key 7: 1209Hz, 852Hz, continuous
88      *
89      * @see #ToneGenerator(int, int)
90      */
91     public static final int TONE_DTMF_7 = 7;
92     /**
93      * DTMF tone for key 8: 1336Hz, 852Hz, continuous
94      *
95      * @see #ToneGenerator(int, int)
96      */
97     public static final int TONE_DTMF_8 = 8;
98     /**
99      * DTMF tone for key 9: 1477Hz, 852Hz, continuous
100      *
101      * @see #ToneGenerator(int, int)
102      */
103     public static final int TONE_DTMF_9 = 9;
104     /**
105      * DTMF tone for key *: 1209Hz, 941Hz, continuous
106      *
107      * @see #ToneGenerator(int, int)
108      */
109     public static final int TONE_DTMF_S = 10;
110     /**
111      * DTMF tone for key #: 1477Hz, 941Hz, continuous
112      *
113      * @see #ToneGenerator(int, int)
114      */
115     public static final int TONE_DTMF_P = 11;
116     /**
117      * DTMF tone for key A: 1633Hz, 697Hz, continuous
118      *
119      * @see #ToneGenerator(int, int)
120      */
121     public static final int TONE_DTMF_A = 12;
122     /**
123      * DTMF tone for key B: 1633Hz, 770Hz, continuous
124      *
125      * @see #ToneGenerator(int, int)
126      */
127     public static final int TONE_DTMF_B = 13;
128     /**
129      * DTMF tone for key C: 1633Hz, 852Hz, continuous
130      *
131      * @see #ToneGenerator(int, int)
132      */
133     public static final int TONE_DTMF_C = 14;
134     /**
135      * DTMF tone for key D: 1633Hz, 941Hz, continuous
136      *
137      * @see #ToneGenerator(int, int)
138      */
139     public static final int TONE_DTMF_D = 15;
140     /**
141      * Call supervisory tone, Dial tone:
142      *      CEPT:           425Hz, continuous
143      *      ANSI (IS-95):   350Hz+440Hz, continuous
144      *      JAPAN:          400Hz, continuous
145      *
146      * @see #ToneGenerator(int, int)
147      */
148     public static final int TONE_SUP_DIAL = 16;
149     /**
150      * Call supervisory tone, Busy:
151      *      CEPT:           425Hz, 500ms ON, 500ms OFF...
152      *      ANSI (IS-95):   480Hz+620Hz, 500ms ON, 500ms OFF...
153      *      JAPAN:          400Hz, 500ms ON, 500ms OFF...
154      *
155      * @see #ToneGenerator(int, int)
156      */
157     public static final int TONE_SUP_BUSY = 17;
158     /**
159      * Call supervisory tone, Congestion:
160      *      CEPT, JAPAN:    425Hz, 200ms ON, 200ms OFF...
161      *      ANSI (IS-95):   480Hz+620Hz, 250ms ON, 250ms OFF...
162      *
163      * @see #ToneGenerator(int, int)
164      */
165     public static final int TONE_SUP_CONGESTION = 18;
166     /**
167      * Call supervisory tone, Radio path acknowlegment :
168      *      CEPT, ANSI:    425Hz, 200ms ON
169      *      JAPAN:         400Hz, 1s ON, 2s OFF...
170      *
171      * @see #ToneGenerator(int, int)
172      */
173     public static final int TONE_SUP_RADIO_ACK = 19;
174     /**
175      * Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts
176      *
177      * @see #ToneGenerator(int, int)
178      */
179     public static final int TONE_SUP_RADIO_NOTAVAIL = 20;
180     /**
181      * Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF...
182      *
183      * @see #ToneGenerator(int, int)
184      */
185     public static final int TONE_SUP_ERROR = 21;
186     /**
187      * Call supervisory tone, Call Waiting:
188      *      CEPT, JAPAN:    425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF...
189      *      ANSI (IS-95):   440 Hz, 300 ms ON, 9.7 s OFF,
190      *                      (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...)
191      *
192      * @see #ToneGenerator(int, int)
193      */
194     public static final int TONE_SUP_CALL_WAITING = 22;
195     /**
196      * Call supervisory tone, Ring Tone:
197      *      CEPT, JAPAN:    425Hz, 1s ON, 4s OFF...
198      *      ANSI (IS-95):   440Hz + 480Hz, 2s ON, 4s OFF...
199      *
200      * @see #ToneGenerator(int, int)
201      */
202     public static final int TONE_SUP_RINGTONE = 23;
203     /**
204      * Proprietary tone, general beep: 400Hz+1200Hz, 35ms ON
205      *
206      * @see #ToneGenerator(int, int)
207      */
208     public static final int TONE_PROP_BEEP = 24;
209     /**
210      * Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts
211      *
212      * @see #ToneGenerator(int, int)
213      */
214     public static final int TONE_PROP_ACK = 25;
215     /**
216      * Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON
217      *
218      * @see #ToneGenerator(int, int)
219      */
220     public static final int TONE_PROP_NACK = 26;
221     /**
222      * Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON
223      *
224      * @see #ToneGenerator(int, int)
225      */
226     public static final int  TONE_PROP_PROMPT = 27;
227     /**
228      * Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON
229      *
230      * @see #ToneGenerator(int, int)
231      */
232     public static final int TONE_PROP_BEEP2 = 28;
233     /**
234      * Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones,
235      * each on for 250 ms
236      *
237      * @see #ToneGenerator(int, int)
238      */
239     public static final int TONE_SUP_INTERCEPT = 29;
240     /**
241      * Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds
242      *
243      * @see #ToneGenerator(int, int)
244      */
245     public static final int TONE_SUP_INTERCEPT_ABBREV = 30;
246     /**
247      * Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds
248      *
249      * @see #ToneGenerator(int, int)
250      */
251     public static final int TONE_SUP_CONGESTION_ABBREV = 31;
252     /**
253      * Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone
254      * repeated 3 times in a 100 ms on, 100 ms off cycle
255      *
256      * @see #ToneGenerator(int, int)
257      */
258     public static final int TONE_SUP_CONFIRM = 32;
259     /**
260      * Call supervisory tone (IS-95), pip tone: four bursts of 480 Hz tone (0.1 s on, 0.1 s off).
261      *
262      * @see #ToneGenerator(int, int)
263      */
264     public static final int TONE_SUP_PIP = 33;
265     /**
266      *  CDMA Dial tone : 425Hz  continuous
267      *
268      * @see #ToneGenerator(int, int)
269      */
270     public static final int TONE_CDMA_DIAL_TONE_LITE = 34;
271     /**
272      * CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...
273      *
274      * @see #ToneGenerator(int, int)
275      */
276     public static final int TONE_CDMA_NETWORK_USA_RINGBACK = 35;
277     /**
278      *  CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...
279      *
280      * @see #ToneGenerator(int, int)
281      */
282     public static final int TONE_CDMA_INTERCEPT = 36;
283     /**
284      * CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON
285      *
286      * @see #ToneGenerator(int, int)
287      */
288     public static final int TONE_CDMA_ABBR_INTERCEPT = 37;
289     /**
290      * CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF...
291      *
292      * @see #ToneGenerator(int, int)
293      */
294     public static final int TONE_CDMA_REORDER = 38;
295     /**
296      *
297      * CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times
298      * @see #ToneGenerator(int, int)
299      */
300     public static final int TONE_CDMA_ABBR_REORDER = 39;
301     /**
302      * CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous
303      *
304      * @see #ToneGenerator(int, int)
305      */
306     public static final int TONE_CDMA_NETWORK_BUSY = 40;
307     /**
308      * CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times
309      *
310      * @see #ToneGenerator(int, int)
311      */
312     public static final int TONE_CDMA_CONFIRM = 41;
313     /**
314      *
315      * CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF
316      * @see #ToneGenerator(int, int)
317      */
318     public static final int TONE_CDMA_ANSWER = 42;
319     /**
320      *
321      * CDMA Network Callwaiting tone: 440Hz 300ms ON
322      * @see #ToneGenerator(int, int)
323      */
324     public static final int TONE_CDMA_NETWORK_CALLWAITING = 43;
325     /**
326      * CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times
327      *
328      * @see #ToneGenerator(int, int)
329      */
330     public static final int TONE_CDMA_PIP = 44;
331     /**
332      *  ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times,
333      *  2091 32ms ON, 2556 48ms ON, 4s OFF
334      *
335      * @see #ToneGenerator(int, int)
336      */
337     public static final int TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL = 45;
338     /**
339      *  ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times,
340      * 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} times,
341      * 2091Hz 32ms ON, 4s OFF.
342      *
343      * @see #ToneGenerator(int, int)
344      */
345     public static final int TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP = 46;
346     /**
347      * ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times
348      * 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times,
349      * 2091Hz 16ms ON, 200ms OFF
350      *
351      * @see #ToneGenerator(int, int)
352      */
353     public static final int TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI = 47;
354     /**
355      * ISDN Call sign PAT3 tone: silent tone
356      *
357      * @see #ToneGenerator(int, int)
358      */
359     public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT3 = 48;
360     /**
361      * ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times
362      * 2091Hz 20ms ON
363      *
364      * @see #ToneGenerator(int, int)
365      */
366     public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING = 49;
367     /**
368      *
369      * ISDN Pat5 tone: silent tone
370      * @see #ToneGenerator(int, int)
371      */
372     public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT5 = 50;
373     /**
374      *
375      * ISDN Pat6 tone: silent tone
376      * @see #ToneGenerator(int, int)
377      */
378     public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT6 = 51;
379     /**
380      * ISDN Pat7 tone: silent tone
381      *
382      * @see #ToneGenerator(int, int)
383      */
384     public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT7 = 52;
385     /**
386      * TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times
387      * 4000ms OFF, Repeat ....
388      *
389      * @see #ToneGenerator(int, int)
390      */
391     public static final int TONE_CDMA_HIGH_L = 53;
392     /**
393      * TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times
394      * 4000ms OFF, Repeat ....
395      *
396      * @see #ToneGenerator(int, int)
397      */
398     public static final int TONE_CDMA_MED_L = 54;
399     /**
400      * TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times,
401      * 4000ms OFF, Repeat ....
402      *
403      * @see #ToneGenerator(int, int)
404      */
405     public static final int TONE_CDMA_LOW_L = 55;
406     /**
407      * CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times,
408      * 400ms OFF, repeat ....
409      *
410      * @see #ToneGenerator(int, int)
411      */
412     public static final int TONE_CDMA_HIGH_SS = 56;
413     /**
414      * CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times,
415      * 400ms OFF, repeat ....
416      *
417      * @see #ToneGenerator(int, int)
418      */
419     public static final int TONE_CDMA_MED_SS = 57;
420     /**
421      * CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times,
422      * 400ms OFF, repeat ....
423      *
424      * @see #ToneGenerator(int, int)
425      */
426     public static final int TONE_CDMA_LOW_SS = 58;
427     /**
428      * CDMA HIGH SSL tone: {3700Hz 25ms, 4000Hz 25ms} 8 times,
429      * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 8 times,
430      * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 16 times,
431      * 4000ms OFF, repeat ...
432      *
433      * @see #ToneGenerator(int, int)
434      */
435     public static final int TONE_CDMA_HIGH_SSL = 59;
436     /**
437      * CDMA MED SSL tone: {2600Hz 25ms, 2900Hz 25ms} 8 times,
438      * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 8 times,
439      * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 16 times,
440      * 4000ms OFF, repeat ...
441      *
442      * @see #ToneGenerator(int, int)
443      */
444     public static final int TONE_CDMA_MED_SSL = 60;
445     /**
446      * CDMA LOW SSL tone: {1300Hz 25ms, 1450Hz 25ms} 8 times,
447      * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 8 times,
448      * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 16 times,
449      * 4000ms OFF, repeat ...
450      *
451      * @see #ToneGenerator(int, int)
452      */
453     public static final int TONE_CDMA_LOW_SSL = 61;
454     /**
455      * CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times,
456      * 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times,
457      * 3000ms OFF, repeat ....
458      *
459      * @see #ToneGenerator(int, int)
460      */
461     public static final int TONE_CDMA_HIGH_SS_2 = 62;
462     /**
463      * CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times,
464      * 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times,
465      * 3000ms OFF, repeat ....
466      *
467      * @see #ToneGenerator(int, int)
468      */
469     public static final int TONE_CDMA_MED_SS_2 = 63;
470     /**
471      * CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times,
472      * 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times,
473      * 3000ms OFF, repeat ....
474      *
475      * @see #ToneGenerator(int, int)
476      */
477     public static final int TONE_CDMA_LOW_SS_2 = 64;
478     /**
479      *  CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times,
480      *  500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF,
481      *  {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT
482      *
483      * @see #ToneGenerator(int, int)
484      */
485     public static final int TONE_CDMA_HIGH_SLS = 65;
486     /**
487      *  CDMA MED  SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times,
488      *  500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF,
489      *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT
490      *
491      *
492      * @see #ToneGenerator(int, int)
493      */
494     public static final int TONE_CDMA_MED_SLS = 66;
495     /**
496      *  CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times,
497      *  500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF,
498      *  {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT
499      *
500      * @see #ToneGenerator(int, int)
501      */
502     public static final int TONE_CDMA_LOW_SLS = 67;
503     /**
504      *  CDMA HIGH S X4 tone: {3700Hz 25ms, 4000Hz 25ms} 10 times,
505      *  500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF,
506      *  {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF,
507      *  {3700Hz 25ms, 4000Hz 25ms} 10 times, 2500ms OFF, REPEAT....
508      *
509      * @see #ToneGenerator(int, int)
510      */
511     public static final int TONE_CDMA_HIGH_S_X4 = 68;
512     /**
513      *  CDMA MED S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times,
514      *  500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF,
515      *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF,
516      *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....
517      *
518      * @see #ToneGenerator(int, int)
519      */
520     public static final int TONE_CDMA_MED_S_X4 = 69;
521     /**
522      *  CDMA LOW  S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times,
523      *  500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF,
524      *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF,
525      *  {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....
526      *
527      *
528      * @see #ToneGenerator(int, int)
529      */
530     public static final int TONE_CDMA_LOW_S_X4 = 70;
531     /**
532      * CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times,
533      * 2000ms OFF,  REPEAT....
534      *
535      * @see #ToneGenerator(int, int)
536      */
537     public static final int TONE_CDMA_HIGH_PBX_L = 71;
538     /**
539      *  CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times,
540      * 2000ms OFF,  REPEAT....
541      *
542      * @see #ToneGenerator(int, int)
543      */
544     public static final int TONE_CDMA_MED_PBX_L = 72;
545     /**
546      * CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times,
547      * 2000ms OFF,  REPEAT....
548      *
549      * @see #ToneGenerator(int, int)
550      */
551     public static final int TONE_CDMA_LOW_PBX_L = 73;
552     /**
553      * CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times
554      * 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times,
555      * 2000ms OFF, REPEAT....
556      *
557      * @see #ToneGenerator(int, int)
558      */
559     public static final int TONE_CDMA_HIGH_PBX_SS = 74;
560     /**
561      * CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times
562      * 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times,
563      * 2000ms OFF, REPEAT....
564      *
565      * @see #ToneGenerator(int, int)
566      */
567     public static final int TONE_CDMA_MED_PBX_SS = 75;
568     /**
569      * CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times
570      * 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times,
571      * 2000ms OFF, REPEAT....
572      *
573      * @see #ToneGenerator(int, int)
574      */
575     public static final int TONE_CDMA_LOW_PBX_SS = 76;
576     /**
577      * CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times
578      * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF,
579      * {3700Hz 25ms, 4000Hz 25ms} 16 times, 1000ms OFF, REPEAT....
580      *
581      * @see #ToneGenerator(int, int)
582      */
583     public static final int TONE_CDMA_HIGH_PBX_SSL = 77;
584     /**
585      * CDMA MED PBX SSL tone:{2600Hz 25ms, 2900Hz 25ms} 8 times
586      * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF,
587      * {2600Hz 25ms, 2900Hz 25ms} 16 times, 1000ms OFF, REPEAT....
588      *
589      * @see #ToneGenerator(int, int)
590      */
591     public static final int TONE_CDMA_MED_PBX_SSL = 78;
592     /**
593      * CDMA LOW PBX SSL tone:{1300Hz 25ms, 1450Hz 25ms} 8 times
594      * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF,
595      * {1300Hz 25ms, 1450Hz 25ms} 16 times, 1000ms OFF, REPEAT....
596      *
597      *
598      * @see #ToneGenerator(int, int)
599      */
600     public static final int TONE_CDMA_LOW_PBX_SSL = 79;
601     /**
602      * CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times
603      * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 200ms OFF,
604      * {3700Hz 25ms, 4000Hz 25ms} 8 times, 1000ms OFF, REPEAT....
605      *
606      * @see #ToneGenerator(int, int)
607      */
608     public static final int TONE_CDMA_HIGH_PBX_SLS = 80;
609     /**
610      * CDMA HIGH PBX SLS tone:{2600Hz 25ms, 2900Hz 25ms} 8 times
611      * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 200ms OFF,
612      * {2600Hz 25ms, 2900Hz 25ms} 8 times, 1000ms OFF, REPEAT....
613      *
614      * @see #ToneGenerator(int, int)
615      */
616     public static final int TONE_CDMA_MED_PBX_SLS = 81;
617     /**
618      * CDMA HIGH PBX SLS tone:{1300Hz 25ms, 1450Hz 25ms} 8 times
619      * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 200ms OFF,
620      * {1300Hz 25ms, 1450Hz 25ms} 8 times, 1000ms OFF, REPEAT....
621      *
622      * @see #ToneGenerator(int, int)
623      */
624     public static final int TONE_CDMA_LOW_PBX_SLS = 82;
625     /**
626      * CDMA HIGH PBX X S4 tone: {3700Hz 25ms 4000Hz 25ms} 8 times,
627      * 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF,
628      * {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF,
629      * {3700Hz 25ms 4000Hz 25ms} 8 times, 800ms OFF, REPEAT...
630      *
631      * @see #ToneGenerator(int, int)
632      */
633     public static final int TONE_CDMA_HIGH_PBX_S_X4 = 83;
634     /**
635      * CDMA MED PBX X S4 tone: {2600Hz 25ms 2900Hz 25ms} 8 times,
636      * 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF,
637      * {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF,
638      * {2600Hz 25ms 2900Hz 25ms} 8 times, 800ms OFF, REPEAT...
639      *
640      * @see #ToneGenerator(int, int)
641      */
642     public static final int TONE_CDMA_MED_PBX_S_X4 = 84;
643     /**
644      * CDMA LOW PBX X S4 tone: {1300Hz 25ms 1450Hz 25ms} 8 times,
645      * 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF,
646      * {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF,
647      * {1300Hz 25ms 1450Hz 25ms} 8 times, 800ms OFF, REPEAT...
648      *
649      * @see #ToneGenerator(int, int)
650      */
651     public static final int TONE_CDMA_LOW_PBX_S_X4 = 85;
652     /**
653      * CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON
654      * 622Hz 62ms ON, 1109Hz 62ms ON
655      *
656      * @see #ToneGenerator(int, int)
657      */
658     public static final int    TONE_CDMA_ALERT_NETWORK_LITE = 86;
659     /**
660      * CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times,
661      * 1245 62ms ON
662      *
663      * @see #ToneGenerator(int, int)
664      */
665     public static final int    TONE_CDMA_ALERT_AUTOREDIAL_LITE = 87;
666     /**
667      * CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON
668      *
669      * @see #ToneGenerator(int, int)
670      */
671     public static final int    TONE_CDMA_ONE_MIN_BEEP = 88;
672     /**
673      *
674      * CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON
675      * @see #ToneGenerator(int, int)
676      */
677     public static final int    TONE_CDMA_KEYPAD_VOLUME_KEY_LITE = 89;
678     /**
679      * CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON
680      *
681      * @see #ToneGenerator(int, int)
682      */
683     public static final int    TONE_CDMA_PRESSHOLDKEY_LITE = 90;
684     /**
685      * CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms,
686      * 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms
687      *
688      * @see #ToneGenerator(int, int)
689      */
690     public static final int    TONE_CDMA_ALERT_INCALL_LITE = 91;
691     /**
692      * CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times
693      * 4990ms OFF, REPEAT...
694      *
695      * @see #ToneGenerator(int, int)
696      */
697     public static final int    TONE_CDMA_EMERGENCY_RINGBACK = 92;
698     /**
699      * CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times
700      *
701      * @see #ToneGenerator(int, int)
702      */
703     public static final int    TONE_CDMA_ALERT_CALL_GUARD = 93;
704     /**
705      * CDMA SOFT ERROR LITE  tone: 1047Hz 125ms ON, 370Hz 125ms
706      *
707      * @see #ToneGenerator(int, int)
708      */
709     public static final int    TONE_CDMA_SOFT_ERROR_LITE = 94;
710     /**
711      * CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms
712      *
713      * @see #ToneGenerator(int, int)
714      */
715     public static final int    TONE_CDMA_CALLDROP_LITE = 95;
716     /**
717      * CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF.
718      *
719      * @see #ToneGenerator(int, int)
720      */
721     public static final int    TONE_CDMA_NETWORK_BUSY_ONE_SHOT = 96;
722     /**
723      * CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON
724      * @see #ToneGenerator(int, int)
725      */
726     public static final int    TONE_CDMA_ABBR_ALERT = 97;
727     /**
728      * CDMA_SIGNAL_OFF - silent tone
729      *
730      * @see #ToneGenerator(int, int)
731      */
732     public static final int TONE_CDMA_SIGNAL_OFF = 98;
733 
734     /** Maximum volume, for use with {@link #ToneGenerator(int,int)} */
735     public static final int MAX_VOLUME = 100;
736     /** Minimum volume setting, for use with {@link #ToneGenerator(int,int)} */
737     public static final int MIN_VOLUME = 0;
738 
739 
740     /**
741      * ToneGenerator class contructor specifying output stream type and volume.
742      *
743      * @param streamType The streame type used for tone playback (e.g. STREAM_MUSIC).
744      * @param volume     The volume of the tone, given in percentage of maximum volume (from 0-100).
745      *
746      */
ToneGenerator(int streamType, int volume)747     public ToneGenerator(int streamType, int volume) {
748         native_setup(streamType, volume);
749     }
750 
751     /**
752      * This method starts the playback of a tone of the specified type.
753      * only one tone can play at a time: if a tone is playing while this method is called,
754      * this tone is stopped and replaced by the one requested.
755      * @param toneType   The type of tone generated chosen from the following list:
756      * <ul>
757      * <li>{@link #TONE_DTMF_0}
758      * <li>{@link #TONE_DTMF_1}
759      * <li>{@link #TONE_DTMF_2}
760      * <li>{@link #TONE_DTMF_3}
761      * <li>{@link #TONE_DTMF_4}
762      * <li>{@link #TONE_DTMF_5}
763      * <li>{@link #TONE_DTMF_6}
764      * <li>{@link #TONE_DTMF_7}
765      * <li>{@link #TONE_DTMF_8}
766      * <li>{@link #TONE_DTMF_9}
767      * <li>{@link #TONE_DTMF_A}
768      * <li>{@link #TONE_DTMF_B}
769      * <li>{@link #TONE_DTMF_C}
770      * <li>{@link #TONE_DTMF_D}
771      * <li>{@link #TONE_SUP_DIAL}
772      * <li>{@link #TONE_SUP_BUSY}
773      * <li>{@link #TONE_SUP_CONGESTION}
774      * <li>{@link #TONE_SUP_RADIO_ACK}
775      * <li>{@link #TONE_SUP_RADIO_NOTAVAIL}
776      * <li>{@link #TONE_SUP_ERROR}
777      * <li>{@link #TONE_SUP_CALL_WAITING}
778      * <li>{@link #TONE_SUP_RINGTONE}
779      * <li>{@link #TONE_PROP_BEEP}
780      * <li>{@link #TONE_PROP_ACK}
781      * <li>{@link #TONE_PROP_NACK}
782      * <li>{@link #TONE_PROP_PROMPT}
783      * <li>{@link #TONE_PROP_BEEP2}
784      * <li>{@link #TONE_SUP_INTERCEPT}
785      * <li>{@link #TONE_SUP_INTERCEPT_ABBREV}
786      * <li>{@link #TONE_SUP_CONGESTION_ABBREV}
787      * <li>{@link #TONE_SUP_CONFIRM}
788      * <li>{@link #TONE_SUP_PIP}
789      * <li>{@link #TONE_CDMA_DIAL_TONE_LITE}
790      * <li>{@link #TONE_CDMA_NETWORK_USA_RINGBACK}
791      * <li>{@link #TONE_CDMA_INTERCEPT}
792      * <li>{@link #TONE_CDMA_ABBR_INTERCEPT}
793      * <li>{@link #TONE_CDMA_REORDER}
794      * <li>{@link #TONE_CDMA_ABBR_REORDER}
795      * <li>{@link #TONE_CDMA_NETWORK_BUSY}
796      * <li>{@link #TONE_CDMA_CONFIRM}
797      * <li>{@link #TONE_CDMA_ANSWER}
798      * <li>{@link #TONE_CDMA_NETWORK_CALLWAITING}
799      * <li>{@link #TONE_CDMA_PIP}
800      * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL}
801      * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP}
802      * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI}
803      * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT3}
804      * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING}
805      * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT5}
806      * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT6}
807      * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT7}
808      * <li>{@link #TONE_CDMA_HIGH_L}
809      * <li>{@link #TONE_CDMA_MED_L}
810      * <li>{@link #TONE_CDMA_LOW_L}
811      * <li>{@link #TONE_CDMA_HIGH_SS}
812      * <li>{@link #TONE_CDMA_MED_SS}
813      * <li>{@link #TONE_CDMA_LOW_SS}
814      * <li>{@link #TONE_CDMA_HIGH_SSL}
815      * <li>{@link #TONE_CDMA_MED_SSL}
816      * <li>{@link #TONE_CDMA_LOW_SSL}
817      * <li>{@link #TONE_CDMA_HIGH_SS_2}
818      * <li>{@link #TONE_CDMA_MED_SS_2}
819      * <li>{@link #TONE_CDMA_LOW_SS_2}
820      * <li>{@link #TONE_CDMA_HIGH_SLS}
821      * <li>{@link #TONE_CDMA_MED_SLS}
822      * <li>{@link #TONE_CDMA_LOW_SLS}
823      * <li>{@link #TONE_CDMA_HIGH_S_X4}
824      * <li>{@link #TONE_CDMA_MED_S_X4}
825      * <li>{@link #TONE_CDMA_LOW_S_X4}
826      * <li>{@link #TONE_CDMA_HIGH_PBX_L}
827      * <li>{@link #TONE_CDMA_MED_PBX_L}
828      * <li>{@link #TONE_CDMA_LOW_PBX_L}
829      * <li>{@link #TONE_CDMA_HIGH_PBX_SS}
830      * <li>{@link #TONE_CDMA_MED_PBX_SS}
831      * <li>{@link #TONE_CDMA_LOW_PBX_SS}
832      * <li>{@link #TONE_CDMA_HIGH_PBX_SSL}
833      * <li>{@link #TONE_CDMA_MED_PBX_SSL}
834      * <li>{@link #TONE_CDMA_LOW_PBX_SSL}
835      * <li>{@link #TONE_CDMA_HIGH_PBX_SLS}
836      * <li>{@link #TONE_CDMA_MED_PBX_SLS}
837      * <li>{@link #TONE_CDMA_LOW_PBX_SLS}
838      * <li>{@link #TONE_CDMA_HIGH_PBX_S_X4}
839      * <li>{@link #TONE_CDMA_MED_PBX_S_X4}
840      * <li>{@link #TONE_CDMA_LOW_PBX_S_X4}
841      * <li>{@link #TONE_CDMA_ALERT_NETWORK_LITE}
842      * <li>{@link #TONE_CDMA_ALERT_AUTOREDIAL_LITE}
843      * <li>{@link #TONE_CDMA_ONE_MIN_BEEP}
844      * <li>{@link #TONE_CDMA_KEYPAD_VOLUME_KEY_LITE}
845      * <li>{@link #TONE_CDMA_PRESSHOLDKEY_LITE}
846      * <li>{@link #TONE_CDMA_ALERT_INCALL_LITE}
847      * <li>{@link #TONE_CDMA_EMERGENCY_RINGBACK}
848      * <li>{@link #TONE_CDMA_ALERT_CALL_GUARD}
849      * <li>{@link #TONE_CDMA_SOFT_ERROR_LITE}
850      * <li>{@link #TONE_CDMA_CALLDROP_LITE}
851      * <li>{@link #TONE_CDMA_NETWORK_BUSY_ONE_SHOT}
852      * <li>{@link #TONE_CDMA_ABBR_ALERT}
853      * <li>{@link #TONE_CDMA_SIGNAL_OFF}
854      * </ul>
855      * @see #ToneGenerator(int, int)
856     */
startTone(int toneType)857     public boolean startTone(int toneType) {
858         return startTone(toneType, -1);
859     }
860 
861     /**
862      * This method starts the playback of a tone of the specified type for the specified duration.
863      * @param toneType   The type of tone generated @see {@link #startTone(int)}.
864      * @param durationMs  The tone duration in milliseconds. If the tone is limited in time by definition,
865      * the actual duration will be the minimum of durationMs and the defined tone duration. Setting durationMs to -1,
866      * is equivalent to calling {@link #startTone(int)}.
867     */
startTone(int toneType, int durationMs)868     public native boolean startTone(int toneType, int durationMs);
869 
870     /**
871      * This method stops the tone currently playing playback.
872      * @see #ToneGenerator(int, int)
873      */
stopTone()874     public native void stopTone();
875 
876     /**
877      * Releases resources associated with this ToneGenerator object. It is good
878      * practice to call this method when you're done using the ToneGenerator.
879      */
release()880     public native void release();
881 
native_setup(int streamType, int volume)882     private native final void native_setup(int streamType, int volume);
883 
native_finalize()884     private native final void native_finalize();
885 
886     /**
887     * Returns the audio session ID.
888     *
889     * @return the ID of the audio session this ToneGenerator belongs to or 0 if an error
890     * occured.
891     */
getAudioSessionId()892     public native final int getAudioSessionId();
893 
894     @Override
finalize()895     protected void finalize() { native_finalize(); }
896 
897     @SuppressWarnings("unused")
898     @UnsupportedAppUsage
899     private long mNativeContext; // accessed by native methods
900 }
901