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 * Gets system sound manager for all type sound. 323 * @returns { SystemSoundManager } SystemSoundManager instance. 324 * @syscap SystemCapability.Multimedia.SystemSound.Core 325 * @systemapi 326 * @since 10 327 */ 328 function getSystemSoundManager(): SystemSoundManager; 329 330 /** 331 * System sound manager object. 332 * @typedef SystemSoundManager 333 * @syscap SystemCapability.Multimedia.SystemSound.Core 334 * @systemapi 335 * @since 10 336 */ 337 interface SystemSoundManager { 338 /** 339 * Sets the ringtone uri to system. 340 * @param { Context } context - Current application context. 341 * @param { string } uri - Ringtone uri to set. 342 * @param { RingtoneType } type - Ringtone type to set. 343 * @param { AsyncCallback<void> } callback - Callback used to return the set uri result. 344 * @syscap SystemCapability.Multimedia.SystemSound.Core 345 * @systemapi 346 * @since 10 347 * @deprecated since 11 348 * @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri 349 */ 350 setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback<void>): void; 351 352 /** 353 * Sets the ringtone uri to system. 354 * @param { Context } context - Current application context. 355 * @param { string } uri - Ringtone uri to set. 356 * @param { RingtoneType } type - Ringtone type to set. 357 * @returns { Promise<void> } Promise used to return the set uri result. 358 * @syscap SystemCapability.Multimedia.SystemSound.Core 359 * @systemapi 360 * @since 10 361 * @deprecated since 11 362 * @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri 363 */ 364 setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise<void>; 365 366 /** 367 * Sets the ringtone uri to system. 368 * @param { BaseContext } context - Current application context. 369 * @param { string } uri - Ringtone uri to set. 370 * @param { RingtoneType } type - Ringtone type to set. 371 * @returns { Promise<void> } Promise used to return the set uri result. 372 * @throws { BusinessError } 202 - Caller is not a system application. 373 * @throws { BusinessError } 401 - Parameter error. Possible causes: 374 * 1.Mandatory parameters are left unspecified; 375 * 2.Incorrect parameter types. 376 * @throws { BusinessError } 5400103 - I/O error. 377 * @syscap SystemCapability.Multimedia.SystemSound.Core 378 * @systemapi 379 * @since 11 380 */ 381 setRingtoneUri(context: BaseContext, uri: string, type: RingtoneType): Promise<void>; 382 383 /** 384 * Gets the ringtone uri. 385 * @param { Context } context - Current application context. 386 * @param { RingtoneType } type - Ringtone type to get. 387 * @param { AsyncCallback<string> } callback - Callback used to return the ringtone uri maintained in system. 388 * @syscap SystemCapability.Multimedia.SystemSound.Core 389 * @systemapi 390 * @since 10 391 * @deprecated since 11 392 * @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri 393 */ 394 getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback<string>): void; 395 396 /** 397 * Gets the ringtone uri. 398 * @param { Context } context - Current application context. 399 * @param { RingtoneType } type - Ringtone type to get. 400 * @returns { Promise<string> } Promise used to return the ringtone uri maintained in system. 401 * @syscap SystemCapability.Multimedia.SystemSound.Core 402 * @systemapi 403 * @since 10 404 * @deprecated since 11 405 * @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri 406 */ 407 getSystemRingtoneUri(context: Context, type: RingtoneType): Promise<string>; 408 409 /** 410 * Gets the ringtone uri. 411 * @param { BaseContext } context - Current application context. 412 * @param { RingtoneType } type - Ringtone type to get. 413 * @returns { Promise<string> } Promise used to return the ringtone uri maintained in system. 414 * @throws { BusinessError } 202 - Caller is not a system application. 415 * @throws { BusinessError } 401 - Parameter error. Possible causes: 416 * 1.Mandatory parameters are left unspecified; 417 * 2.Incorrect parameter types. 418 * @throws { BusinessError } 5400103 - I/O error. 419 * @syscap SystemCapability.Multimedia.SystemSound.Core 420 * @systemapi 421 * @since 11 422 */ 423 getRingtoneUri(context: BaseContext, type: RingtoneType): Promise<string>; 424 425 /** 426 * Gets attributes of the default ringtone. 427 * @param { BaseContext } context - Current application context. 428 * @param { RingtoneType } type - Ringtone type to get. 429 * @returns { Promise<ToneAttrs> } Promise used to return attributes of the default ringtone. 430 * @throws { BusinessError } 202 - Caller is not a system application. 431 * @throws { BusinessError } 401 - Parameter error. Possible causes: 432 * 1.Mandatory parameters are left unspecified; 433 * 2.Incorrect parameter types. 434 * @throws { BusinessError } 5400103 - I/O error. 435 * @syscap SystemCapability.Multimedia.SystemSound.Core 436 * @systemapi 437 * @since 12 438 */ 439 getDefaultRingtoneAttrs(context: BaseContext, type: RingtoneType): Promise<ToneAttrs>; 440 441 /** 442 * Gets attribute list of ringtones. 443 * @param { BaseContext } context - Current application context. 444 * @param { RingtoneType } type - Ringtone type to get. 445 * @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of ringtone. 446 * @throws { BusinessError } 202 - Caller is not a system application. 447 * @throws { BusinessError } 401 - Parameter error. Possible causes: 448 * 1.Mandatory parameters are left unspecified; 449 * 2.Incorrect parameter types. 450 * @throws { BusinessError } 5400103 - I/O error. 451 * @syscap SystemCapability.Multimedia.SystemSound.Core 452 * @systemapi 453 * @since 12 454 */ 455 getRingtoneAttrList(context: BaseContext, type: RingtoneType): Promise<ToneAttrsArray>; 456 457 /** 458 * Gets the ringtone player. 459 * @param { Context } context - Current application context. 460 * @param { RingtoneType } type - Ringtone type to get. 461 * @param { AsyncCallback<RingtonePlayer> } callback - Callback used to return a ringtone player instance. 462 * @syscap SystemCapability.Multimedia.SystemSound.Core 463 * @systemapi 464 * @since 10 465 * @deprecated since 11 466 * @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer 467 */ 468 getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback<RingtonePlayer>): void; 469 470 /** 471 * Gets the ringtone player. 472 * @param { Context } context - Current application context. 473 * @param { RingtoneType } type - Ringtone type to get. 474 * @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance. 475 * @syscap SystemCapability.Multimedia.SystemSound.Core 476 * @systemapi 477 * @since 10 478 * @deprecated since 11 479 * @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer 480 */ 481 getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise<RingtonePlayer>; 482 483 /** 484 * Gets the ringtone player. 485 * @param { BaseContext } context - Current application context. 486 * @param { RingtoneType } type - Ringtone type to get. 487 * @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance. 488 * @throws { BusinessError } 202 - Caller is not a system application. 489 * @throws { BusinessError } 401 - Parameter error. Possible causes: 490 * 1.Mandatory parameters are left unspecified; 491 * 2.Incorrect parameter types. 492 * @syscap SystemCapability.Multimedia.SystemSound.Core 493 * @systemapi 494 * @since 11 495 */ 496 getRingtonePlayer(context: BaseContext, type: RingtoneType): Promise<RingtonePlayer>; 497 498 /** 499 * Sets the system tone uri to system. 500 * @param { BaseContext } context - Current application context. 501 * @param { string } uri - Ringtone uri to set. 502 * @param { SystemToneType } type - System tone type to set. 503 * @returns { Promise<void> } Promise used to return the result of set system tone uri. 504 * @throws { BusinessError } 202 - Caller is not a system application. 505 * @throws { BusinessError } 401 - Parameter error. Possible causes: 506 * 1.Mandatory parameters are left unspecified; 507 * 2.Incorrect parameter types. 508 * @throws { BusinessError } 5400103 - I/O error. 509 * @syscap SystemCapability.Multimedia.SystemSound.Core 510 * @systemapi 511 * @since 11 512 */ 513 setSystemToneUri(context: BaseContext, uri: string, type: SystemToneType): Promise<void>; 514 515 /** 516 * Gets the system tone uri. 517 * @param { BaseContext } context - Current application context. 518 * @param { SystemToneType } type - System tone type to get. 519 * @returns { Promise<string> } Promise used to return the system tone maintained in system. 520 * @throws { BusinessError } 202 - Caller is not a system application. 521 * @throws { BusinessError } 401 - Parameter error. Possible causes: 522 * 1.Mandatory parameters are left unspecified; 523 * 2.Incorrect parameter types. 524 * @throws { BusinessError } 5400103 - I/O error. 525 * @syscap SystemCapability.Multimedia.SystemSound.Core 526 * @systemapi 527 * @since 11 528 */ 529 getSystemToneUri(context: BaseContext, type: SystemToneType): Promise<string>; 530 531 /** 532 * Gets attributes of the default system tone. 533 * 534 * @param { BaseContext } context - Current application context. 535 * @param { SystemToneType } type - system tone type to get. 536 * @returns { Promise<ToneAttrs> } Promise used to return attributes of the default system tone. 537 * @throws { BusinessError } 202 - Caller is not a system application. 538 * @throws { BusinessError } 401 - Parameter error. Possible causes: 539 * 1.Mandatory parameters are left unspecified; 540 * 2.Incorrect parameter types. 541 * @throws { BusinessError } 5400103 - I/O error. 542 * @syscap SystemCapability.Multimedia.SystemSound.Core 543 * @systemapi 544 * @since 12 545 */ 546 getDefaultSystemToneAttrs(context: BaseContext, type: SystemToneType): Promise<ToneAttrs>; 547 548 /** 549 * Gets attribute list of alarm tones. 550 * @param { BaseContext } context - Current application context. 551 * @param { SystemToneType } type - System tone type to get. 552 * @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of system tone. 553 * @throws { BusinessError } 202 - Caller is not a system application. 554 * @throws { BusinessError } 401 - Parameter error. Possible causes: 555 * 1.Mandatory parameters are left unspecified; 556 * 2.Incorrect parameter types. 557 * @throws { BusinessError } 5400103 - I/O error. 558 * @syscap SystemCapability.Multimedia.SystemSound.Core 559 * @systemapi 560 * @since 12 561 */ 562 getSystemToneAttrList(context: BaseContext, type: SystemToneType): Promise<ToneAttrsArray>; 563 564 /** 565 * Gets the system tone player. 566 * @param { BaseContext } context - Current application context. 567 * @param { SystemToneType } type - System tone type to get. 568 * @returns { Promise<SystemTonePlayer> } Promise used to return the SystemTonePlayer. 569 * @throws { BusinessError } 202 - Caller is not a system application. 570 * @throws { BusinessError } 401 - Parameter error. Possible causes: 571 * 1.Mandatory parameters are left unspecified; 572 * 2.Incorrect parameter types. 573 * @syscap SystemCapability.Multimedia.SystemSound.Core 574 * @systemapi 575 * @since 11 576 */ 577 getSystemTonePlayer(context: BaseContext, type: SystemToneType): Promise<SystemTonePlayer>; 578 579 /** 580 * Gets attributes of the default alarm tone. 581 * 582 * @param { BaseContext } context - Current application context. 583 * @returns { Promise<ToneAttrs> } Promise used to return attributes of the default alarm tone. 584 * @throws { BusinessError } 202 - Caller is not a system application. 585 * @throws { BusinessError } 401 - Parameter error. Possible causes: 586 * 1.Mandatory parameters are left unspecified; 587 * 2.Incorrect parameter types. 588 * @throws { BusinessError } 5400103 - I/O error. 589 * @syscap SystemCapability.Multimedia.SystemSound.Core 590 * @systemapi 591 * @since 12 592 */ 593 getDefaultAlarmToneAttrs(context: BaseContext): Promise<ToneAttrs>; 594 595 /** 596 * Sets uri of the current alarm tone. 597 * 598 * @param { BaseContext } context - Current application context. 599 * @param { string } uri - Alarm tone uri. 600 * @returns { Promise<void> } Promise used to return result of set alarm tone. 601 * @throws { BusinessError } 202 - Caller is not a system application. 602 * @throws { BusinessError } 401 - Parameter error. Possible causes: 603 * 1.Mandatory parameters are left unspecified; 604 * 2.Incorrect parameter types. 605 * @throws { BusinessError } 5400103 - I/O error. 606 * @throws { BusinessError } 20700001 - Tone type mismatch, e.g. tone of input uri is not an alarm tone. 607 * @syscap SystemCapability.Multimedia.SystemSound.Core 608 * @systemapi 609 * @since 12 610 */ 611 setAlarmToneUri(context: BaseContext, uri: string): Promise<void>; 612 613 /** 614 * Gets uri of the current alarm tone. 615 * 616 * @param { BaseContext } context - Current application context. 617 * @returns { Promise<string> } Promise used to return uri of current alarm tone. 618 * @throws { BusinessError } 202 - Caller is not a system application. 619 * @throws { BusinessError } 401 - Parameter error. Possible causes: 620 * 1.Mandatory parameters are left unspecified; 621 * 2.Incorrect parameter types. 622 * @throws { BusinessError } 5400103 - I/O error. 623 * @syscap SystemCapability.Multimedia.SystemSound.Core 624 * @systemapi 625 * @since 12 626 */ 627 getAlarmToneUri(context: BaseContext): Promise<string>; 628 629 /** 630 * Gets attribute list of alarm tones. 631 * @param { BaseContext } context - Current application context. 632 * @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of system tone. 633 * @throws { BusinessError } 202 - Caller is not a system application. 634 * @throws { BusinessError } 401 - Parameter error. Possible causes: 635 * 1.Mandatory parameters are left unspecified; 636 * 2.Incorrect parameter types. 637 * @throws { BusinessError } 5400103 - I/O error. 638 * @syscap SystemCapability.Multimedia.SystemSound.Core 639 * @systemapi 640 * @since 12 641 */ 642 getAlarmToneAttrList(context: BaseContext): Promise<ToneAttrsArray>; 643 644 /** 645 * Open alarm tone file. 646 * @param { BaseContext } context - Current application context. 647 * @param { string } uri - Uri of alarm tone to open. 648 * @returns { Promise<number> } Promise used to return fd. 649 * @throws { BusinessError } 202 - Caller is not a system application. 650 * @throws { BusinessError } 401 - Parameter error. Possible causes: 651 * 1.Mandatory parameters are left unspecified; 652 * 2.Incorrect parameter types. 653 * @throws { BusinessError } 5400103 - I/O error. 654 * @throws { BusinessError } 20700001 - Tone type mismatch, e.g. tone of uri is notification instead of alarm. 655 * @syscap SystemCapability.Multimedia.SystemSound.Core 656 * @systemapi 657 * @since 12 658 */ 659 openAlarmTone(context: BaseContext, uri: string): Promise<number> 660 661 /** 662 * Close fd. 663 * @param { number } fd - File descriptor to close. 664 * @returns { Promise<void> } Promise used to return the result of close fd. 665 * @throws { BusinessError } 202 - Caller is not a system application. 666 * @throws { BusinessError } 401 - Parameter error. Possible causes: 667 * 1.Mandatory parameters are left unspecified; 668 * 2.Incorrect parameter types. 669 * @throws { BusinessError } 5400103 - I/O error. 670 * @syscap SystemCapability.Multimedia.SystemSound.Core 671 * @systemapi 672 * @since 12 673 */ 674 close(fd: number): Promise<void>; 675 676 /** 677 * Add customized tone into ringtone library. 678 * @permission ohos.permission.WRITE_RINGTONE 679 * @param { BaseContext } context - Current application context. 680 * @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}. 681 * @param { string } externalUri - Tone uri in external storage. 682 * @returns { Promise<string> } Tone uri after adding into ringtone library. 683 * @throws { BusinessError } 201 - Permission denied. 684 * @throws { BusinessError } 202 - Caller is not a system application. 685 * @throws { BusinessError } 401 - Parameter error. Possible causes: 686 * 1.Mandatory parameters are left unspecified; 687 * 2.Incorrect parameter types. 688 * @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized. 689 * @throws { BusinessError } 5400103 - I/O error. 690 * @syscap SystemCapability.Multimedia.SystemSound.Core 691 * @systemapi 692 * @since 12 693 */ 694 addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, externalUri: string): Promise<string>; 695 696 /** 697 * Add customized tone into ringtone library. 698 * @permission ohos.permission.WRITE_RINGTONE 699 * @param { BaseContext } context - Current application context. 700 * @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}. 701 * @param { number } fd - File descriptor. 702 * @param { number } [offset] - The offset in the file where the data to be read, in bytes. By default, the offset 703 * is zero. 704 * @param { number } [length] - The length in bytes of the data to be read. By default, the length is the rest of 705 * bytes in the file from the offset. 706 * @returns { Promise<string> } Tone uri after adding into ringtone library. 707 * @throws { BusinessError } 201 - Permission denied. 708 * @throws { BusinessError } 202 - Caller is not a system application. 709 * @throws { BusinessError } 401 - Parameter error. Possible causes: 710 * 1.Mandatory parameters are left unspecified; 711 * 2.Incorrect parameter types. 712 * @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized. 713 * @throws { BusinessError } 5400103 - I/O error. 714 * @syscap SystemCapability.Multimedia.SystemSound.Core 715 * @systemapi 716 * @since 12 717 */ 718 addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, fd: number, offset?: number, length?: number) 719 : Promise<string>; 720 721 /** 722 * Remove customized tone in ringtone library. 723 * @permission ohos.permission.WRITE_RINGTONE 724 * @param { BaseContext } context - Current application context. 725 * @param { string } uri - Tone uri. 726 * @returns { Promise<void> } Promise used to return removing result. 727 * @throws { BusinessError } 201 - Permission denied. 728 * @throws { BusinessError } 202 - Caller is not a system application. 729 * @throws { BusinessError } 401 - Parameter error. Possible causes: 730 * 1.Mandatory parameters are left unspecified; 731 * 2.Incorrect parameter types. 732 * @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone of this uri is not customized. 733 * @throws { BusinessError } 5400103 - I/O error. 734 * @syscap SystemCapability.Multimedia.SystemSound.Core 735 * @systemapi 736 * @since 12 737 */ 738 removeCustomizedTone(context: BaseContext, uri:string): Promise<void>; 739 } 740 741 /** 742 * Ringtone player object. 743 * @typedef { _RingtonePlayer } RingtonePlayer 744 * @syscap SystemCapability.Multimedia.SystemSound.Core 745 * @systemapi 746 * @since 10 747 */ 748 type RingtonePlayer = _RingtonePlayer; 749 750 /** 751 * SystemTone player object. 752 * @typedef { _SystemTonePlayer } SystemTonePlayer 753 * @syscap SystemCapability.Multimedia.SystemSound.Core 754 * @systemapi 755 * @since 11 756 */ 757 type SystemTonePlayer = _SystemTonePlayer; 758 759 /** 760 * Interface for ringtone options. 761 * @typedef { _RingtoneOptions } RingtoneOptions 762 * @syscap SystemCapability.Multimedia.SystemSound.Core 763 * @systemapi 764 * @since 10 765 */ 766 type RingtoneOptions = _RingtoneOptions; 767 768 /** 769 * System tone options. 770 * @typedef { _SystemToneOptions } SystemToneOptions 771 * @syscap SystemCapability.Multimedia.SystemSound.Core 772 * @systemapi 773 * @since 11 774 */ 775 type SystemToneOptions = _SystemToneOptions; 776} 777 778export default systemSoundManager;