1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit AudioKit
19 */
20
21import type { AsyncCallback } from './@ohos.base';
22import type Context from './application/Context';
23import type BaseContext from './application/BaseContext';
24import type { RingtonePlayer as _RingtonePlayer } from './multimedia/ringtonePlayer';
25import type { RingtoneOptions as _RingtoneOptions } from './multimedia/ringtonePlayer';
26import type { SystemTonePlayer as _SystemTonePlayer } from './multimedia/systemTonePlayer';
27import type { SystemToneOptions as _SystemToneOptions } from './multimedia/systemTonePlayer';
28
29/**
30 * Provides ringtone player interfaces.
31 *
32 * @namespace systemSoundManager
33 * @syscap SystemCapability.Multimedia.SystemSound.Core
34 * @systemapi
35 * @since 10
36 */
37declare namespace systemSoundManager {
38  /**
39   * Enum for ringtone type.
40   * @enum { number }
41   * @syscap SystemCapability.Multimedia.SystemSound.Core
42   * @systemapi
43   * @since 10
44   */
45  enum RingtoneType {
46    /**
47     * Default type.
48     * @syscap SystemCapability.Multimedia.SystemSound.Core
49     * @systemapi
50     * @since 10
51     * @deprecated since 11
52     * @useinstead systemSoundManager.RingtoneType#RINGTONE_TYPE_SIM_CARD_0
53     */
54    RINGTONE_TYPE_DEFAULT = 0,
55
56    /**
57     * Ringtone type for sim card 0.
58     * @syscap SystemCapability.Multimedia.SystemSound.Core
59     * @systemapi
60     * @since 11
61     */
62    RINGTONE_TYPE_SIM_CARD_0 = 0,
63
64    /**
65     * Multi-sim type.
66     * @syscap SystemCapability.Multimedia.SystemSound.Core
67     * @systemapi
68     * @since 10
69     * @deprecated since 11
70     * @useinstead systemSoundManager.RingtoneType#RINGTONE_TYPE_SIM_CARD_1
71     */
72    RINGTONE_TYPE_MULTISIM = 1,
73
74    /**
75     * Ringtone type for sim card 1.
76     * @syscap SystemCapability.Multimedia.SystemSound.Core
77     * @systemapi
78     * @since 11
79     */
80    RINGTONE_TYPE_SIM_CARD_1 = 1,
81  }
82
83  /**
84   * Enum for system tone type.
85   * @enum { number }
86   * @syscap SystemCapability.Multimedia.SystemSound.Core
87   * @systemapi
88   * @since 11
89   */
90  enum SystemToneType {
91    /**
92     * System tone type for sim card 0.
93     * @syscap SystemCapability.Multimedia.SystemSound.Core
94     * @systemapi
95     * @since 11
96     */
97    SYSTEM_TONE_TYPE_SIM_CARD_0 = 0,
98
99    /**
100     * System tone type for sim card 1.
101     * @syscap SystemCapability.Multimedia.SystemSound.Core
102     * @systemapi
103     * @since 11
104     */
105    SYSTEM_TONE_TYPE_SIM_CARD_1 = 1,
106
107    /**
108     * System tone type notification.
109     * @syscap SystemCapability.Multimedia.SystemSound.Core
110     * @systemapi
111     * @since 11
112     */
113    SYSTEM_TONE_TYPE_NOTIFICATION = 32,
114  }
115
116  /**
117   * Enum for tone customized type.
118   * @enum {number}
119   * @syscap SystemCapability.Multimedia.SystemSound.Core
120   * @systemapi
121   * @since 12
122   */
123  enum ToneCustomizedType {
124    /**
125     * Pre-installed tone type.
126     * @syscap SystemCapability.Multimedia.SystemSound.Core
127     * @systemapi
128     * @since 12
129     */
130    PRE_INSTALLED = 0,
131    /**
132     * Customized tone type.
133     * @syscap SystemCapability.Multimedia.SystemSound.Core
134     * @systemapi
135     * @since 12
136     */
137    CUSTOMIZED = 1,
138  }
139
140  /**
141   * Define the ringtone category.
142   * @constant
143   * @syscap SystemCapability.Multimedia.SystemSound.Core
144   * @systemapi
145   * @since 12
146   */
147  const TONE_CATEGORY_RINGTONE: number;
148
149  /**
150   * Define the text message tone category.
151   * @constant
152   * @syscap SystemCapability.Multimedia.SystemSound.Core
153   * @systemapi
154   * @since 12
155   */
156  const TONE_CATEGORY_TEXT_MESSAGE:number;
157
158  /**
159   * Define the notification tone category.
160   * @constant
161   * @syscap SystemCapability.Multimedia.SystemSound.Core
162   * @systemapi
163   * @since 12
164   */
165  const TONE_CATEGORY_NOTIFICATION:number;
166
167  /**
168   * Define the alarm tone category.
169   * @constant
170   * @syscap SystemCapability.Multimedia.SystemSound.Core
171   * @systemapi
172   * @since 12
173   */
174  const TONE_CATEGORY_ALARM:number;
175
176  /**
177   * Tone attributes.
178   * @typedef ToneAttrs
179   * @syscap SystemCapability.Multimedia.SystemSound.Core
180   * @systemapi
181   * @since 12
182   */
183  interface ToneAttrs {
184    /**
185     * Gets title of tone.
186     * @returns { string } title.
187     * @throws { BusinessError } 202 - Caller is not a system application.
188     * @syscap SystemCapability.Multimedia.SystemSound.Core
189     * @systemapi
190     * @since 12
191     */
192    getTitle(): string;
193
194    /**
195     * Sets title of tone.
196     * @param { string } title - Title of tone.
197     * @throws { BusinessError } 202 - Caller is not a system application.
198     * @throws { BusinessError } 401 - Parameter error. Possible causes:
199     *                                 1.Mandatory parameters are left unspecified;
200     *                                 2.Incorrect parameter types.
201     * @syscap SystemCapability.Multimedia.SystemSound.Core
202     * @systemapi
203     * @since 12
204     */
205    setTitle(title: string): void;
206
207    /**
208     * Gets file name of tone.
209     * @returns { string } file name.
210     * @throws { BusinessError } 202 - Caller is not a system application.
211     * @syscap SystemCapability.Multimedia.SystemSound.Core
212     * @systemapi
213     * @since 12
214     */
215    getFileName(): string;
216
217    /**
218     * Sets file name of tone.
219     * @param { string } name - file name.
220     * @throws { BusinessError } 202 - Caller is not a system application.
221     * @throws { BusinessError } 401 - Parameter error. Possible causes:
222     *                                 1.Mandatory parameters are left unspecified;
223     *                                 2.Incorrect parameter types.
224     * @syscap SystemCapability.Multimedia.SystemSound.Core
225     * @systemapi
226     * @since 12
227     */
228    setFileName(name: string): void;
229
230    /**
231     * Gets uri of tone.
232     * @returns { string } uri.
233     * @throws { BusinessError } 202 - Caller is not a system application.
234     * @syscap SystemCapability.Multimedia.SystemSound.Core
235     * @systemapi
236     * @since 12
237     */
238    getUri(): string;
239
240    /**
241     * Gets customized type of tone.
242     * @returns { ToneCustomizedType } Customized type of tone.
243     * @throws { BusinessError } 202 - Caller is not a system application.
244     * @syscap SystemCapability.Multimedia.SystemSound.Core
245     * @systemapi
246     * @since 12
247     */
248    getCustomizedType(): ToneCustomizedType;
249
250    /**
251     * Sets tone category.
252     * @param { number } category - tone category. This parameter can be one of {@link TONE_CATEGORY_RINGTONE},
253     * {@link TONE_CATEGORY_TEXT_MESSAGE}, {@link TONE_CATEGORY_NOTIFICATION}, {@link TONE_CATEGORY_ALARM}.
254     * In addition, this parameter can be result of OR logical operator of these constants.
255     * @throws { BusinessError } 202 - Caller is not a system application.
256     * @throws { BusinessError } 401 - Parameter error. Possible causes:
257     *                                 1.Mandatory parameters are left unspecified;
258     *                                 2.Incorrect parameter types.
259     * @syscap SystemCapability.Multimedia.SystemSound.Core
260     * @systemapi
261     * @since 12
262     */
263    setCategory(category: number): void;
264
265    /**
266     * Gets tone category.
267     * @returns { number } Tone category. This value can be one of {@link TONE_CATEGORY_RINGTONE},
268     * {@link TONE_CATEGORY_TEXT_MESSAGE}, {@link TONE_CATEGORY_NOTIFICATION}, {@link TONE_CATEGORY_ALARM}.
269     * In addition, this value can be result of OR logical operator of these constants.
270     * @throws { BusinessError } 202 - Caller is not a system application.
271     * @syscap SystemCapability.Multimedia.SystemSound.Core
272     * @systemapi
273     * @since 12
274     */
275    getCategory(): number;
276  }
277
278  /**
279   * Array of tone attributes.
280   *
281   * @typedef {Array<ToneAttrs>} ToneAttrsArray
282   * @syscap SystemCapability.Multimedia.SystemSound.Core
283   * @systemapi
284   * @since 12
285   */
286  type ToneAttrsArray = Array<ToneAttrs>;
287
288  /**
289   * Create customized tone attributes.
290   * @returns { ToneAttrs } Tone attributes created.
291   * @throws { BusinessError } 202 - Caller is not a system application.
292   * @syscap SystemCapability.Multimedia.SystemSound.Core
293   * @systemapi
294   * @since 12
295   */
296  function createCustomizedToneAttrs(): ToneAttrs;
297
298  /**
299   * Definition of haptics feature in tone scenario.
300   * @enum { number }
301   * @syscap SystemCapability.Multimedia.SystemSound.Core
302   * @systemapi
303   * @since 13
304   */
305  enum ToneHapticsFeature {
306    /**
307     * Standard haptics feature.
308     * @syscap SystemCapability.Multimedia.SystemSound.Core
309     * @systemapi
310     * @since 13
311     */
312    STANDARD = 0,
313    /**
314     * Gentle haptics feature.
315     * @syscap SystemCapability.Multimedia.SystemSound.Core
316     * @systemapi
317     * @since 13
318     */
319    GENTLE = 1,
320  }
321  /**
322   * Type definition of haptics in tone scenario.
323   *
324   * @typedef {RingtoneType | SystemToneType} ToneHapticsType
325   * @syscap SystemCapability.Multimedia.SystemSound.Core
326   * @systemapi
327   * @since 13
328   */
329  type ToneHapticsType = RingtoneType | SystemToneType;
330
331  /**
332   * Enum for haptics mode in tone scenario.
333   * @enum {number}
334   * @syscap SystemCapability.Multimedia.SystemSound.Core
335   * @systemapi
336   * @since 13
337   */
338  enum ToneHapticsMode {
339    /**
340     * None haptics mode.
341     * @syscap SystemCapability.Multimedia.SystemSound.Core
342     * @systemapi
343     * @since 13
344     */
345    NONE = 0,
346    /**
347     * Haptics is synchronized with tone.
348     * @syscap SystemCapability.Multimedia.SystemSound.Core
349     * @systemapi
350     * @since 13
351     */
352    SYNC = 1,
353
354    /**
355     * Haptics is out of synchronize with tone.
356     * @syscap SystemCapability.Multimedia.SystemSound.Core
357     * @systemapi
358     * @since 13
359     */
360    NON_SYNC = 2,
361  }
362  /**
363   * Haptics settings in tone scenario.
364   * @typedef ToneHapticsSettings
365   * @syscap SystemCapability.Multimedia.SystemSound.Core
366   * @systemapi
367   * @since 13
368   */
369  interface ToneHapticsSettings {
370    /**
371     * Haptics mode.
372     * @type { ToneHapticsMode }
373     * @syscap SystemCapability.Multimedia.SystemSound.Core
374     * @systemapi
375     * @since 13
376     */
377    mode: ToneHapticsMode;
378    /**
379     * Haptics uri. Users can set/get this parameter when {@link ToneHapticsSettings#mode} is
380     * {@link ToneHapticsMode#NON_SYC}. In other cases, this uri is useless and should be ignored.
381     * @type { ?string }
382     * @syscap SystemCapability.Multimedia.SystemSound.Core
383     * @systemapi
384     * @since 13
385     */
386    hapticsUri?: string;
387  }
388
389  /**
390   * Haptics attributes in tone scenario.
391   * @typedef ToneHapticsAttrs
392   * @syscap SystemCapability.Multimedia.SystemSound.Core
393   * @systemapi
394   * @since 13
395   */
396  interface ToneHapticsAttrs {
397    /**
398     * Get haptics uri.
399     * @returns { string } Haptics uri.
400     * @throws { BusinessError } 202 - Caller is not a system application.
401     * @syscap SystemCapability.Multimedia.SystemSound.Core
402     * @systemapi
403     * @since 13
404     */
405    getUri(): string;
406
407    /**
408     * Get title of haptics.
409     * @returns { string } Haptics title.
410     * @throws { BusinessError } 202 - Caller is not a system application.
411     * @syscap SystemCapability.Multimedia.SystemSound.Core
412     * @systemapi
413     * @since 13
414     */
415    getTitle(): string;
416
417    /**
418     * Get file name of haptics.
419     * @returns { string } Haptics title.
420     * @throws { BusinessError } 202 - Caller is not a system application.
421     * @syscap SystemCapability.Multimedia.SystemSound.Core
422     * @systemapi
423     * @since 13
424     */
425    getFileName(): string;
426  }
427
428  /**
429   * Type definition of tone haptics array.
430   *
431   * @typedef { Array<ToneHapticsAttrs> } ToneHapticsAttrsArray
432   * @syscap SystemCapability.Multimedia.SystemSound.Core
433   * @systemapi
434   * @since 13
435   */
436  type ToneHapticsAttrsArray = Array<ToneHapticsAttrs>;
437
438
439  /**
440   * Gets system sound manager for all type sound.
441   * @returns { SystemSoundManager } SystemSoundManager instance.
442   * @syscap SystemCapability.Multimedia.SystemSound.Core
443   * @systemapi
444   * @since 10
445   */
446  function getSystemSoundManager(): SystemSoundManager;
447
448  /**
449   * System sound manager object.
450   * @typedef SystemSoundManager
451   * @syscap SystemCapability.Multimedia.SystemSound.Core
452   * @systemapi
453   * @since 10
454   */
455  interface SystemSoundManager {
456    /**
457     * Sets the ringtone uri to system.
458     * @param { Context } context - Current application context.
459     * @param { string } uri - Ringtone uri to set.
460     * @param { RingtoneType } type - Ringtone type to set.
461     * @param { AsyncCallback<void> } callback - Callback used to return the set uri result.
462     * @syscap SystemCapability.Multimedia.SystemSound.Core
463     * @systemapi
464     * @since 10
465     * @deprecated since 11
466     * @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri
467     */
468    setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback<void>): void;
469
470    /**
471     * Sets the ringtone uri to system.
472     * @param { Context } context - Current application context.
473     * @param { string } uri - Ringtone uri to set.
474     * @param { RingtoneType } type - Ringtone type to set.
475     * @returns { Promise<void> } Promise used to return the set uri result.
476     * @syscap SystemCapability.Multimedia.SystemSound.Core
477     * @systemapi
478     * @since 10
479     * @deprecated since 11
480     * @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri
481     */
482    setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise<void>;
483
484    /**
485     * Sets the ringtone uri to system.
486     * @param { BaseContext } context - Current application context.
487     * @param { string } uri - Ringtone uri to set.
488     * @param { RingtoneType } type - Ringtone type to set.
489     * @returns { Promise<void> } Promise used to return the set uri result.
490     * @throws { BusinessError } 202 - Caller is not a system application.
491     * @throws { BusinessError } 401 - Parameter error. Possible causes:
492     *         1.Mandatory parameters are left unspecified;
493     *         2.Incorrect parameter types.
494     * @throws { BusinessError } 5400103 - I/O error.
495     * @syscap SystemCapability.Multimedia.SystemSound.Core
496     * @systemapi
497     * @since 11
498     */
499    setRingtoneUri(context: BaseContext, uri: string, type: RingtoneType): Promise<void>;
500
501    /**
502     * Gets the ringtone uri.
503     * @param { Context } context - Current application context.
504     * @param { RingtoneType } type - Ringtone type to get.
505     * @param { AsyncCallback<string> } callback - Callback used to return the ringtone uri maintained in system.
506     * @syscap SystemCapability.Multimedia.SystemSound.Core
507     * @systemapi
508     * @since 10
509     * @deprecated since 11
510     * @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri
511     */
512    getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback<string>): void;
513
514    /**
515     * Gets the ringtone uri.
516     * @param { Context } context - Current application context.
517     * @param { RingtoneType } type - Ringtone type to get.
518     * @returns { Promise<string> } Promise used to return the ringtone uri maintained in system.
519     * @syscap SystemCapability.Multimedia.SystemSound.Core
520     * @systemapi
521     * @since 10
522     * @deprecated since 11
523     * @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri
524     */
525    getSystemRingtoneUri(context: Context, type: RingtoneType): Promise<string>;
526
527    /**
528     * Gets the ringtone uri.
529     * @param { BaseContext } context - Current application context.
530     * @param { RingtoneType } type - Ringtone type to get.
531     * @returns { Promise<string> } Promise used to return the ringtone uri maintained in system.
532     * @throws { BusinessError } 202 - Caller is not a system application.
533     * @throws { BusinessError } 401 - Parameter error. Possible causes:
534     *                                 1.Mandatory parameters are left unspecified;
535     *                                 2.Incorrect parameter types.
536     * @throws { BusinessError } 5400103 - I/O error.
537     * @syscap SystemCapability.Multimedia.SystemSound.Core
538     * @systemapi
539     * @since 11
540     */
541    getRingtoneUri(context: BaseContext, type: RingtoneType): Promise<string>;
542
543    /**
544     * Gets attributes of the default ringtone.
545     * @param { BaseContext } context - Current application context.
546     * @param { RingtoneType } type - Ringtone type to get.
547     * @returns { Promise<ToneAttrs> } Promise used to return attributes of the default ringtone.
548     * @throws { BusinessError } 202 - Caller is not a system application.
549     * @throws { BusinessError } 401 - Parameter error. Possible causes:
550     *                                 1.Mandatory parameters are left unspecified;
551     *                                 2.Incorrect parameter types.
552     * @throws { BusinessError } 5400103 - I/O error.
553     * @syscap SystemCapability.Multimedia.SystemSound.Core
554     * @systemapi
555     * @since 12
556     */
557    getDefaultRingtoneAttrs(context: BaseContext, type: RingtoneType): Promise<ToneAttrs>;
558
559    /**
560     * Gets attribute list of ringtones.
561     * @param { BaseContext } context - Current application context.
562     * @param { RingtoneType } type - Ringtone type to get.
563     * @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of ringtone.
564     * @throws { BusinessError } 202 - Caller is not a system application.
565     * @throws { BusinessError } 401 - Parameter error. Possible causes:
566     *                                 1.Mandatory parameters are left unspecified;
567     *                                 2.Incorrect parameter types.
568     * @throws { BusinessError } 5400103 - I/O error.
569     * @syscap SystemCapability.Multimedia.SystemSound.Core
570     * @systemapi
571     * @since 12
572     */
573    getRingtoneAttrList(context: BaseContext, type: RingtoneType): Promise<ToneAttrsArray>;
574
575    /**
576     * Gets the ringtone player.
577     * @param { Context } context - Current application context.
578     * @param { RingtoneType } type - Ringtone type to get.
579     * @param { AsyncCallback<RingtonePlayer> } callback - Callback used to return a ringtone player instance.
580     * @syscap SystemCapability.Multimedia.SystemSound.Core
581     * @systemapi
582     * @since 10
583     * @deprecated since 11
584     * @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer
585     */
586    getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback<RingtonePlayer>): void;
587
588    /**
589     * Gets the ringtone player.
590     * @param { Context } context - Current application context.
591     * @param { RingtoneType } type - Ringtone type to get.
592     * @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance.
593     * @syscap SystemCapability.Multimedia.SystemSound.Core
594     * @systemapi
595     * @since 10
596     * @deprecated since 11
597     * @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer
598     */
599    getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise<RingtonePlayer>;
600
601    /**
602     * Gets the ringtone player.
603     * @param { BaseContext } context - Current application context.
604     * @param { RingtoneType } type - Ringtone type to get.
605     * @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance.
606     * @throws { BusinessError } 202 - Caller is not a system application.
607     * @throws { BusinessError } 401 - Parameter error. Possible causes:
608     *                                 1.Mandatory parameters are left unspecified;
609     *                                 2.Incorrect parameter types.
610     * @syscap SystemCapability.Multimedia.SystemSound.Core
611     * @systemapi
612     * @since 11
613     */
614    getRingtonePlayer(context: BaseContext, type: RingtoneType): Promise<RingtonePlayer>;
615
616    /**
617     * Sets the system tone uri to system.
618     * @param { BaseContext } context - Current application context.
619     * @param { string } uri - Ringtone uri to set.
620     * @param { SystemToneType } type - System tone type to set.
621     * @returns { Promise<void> } Promise used to return the result of set system tone uri.
622     * @throws { BusinessError } 202 - Caller is not a system application.
623     * @throws { BusinessError } 401 - Parameter error. Possible causes:
624     *                                 1.Mandatory parameters are left unspecified;
625     *                                 2.Incorrect parameter types.
626     * @throws { BusinessError } 5400103 - I/O error.
627     * @syscap SystemCapability.Multimedia.SystemSound.Core
628     * @systemapi
629     * @since 11
630     */
631    setSystemToneUri(context: BaseContext, uri: string, type: SystemToneType): Promise<void>;
632
633    /**
634     * Gets the system tone uri.
635     * @param { BaseContext } context - Current application context.
636     * @param { SystemToneType } type - System tone type to get.
637     * @returns { Promise<string> } Promise used to return the system tone maintained in system.
638     * @throws { BusinessError } 202 - Caller is not a system application.
639     * @throws { BusinessError } 401 - Parameter error. Possible causes:
640     *                                 1.Mandatory parameters are left unspecified;
641     *                                 2.Incorrect parameter types.
642     * @throws { BusinessError } 5400103 - I/O error.
643     * @syscap SystemCapability.Multimedia.SystemSound.Core
644     * @systemapi
645     * @since 11
646     */
647    getSystemToneUri(context: BaseContext, type: SystemToneType): Promise<string>;
648
649    /**
650     * Gets attributes of the default system tone.
651     *
652     * @param { BaseContext } context - Current application context.
653     * @param { SystemToneType } type - system tone type to get.
654     * @returns { Promise<ToneAttrs> } Promise used to return attributes of the default system tone.
655     * @throws { BusinessError } 202 - Caller is not a system application.
656     * @throws { BusinessError } 401 - Parameter error. Possible causes:
657     *                                 1.Mandatory parameters are left unspecified;
658     *                                 2.Incorrect parameter types.
659     * @throws { BusinessError } 5400103 - I/O error.
660     * @syscap SystemCapability.Multimedia.SystemSound.Core
661     * @systemapi
662     * @since 12
663     */
664    getDefaultSystemToneAttrs(context: BaseContext, type: SystemToneType): Promise<ToneAttrs>;
665
666    /**
667     * Gets attribute list of alarm tones.
668     * @param { BaseContext } context - Current application context.
669     * @param { SystemToneType } type - System tone type to get.
670     * @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of system tone.
671     * @throws { BusinessError } 202 - Caller is not a system application.
672     * @throws { BusinessError } 401 - Parameter error. Possible causes:
673     *                                 1.Mandatory parameters are left unspecified;
674     *                                 2.Incorrect parameter types.
675     * @throws { BusinessError } 5400103 - I/O error.
676     * @syscap SystemCapability.Multimedia.SystemSound.Core
677     * @systemapi
678     * @since 12
679     */
680    getSystemToneAttrList(context: BaseContext, type: SystemToneType): Promise<ToneAttrsArray>;
681
682    /**
683     * Gets the system tone player.
684     * @param { BaseContext } context - Current application context.
685     * @param { SystemToneType } type - System tone type to get.
686     * @returns { Promise<SystemTonePlayer> } Promise used to return the SystemTonePlayer.
687     * @throws { BusinessError } 202 - Caller is not a system application.
688     * @throws { BusinessError } 401 - Parameter error. Possible causes:
689     *                                 1.Mandatory parameters are left unspecified;
690     *                                 2.Incorrect parameter types.
691     * @syscap SystemCapability.Multimedia.SystemSound.Core
692     * @systemapi
693     * @since 11
694     */
695    getSystemTonePlayer(context: BaseContext, type: SystemToneType): Promise<SystemTonePlayer>;
696
697    /**
698     * Gets attributes of the default alarm tone.
699     *
700     * @param { BaseContext } context - Current application context.
701     * @returns { Promise<ToneAttrs> } Promise used to return attributes of the default alarm tone.
702     * @throws { BusinessError } 202 - Caller is not a system application.
703     * @throws { BusinessError } 401 - Parameter error. Possible causes:
704     *                                 1.Mandatory parameters are left unspecified;
705     *                                 2.Incorrect parameter types.
706     * @throws { BusinessError } 5400103 - I/O error.
707     * @syscap SystemCapability.Multimedia.SystemSound.Core
708     * @systemapi
709     * @since 12
710     */
711    getDefaultAlarmToneAttrs(context: BaseContext): Promise<ToneAttrs>;
712
713    /**
714     * Sets uri of the current alarm tone.
715     *
716     * @param { BaseContext } context - Current application context.
717     * @param { string } uri - Alarm tone uri.
718     * @returns { Promise<void> } Promise used to return result of set alarm tone.
719     * @throws { BusinessError } 202 - Caller is not a system application.
720     * @throws { BusinessError } 401 - Parameter error. Possible causes:
721     *                                 1.Mandatory parameters are left unspecified;
722     *                                 2.Incorrect parameter types.
723     * @throws { BusinessError } 5400103 - I/O error.
724     * @throws { BusinessError } 20700001 - Tone type mismatch, e.g. tone of input uri is not an alarm tone.
725     * @syscap SystemCapability.Multimedia.SystemSound.Core
726     * @systemapi
727     * @since 12
728     */
729    setAlarmToneUri(context: BaseContext, uri: string): Promise<void>;
730
731    /**
732     * Gets uri of the current alarm tone.
733     *
734     * @param { BaseContext } context - Current application context.
735     * @returns { Promise<string> } Promise used to return uri of current alarm tone.
736     * @throws { BusinessError } 202 - Caller is not a system application.
737     * @throws { BusinessError } 401 - Parameter error. Possible causes:
738     *                                 1.Mandatory parameters are left unspecified;
739     *                                 2.Incorrect parameter types.
740     * @throws { BusinessError } 5400103 - I/O error.
741     * @syscap SystemCapability.Multimedia.SystemSound.Core
742     * @systemapi
743     * @since 12
744     */
745    getAlarmToneUri(context: BaseContext): Promise<string>;
746
747    /**
748     * Gets attribute list of alarm tones.
749     * @param { BaseContext } context - Current application context.
750     * @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of system tone.
751     * @throws { BusinessError } 202 - Caller is not a system application.
752     * @throws { BusinessError } 401 - Parameter error. Possible causes:
753     *                                 1.Mandatory parameters are left unspecified;
754     *                                 2.Incorrect parameter types.
755     * @throws { BusinessError } 5400103 - I/O error.
756     * @syscap SystemCapability.Multimedia.SystemSound.Core
757     * @systemapi
758     * @since 12
759     */
760    getAlarmToneAttrList(context: BaseContext): Promise<ToneAttrsArray>;
761
762    /**
763     * Open alarm tone file.
764     * @param { BaseContext } context - Current application context.
765     * @param { string } uri - Uri of alarm tone to open.
766     * @returns { Promise<number> } Promise used to return fd.
767     * @throws { BusinessError } 202 - Caller is not a system application.
768     * @throws { BusinessError } 401 - Parameter error. Possible causes:
769     *                                 1.Mandatory parameters are left unspecified;
770     *                                 2.Incorrect parameter types.
771     * @throws { BusinessError } 5400103 - I/O error.
772     * @throws { BusinessError } 20700001 - Tone type mismatch, e.g. tone of uri is notification instead of alarm.
773     * @syscap SystemCapability.Multimedia.SystemSound.Core
774     * @systemapi
775     * @since 12
776     */
777    openAlarmTone(context: BaseContext, uri: string): Promise<number>
778
779    /**
780     * Close fd.
781     * @param { number } fd - File descriptor to close.
782     * @returns { Promise<void> } Promise used to return the result of close fd.
783     * @throws { BusinessError } 202 - Caller is not a system application.
784     * @throws { BusinessError } 401 - Parameter error. Possible causes:
785     *                                 1.Mandatory parameters are left unspecified;
786     *                                 2.Incorrect parameter types.
787     * @throws { BusinessError } 5400103 - I/O error.
788     * @syscap SystemCapability.Multimedia.SystemSound.Core
789     * @systemapi
790     * @since 12
791     */
792    close(fd: number): Promise<void>;
793
794    /**
795     * Add customized tone into ringtone library.
796     * @permission ohos.permission.WRITE_RINGTONE
797     * @param { BaseContext } context - Current application context.
798     * @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}.
799     * @param { string } externalUri - Tone uri in external storage.
800     * @returns { Promise<string> } Tone uri after adding into ringtone library.
801     * @throws { BusinessError } 201 - Permission denied.
802     * @throws { BusinessError } 202 - Caller is not a system application.
803     * @throws { BusinessError } 401 - Parameter error. Possible causes:
804     *                                 1.Mandatory parameters are left unspecified;
805     *                                 2.Incorrect parameter types.
806     * @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized.
807     * @throws { BusinessError } 5400103 - I/O error.
808     * @syscap SystemCapability.Multimedia.SystemSound.Core
809     * @systemapi
810     * @since 12
811     */
812    addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, externalUri: string): Promise<string>;
813
814    /**
815     * Add customized tone into ringtone library.
816     * @permission ohos.permission.WRITE_RINGTONE
817     * @param { BaseContext } context - Current application context.
818     * @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}.
819     * @param { number } fd - File descriptor.
820     * @param { number } [offset] - The offset in the file where the data to be read, in bytes. By default, the offset
821     * is zero.
822     * @param { number } [length] - The length in bytes of the data to be read. By default, the length is the rest of
823     * bytes in the file from the offset.
824     * @returns { Promise<string> } Tone uri after adding into ringtone library.
825     * @throws { BusinessError } 201 - Permission denied.
826     * @throws { BusinessError } 202 - Caller is not a system application.
827     * @throws { BusinessError } 401 - Parameter error. Possible causes:
828     *                                 1.Mandatory parameters are left unspecified;
829     *                                 2.Incorrect parameter types.
830     * @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized.
831     * @throws { BusinessError } 5400103 - I/O error.
832     * @syscap SystemCapability.Multimedia.SystemSound.Core
833     * @systemapi
834     * @since 12
835     */
836    addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, fd: number, offset?: number, length?: number)
837      : Promise<string>;
838
839    /**
840     * Remove customized tone in ringtone library.
841     * @permission ohos.permission.WRITE_RINGTONE
842     * @param { BaseContext } context - Current application context.
843     * @param { string } uri - Tone uri.
844     * @returns { Promise<void> } Promise used to return removing result.
845     * @throws { BusinessError } 201 - Permission denied.
846     * @throws { BusinessError } 202 - Caller is not a system application.
847     * @throws { BusinessError } 401 - Parameter error. Possible causes:
848     *                                 1.Mandatory parameters are left unspecified;
849     *                                 2.Incorrect parameter types.
850     * @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone of this uri is not customized.
851     * @throws { BusinessError } 5400103 - I/O error.
852     * @syscap SystemCapability.Multimedia.SystemSound.Core
853     * @systemapi
854     * @since 12
855     */
856    removeCustomizedTone(context: BaseContext, uri:string): Promise<void>;
857
858    /**
859     * Get haptics settings.
860     * @param { BaseContext } context - Current application context.
861     * @param { ToneHapticsType } type - Tone haptics type.
862     * @returns { Promise<ToneHapticsSettings> } Promise used to return results of this call.
863     * @throws { BusinessError } 202 - Caller is not a system application.
864     * @throws { BusinessError } 401 - Parameter error. Possible causes:
865     *                                 1.Mandatory parameters are left unspecified;
866     *                                 2.Incorrect parameter types.
867     * @throws { BusinessError } 5400103 - I/O error.
868     * @throws { BusinessError } 20700003 - Unsupported operation.
869     * @syscap SystemCapability.Multimedia.SystemSound.Core
870     * @systemapi
871     * @since 13
872     */
873    getToneHapticsSettings(context: BaseContext, type: ToneHapticsType): Promise<ToneHapticsSettings>;
874
875    /**
876     * Set haptics settings.
877     * @param { BaseContext } context - Current application context.
878     * @param { ToneHapticsType } type - Tone haptics type.
879     * @param { ToneHapticsSettings } settings - Tone haptics settings.
880     * @returns { Promise<void> } Promise used to return results of this call.
881     * @throws { BusinessError } 202 - Caller is not a system application.
882     * @throws { BusinessError } 401 - Parameter error. Possible causes:
883     *                                 1.Mandatory parameters are left unspecified;
884     *                                 2.Incorrect parameter types.
885     * @throws { BusinessError } 5400102 - Operation not allowed. For example, the input URI is not valid.
886     * @throws { BusinessError } 5400103 - I/O error.
887     * @throws { BusinessError } 20700003 - Unsupported operation.
888     * @syscap SystemCapability.Multimedia.SystemSound.Core
889     * @systemapi
890     * @since 13
891     */
892    setToneHapticsSettings(context: BaseContext, type: ToneHapticsType, settings: ToneHapticsSettings): Promise<void>;
893
894    /**
895     * Get haptics list.
896     * @param { BaseContext } context - Current application context.
897     * @param { boolean } isSynced - The queried haptics is synchronized with tone or not.
898     * @returns { Promise<ToneHapticsAttrsArray> } Promise used to return ToneHapticsAttrsArray.
899     * @throws { BusinessError } 202 - Caller is not a system application.
900     * @throws { BusinessError } 401 - Parameter error. Possible causes:
901     *                                 1.Mandatory parameters are left unspecified;
902     *                                 2.Incorrect parameter types.
903     * @throws { BusinessError } 5400103 - I/O error.
904     * @throws { BusinessError } 20700003 - Unsupported operation.
905     * @syscap SystemCapability.Multimedia.SystemSound.Core
906     * @systemapi
907     * @since 13
908     */
909    getToneHapticsList(context: BaseContext, isSynced: boolean): Promise<ToneHapticsAttrsArray>;
910
911    /**
912     * Get attributes of haptics which is synchronized with one tone. If no haptics is found, then the attributes in
913     * the returned ToneHapticsAttrs is empty.
914     * @param { BaseContext } context - Current application context.
915     * @param { string } toneUri - Uri of tone to query.
916     * @returns { Promise<ToneHapticsAttrs> } Promise used to return ToneHapticsAttrs.
917     * @throws { BusinessError } 202 - Caller is not a system application.
918     * @throws { BusinessError } 401 - Parameter error. Possible causes:
919     *                                 1.Mandatory parameters are left unspecified;
920     *                                 2.Incorrect parameter types.
921     * @throws { BusinessError } 5400102 - Operation not allowed. For example, the input URI is not used for tones.
922     * @throws { BusinessError } 5400103 - I/O error.
923     * @throws { BusinessError } 20700003 - Unsupported operation.
924     * @syscap SystemCapability.Multimedia.SystemSound.Core
925     * @systemapi
926     * @since 13
927     */
928    getHapticsAttrsSyncedWithTone(context: BaseContext, toneUri: string): Promise<ToneHapticsAttrs>;
929
930    /**
931     * Open haptics.
932     * @param { BaseContext } context - Current application context.
933     * @param { string } hapticsUri - Uri of haptics to open.
934     * @returns { Promise<number> } Promise used to return fd.
935     * @throws { BusinessError } 202 - Caller is not a system application.
936     * @throws { BusinessError } 401 - Parameter error. Possible causes:
937     *                                 1.Mandatory parameters are left unspecified;
938     *                                 2.Incorrect parameter types.
939     * @throws { BusinessError } 5400102 - Operation not allowed. For example, the input URI is not one for haptics.
940     * @throws { BusinessError } 5400103 - I/O error.
941     * @throws { BusinessError } 20700003 - Unsupported operation.
942     * @syscap SystemCapability.Multimedia.SystemSound.Core
943     * @systemapi
944     * @since 13
945     */
946    openToneHaptics(context: BaseContext, hapticsUri: string): Promise<number>;
947  }
948
949  /**
950   * Ringtone player object.
951   * @typedef { _RingtonePlayer } RingtonePlayer
952   * @syscap SystemCapability.Multimedia.SystemSound.Core
953   * @systemapi
954   * @since 10
955   */
956  type RingtonePlayer = _RingtonePlayer;
957
958  /**
959   * SystemTone player object.
960   * @typedef { _SystemTonePlayer } SystemTonePlayer
961   * @syscap SystemCapability.Multimedia.SystemSound.Core
962   * @systemapi
963   * @since 11
964   */
965  type SystemTonePlayer = _SystemTonePlayer;
966
967  /**
968   * Interface for ringtone options.
969   * @typedef { _RingtoneOptions } RingtoneOptions
970   * @syscap SystemCapability.Multimedia.SystemSound.Core
971   * @systemapi
972   * @since 10
973   */
974  type RingtoneOptions = _RingtoneOptions;
975
976  /**
977   * System tone options.
978   * @typedef { _SystemToneOptions } SystemToneOptions
979   * @syscap SystemCapability.Multimedia.SystemSound.Core
980   * @systemapi
981   * @since 11
982   */
983  type SystemToneOptions = _SystemToneOptions;
984}
985
986export default systemSoundManager;