1# @ohos.multimedia.systemSoundManager (System Sound Management) (System API)
2
3The **systemSoundManager** module provides basic capabilities for managing system sounds, including setting and obtaining system ringtones and obtaining a player to play the system ringtones.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> - The APIs provided by this module are system APIs.
9
10## Modules to Import
11
12```ts
13import { systemSoundManager } from '@kit.AudioKit';
14```
15
16## Constants
17
18**System API**: This is a system API.
19
20**System capability**: SystemCapability.Multimedia.SystemSound.Core
21
22| Name                                     | Value  | Description     |
23|------------------------------------------|-----|---------|
24| TONE_CATEGORY_RINGTONE<sup>12+</sup>     | 1   | Ringtone.  |
25| TONE_CATEGORY_TEXT_MESSAGE<sup>12+</sup> | 2   | SMS alert tone.|
26| TONE_CATEGORY_NOTIFICATION<sup>12+</sup> | 4   | Notification alert tone.|
27| TONE_CATEGORY_ALARM<sup>12+</sup>        | 8   | Alarm alert tone.|
28
29## RingtoneType
30
31Enumerates the ringtone types.
32
33**System API**: This is a system API.
34
35**System capability**: SystemCapability.Multimedia.SystemSound.Core
36
37| Name                           | Value | Description                                                                    |
38| ------------------------------- |----|------------------------------------------------------------------------|
39| RINGTONE_TYPE_DEFAULT<sup>(deprecated)</sup>           | 0  | Default ringtone type.<br> This enumerated value is deprecated since API version 11. You are advised to use **RINGTONE_TYPE_SIM_CARD_0** instead.|
40| RINGTONE_TYPE_SIM_CARD_0<sup>11+</sup> | 0  | Ringtone of SIM card 1.                                                             |
41| RINGTONE_TYPE_MULTISIM<sup>(deprecated)</sup>          | 1  | Multi-SIM ringtone type.<br> This enumerated value is deprecated since API version 11. You are advised to use **RINGTONE_TYPE_SIM_CARD_1** instead.|
42| RINGTONE_TYPE_SIM_CARD_1<sup>11+</sup> | 1  | Ringtone of SIM card 2.                                                             |
43
44## SystemToneType<sup>11+</sup>
45
46Enumerates the system alert tone types.
47
48**System API**: This is a system API.
49
50**System capability**: SystemCapability.Multimedia.SystemSound.Core
51
52| Name                           | Value  | Description        |
53| ------------------------------- |-----|------------|
54| SYSTEM_TONE_TYPE_SIM_CARD_0     | 0   | SMS alert tone of SIM card 1.|
55| SYSTEM_TONE_TYPE_SIM_CARD_1     | 1   | SMS alert tone of SIM card 2.|
56| SYSTEM_TONE_TYPE_NOTIFICATION   | 32  | Notification alert tone.    |
57
58
59## ToneCustomizedType<sup>12+</sup>
60
61Enumerates the tone customization types.
62
63**System API**: This is a system API.
64
65**System capability**: SystemCapability.Multimedia.SystemSound.Core
66
67| Name                        | Value  | Description        |
68| ----------------------------|-----|------------|
69| PRE_INSTALLED<sup>12+</sup> | 0   | Preinstalled tone.|
70| CUSTOMIZED<sup>12+</sup>    | 1   | Customized tone.|
71
72## ToneAttrs<sup>12+</sup>
73
74Manages tone attributes. Before calling any API in **ToneAttrs<sup>12+</sup>**, you must use [createCustomizedToneAttrs](#systemsoundmanagercreatecustomizedtoneattrs12), [getDefaultRingtoneAttrs](#getdefaultringtoneattrs12), or [getRingtoneAttrList](#getringtoneattrlist12) to obtain a tone instance.
75
76### getTitle<sup>12+</sup>
77
78getTitle(): string
79
80Obtains the title of this tone.
81
82**System API**: This is a system API.
83
84**System capability**: SystemCapability.Multimedia.SystemSound.Core
85
86**Return value**
87
88| Type   | Description |
89|--------|-----|
90| string | Title.|
91
92**Error codes**
93
94| ID  | Error Message             |
95|---------| -------------------- |
96| 202     | Caller is not a system application. |
97
98**Example**
99
100```ts
101toneAttrs.getTitle();
102```
103
104### setTitle<sup>12+</sup>
105
106setTitle(title: string): void
107
108Sets the title for this tone.
109
110**System API**: This is a system API.
111
112**System capability**: SystemCapability.Multimedia.SystemSound.Core
113
114**Parameters**
115
116| Name | Type   | Mandatory| Description         |
117| -------| -------| ---- | ------------|
118| title  | string | Yes  | Title.  |
119
120**Error codes**
121
122| ID| Error Message             |
123|-------| -------------------- |
124| 202   | Caller is not a system application. |
125| 401   | The parameters check failed. |
126
127**Example**
128
129```ts
130let toneAttrs = systemSoundManager.createCustomizedToneAttrs();
131let title = 'text';
132toneAttrs.setTitle(title);
133```
134
135### getFileName<sup>12+</sup>
136
137getFileName(): string
138
139Obtains the file name of this tone.
140
141**System API**: This is a system API.
142
143**System capability**: SystemCapability.Multimedia.SystemSound.Core
144
145**Return value**
146
147| Type   | Description  |
148|--------|------|
149| string | File name.|
150
151**Error codes**
152
153| ID| Error Message             |
154|---------| -------------------- |
155| 202     | Caller is not a system application. |
156
157
158**Example**
159
160```ts
161toneAttrs.getFileName();
162```
163
164### setFileName<sup>12+</sup>
165
166setFileName(name: string): void
167
168Sets the file name for this tone.
169
170**System API**: This is a system API.
171
172**System capability**: SystemCapability.Multimedia.SystemSound.Core
173
174**Parameters**
175
176| Name| Type   | Mandatory| Description        |
177| ------| -------|-----| ------------|
178| name  | string | Yes  | File name.|
179
180**Error codes**
181
182| ID| Error Message             |
183|-------| -------------------- |
184| 202   | Caller is not a system application. |
185| 401   | The parameters check failed. |
186
187**Example**
188
189```ts
190let toneAttrs = systemSoundManager.createCustomizedToneAttrs();
191let fileName = 'textFileName';
192toneAttrs.setFileName(fileName);
193```
194
195### getUri<sup>12+</sup>
196
197getUri(): string
198
199Obtains the URI of this tone.
200
201**System API**: This is a system API.
202
203**System capability**: SystemCapability.Multimedia.SystemSound.Core
204
205**Return value**
206
207| Type   | Description                                                     |
208|--------|---------------------------------------------------------|
209| string | URI, for example, **'/data/storage/el2/base/RingTone/alarms/test.ogg'**.|
210
211**Error codes**
212
213| ID| Error Message             |
214|---------| -------------------- |
215| 202     | Caller is not a system application. |
216
217**Example**
218
219```ts
220toneAttrs.getUri();
221```
222
223### getCustomizedType<sup>12+</sup>
224
225getCustomizedType(): string
226
227Obtains the tone customization type.
228
229**System API**: This is a system API.
230
231**System capability**: SystemCapability.Multimedia.SystemSound.Core
232
233**Return value**
234
235| Type                                        | Description     |
236|--------------------------------------------|---------|
237| [ToneCustomizedType](#tonecustomizedtype12) | Tone customization type.|
238
239**Error codes**
240
241| ID  | Error Message             |
242|---------| -------------------- |
243| 202     | Caller is not a system application. |
244
245**Example**
246
247```ts
248toneAttrs.getCustomizedType();
249```
250
251### setCategory<sup>12+</sup>
252
253setCategory(category: number): void
254
255Sets a category for this tone.
256
257**System API**: This is a system API.
258
259**System capability**: SystemCapability.Multimedia.SystemSound.Core
260
261**Parameters**
262
263| Name     | Type     | Mandatory| Description      |
264|----------| ---------| ---- |----------|
265| category | number   | Yes  | Category of the tone. For details, see [Constants](#constants). |
266
267**Error codes**
268
269| ID| Error Message             |
270|-------| -------------------- |
271| 202   | Caller is not a system application. |
272| 401   | The parameters check failed. |
273
274**Example**
275
276```ts
277let toneAttrs = systemSoundManager.createCustomizedToneAttrs();
278let categoryValue = systemSoundManager.TONE_CATEGORY_ALARM; // Change the value to the required constant.
279toneAttrs.setCategory(categoryValue);
280```
281
282### getCategory<sup>12+</sup>
283
284getCategory(): string
285
286Obtains the category of this tone.
287
288**System API**: This is a system API.
289
290**System capability**: SystemCapability.Multimedia.SystemSound.Core
291
292**Return value**
293
294| Type   | Description    |
295|--------|--------|
296| number | Category of the tone. For details, see [Constants](#constants).|
297
298**Error codes**
299
300| ID  | Error Message             |
301|---------| -------------------- |
302| 202     | Caller is not a system application. |
303
304
305**Example**
306
307```ts
308toneAttrs.getCategory();
309```
310
311## ToneAttrsArray<sup>12+</sup>
312
313type ToneAttrsArray = Array&lt;[ToneAttrs](#toneattrs12)&gt;
314
315Defines an array of tone attributes.
316
317**System capability**: SystemCapability.Multimedia.SystemSound.Core
318
319| Type                                    | Description     |
320|----------------------------------------|---------|
321| Array&lt;[ToneAttrs](#toneattrs12)&gt; | Array of tone attributes.|
322
323## systemSoundManager.createCustomizedToneAttrs<sup>12+</sup>
324
325createCustomizedToneAttrs(): ToneAttrs
326
327Creates customized tone attributes.
328
329**System API**: This is a system API.
330
331**System capability**: SystemCapability.Multimedia.SystemSound.Core
332
333**Return value**
334
335| Type                       | Description        |
336|---------------------------| ------------ |
337| [ToneAttrs](#toneattrs12) | Class for tone attributes.|
338
339**Error codes**
340
341For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
342
343| ID  | Error Message             |
344|---------| -------------------- |
345| 202     | Caller is not a system application. |
346
347**Example**
348```ts
349let toneAttrs: systemSoundManager.ToneAttrs = systemSoundManager.createCustomizedToneAttrs();
350```
351## ToneHapticsFeature<sup>13+</sup>
352
353Enumerates the haptics styles for system ringtones.
354
355**System API**: This is a system API.
356
357**System capability**: SystemCapability.Multimedia.SystemSound.Core
358
359| Name                         | Value| Description                |
360| ----------------------------- | -- | -------------------- |
361| STANDARD| 0  | Standard haptics style.|
362| GENTLE   | 1  | Gentle haptics style.|
363
364## ToneHapticsType<sup>14+</sup>
365
366Enumerates the haptics types for system ringtones.
367
368**System API**: This is a system API.
369
370**System capability**: SystemCapability.Multimedia.SystemSound.Core
371
372| Name                    | Value| Description        |
373| ------------------------|----|--------|
374| CALL_SIM_CARD_0         | 0  | Haptic feedback with the ringtone for an incoming call on SIM card 1.|
375| CALL_SIM_CARD_1         | 1  | Haptic feedback with the ringtone for an incoming call on SIM card 2.|
376| TEXT_MESSAGE_SIM_CARD_0 | 20 | Haptic feedback with the ringtone for an incoming message on SIM card 1.|
377| TEXT_MESSAGE_SIM_CARD_1 | 21 | Haptic feedback with the ringtone for an incoming message on SIM card 2.|
378| NOTIFICATION            | 40 | Haptic feedback with the notification tone.|
379
380## ToneHapticsMode<sup>14+</sup>
381
382Enumerates the haptics modes in system ringtone scenarios.
383
384**System API**: This is a system API.
385
386**System capability**: SystemCapability.Multimedia.SystemSound.Core
387
388| Name                         | Value| Description                |
389| ----------------------------- | -- | -------------------- |
390| NONE        | 0  | No haptics.|
391| SYNC        | 1  | Sync mode, where the haptic feedback is aligned with the system ringtone.|
392| NON_SYNC    | 2  | Non-sync mode, where the haptic feedback is not aligned with the system ringtone.|
393
394## ToneHapticsSettings<sup>14+</sup>
395
396Describes the haptics settings of a system ringtone.
397
398**System API**: This is a system API.
399
400**System capability**: SystemCapability.Multimedia.SystemSound.Core
401
402| Name         | Type| Read-Only| Optional| Description                |
403| ------------ | -- | -- | -- | -------------------- |
404| mode | [ToneHapticsMode](#tonehapticsmode14) | No| No| Haptics mode.|
405| hapticsUri | string                          | No| Yes| URI of the haptics resource. The URI, obtained by calling [getToneHapticsList](#gettonehapticslist14), is valid only in the non-sync mode and should be ignored in other haptics modes.|
406
407## ToneHapticsAttrs<sup>14+</sup>
408
409Manages haptics attributes of system ringtones. Before calling any API in **ToneHapticsAttrs<sup>14+</sup>**, you must call [getToneHapticsList](#gettonehapticslist14) or [getHapticsAttrsSyncedWithTone](#gethapticsattrssyncedwithtone14) to obtain an instance.
410
411### getUri<sup>14+</sup>
412
413getUri(): string
414
415Obtains the URI of this haptics resource.
416
417**System API**: This is a system API.
418
419**System capability**: SystemCapability.Multimedia.SystemSound.Core
420
421**Return value**
422
423| Type   | Description |
424|--------|-----|
425| string | URI, for example, **'/data/storage/el2/base/haptics/synchronized/alarms/test.json'**.|
426
427**Error codes**
428
429| ID  | Error Message             |
430|---------| -------------------- |
431| 202     | Caller is not a system application. |
432
433**Example**
434
435```ts
436toneHapticsAttrs.getUri();
437```
438
439### getTitle<sup>14+</sup>
440
441getTitle(): string
442
443Obtains the title of this haptics resource.
444
445**System API**: This is a system API.
446
447**System capability**: SystemCapability.Multimedia.SystemSound.Core
448
449**Return value**
450
451| Type   | Description |
452|--------|-----|
453| string | Title.|
454
455**Error codes**
456
457| ID  | Error Message             |
458|---------| -------------------- |
459| 202     | Caller is not a system application. |
460
461**Example**
462
463```ts
464toneHapticsAttrs.getTitle();
465```
466
467### getFileName<sup>14+</sup>
468
469getFileName(): string
470
471Obtains the file name of this haptics resource.
472
473**System API**: This is a system API.
474
475**System capability**: SystemCapability.Multimedia.SystemSound.Core
476
477**Return value**
478
479| Type   | Description |
480|--------|-----|
481| string | File name.|
482
483**Error codes**
484
485| ID  | Error Message             |
486|---------| -------------------- |
487| 202     | Caller is not a system application. |
488
489**Example**
490
491```ts
492toneHapticsAttrs.getFileName();
493```
494
495## ToneHapticsAttrsArray<sup>14+</sup>
496
497type ToneHapticsAttrsArray = Array&lt;ToneHapticsAttrs&gt;
498
499Describes the haptics attribute array of a system ringtone.
500
501**System capability**: SystemCapability.Multimedia.SystemSound.Core
502
503| Type                                    | Description     |
504|----------------------------------------|---------|
505| Array&lt;[ToneHapticsAttrs](#tonehapticsattrs14)&gt; | Array of haptics attributes.|
506
507## systemSoundManager.getSystemSoundManager
508
509getSystemSoundManager(): SystemSoundManager
510
511Obtains a system sound manager.
512
513**System API**: This is a system API.
514
515**System capability**: SystemCapability.Multimedia.SystemSound.Core
516
517**Return value**
518
519| Type                         | Description        |
520| ----------------------------- | ------------ |
521| [SystemSoundManager](#systemsoundmanager) | System sound manager obtained.|
522
523**Example**
524```ts
525let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
526```
527
528## SystemSoundManager
529
530Provides APIs to manage system sounds. Before calling any API in **SystemSoundManager**, you must use [getSystemSoundManager](#systemsoundmanagergetsystemsoundmanager) to create a **SystemSoundManager** instance.
531
532### setSystemRingtoneUri<sup>(deprecated)</sup>
533
534setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback&lt;void&gt;): void
535
536Sets a URI for a system ringtone. This API uses an asynchronous callback to return the result.
537
538> **NOTE**
539>
540> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [setRingtoneUri](#setringtoneuri11) instead.
541
542**System API**: This is a system API.
543
544**System capability**: SystemCapability.Multimedia.SystemSound.Core
545
546**Parameters**
547
548| Name  | Type                                     | Mandatory| Description                    |
549| -------- | ---------------------------------------- | ---- | ------------------------ |
550| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)   | Yes  | Application context.          |
551| uri      | string                                   | Yes  | URI of the system ringtone. For details about supported resources, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
552| type     | [RingtoneType](#ringtonetype)            | Yes  | Type of the system ringtone.    |
553| callback | AsyncCallback&lt;void&gt;                | Yes  | Callback used to return the result.    |
554
555**Example**
556
557```ts
558import { BusinessError } from '@kit.BasicServicesKit';
559import { common } from '@kit.AbilityKit';
560
561let context: Context = getContext(this);
562let uri = 'file://data/test.wav'; // Set the URI of the target tone file.
563let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
564
565let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
566systemSoundManagerInstance.setSystemRingtoneUri(context, uri, type, (err: BusinessError) => {
567  if (err) {
568    console.error(`Failed to set system ringtone uri. ${err}`);
569    return;
570  }
571  console.info(`Callback invoked to indicate a successful setting of the system ringtone uri.`);
572});
573```
574
575### setSystemRingtoneUri<sup>(deprecated)</sup>
576
577setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise&lt;void&gt;
578
579Sets a URI for a system ringtone. This API uses a promise to return the result.
580
581> **NOTE**
582>
583> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [setRingtoneUri](#setringtoneuri11) instead.
584
585**System API**: This is a system API.
586
587**System capability**: SystemCapability.Multimedia.SystemSound.Core
588
589**Parameters**
590
591| Name  | Type                                     | Mandatory| Description                    |
592| -------- | ---------------------------------------- | ---- | ------------------------ |
593| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)  | Yes  | Application context.        |
594| uri      | string                                   | Yes  | URI of the system ringtone. For details about supported resources, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
595| type     | [RingtoneType](#ringtonetype)            | Yes  | Type of the system ringtone.  |
596
597**Return value**
598
599| Type               | Description                           |
600| ------------------- | ------------------------------- |
601| Promise&lt;void&gt; | Promise used to return the result.  |
602
603**Example**
604
605```ts
606import { BusinessError } from '@kit.BasicServicesKit';
607import { common } from '@kit.AbilityKit';
608
609let context: Context = getContext(this);
610let uri = 'file://data/test.wav'; // Set the URI of the target tone file.
611let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
612
613let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
614systemSoundManagerInstance.setSystemRingtoneUri(context, uri, type).then(() => {
615  console.info(`Promise returned to indicate a successful setting of the system ringtone uri.`);
616}).catch ((err: BusinessError) => {
617  console.error(`Failed to set the system ringtone uri ${err}`);
618});
619```
620
621### getSystemRingtoneUri<sup>(deprecated)</sup>
622
623getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback&lt;string&gt;): void
624
625Obtains the URI of a system ringtone. This API uses an asynchronous callback to return the result.
626
627> **NOTE**
628>
629> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getRingtoneUri](#getringtoneuri11) instead.
630
631**System API**: This is a system API.
632
633**System capability**: SystemCapability.Multimedia.SystemSound.Core
634
635**Parameters**
636
637| Name  | Type                                                                   | Mandatory| Description                    |
638| -------- |-----------------------------------------------------------------------| ---- | ------------------------ |
639| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)   | Yes  | Application context.        |
640| type     | [RingtoneType](#ringtonetype)                                         | Yes  | Type of the system ringtone.   |
641| callback | AsyncCallback&lt;string&gt;                                           | Yes  | Callback used to return the URI obtained.|
642
643**Example**
644
645```ts
646import { BusinessError } from '@kit.BasicServicesKit';
647import { common } from '@kit.AbilityKit';
648
649let context: Context = getContext(this);
650let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
651
652let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
653systemSoundManagerInstance.getSystemRingtoneUri(context, type, (err: BusinessError, value: string) => {
654  if (err) {
655    console.error(`Failed to get system ringtone uri. ${err}`);
656    return;
657  }
658  console.info(`Callback invoked to indicate the value of the system ringtone uri is obtained ${value}.`);
659});
660```
661
662### getSystemRingtoneUri<sup>(deprecated)</sup>
663
664getSystemRingtoneUri(context: Context, type: RingtoneType): Promise&lt;string&gt;
665
666Obtains the URI of a system ringtone. This API uses a promise to return the result.
667
668> **NOTE**
669>
670> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getRingtoneUri](#getringtoneuri11) instead.
671
672**System API**: This is a system API.
673
674**System capability**: SystemCapability.Multimedia.SystemSound.Core
675
676**Parameters**
677
678| Name  | Type                                                                  | Mandatory| Description                    |
679| -------- |----------------------------------------------------------------------| ---- | ------------------------ |
680| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)  | Yes  | Application context.        |
681| type     | [RingtoneType](#ringtonetype)                                        | Yes  | Type of the system ringtone.  |
682
683**Return value**
684
685| Type               | Description                               |
686| ------------------- | ---------------------------------- |
687| Promise&lt;string&gt; | Promise used to return the URI obtained.|
688
689**Example**
690
691```ts
692import { BusinessError } from '@kit.BasicServicesKit';
693import { common } from '@kit.AbilityKit';
694
695let context: Context = getContext(this);
696let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
697
698let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
699systemSoundManagerInstance.getSystemRingtoneUri(context, type).then((value: string) => {
700  console.info(`Promise returned to indicate that the value of the system ringtone uri is obtained ${value}.`);
701}).catch ((err: BusinessError) => {
702  console.error(`Failed to get the system ringtone uri ${err}`);
703});
704```
705
706### getSystemRingtonePlayer<sup>(deprecated)</sup>
707
708getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback&lt;RingtonePlayer&gt;): void
709
710Obtains a player to play a system ringtone. This API uses an asynchronous callback to return the result.
711
712> **NOTE**
713>
714> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getRingtonePlayer](#getringtoneplayer11) instead.
715
716**System API**: This is a system API.
717
718**System capability**: SystemCapability.Multimedia.SystemSound.Core
719
720**Parameters**
721
722| Name  | Type                                     | Mandatory| Description                        |
723| -------- | -----------------------------------------| ---- | --------------------------- |
724| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)  | Yes  | Application context.           |
725| type     | [RingtoneType](#ringtonetype)            | Yes  | Type of the system ringtone.|
726| callback | AsyncCallback&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer-sys.md#ringtoneplayer)&gt; | Yes| Callback used to return the player obtained.|
727
728**Example**
729
730```ts
731import { BusinessError } from '@kit.BasicServicesKit';
732import { common } from '@kit.AbilityKit';
733
734let context: Context = getContext(this);
735let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
736let systemRingtonePlayer: systemSoundManager.RingtonePlayer | undefined = undefined;
737
738let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
739systemSoundManagerInstance.getSystemRingtonePlayer(context, type, (err: BusinessError, value: systemSoundManager.RingtonePlayer) => {
740  if (err) {
741    console.error(`Failed to get system ringtone player. ${err}`);
742    return;
743  }
744  console.info(`Callback invoked to indicate the value of the system ringtone player is obtained.`);
745  systemRingtonePlayer = value;
746});
747```
748
749### getSystemRingtonePlayer<sup>(deprecated)</sup>
750
751getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise&lt;RingtonePlayer&gt;
752
753Obtains a player to play a system ringtone. This API uses a promise to return the result.
754
755> **NOTE**
756>
757> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getRingtonePlayer](#getringtoneplayer11) instead.
758
759**System API**: This is a system API.
760
761**System capability**: SystemCapability.Multimedia.SystemSound.Core
762
763**Parameters**
764
765| Name  | Type                                                                 | Mandatory| Description                        |
766| -------- |---------------------------------------------------------------------| ---- | --------------------------- |
767| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.           |
768| type     | [RingtoneType](#ringtonetype)                                       | Yes  | Type of the system ringtone.|
769
770**Return value**
771
772| Type               | Description                           |
773| ------------------- | ------------------------------- |
774| Promise&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer-sys.md#ringtoneplayer)&gt; | Promise used to return the player obtained.|
775
776**Example**
777
778```ts
779import { BusinessError } from '@kit.BasicServicesKit';
780import { common } from '@kit.AbilityKit';
781
782let context: Context = getContext(this);
783let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
784let systemRingtonePlayer: systemSoundManager.RingtonePlayer | undefined = undefined;
785
786let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
787systemSoundManagerInstance.getSystemRingtonePlayer(context, type).then((value: systemSoundManager.RingtonePlayer) => {
788  console.info(`Promise returned to indicate that the value of the system ringtone player is obtained.`);
789  systemRingtonePlayer = value;
790}).catch ((err: BusinessError) => {
791  console.error(`Failed to get the system ringtone player ${err}`);
792});
793```
794
795### setRingtoneUri<sup>11+</sup>
796
797setRingtoneUri(context: BaseContext, uri: string, type: RingtoneType): Promise&lt;void&gt;
798
799Sets a URI for a system ringtone. This API uses a promise to return the result.
800
801**System API**: This is a system API.
802
803**System capability**: SystemCapability.Multimedia.SystemSound.Core
804
805**Parameters**
806
807| Name  | Type                           | Mandatory| Description                    |
808| -------- |-------------------------------| ---- | ------------------------ |
809| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md)            | Yes  | Application context.        |
810| uri      | string                        | Yes  | URI of the system ringtone. For details about supported resources, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
811| type     | [RingtoneType](#ringtonetype) | Yes  | Type of the system ringtone.  |
812
813**Return value**
814
815| Type               | Description                           |
816| ------------------- | ------------------------------- |
817| Promise&lt;void&gt; | Promise used to return the result.  |
818
819**Error codes**
820
821For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
822
823| ID| Error Message             |
824| ------- | --------------------- |
825| 202 | Caller is not a system application. |
826| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
827| 5400103 | I/O error. |
828
829**Example**
830
831```ts
832import { BusinessError } from '@kit.BasicServicesKit';
833import { common } from '@kit.AbilityKit';
834
835let context: common.BaseContext = getContext(this);
836let uri = 'file://data/test.wav'; // Set the URI of the target tone file.
837let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
838
839let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
840systemSoundManagerInstance.setRingtoneUri(context, uri, type).then(() => {
841  console.info(`Promise returned to indicate a successful setting of the system ringtone uri.`);
842}).catch ((err: BusinessError) => {
843  console.error(`Failed to set the system ringtone uri ${err}`);
844});
845```
846
847### getRingtoneUri<sup>11+</sup>
848
849getRingtoneUri(context: BaseContext, type: RingtoneType): Promise&lt;string&gt;
850
851Obtains the URI of a system ringtone. This API uses a promise to return the result.
852
853**System API**: This is a system API.
854
855**System capability**: SystemCapability.Multimedia.SystemSound.Core
856
857**Parameters**
858
859| Name  | Type                            | Mandatory| Description                    |
860| -------- | -------------------------------| ---- | ------------------------ |
861| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md)| Yes  | Application context.        |
862| type     | [RingtoneType](#ringtonetype)  | Yes  | Type of the system ringtone.  |
863
864**Return value**
865
866| Type               | Description                               |
867| ------------------- | ---------------------------------- |
868| Promise&lt;string&gt; | Promise used to return the URI obtained.|
869
870**Error codes**
871
872For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
873
874| ID| Error Message             |
875| -------- | --------------------- |
876| 202 | Caller is not a system application. |
877| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
878| 5400103  | I/O error. |
879
880**Example**
881
882```ts
883import { BusinessError } from '@kit.BasicServicesKit';
884import { common } from '@kit.AbilityKit';
885
886let context: common.BaseContext = getContext(this);
887let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
888
889let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
890systemSoundManagerInstance.getRingtoneUri(context, type).then((value: string) => {
891  console.info(`Promise returned to indicate that the value of the system ringtone uri is obtained ${value}.`);
892}).catch ((err: BusinessError) => {
893  console.error(`Failed to get the system ringtone uri ${err}`);
894});
895```
896
897### getRingtonePlayer<sup>11+</sup>
898
899getRingtonePlayer(context: BaseContext, type: RingtoneType): Promise&lt;RingtonePlayer&gt;
900
901Obtains a player to play a system ringtone. This API uses a promise to return the result.
902
903**System API**: This is a system API.
904
905**System capability**: SystemCapability.Multimedia.SystemSound.Core
906
907**Parameters**
908
909| Name  | Type                             | Mandatory| Description                        |
910| -------- | --------------------------------| ---- | --------------------------- |
911| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
912| type     | [RingtoneType](#ringtonetype)   | Yes  | Type of the system ringtone.|
913
914**Return value**
915
916| Type               | Description                           |
917| ------------------- | ------------------------------- |
918| Promise&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer-sys.md#ringtoneplayer)&gt; | Promise used to return the player obtained.|
919
920**Error codes**
921
922For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
923
924| ID| Error Message             |
925| -------- | --------------------- |
926| 202 | Caller is not a system application. |
927| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
928
929**Example**
930
931```ts
932import { BusinessError } from '@kit.BasicServicesKit';
933import { common } from '@kit.AbilityKit';
934
935let context: common.BaseContext = getContext(this);
936let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
937let systemRingtonePlayer: systemSoundManager.RingtonePlayer | undefined = undefined;
938
939let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
940systemSoundManagerInstance.getRingtonePlayer(context, type).then((value: systemSoundManager.RingtonePlayer) => {
941  console.info(`Promise returned to indicate that the value of the system ringtone player is obtained.`);
942  systemRingtonePlayer = value;
943}).catch ((err: BusinessError) => {
944  console.error(`Failed to get the system ringtone player ${err}`);
945});
946```
947
948### setSystemToneUri<sup>11+</sup>
949
950setSystemToneUri(context: BaseContext, uri: string, type: SystemToneType): Promise&lt;void&gt;
951
952Sets a URI for a system alert tone. This API uses a promise to return the result.
953
954**System API**: This is a system API.
955
956**System capability**: SystemCapability.Multimedia.SystemSound.Core
957
958**Parameters**
959
960| Name  | Type                                 | Mandatory| Description                    |
961| -------- |-------------------------------------| ---- | ------------------------ |
962| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.        |
963| uri      | string                              | Yes  | URI of the system alert tone. For details about supported resources, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
964| type     | [SystemToneType](#systemtonetype11) | Yes  | Type of the system alert tone.  |
965
966**Return value**
967
968| Type               | Description                           |
969| ------------------- | ------------------------------- |
970| Promise&lt;void&gt; | Promise used to return the result.  |
971
972**Error codes**
973
974For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
975
976| ID| Error Message             |
977| ------- | --------------------- |
978| 202 | Caller is not a system application. |
979| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
980| 5400103 | I/O error. |
981
982**Example**
983
984```ts
985import { BusinessError } from '@kit.BasicServicesKit';
986import { common } from '@kit.AbilityKit';
987
988let context: common.BaseContext = getContext(this);
989let uri = 'file://data/test.wav'; // Set the URI of the target tone file.
990let type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
991
992let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
993systemSoundManagerInstance.setSystemToneUri(context, uri, type).then(() => {
994  console.info(`Promise returned to indicate a successful setting of the system tone uri.`);
995}).catch ((err: BusinessError) => {
996  console.error(`Failed to set the system tone uri ${err}`);
997});
998```
999
1000### getSystemToneUri<sup>11+</sup>
1001
1002getSystemToneUri(context: BaseContext, type: SystemToneType): Promise&lt;string&gt;
1003
1004Obtains the URI of a system alert tone. This API uses a promise to return the result.
1005
1006**System API**: This is a system API.
1007
1008**System capability**: SystemCapability.Multimedia.SystemSound.Core
1009
1010**Parameters**
1011
1012| Name  | Type                                 | Mandatory| Description                    |
1013| -------- |-------------------------------------| ---- | ------------------------ |
1014| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.        |
1015| type     | [SystemToneType](#systemtonetype11) | Yes  | Type of the system alert tone.  |
1016
1017**Return value**
1018
1019| Type               | Description                               |
1020| ------------------- | ---------------------------------- |
1021| Promise&lt;string&gt; | Promise used to return the URI obtained.|
1022
1023**Error codes**
1024
1025For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1026
1027| ID| Error Message             |
1028| ------- | --------------------- |
1029| 202 | Caller is not a system application. |
1030| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1031| 5400103 | I/O error. |
1032
1033**Example**
1034
1035```ts
1036import { BusinessError } from '@kit.BasicServicesKit';
1037import { common } from '@kit.AbilityKit';
1038
1039let context: common.BaseContext = getContext(this);
1040let type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1041
1042let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1043systemSoundManagerInstance.getSystemToneUri(context, type).then((value: string) => {
1044  console.info(`Promise returned to indicate that the value of the system tone uri is obtained ${value}.`);
1045}).catch ((err: BusinessError) => {
1046  console.error(`Failed to get the system tone uri ${err}`);
1047});
1048```
1049
1050### getSystemTonePlayer<sup>11+</sup>
1051
1052getSystemTonePlayer(context: BaseContext, type: SystemToneType): Promise&lt;SystemTonePlayer&gt;
1053
1054Obtains a player to play a system alert tone. This API uses a promise to return the result.
1055
1056**System API**: This is a system API.
1057
1058**System capability**: SystemCapability.Multimedia.SystemSound.Core
1059
1060**Parameters**
1061
1062| Name  | Type                                 | Mandatory| Description                        |
1063| -------- |-------------------------------------| ---- | --------------------------- |
1064| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
1065| type     | [SystemToneType](#systemtonetype11) | Yes  | Type of the system alert tone.|
1066
1067**Return value**
1068
1069| Type                                                                                              | Description                           |
1070|--------------------------------------------------------------------------------------------------| ------------------------------- |
1071| Promise&lt;[SystemTonePlayer](js-apis-inner-multimedia-systemTonePlayer-sys.md#systemtoneplayer)&gt; | Promise used to return the player obtained.|
1072
1073**Error codes**
1074
1075For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1076
1077| ID| Error Message             |
1078| ------- | --------------------- |
1079| 202 | Caller is not a system application. |
1080| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1081
1082**Example**
1083
1084```ts
1085import { BusinessError } from '@kit.BasicServicesKit';
1086import { common } from '@kit.AbilityKit';
1087
1088let context: common.BaseContext = getContext(this);
1089let type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1090let systemTonePlayer: systemSoundManager.SystemTonePlayer | undefined = undefined;
1091
1092let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1093systemSoundManagerInstance.getSystemTonePlayer(context, type).then((value: systemSoundManager.SystemTonePlayer) => {
1094  console.info(`Promise returned to indicate that the value of the system tone player is obtained.`);
1095    systemTonePlayer = value;
1096}).catch ((err: BusinessError) => {
1097  console.error(`Failed to get the system tone player ${err}`);
1098});
1099```
1100
1101### getDefaultRingtoneAttrs<sup>12+</sup>
1102
1103getDefaultRingtoneAttrs(context: BaseContext, type: RingtoneType): Promise&lt;ToneAttrs&gt;
1104
1105Obtains the attributes of the default system ringtone. This API uses a promise to return the result.
1106
1107**System API**: This is a system API.
1108
1109**System capability**: SystemCapability.Multimedia.SystemSound.Core
1110
1111**Parameters**
1112
1113| Name  | Type                                 | Mandatory| Description                        |
1114| -------- |-------------------------------------| ---- | --------------------------- |
1115| context  |[BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
1116| type     |[RingtoneType](#ringtonetype)        | Yes  | Type of the system ringtone. |
1117
1118**Return value**
1119
1120| Type                                      | Description                 |
1121|------------------------------------------|---------------------|
1122| Promise&lt;[ToneAttrs](#toneattrs12)&gt; | Promise used to return the attributes of the default system ringtone.|
1123
1124**Error codes**
1125
1126For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1127
1128| ID| Error Message             |
1129| ------- | --------------------- |
1130| 202 | Caller is not a system application. |
1131| 401 | The parameters check failed. |
1132| 5400103 | I/O error. |
1133
1134**Example**
1135
1136```ts
1137import { BusinessError } from '@kit.BasicServicesKit';
1138import { common } from '@kit.AbilityKit';
1139
1140let context: common.BaseContext = getContext(this);
1141let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
1142
1143let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1144systemSoundManagerInstance.getDefaultRingtoneAttrs(context, type).then((value: systemSoundManager.ToneAttrs) => {
1145  console.info(`Promise returned to indicate that the value of the attributes of the default ringtone is obtained.`);
1146}).catch ((err: BusinessError) => {
1147  console.error(`Failed to get the default ring tone attrs ${err}`);
1148});
1149```
1150
1151### getRingtoneAttrList<sup>12+</sup>
1152
1153getRingtoneAttrList(context: BaseContext, type: RingtoneType): Promise&lt;ToneAttrsArray&gt;
1154
1155Obtains the list of attributes of the default system ringtone. This API uses a promise to return the result.
1156
1157**System API**: This is a system API.
1158
1159**System capability**: SystemCapability.Multimedia.SystemSound.Core
1160
1161**Parameters**
1162
1163| Name  | Type                                 | Mandatory| Description                        |
1164| -------- |-------------------------------------| ---- | --------------------------- |
1165| context  |[BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
1166| type     |[RingtoneType](#ringtonetype)        | Yes  | Type of the system ringtone. |
1167
1168**Return value**
1169
1170| Type                                                | Description                   |
1171|----------------------------------------------------|-----------------------|
1172| Promise&lt;[ToneAttrsArray](#toneattrsarray12)&gt; | Promise used to return an array of the attributes of the default system ringtone.|
1173
1174**Error codes**
1175
1176For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1177
1178| ID| Error Message             |
1179| ------- | --------------------- |
1180| 202 | Caller is not a system application. |
1181| 401 | The parameters check failed. |
1182| 5400103 | I/O error. |
1183
1184**Example**
1185
1186```ts
1187import { BusinessError } from '@kit.BasicServicesKit';
1188import { common } from '@kit.AbilityKit';
1189
1190let context: common.BaseContext = getContext(this);
1191let type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
1192
1193let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1194systemSoundManagerInstance.getRingtoneAttrList(context, type).then((value: systemSoundManager.ToneAttrsArray) => {
1195  console.info(`Promise returned to indicate that the value of the attribute list of ringtone is obtained.`);
1196}).catch ((err: BusinessError) => {
1197  console.error(`Failed to get the attribute list of ringtone ${err}`);
1198});
1199```
1200
1201### getDefaultSystemToneAttrs<sup>12+</sup>
1202
1203getDefaultSystemToneAttrs(context: BaseContext, type: SystemToneType): Promise&lt;ToneAttrs&gt;
1204
1205Obtains the attributes of the default system alert tone. This API uses a promise to return the result.
1206
1207**System API**: This is a system API.
1208
1209**System capability**: SystemCapability.Multimedia.SystemSound.Core
1210
1211**Parameters**
1212
1213| Name  | Type                                                                         | Mandatory| Description                        |
1214| -------- |-----------------------------------------------------------------------------| ---- | --------------------------- |
1215| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
1216| type     | [SystemToneType](#systemtonetype11)                                         | Yes  | Type of the system alert tone.|
1217
1218**Return value**
1219
1220| Type                                     | Description                  |
1221|-----------------------------------------|----------------------|
1222| Promise&lt;[ToneAttrs](#toneattrs12)&gt; | Promise used to return the attributes of the default system alert tone.|
1223
1224**Error codes**
1225
1226For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1227
1228| ID| Error Message             |
1229| ------- | --------------------- |
1230| 202 | Caller is not a system application. |
1231| 401 | The parameters check failed. |
1232| 5400103 | I/O error. |
1233
1234**Example**
1235
1236```ts
1237import { BusinessError } from '@kit.BasicServicesKit';
1238import { common } from '@kit.AbilityKit';
1239
1240let context: common.BaseContext = getContext(this);
1241let type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1242
1243let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1244systemSoundManagerInstance.getDefaultSystemToneAttrs(context, type).then((value: systemSoundManager.ToneAttrs) => {
1245  console.info(`Promise returned to indicate that the value of the attributes of the system ringtone is obtained.`);
1246}).catch ((err: BusinessError) => {
1247  console.error(`Failed to get the system tone attrs ${err}`);
1248});
1249```
1250
1251### getSystemToneAttrList<sup>12+</sup>
1252
1253getSystemToneAttrList(context: BaseContext, type: SystemToneType): Promise&lt;ToneAttrsArray&gt;
1254
1255Obtains the list of attributes of the default system alert tone. This API uses a promise to return the result.
1256
1257**System API**: This is a system API.
1258
1259**System capability**: SystemCapability.Multimedia.SystemSound.Core
1260
1261**Parameters**
1262
1263| Name  | Type                                                                         | Mandatory| Description                        |
1264| -------- |-----------------------------------------------------------------------------| ---- | --------------------------- |
1265| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
1266| type     | [SystemToneType](#systemtonetype11)                                         | Yes  | Type of the system alert tone. |
1267
1268**Return value**
1269
1270| Type                                               | Description                    |
1271|---------------------------------------------------|------------------------|
1272| Promise&lt;[ToneAttrsArray](#toneattrsarray12)&gt; | Promise used to return an array of the attributes of the default system alert tone.|
1273
1274**Error codes**
1275
1276For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1277
1278| ID| Error Message             |
1279| ------- | --------------------- |
1280| 202 | Caller is not a system application. |
1281| 401 | The parameters check failed. |
1282| 5400103 | I/O error. |
1283
1284**Example**
1285
1286```ts
1287import { BusinessError } from '@kit.BasicServicesKit';
1288import { common } from '@kit.AbilityKit';
1289
1290let context: common.BaseContext = getContext(this);
1291let type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1292
1293let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1294systemSoundManagerInstance.getSystemToneAttrList(context, type).then((value: systemSoundManager.ToneAttrsArray) => {
1295  console.info(`Promise returned to indicate that the value of the attribute list of system tone is obtained.`);
1296}).catch ((err: BusinessError) => {
1297  console.error(`Failed to get the attribute list of system tone ${err}`);
1298});
1299```
1300
1301### getDefaultAlarmToneAttrs<sup>12+</sup>
1302
1303getDefaultAlarmToneAttrs(context: BaseContext): Promise&lt;ToneAttrs&gt;
1304
1305Obtains the attributes of the default alarm alert tone. This API uses a promise to return the result.
1306
1307**System API**: This is a system API.
1308
1309**System capability**: SystemCapability.Multimedia.SystemSound.Core
1310
1311**Parameters**
1312
1313| Name  | Type        | Mandatory| Description       |
1314| --------|------------| ---- |-----------|
1315| context | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.|
1316
1317**Return value**
1318
1319| Type                                     | Description                 |
1320|-----------------------------------------|---------------------|
1321| Promise&lt;[ToneAttrs](#toneattrs12)&gt; | Promise used to return the attributes of the default alarm alert tone.|
1322
1323**Error codes**
1324
1325For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1326
1327| ID| Error Message             |
1328| ------- | --------------------- |
1329| 202 | Caller is not a system application. |
1330| 401 | The parameters check failed. |
1331| 5400103 | I/O error. |
1332
1333**Example**
1334
1335```ts
1336import { BusinessError } from '@kit.BasicServicesKit';
1337import { common } from '@kit.AbilityKit';
1338
1339let context: common.BaseContext = getContext(this);
1340
1341let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1342systemSoundManagerInstance.getDefaultAlarmToneAttrs(context).then((value: systemSoundManager.ToneAttrs) => {
1343  console.info(`Promise returned to indicate that the value of the attributes of the default alarm tone is obtained.`);
1344}).catch ((err: BusinessError) => {
1345  console.error(`Failed to get the default alarm tone attrs ${err}`);
1346});
1347```
1348
1349### setAlarmToneUri<sup>12+</sup>
1350
1351setAlarmToneUri(context: Context, uri: string): Promise&lt;void&gt;
1352
1353Sets a URI for an alarm alert tone. This API uses a promise to return the result.
1354
1355**System API**: This is a system API.
1356
1357**System capability**: SystemCapability.Multimedia.SystemSound.Core
1358
1359**Parameters**
1360
1361| Name  | Type       | Mandatory| Description  |
1362| -------- | --------- | ---- |--------------------------|
1363| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.                                                                          |
1364| uri      | string    | Yes  | URI of the alarm alert tone. For details about supported resources, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
1365
1366**Return value**
1367
1368| Type               | Description                  |
1369| ------------------- |----------------------|
1370| Promise&lt;void&gt; | Promise used to return the result. |
1371
1372**Example**
1373
1374```ts
1375import { BusinessError } from '@kit.BasicServicesKit';
1376import { common } from '@kit.AbilityKit';
1377
1378let context: Context = getContext(this);
1379let uri = 'file://data/test.wav'; // Set the URI of the target tone file.
1380
1381let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1382systemSoundManagerInstance.setAlarmToneUri(context, uri).then(() => {
1383  console.info(`Promise returned to indicate a successful setting of the alarm tone uri.`);
1384}).catch ((err: BusinessError) => {
1385  console.error(`Failed to set the alarm tone uri ${err}`);
1386});
1387```
1388
1389### getAlarmToneUri<sup>12+</sup>
1390
1391getAlarmToneUri(context: Context): Promise&lt;string&gt;
1392
1393Obtains the URI of an alarm alert tone. This API uses a promise to return the result.
1394
1395**System API**: This is a system API.
1396
1397**System capability**: SystemCapability.Multimedia.SystemSound.Core
1398
1399**Parameters**
1400
1401| Name  | Type     | Mandatory| Description             |
1402| -------- | --------| ---- |-----------------|
1403| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context. |
1404
1405**Return value**
1406
1407| Type                   | Description                   |
1408|-----------------------|-----------------------|
1409| Promise&lt;string&gt; | Promise used to return the URI of the alarm alert tone.|
1410
1411**Example**
1412
1413```ts
1414import { BusinessError } from '@kit.BasicServicesKit';
1415import { common } from '@kit.AbilityKit';
1416
1417let context: Context = getContext(this);
1418
1419let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1420systemSoundManagerInstance.getAlarmToneUri(context).then((value: string) => {
1421  console.info(`Promise returned to indicate that the value of alarm tone uri.`);
1422}).catch ((err: BusinessError) => {
1423  console.error(`Failed to get the alarm tone uri ${err}`);
1424});
1425```
1426
1427### getAlarmToneAttrList<sup>12+</sup>
1428
1429getAlarmToneAttrList(context: BaseContext): Promise&lt;ToneAttrsArray&gt;
1430
1431Obtains the list of attributes of alarm alert tones. This API uses a promise to return the result.
1432
1433**System API**: This is a system API.
1434
1435**System capability**: SystemCapability.Multimedia.SystemSound.Core
1436
1437**Parameters**
1438
1439| Name  | Type           | Mandatory| Description                        |
1440| -------- |--------------| ---- | --------------------------- |
1441| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md)  | Yes  | Application context.           |
1442
1443**Return value**
1444
1445| Type                                                | Description                  |
1446|----------------------------------------------------|----------------------|
1447| Promise&lt;[ToneAttrsArray](#toneattrsarray12)&gt; | Promise used to return an array of the attributes of the alarm alert tones.|
1448
1449**Error codes**
1450
1451For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1452
1453| ID| Error Message             |
1454| ------- | --------------------- |
1455| 202 | Caller is not a system application. |
1456| 401 | The parameters check failed. |
1457| 5400103 | I/O error. |
1458
1459**Example**
1460
1461```ts
1462import { BusinessError } from '@kit.BasicServicesKit';
1463import { common } from '@kit.AbilityKit';
1464
1465let context: common.BaseContext = getContext(this);
1466
1467let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1468systemSoundManagerInstance.getAlarmToneAttrList(context).then((value: systemSoundManager.ToneAttrsArray) => {
1469  console.info(`Promise returned to indicate that the value of the attribute list of alarm tone is obtained.`);
1470}).catch ((err: BusinessError) => {
1471  console.error(`Failed to get the attribute list of alarm tone ${err}`);
1472});
1473```
1474
1475### openAlarmTone<sup>12+</sup>
1476
1477openAlarmTone(context: Context, uri: string): Promise&lt;number&gt;
1478
1479Enables an alarm alert tone. This API uses a promise to return the result.
1480
1481**System API**: This is a system API.
1482
1483**System capability**: SystemCapability.Multimedia.SystemSound.Core
1484
1485**Parameters**
1486
1487| Name  | Type      | Mandatory| Description                                                                                 |
1488| -------- | ---------| ---- |-------------------------------------------------------------------------------------|
1489| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.                                                                          |
1490| uri      | string   | Yes  | URI of the alarm alert tone. For details about supported resources, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
1491
1492**Return value**
1493
1494| Type                   | Description            |
1495|-----------------------|----------------|
1496| Promise&lt;number&gt; | Promise used to return the FD.|
1497
1498**Error codes**
1499
1500For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1501
1502| ID| Error Message             |
1503| ------- | --------------------- |
1504| 202 | Caller is not a system application. |
1505| 401 | The parameters check failed. |
1506| 5400103 | I/O error. |
1507| 20700001 | Tone type mismatch, e.g. tone of uri is notification instead of alarm. |
1508
1509**Example**
1510
1511```ts
1512import { BusinessError } from '@kit.BasicServicesKit';
1513import { common } from '@kit.AbilityKit';
1514
1515let context: Context = getContext(this);
1516let uri = 'file://data/test.wav'; // Set the URI of the target tone file.
1517
1518let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1519systemSoundManagerInstance.openAlarmTone(context, uri).then((value: number) => {
1520  console.info(`Promise returned to indicate the value of fd.`);
1521}).catch ((err: BusinessError) => {
1522  console.error(`Failed to open alarm tone ${err}`);
1523});
1524```
1525
1526### close<sup>12+</sup>
1527
1528close(fd: number): Promise&lt;void&gt;
1529
1530Disables an alarm alert tone. This API uses a promise to return the result.
1531
1532**System API**: This is a system API.
1533
1534**System capability**: SystemCapability.Multimedia.SystemSound.Core
1535
1536**Parameters**
1537
1538| Name| Type  | Mandatory| Description                                          |
1539|-----| --------| ---- |----------------------------------------------|
1540| fd  | number  | Yes  | File descriptor, which is obtained through [openAlarmTone](#openalarmtone12).|
1541
1542**Return value**
1543
1544| Type                 | Description            |
1545|---------------------|----------------|
1546| Promise&lt;void&gt; | Promise used to return the result.|
1547
1548**Error codes**
1549
1550For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1551
1552| ID| Error Message             |
1553| ------- | --------------------- |
1554| 202 | Caller is not a system application. |
1555| 401 | The parameters check failed. |
1556| 5400103 | I/O error. |
1557
1558**Example**
1559
1560```ts
1561import { BusinessError } from '@kit.BasicServicesKit';
1562import { common } from '@kit.AbilityKit';
1563
1564let context: Context = getContext(this);
1565let fd = 50; // Use the FD of the target alarm alert tone.
1566
1567let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1568systemSoundManagerInstance.close(fd).then(() => {
1569  console.info(`Promise returned to indicate that the fd has been close.`);
1570}).catch ((err: BusinessError) => {
1571  console.error(`Failed to close fd ${err}`);
1572});
1573```
1574
1575### addCustomizedTone<sup>12+</sup>
1576
1577addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, externalUri: string): Promise&lt;string&gt;
1578
1579Adds a customized tone with a given URI to the tone library. This API uses a promise to return the result.
1580
1581**System API**: This is a system API.
1582
1583**System capability**: SystemCapability.Multimedia.SystemSound.Core
1584
1585**Parameters**
1586
1587| Name| Type       | Mandatory| Description           |
1588|-----|-----------| ---- |---------------|
1589| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.    |
1590| toneAttr  | ToneAttrs | Yes  | Attributes of the tone.        |
1591| externalUri  | string    | Yes  | URI of the tone in the external storage device.|
1592
1593**Return value**
1594
1595| Type                   | Description                     |
1596|-----------------------|-------------------------|
1597| Promise&lt;string&gt; | Promise used to return the URI of the tone in the tone library.|
1598
1599**Error codes**
1600
1601For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1602
1603| ID  | Error Message             |
1604|---------| -------------------- |
1605| 201     | Permission denied. |
1606| 202     | Caller is not a system application. |
1607| 401     | The parameters check failed. |
1608| 5400102     | Operation is not allowed, e.g. ringtone to add is not customized. |
1609| 5400103 | I/O error. |
1610
1611**Example**
1612
1613```ts
1614import { BusinessError } from '@kit.BasicServicesKit';
1615import { common } from '@kit.AbilityKit';
1616
1617let context: Context = getContext(this);
1618let title = 'test'; // Set the title of the target tone.
1619let fileName = 'displayName_test'; // Set the file name of the target tone.
1620let categoryValue = systemSoundManager.TONE_CATEGORY_ALARM;
1621
1622let toneAttrs = systemSoundManager.createCustomizedToneAttrs();
1623toneAttrs.setTitle(title);
1624toneAttrs.setFileName(fileName);
1625toneAttrs.setCategory(categoryValue);
1626
1627let path = 'file://data/test.ogg'; // Set the URI of the target tone.
1628
1629let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1630systemSoundManagerInstance.addCustomizedTone(context, toneAttrs, path).then((value: string) => {
1631  console.info(`Promise returned to indicate that the value of tone uri in ringtone library.`);
1632}).catch ((err: BusinessError) => {
1633  console.error(`Failed to add customized tone ${err}`);
1634});
1635```
1636
1637### addCustomizedTone<sup>12+</sup>
1638
1639addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, fd: number, offset?: number, length?: number): Promise&lt;string&gt;
1640
1641Adds a customized tone with a given FD to the tone library. This API uses a promise to return the result.
1642
1643**System API**: This is a system API.
1644
1645**System capability**: SystemCapability.Multimedia.SystemSound.Core
1646
1647**Parameters**
1648
1649| Name| Type       | Mandatory| Description                                                                    |
1650|-----|-----------|----|------------------------------------------------------------------------|
1651| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes | Application context.                                                             |
1652| toneAttr | [ToneAttrs](#toneattrs12) | Yes | Attributes of the tone.                                                                 |
1653| fd  | number    | Yes | File descriptor, which is obtained by calling [fs.open](../apis-core-file-kit/js-apis-file-fs.md#fsopen).|
1654| offset | number    | No | Offset from which the data is read, in bytes. The default value is **0**.                                             |
1655| length | number    | No | Length of the data to read, in bytes. By default, the length is the total number of remaining bytes after the offset.                                |
1656
1657**Return value**
1658
1659| Type                   | Description                     |
1660|-----------------------|-------------------------|
1661| Promise&lt;string&gt; | Promise used to return the URI of the tone in the tone library.|
1662
1663**Error codes**
1664
1665For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1666
1667| ID  | Error Message             |
1668|---------| -------------------- |
1669| 201     | Permission denied. |
1670| 202     | Caller is not a system application. |
1671| 401     | The parameters check failed. |
1672| 5400102     | Operation is not allowed, e.g. ringtone to add is not customized. |
1673| 5400103 | I/O error. |
1674
1675**Example**
1676
1677```ts
1678import { BusinessError } from '@kit.BasicServicesKit';
1679import { common } from '@kit.AbilityKit';
1680
1681let context: Context = getContext(this);
1682let title = 'test'; // Set the title of the target tone.
1683let fileName = 'displayName_test'; // Set the file name of the target tone.
1684let categoryValue = systemSoundManager.TONE_CATEGORY_ALARM;
1685
1686let toneAttrs = systemSoundManager.createCustomizedToneAttrs();
1687toneAttrs.setTitle(title);
1688toneAttrs.setFileName(fileName);
1689toneAttrs.setCategory(categoryValue);
1690
1691let fd = 10; // Set the FD of the target tone.
1692let offset = 0; // Set the offset.
1693let length = 50; // Set the data length.
1694
1695let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1696systemSoundManagerInstance.addCustomizedTone(context, toneAttrs, fd, offset, length).then((value: string) => {
1697  console.info(`Promise returned to indicate that the value of tone uri in ringtone library.`);
1698}).catch ((err: BusinessError) => {
1699  console.error(`Failed to add customized tone ${err}`);
1700});
1701```
1702
1703### removeCustomizedTone<sup>12+</sup>
1704
1705removeCustomizedTone(context: BaseContext, uri: string): Promise&lt;void&gt;
1706
1707Removes a custom tone from the one library. This API uses a promise to return the result.
1708
1709**System API**: This is a system API.
1710
1711**System capability**: SystemCapability.Multimedia.SystemSound.Core
1712
1713**Parameters**
1714
1715| Name| Type       | Mandatory| Description                                                                                                     |
1716|-----|-----------| ---- |---------------------------------------------------------------------------------------------------------|
1717| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.                                                                                              |
1718| uri  | string    | Yes  | Tone URI, which is obtained by using [addCustomizedTone](#addcustomizedtone12) or [getAlarmToneAttrList](#getalarmtoneattrlist12).|
1719
1720**Return value**
1721
1722| Type                 | Description                   |
1723|---------------------|-----------------------|
1724| Promise&lt;void&gt; | Promise used to return the result.|
1725
1726**Error codes**
1727
1728For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1729
1730| ID  | Error Message             |
1731|---------| -------------------- |
1732| 201     | Permission denied. |
1733| 202     | Caller is not a system application. |
1734| 401     | The parameters check failed. |
1735| 5400102     | Operation is not allowed, e.g. ringtone to add is not customized. |
1736| 5400103 | I/O error. |
1737
1738**Example**
1739
1740```ts
1741import { BusinessError } from '@kit.BasicServicesKit';
1742import { common } from '@kit.AbilityKit';
1743
1744let context: Context = getContext(this);
1745let uri = 'file://data/test.wav'; // Set the URI of the target tone file.
1746
1747let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1748systemSoundManagerInstance.removeCustomizedTone(context, uri).then(() => {
1749  console.info(`Promise returned to indicate that the customized tone has been deleted.`);
1750}).catch ((err: BusinessError) => {
1751  console.error(`Failed to delete customized tone ${err}`);
1752});
1753```
1754
1755### getToneHapticsSettings<sup>14+</sup>
1756
1757getToneHapticsSettings(context: BaseContext, type: ToneHapticsType): Promise&lt;ToneHapticsSettings&gt;
1758
1759Obtains the haptics settings of the system ringtone. This API uses a promise to return the result.
1760
1761**System API**: This is a system API.
1762
1763**System capability**: SystemCapability.Multimedia.SystemSound.Core
1764
1765**Parameters**
1766
1767| Name| Type       | Mandatory| Description                                                                         |
1768|-----|-----------| ---- |----------------------------------------------------------------------------------|
1769| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.  |
1770| type  | [ToneHapticsType](#tonehapticstype14)    | Yes  | Haptics type of the system ringtone.|
1771
1772**Return value**
1773
1774| Type                 | Description                   |
1775|---------------------|-----------------------|
1776| Promise&lt;[ToneHapticsSettings](#tonehapticssettings14)&gt; | Promise used to return the haptics settings.|
1777
1778**Error codes**
1779
1780For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1781
1782| ID  | Error Message             |
1783|---------| -------------------- |
1784| 202     | Caller is not a system application. |
1785| 401     | The parameters check failed. |
1786| 5400103 | I/O error. |
1787| 20700003 | Unsupported operation. |
1788
1789**Example**
1790
1791```ts
1792import { BusinessError } from '@kit.BasicServicesKit';
1793import { common } from '@kit.AbilityKit';
1794
1795let context: common.BaseContext = getContext(this);
1796let type: systemSoundManager.ToneHapticsType = systemSoundManager.ToneHapticsType.CALL_SIM_CARD_0;
1797
1798let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1799systemSoundManagerInstance.getToneHapticsSettings(context, type).then((value: systemSoundManager.ToneHapticsSettings) => {
1800  console.info(`Promise returned to indicate that the value of the tone haptics settings is obtained.`);
1801}).catch ((err: BusinessError) => {
1802  console.error(`Failed to get the tone haptics settings ${err}`);
1803});
1804```
1805
1806### setToneHapticsSettings<sup>14+</sup>
1807
1808setToneHapticsSettings(context: BaseContext, type: ToneHapticsType, settings: ToneHapticsSettings): Promise&lt;void&gt;
1809
1810Sets the haptics settings for the system ringtone. This API uses a promise to return the result.
1811
1812**System API**: This is a system API.
1813
1814**System capability**: SystemCapability.Multimedia.SystemSound.Core
1815
1816**Parameters**
1817
1818| Name| Type       | Mandatory| Description                                                                         |
1819|-----|-----------| ---- |----------------------------------------------------------------------------------|
1820| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.  |
1821| type  | [ToneHapticsType](#tonehapticstype14)    | Yes  | Haptics type of the system ringtone.|
1822| settings  | [ToneHapticsSettings](#tonehapticssettings14)    | Yes  | Haptics settings of the system ringtone.|
1823
1824**Return value**
1825
1826| Type                 | Description                   |
1827|---------------------|-----------------------|
1828| Promise&lt;void&gt; | Promise used to return the result.|
1829
1830**Error codes**
1831
1832For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1833
1834| ID  | Error Message             |
1835|---------| -------------------- |
1836| 202     | Caller is not a system application. |
1837| 401     | The parameters check failed. |
1838| 5400102 | Operation is not allowed, e.g. ringtone to add is not customized. |
1839| 5400103 | I/O error. |
1840| 20700003 | Unsupported operation. |
1841
1842**Example**
1843
1844```ts
1845import { BusinessError } from '@kit.BasicServicesKit';
1846import { common } from '@kit.AbilityKit';
1847
1848let context: common.BaseContext = getContext(this);
1849let type: systemSoundManager.ToneHapticsType = systemSoundManager.ToneHapticsType.CALL_SIM_CARD_0;
1850let toneHapticsSettings: systemSoundManager.ToneHapticsSettings = {
1851  mode: systemSoundManager.ToneHapticsMode.NON_SYNC,
1852  hapticsUri: '/data/storage/el2/base/haptics/synchronized/alarms/test.json', // Use the URI obtained through getToneHapticsList.
1853}
1854
1855let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1856systemSoundManagerInstance.setToneHapticsSettings(context, type, toneHapticsSettings).then(() => {
1857  console.info(`Promise returned to indicate a successful setting of the tone haptics.`);
1858}).catch ((err: BusinessError) => {
1859  console.error(`Failed to set the tone haptics settings ${err}`);
1860});
1861```
1862
1863### getToneHapticsList<sup>14+</sup>
1864
1865getToneHapticsList(context: BaseContext, isSynced: boolean): Promise&lt;ToneHapticsAttrsArray&gt;
1866
1867Obtains the haptics attributes of the system ringtone in sync or non-sync mode. This API uses a promise to return the result.
1868
1869**System API**: This is a system API.
1870
1871**System capability**: SystemCapability.Multimedia.SystemSound.Core
1872
1873**Parameters**
1874
1875| Name| Type       | Mandatory| Description                                                                         |
1876|-----|-----------| ---- |----------------------------------------------------------------------------------|
1877| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.  |
1878| isSynced  | boolean    | Yes  | Whether the haptics feedback is synchronized with the ringtone.|
1879
1880**Return value**
1881
1882| Type                 | Description                   |
1883|---------------------|-----------------------|
1884| Promise&lt;[ToneHapticsAttrsArray](#tonehapticsattrsarray14)&gt; | Promise used to return the haptics attributes.|
1885
1886**Error codes**
1887
1888For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1889
1890| ID  | Error Message             |
1891|---------| -------------------- |
1892| 202     | Caller is not a system application. |
1893| 401     | The parameters check failed. |
1894| 5400103 | I/O error. |
1895| 20700003 | Unsupported operation. |
1896
1897**Example**
1898
1899```ts
1900import { BusinessError } from '@kit.BasicServicesKit';
1901import { common } from '@kit.AbilityKit';
1902
1903let context: common.BaseContext = getContext(this);
1904
1905let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1906systemSoundManagerInstance.getToneHapticsList(context, false).then((value: systemSoundManager.ToneHapticsAttrsArray) => {
1907  console.info(`Promise returned to indicate that the value of the attribute list of tone haptics is obtained.`);
1908}).catch ((err: BusinessError) => {
1909  console.error(`Failed to get the attribute list of tone haptics ${err}`);
1910});
1911```
1912
1913### getHapticsAttrsSyncedWithTone<sup>14+</sup>
1914
1915getHapticsAttrsSyncedWithTone(context: BaseContext, toneUri: string): Promise&lt;ToneHapticsAttrs&gt;
1916
1917Obtains the attributes of the haptics feedback synchronized with the system ringtone. This API uses a promise to return the result.
1918
1919**System API**: This is a system API.
1920
1921**System capability**: SystemCapability.Multimedia.SystemSound.Core
1922
1923**Parameters**
1924
1925| Name| Type       | Mandatory| Description                                                                         |
1926|-----|-----------| ---- |----------------------------------------------------------------------------------|
1927| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.  |
1928| toneUri  | string    | Yes  | URI of the system ringtone. The URI can be obtained by calling [getRingtoneAttrList](#getringtoneattrlist12) or [getSystemToneAttrList](#getsystemtoneattrlist12).|
1929
1930**Return value**
1931
1932| Type                 | Description                   |
1933|---------------------|-----------------------|
1934| Promise&lt;[ToneHapticsAttrs](#tonehapticsattrs14)&gt; | Promise used to return the haptics attributes.|
1935
1936**Error codes**
1937
1938For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1939
1940| ID  | Error Message             |
1941|---------| -------------------- |
1942| 202     | Caller is not a system application. |
1943| 401     | The parameters check failed. |
1944| 5400102 | Operation is not allowed, e.g. ringtone to add is not customized. |
1945| 5400103 | I/O error. |
1946| 20700003 | Unsupported operation. |
1947
1948**Example**
1949
1950```ts
1951import { BusinessError } from '@kit.BasicServicesKit';
1952import { common } from '@kit.AbilityKit';
1953
1954let context: common.BaseContext = getContext(this);
1955let toneUri: string = '/data/storage/el2/base/RingTone/alarms/test.ogg'; // Use the actual URI of the system ringtone.
1956
1957let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1958systemSoundManagerInstance.getHapticsAttrsSyncedWithTone(context, toneUri).then((value: systemSoundManager.ToneHapticsAttrs) => {
1959  console.info(`Promise returned to indicate that the value of the attribute of tone haptics is obtained.`);
1960}).catch ((err: BusinessError) => {
1961  console.error(`Failed to get the attribute of tone haptics ${err}`);
1962});
1963```
1964
1965### openToneHaptics<sup>14+</sup>
1966
1967openToneHaptics(context: Context, hapticsUri: string): Promise&lt;number&gt;
1968
1969Enables haptics for the system ringtone. This API uses a promise to return the result.
1970
1971**System API**: This is a system API.
1972
1973**System capability**: SystemCapability.Multimedia.SystemSound.Core
1974
1975**Parameters**
1976
1977| Name  | Type      | Mandatory| Description                                                                                 |
1978| -------- | ---------| ---- |-------------------------------------------------------------------------------------|
1979| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.          |
1980| hapticsUri      | string   | Yes  | URI of the haptics resource. For details about supported resources, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
1981
1982**Return value**
1983
1984| Type                   | Description            |
1985|-----------------------|----------------|
1986| Promise&lt;number&gt; | Promise used to return the FD.|
1987
1988**Error codes**
1989
1990For details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1991
1992| ID| Error Message             |
1993| ------- | --------------------- |
1994| 202 | Caller is not a system application. |
1995| 401 | The parameters check failed. |
1996| 5400102 | Operation is not allowed, e.g. ringtone to add is not customized. |
1997| 5400103 | I/O error. |
1998| 20700003 | Unsupported operation. |
1999
2000**Example**
2001
2002```ts
2003import { BusinessError } from '@kit.BasicServicesKit';
2004import { common } from '@kit.AbilityKit';
2005
2006let context: Context = getContext(this);
2007let hapticsUri = '/data/storage/el2/base/haptics/synchronized/alarms/test.json'; // Use the actual URI of the haptics resource.
2008
2009let systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
2010systemSoundManagerInstance.openToneHaptics(context, hapticsUri).then((value: number) => {
2011  console.info(`Promise returned to indicate the value of fd.`);
2012}).catch ((err: BusinessError) => {
2013  console.error(`Failed to open haptics ${err}`);
2014});
2015```
2016
2017## RingtonePlayer<sup>10+</sup>
2018
2019type RingtonePlayer = _RingtonePlayer;
2020
2021Defines a system ringtone player.
2022
2023**System capability**: SystemCapability.Multimedia.SystemSound.Core
2024
2025| Type             |Description    |
2026|-----------------|-------|
2027| _RingtonePlayer | System ringtone player.|
2028
2029## SystemTonePlayer<sup>11+</sup>
2030
2031type SystemTonePlayer = _SystemTonePlayer;
2032
2033Defines a system alert tone player.
2034
2035**System capability**: SystemCapability.Multimedia.SystemSound.Core
2036
2037| Type             | Description       |
2038|-----------------|-----------|
2039| _SystemTonePlayer | System alert tone player.|
2040
2041## RingtoneOptions<sup>10+</sup>
2042
2043type RingtoneOptions = _RingtoneOptions;
2044
2045Defines the configuration of a system ringtone player.
2046
2047**System capability**: SystemCapability.Multimedia.SystemSound.Core
2048
2049| Type             | Description         |
2050|-----------------|-------------|
2051| _RingtoneOptions | Configuration of a system ringtone player.|
2052
2053## SystemToneOptions<sup>11+</sup>
2054
2055type SystemToneOptions = _SystemToneOptions;
2056
2057Defines the configuration of a system alert tone player.
2058
2059**System capability**: SystemCapability.Multimedia.SystemSound.Core
2060
2061| Type             | Description           |
2062|-----------------|---------------|
2063| _SystemToneOptions | Configuration of a system alert tone player.|
2064