• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   * Gets system sound manager for all type sound.
118   * @returns { SystemSoundManager } SystemSoundManager instance.
119   * @syscap SystemCapability.Multimedia.SystemSound.Core
120   * @systemapi
121   * @since 10
122   */
123  function getSystemSoundManager(): SystemSoundManager;
124
125  /**
126   * System sound manager object.
127   * @typedef SystemSoundManager
128   * @syscap SystemCapability.Multimedia.SystemSound.Core
129   * @systemapi
130   * @since 10
131   */
132  interface SystemSoundManager {
133    /**
134     * Sets the ringtone uri to system.
135     * @param { Context } context - Current application context.
136     * @param { string } uri - Ringtone uri to set.
137     * @param { RingtoneType } type - Ringtone type to set.
138     * @param { AsyncCallback<void> } callback - Callback used to return the set uri result.
139     * @syscap SystemCapability.Multimedia.SystemSound.Core
140     * @systemapi
141     * @since 10
142     * @deprecated since 11
143     * @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri
144     */
145    setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback<void>): void;
146
147    /**
148     * Sets the ringtone uri to system.
149     * @param { Context } context - Current application context.
150     * @param { string } uri - Ringtone uri to set.
151     * @param { RingtoneType } type - Ringtone type to set.
152     * @returns { Promise<void> } Promise used to return the set uri result.
153     * @syscap SystemCapability.Multimedia.SystemSound.Core
154     * @systemapi
155     * @since 10
156     * @deprecated since 11
157     * @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri
158     */
159    setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise<void>;
160
161    /**
162     * Sets the ringtone uri to system.
163     * @param { BaseContext } context - Current application context.
164     * @param { string } uri - Ringtone uri to set.
165     * @param { RingtoneType } type - Ringtone type to set.
166     * @returns { Promise<void> } Promise used to return the set uri result.
167     * @throws { BusinessError } 202 - Caller is not a system application.
168     * @throws { BusinessError } 401 - Parameter error. Possible causes:
169     *         1.Mandatory parameters are left unspecified;
170     *         2.Incorrect parameter types.
171     * @throws { BusinessError } 5400103 - I/O error.
172     * @syscap SystemCapability.Multimedia.SystemSound.Core
173     * @systemapi
174     * @since 11
175     */
176    setRingtoneUri(context: BaseContext, uri: string, type: RingtoneType): Promise<void>;
177
178    /**
179     * Gets the ringtone uri.
180     * @param { Context } context - Current application context.
181     * @param { RingtoneType } type - Ringtone type to get.
182     * @param { AsyncCallback<string> } callback - Callback used to return the ringtone uri maintained in system.
183     * @syscap SystemCapability.Multimedia.SystemSound.Core
184     * @systemapi
185     * @since 10
186     * @deprecated since 11
187     * @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri
188     */
189    getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback<string>): void;
190
191    /**
192     * Gets the ringtone uri.
193     * @param { Context } context - Current application context.
194     * @param { RingtoneType } type - Ringtone type to get.
195     * @returns { Promise<string> } Promise used to return the ringtone uri maintained in system.
196     * @syscap SystemCapability.Multimedia.SystemSound.Core
197     * @systemapi
198     * @since 10
199     * @deprecated since 11
200     * @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri
201     */
202    getSystemRingtoneUri(context: Context, type: RingtoneType): Promise<string>;
203
204    /**
205     * Gets the ringtone uri.
206     * @param { BaseContext } context - Current application context.
207     * @param { RingtoneType } type - Ringtone type to get.
208     * @returns { Promise<string> } Promise used to return the ringtone uri maintained in system.
209     * @throws { BusinessError } 202 - Caller is not a system application.
210     * @throws { BusinessError } 401 - Parameter error. Possible causes:
211     *                                 1.Mandatory parameters are left unspecified;
212     *                                 2.Incorrect parameter types.
213     * @throws { BusinessError } 5400103 - I/O error.
214     * @syscap SystemCapability.Multimedia.SystemSound.Core
215     * @systemapi
216     * @since 11
217     */
218    getRingtoneUri(context: BaseContext, type: RingtoneType): Promise<string>;
219
220    /**
221     * Gets the ringtone player.
222     * @param { Context } context - Current application context.
223     * @param { RingtoneType } type - Ringtone type to get.
224     * @param { AsyncCallback<RingtonePlayer> } callback - Callback used to return a ringtone player instance.
225     * @syscap SystemCapability.Multimedia.SystemSound.Core
226     * @systemapi
227     * @since 10
228     * @deprecated since 11
229     * @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer
230     */
231    getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback<RingtonePlayer>): void;
232
233    /**
234     * Gets the ringtone player.
235     * @param { Context } context - Current application context.
236     * @param { RingtoneType } type - Ringtone type to get.
237     * @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance.
238     * @syscap SystemCapability.Multimedia.SystemSound.Core
239     * @systemapi
240     * @since 10
241     * @deprecated since 11
242     * @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer
243     */
244    getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise<RingtonePlayer>;
245
246    /**
247     * Gets the ringtone player.
248     * @param { BaseContext } context - Current application context.
249     * @param { RingtoneType } type - Ringtone type to get.
250     * @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance.
251     * @throws { BusinessError } 202 - Caller is not a system application.
252     * @throws { BusinessError } 401 - Parameter error. Possible causes:
253     *                                 1.Mandatory parameters are left unspecified;
254     *                                 2.Incorrect parameter types.
255     * @syscap SystemCapability.Multimedia.SystemSound.Core
256     * @systemapi
257     * @since 11
258     */
259    getRingtonePlayer(context: BaseContext, type: RingtoneType): Promise<RingtonePlayer>;
260
261    /**
262     * Sets the system tone uri to system.
263     * @param { BaseContext } context - Current application context.
264     * @param { string } uri - Ringtone uri to set.
265     * @param { SystemToneType } type - System tone type to set.
266     * @returns { Promise<void> } Promise used to return the result of set system tone uri.
267     * @throws { BusinessError } 202 - Caller is not a system application.
268     * @throws { BusinessError } 401 - Parameter error. Possible causes:
269     *                                 1.Mandatory parameters are left unspecified;
270     *                                 2.Incorrect parameter types.
271     * @throws { BusinessError } 5400103 - I/O error.
272     * @syscap SystemCapability.Multimedia.SystemSound.Core
273     * @systemapi
274     * @since 11
275     */
276    setSystemToneUri(context: BaseContext, uri: string, type: SystemToneType): Promise<void>;
277
278    /**
279     * Gets the system tone uri.
280     * @param { BaseContext } context - Current application context.
281     * @param { SystemToneType } type - System tone type to get.
282     * @returns { Promise<string> } Promise used to return the system tone maintained in system.
283     * @throws { BusinessError } 202 - Caller is not a system application.
284     * @throws { BusinessError } 401 - Parameter error. Possible causes:
285     *                                 1.Mandatory parameters are left unspecified;
286     *                                 2.Incorrect parameter types.
287     * @throws { BusinessError } 5400103 - I/O error.
288     * @syscap SystemCapability.Multimedia.SystemSound.Core
289     * @systemapi
290     * @since 11
291     */
292    getSystemToneUri(context: BaseContext, type: SystemToneType): Promise<string>;
293
294    /**
295     * Gets the system tone player.
296     * @param { BaseContext } context - Current application context.
297     * @param { SystemToneType } type - System tone type to get.
298     * @returns { Promise<SystemTonePlayer> } Promise used to return the SystemTonePlayer.
299     * @throws { BusinessError } 202 - Caller is not a system application.
300     * @throws { BusinessError } 401 - Parameter error. Possible causes:
301     *                                 1.Mandatory parameters are left unspecified;
302     *                                 2.Incorrect parameter types.
303     * @syscap SystemCapability.Multimedia.SystemSound.Core
304     * @systemapi
305     * @since 11
306     */
307    getSystemTonePlayer(context: BaseContext, type: SystemToneType): Promise<SystemTonePlayer>;
308  }
309
310  /**
311   * Ringtone player object.
312   * @typedef { _RingtonePlayer } RingtonePlayer
313   * @syscap SystemCapability.Multimedia.SystemSound.Core
314   * @systemapi
315   * @since 10
316   */
317  type RingtonePlayer = _RingtonePlayer;
318
319  /**
320   * SystemTone player object.
321   * @typedef { _SystemTonePlayer } SystemTonePlayer
322   * @syscap SystemCapability.Multimedia.SystemSound.Core
323   * @systemapi
324   * @since 11
325   */
326  type SystemTonePlayer = _SystemTonePlayer;
327
328  /**
329   * Interface for ringtone options.
330   * @typedef { _RingtoneOptions } RingtoneOptions
331   * @syscap SystemCapability.Multimedia.SystemSound.Core
332   * @systemapi
333   * @since 10
334   */
335  type RingtoneOptions = _RingtoneOptions;
336
337  /**
338   * System tone options.
339   * @typedef { _SystemToneOptions } SystemToneOptions
340   * @syscap SystemCapability.Multimedia.SystemSound.Core
341   * @systemapi
342   * @since 11
343   */
344  type SystemToneOptions = _SystemToneOptions;
345}
346
347export default systemSoundManager;