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 * @syscap SystemCapability.Multimedia.SystemSound.Core 143 * @systemapi 144 * @since 12 145 */ 146 const TONE_CATEGORY_RINGTONE: number; 147 148 /** 149 * Define the text message tone category. 150 * @syscap SystemCapability.Multimedia.SystemSound.Core 151 * @systemapi 152 * @since 12 153 */ 154 const TONE_CATEGORY_TEXT_MESSAGE:number; 155 156 /** 157 * Define the notification tone category. 158 * @syscap SystemCapability.Multimedia.SystemSound.Core 159 * @systemapi 160 * @since 12 161 */ 162 const TONE_CATEGORY_NOTIFICATION:number; 163 164 /** 165 * Define the alarm tone category. 166 * @syscap SystemCapability.Multimedia.SystemSound.Core 167 * @systemapi 168 * @since 12 169 */ 170 const TONE_CATEGORY_ALARM:number; 171 172 /** 173 * Tone attributes. 174 * @typedef ToneAttrs 175 * @syscap SystemCapability.Multimedia.SystemSound.Core 176 * @systemapi 177 * @since 12 178 */ 179 interface ToneAttrs { 180 /** 181 * Gets title of tone. 182 * @returns { string } title. 183 * @throws { BusinessError } 202 - Caller is not a system application. 184 * @syscap SystemCapability.Multimedia.SystemSound.Core 185 * @systemapi 186 * @since 12 187 */ 188 getTitle(): string; 189 190 /** 191 * Sets title of tone. 192 * @param { string } title - Title of tone. 193 * @throws { BusinessError } 202 - Caller is not a system application. 194 * @throws { BusinessError } 401 - Parameter error. Possible causes: 195 * 1.Mandatory parameters are left unspecified; 196 * 2.Incorrect parameter types. 197 * @syscap SystemCapability.Multimedia.SystemSound.Core 198 * @systemapi 199 * @since 12 200 */ 201 setTitle(title: string): void; 202 203 /** 204 * Gets file name of tone. 205 * @returns { string } file name. 206 * @throws { BusinessError } 202 - Caller is not a system application. 207 * @syscap SystemCapability.Multimedia.SystemSound.Core 208 * @systemapi 209 * @since 12 210 */ 211 getFileName(): string; 212 213 /** 214 * Sets file name of tone. 215 * @param { string } name - file name. 216 * @throws { BusinessError } 202 - Caller is not a system application. 217 * @throws { BusinessError } 401 - Parameter error. Possible causes: 218 * 1.Mandatory parameters are left unspecified; 219 * 2.Incorrect parameter types. 220 * @syscap SystemCapability.Multimedia.SystemSound.Core 221 * @systemapi 222 * @since 12 223 */ 224 setFileName(name: string): void; 225 226 /** 227 * Gets uri of tone. 228 * @returns { string } uri. 229 * @throws { BusinessError } 202 - Caller is not a system application. 230 * @syscap SystemCapability.Multimedia.SystemSound.Core 231 * @systemapi 232 * @since 12 233 */ 234 getUri(): string; 235 236 /** 237 * Gets customized type of tone. 238 * @returns { ToneCustomizedType } Customized type of tone. 239 * @throws { BusinessError } 202 - Caller is not a system application. 240 * @syscap SystemCapability.Multimedia.SystemSound.Core 241 * @systemapi 242 * @since 12 243 */ 244 getCustomizedType(): ToneCustomizedType; 245 246 /** 247 * Sets tone category. 248 * @param { number } category - tone category. This parameter can be one of {@link TONE_CATEGORY_RINGTONE}, 249 * {@link TONE_CATEGORY_TEXT_MESSAGE}, {@link TONE_CATEGORY_NOTIFICATION}, {@link TONE_CATEGORY_ALARM}. 250 * In addition, this parameter can be result of OR logical operator of these constants. 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 12 258 */ 259 setCategory(category: number): void; 260 261 /** 262 * Gets tone category. 263 * @returns { number } Tone category. This value can be one of {@link TONE_CATEGORY_RINGTONE}, 264 * {@link TONE_CATEGORY_TEXT_MESSAGE}, {@link TONE_CATEGORY_NOTIFICATION}, {@link TONE_CATEGORY_ALARM}. 265 * In addition, this value can be result of OR logical operator of these constants. 266 * @throws { BusinessError } 202 - Caller is not a system application. 267 * @syscap SystemCapability.Multimedia.SystemSound.Core 268 * @systemapi 269 * @since 12 270 */ 271 getCategory(): number; 272 } 273 274 /** 275 * Array of tone attributes. 276 * 277 * @typedef {Array<ToneAttrs>} ToneAttrsArray 278 * @syscap SystemCapability.Multimedia.SystemSound.Core 279 * @systemapi 280 * @since 12 281 */ 282 type ToneAttrsArray = Array<ToneAttrs>; 283 284 /** 285 * Create customized tone attributes. 286 * @returns { ToneAttrs } Tone attributes created. 287 * @throws { BusinessError } 202 - Caller is not a system application. 288 * @syscap SystemCapability.Multimedia.SystemSound.Core 289 * @systemapi 290 * @since 12 291 */ 292 function createCustomizedToneAttrs(): ToneAttrs; 293 294 /** 295 * Definition of haptics feature in tone scenario. 296 * @enum { number } 297 * @syscap SystemCapability.Multimedia.SystemSound.Core 298 * @systemapi 299 * @since 13 300 */ 301 enum ToneHapticsFeature { 302 /** 303 * Standard haptics feature. 304 * @syscap SystemCapability.Multimedia.SystemSound.Core 305 * @systemapi 306 * @since 13 307 */ 308 STANDARD = 0, 309 /** 310 * Gentle haptics feature. 311 * @syscap SystemCapability.Multimedia.SystemSound.Core 312 * @systemapi 313 * @since 13 314 */ 315 GENTLE = 1, 316 } 317 /** 318 * Enum for haptics in tone scenario. 319 * 320 * @enum { number } 321 * @syscap SystemCapability.Multimedia.SystemSound.Core 322 * @systemapi 323 * @since 14 324 */ 325 enum ToneHapticsType { 326 /** 327 * Haptics in incoming call scenario for sim card 0. 328 * @syscap SystemCapability.Multimedia.SystemSound.Core 329 * @systemapi 330 * @since 14 331 */ 332 CALL_SIM_CARD_0 = 0, 333 334 /** 335 * Haptics in incoming call scenario for sim card 1. 336 * @syscap SystemCapability.Multimedia.SystemSound.Core 337 * @systemapi 338 * @since 14 339 */ 340 CALL_SIM_CARD_1 = 1, 341 342 /** 343 * Haptics in text message scenario for sim card 0. 344 * @syscap SystemCapability.Multimedia.SystemSound.Core 345 * @systemapi 346 * @since 14 347 */ 348 TEXT_MESSAGE_SIM_CARD_0 = 20, 349 350 /** 351 * Haptics in text message scenario for sim card 1. 352 * @syscap SystemCapability.Multimedia.SystemSound.Core 353 * @systemapi 354 * @since 14 355 */ 356 TEXT_MESSAGE_SIM_CARD_1 = 21, 357 358 /** 359 * Haptics in notification scenario. 360 * @syscap SystemCapability.Multimedia.SystemSound.Core 361 * @systemapi 362 * @since 14 363 */ 364 NOTIFICATION = 40, 365 } 366 367 /** 368 * Enum for haptics mode in tone scenario. 369 * @enum {number} 370 * @syscap SystemCapability.Multimedia.SystemSound.Core 371 * @systemapi 372 * @since 14 373 */ 374 enum ToneHapticsMode { 375 /** 376 * None haptics mode. 377 * @syscap SystemCapability.Multimedia.SystemSound.Core 378 * @systemapi 379 * @since 14 380 */ 381 NONE = 0, 382 /** 383 * Haptics is synchronized with tone. 384 * @syscap SystemCapability.Multimedia.SystemSound.Core 385 * @systemapi 386 * @since 14 387 */ 388 SYNC = 1, 389 390 /** 391 * Haptics is out of synchronize with tone. 392 * @syscap SystemCapability.Multimedia.SystemSound.Core 393 * @systemapi 394 * @since 14 395 */ 396 NON_SYNC = 2, 397 } 398 /** 399 * Haptics settings in tone scenario. 400 * @typedef ToneHapticsSettings 401 * @syscap SystemCapability.Multimedia.SystemSound.Core 402 * @systemapi 403 * @since 14 404 */ 405 interface ToneHapticsSettings { 406 /** 407 * Haptics mode. 408 * @type { ToneHapticsMode } 409 * @syscap SystemCapability.Multimedia.SystemSound.Core 410 * @systemapi 411 * @since 14 412 */ 413 mode: ToneHapticsMode; 414 /** 415 * Haptics uri. Users can set/get this parameter when {@link ToneHapticsSettings#mode} is 416 * {@link ToneHapticsMode#NON_SYC}. In other cases, this uri is useless and should be ignored. 417 * @type { ?string } 418 * @syscap SystemCapability.Multimedia.SystemSound.Core 419 * @systemapi 420 * @since 14 421 */ 422 hapticsUri?: string; 423 } 424 425 /** 426 * Haptics attributes in tone scenario. 427 * @typedef ToneHapticsAttrs 428 * @syscap SystemCapability.Multimedia.SystemSound.Core 429 * @systemapi 430 * @since 14 431 */ 432 interface ToneHapticsAttrs { 433 /** 434 * Get haptics uri. 435 * @returns { string } Haptics uri. 436 * @throws { BusinessError } 202 - Caller is not a system application. 437 * @syscap SystemCapability.Multimedia.SystemSound.Core 438 * @systemapi 439 * @since 14 440 */ 441 getUri(): string; 442 443 /** 444 * Get title of haptics. 445 * @returns { string } Haptics title. 446 * @throws { BusinessError } 202 - Caller is not a system application. 447 * @syscap SystemCapability.Multimedia.SystemSound.Core 448 * @systemapi 449 * @since 14 450 */ 451 getTitle(): string; 452 453 /** 454 * Get file name of haptics. 455 * @returns { string } Haptics title. 456 * @throws { BusinessError } 202 - Caller is not a system application. 457 * @syscap SystemCapability.Multimedia.SystemSound.Core 458 * @systemapi 459 * @since 14 460 */ 461 getFileName(): string; 462 } 463 464 /** 465 * Type definition of tone haptics array. 466 * 467 * @typedef { Array<ToneHapticsAttrs> } ToneHapticsAttrsArray 468 * @syscap SystemCapability.Multimedia.SystemSound.Core 469 * @systemapi 470 * @since 14 471 */ 472 type ToneHapticsAttrsArray = Array<ToneHapticsAttrs>; 473 474 475 /** 476 * Gets system sound manager for all type sound. 477 * @returns { SystemSoundManager } SystemSoundManager instance. 478 * @syscap SystemCapability.Multimedia.SystemSound.Core 479 * @systemapi 480 * @since 10 481 */ 482 function getSystemSoundManager(): SystemSoundManager; 483 484 /** 485 * System sound manager object. 486 * @typedef SystemSoundManager 487 * @syscap SystemCapability.Multimedia.SystemSound.Core 488 * @systemapi 489 * @since 10 490 */ 491 interface SystemSoundManager { 492 /** 493 * Sets the ringtone uri to system. 494 * @param { Context } context - Current application context. 495 * @param { string } uri - Ringtone uri to set. 496 * @param { RingtoneType } type - Ringtone type to set. 497 * @param { AsyncCallback<void> } callback - Callback used to return the set uri result. 498 * @syscap SystemCapability.Multimedia.SystemSound.Core 499 * @systemapi 500 * @since 10 501 * @deprecated since 11 502 * @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri 503 */ 504 setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback<void>): void; 505 506 /** 507 * Sets the ringtone uri to system. 508 * @param { Context } context - Current application context. 509 * @param { string } uri - Ringtone uri to set. 510 * @param { RingtoneType } type - Ringtone type to set. 511 * @returns { Promise<void> } Promise used to return the set uri result. 512 * @syscap SystemCapability.Multimedia.SystemSound.Core 513 * @systemapi 514 * @since 10 515 * @deprecated since 11 516 * @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri 517 */ 518 setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise<void>; 519 520 /** 521 * Sets the ringtone uri to system. 522 * @param { BaseContext } context - Current application context. 523 * @param { string } uri - Ringtone uri to set. 524 * @param { RingtoneType } type - Ringtone type to set. 525 * @returns { Promise<void> } Promise used to return the set uri result. 526 * @throws { BusinessError } 202 - Caller is not a system application. 527 * @throws { BusinessError } 401 - Parameter error. Possible causes: 528 * 1.Mandatory parameters are left unspecified; 529 * 2.Incorrect parameter types. 530 * @throws { BusinessError } 5400103 - I/O error. 531 * @syscap SystemCapability.Multimedia.SystemSound.Core 532 * @systemapi 533 * @since 11 534 */ 535 setRingtoneUri(context: BaseContext, uri: string, type: RingtoneType): Promise<void>; 536 537 /** 538 * Gets the ringtone uri. 539 * @param { Context } context - Current application context. 540 * @param { RingtoneType } type - Ringtone type to get. 541 * @param { AsyncCallback<string> } callback - Callback used to return the ringtone uri maintained in system. 542 * @syscap SystemCapability.Multimedia.SystemSound.Core 543 * @systemapi 544 * @since 10 545 * @deprecated since 11 546 * @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri 547 */ 548 getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback<string>): void; 549 550 /** 551 * Gets the ringtone uri. 552 * @param { Context } context - Current application context. 553 * @param { RingtoneType } type - Ringtone type to get. 554 * @returns { Promise<string> } Promise used to return the ringtone uri maintained in system. 555 * @syscap SystemCapability.Multimedia.SystemSound.Core 556 * @systemapi 557 * @since 10 558 * @deprecated since 11 559 * @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri 560 */ 561 getSystemRingtoneUri(context: Context, type: RingtoneType): Promise<string>; 562 563 /** 564 * Gets the ringtone uri. 565 * @param { BaseContext } context - Current application context. 566 * @param { RingtoneType } type - Ringtone type to get. 567 * @returns { Promise<string> } Promise used to return the ringtone uri maintained in system. 568 * @throws { BusinessError } 202 - Caller is not a system application. 569 * @throws { BusinessError } 401 - Parameter error. Possible causes: 570 * 1.Mandatory parameters are left unspecified; 571 * 2.Incorrect parameter types. 572 * @throws { BusinessError } 5400103 - I/O error. 573 * @syscap SystemCapability.Multimedia.SystemSound.Core 574 * @systemapi 575 * @since 11 576 */ 577 getRingtoneUri(context: BaseContext, type: RingtoneType): Promise<string>; 578 579 /** 580 * Gets attributes of the default ringtone. 581 * @param { BaseContext } context - Current application context. 582 * @param { RingtoneType } type - Ringtone type to get. 583 * @returns { Promise<ToneAttrs> } Promise used to return attributes of the default ringtone. 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 getDefaultRingtoneAttrs(context: BaseContext, type: RingtoneType): Promise<ToneAttrs>; 594 595 /** 596 * Gets attribute list of ringtones. 597 * @param { BaseContext } context - Current application context. 598 * @param { RingtoneType } type - Ringtone type to get. 599 * @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of ringtone. 600 * @throws { BusinessError } 202 - Caller is not a system application. 601 * @throws { BusinessError } 401 - Parameter error. Possible causes: 602 * 1.Mandatory parameters are left unspecified; 603 * 2.Incorrect parameter types. 604 * @throws { BusinessError } 5400103 - I/O error. 605 * @syscap SystemCapability.Multimedia.SystemSound.Core 606 * @systemapi 607 * @since 12 608 */ 609 getRingtoneAttrList(context: BaseContext, type: RingtoneType): Promise<ToneAttrsArray>; 610 611 /** 612 * Gets the ringtone player. 613 * @param { Context } context - Current application context. 614 * @param { RingtoneType } type - Ringtone type to get. 615 * @param { AsyncCallback<RingtonePlayer> } callback - Callback used to return a ringtone player instance. 616 * @syscap SystemCapability.Multimedia.SystemSound.Core 617 * @systemapi 618 * @since 10 619 * @deprecated since 11 620 * @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer 621 */ 622 getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback<RingtonePlayer>): void; 623 624 /** 625 * Gets the ringtone player. 626 * @param { Context } context - Current application context. 627 * @param { RingtoneType } type - Ringtone type to get. 628 * @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance. 629 * @syscap SystemCapability.Multimedia.SystemSound.Core 630 * @systemapi 631 * @since 10 632 * @deprecated since 11 633 * @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer 634 */ 635 getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise<RingtonePlayer>; 636 637 /** 638 * Gets the ringtone player. 639 * @param { BaseContext } context - Current application context. 640 * @param { RingtoneType } type - Ringtone type to get. 641 * @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance. 642 * @throws { BusinessError } 202 - Caller is not a system application. 643 * @throws { BusinessError } 401 - Parameter error. Possible causes: 644 * 1.Mandatory parameters are left unspecified; 645 * 2.Incorrect parameter types. 646 * @syscap SystemCapability.Multimedia.SystemSound.Core 647 * @systemapi 648 * @since 11 649 */ 650 getRingtonePlayer(context: BaseContext, type: RingtoneType): Promise<RingtonePlayer>; 651 652 /** 653 * Sets the system tone uri to system. 654 * @param { BaseContext } context - Current application context. 655 * @param { string } uri - Ringtone uri to set. 656 * @param { SystemToneType } type - System tone type to set. 657 * @returns { Promise<void> } Promise used to return the result of set system tone uri. 658 * @throws { BusinessError } 202 - Caller is not a system application. 659 * @throws { BusinessError } 401 - Parameter error. Possible causes: 660 * 1.Mandatory parameters are left unspecified; 661 * 2.Incorrect parameter types. 662 * @throws { BusinessError } 5400103 - I/O error. 663 * @syscap SystemCapability.Multimedia.SystemSound.Core 664 * @systemapi 665 * @since 11 666 */ 667 setSystemToneUri(context: BaseContext, uri: string, type: SystemToneType): Promise<void>; 668 669 /** 670 * Gets the system tone uri. 671 * @param { BaseContext } context - Current application context. 672 * @param { SystemToneType } type - System tone type to get. 673 * @returns { Promise<string> } Promise used to return the system tone maintained in system. 674 * @throws { BusinessError } 202 - Caller is not a system application. 675 * @throws { BusinessError } 401 - Parameter error. Possible causes: 676 * 1.Mandatory parameters are left unspecified; 677 * 2.Incorrect parameter types. 678 * @throws { BusinessError } 5400103 - I/O error. 679 * @syscap SystemCapability.Multimedia.SystemSound.Core 680 * @systemapi 681 * @since 11 682 */ 683 getSystemToneUri(context: BaseContext, type: SystemToneType): Promise<string>; 684 685 /** 686 * Gets attributes of the default system tone. 687 * 688 * @param { BaseContext } context - Current application context. 689 * @param { SystemToneType } type - system tone type to get. 690 * @returns { Promise<ToneAttrs> } Promise used to return attributes of the default system tone. 691 * @throws { BusinessError } 202 - Caller is not a system application. 692 * @throws { BusinessError } 401 - Parameter error. Possible causes: 693 * 1.Mandatory parameters are left unspecified; 694 * 2.Incorrect parameter types. 695 * @throws { BusinessError } 5400103 - I/O error. 696 * @syscap SystemCapability.Multimedia.SystemSound.Core 697 * @systemapi 698 * @since 12 699 */ 700 getDefaultSystemToneAttrs(context: BaseContext, type: SystemToneType): Promise<ToneAttrs>; 701 702 /** 703 * Gets attribute list of alarm tones. 704 * @param { BaseContext } context - Current application context. 705 * @param { SystemToneType } type - System tone type to get. 706 * @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of system tone. 707 * @throws { BusinessError } 202 - Caller is not a system application. 708 * @throws { BusinessError } 401 - Parameter error. Possible causes: 709 * 1.Mandatory parameters are left unspecified; 710 * 2.Incorrect parameter types. 711 * @throws { BusinessError } 5400103 - I/O error. 712 * @syscap SystemCapability.Multimedia.SystemSound.Core 713 * @systemapi 714 * @since 12 715 */ 716 getSystemToneAttrList(context: BaseContext, type: SystemToneType): Promise<ToneAttrsArray>; 717 718 /** 719 * Gets the system tone player. 720 * @param { BaseContext } context - Current application context. 721 * @param { SystemToneType } type - System tone type to get. 722 * @returns { Promise<SystemTonePlayer> } Promise used to return the SystemTonePlayer. 723 * @throws { BusinessError } 202 - Caller is not a system application. 724 * @throws { BusinessError } 401 - Parameter error. Possible causes: 725 * 1.Mandatory parameters are left unspecified; 726 * 2.Incorrect parameter types. 727 * @syscap SystemCapability.Multimedia.SystemSound.Core 728 * @systemapi 729 * @since 11 730 */ 731 getSystemTonePlayer(context: BaseContext, type: SystemToneType): Promise<SystemTonePlayer>; 732 733 /** 734 * Gets attributes of the default alarm tone. 735 * 736 * @param { BaseContext } context - Current application context. 737 * @returns { Promise<ToneAttrs> } Promise used to return attributes of the default alarm tone. 738 * @throws { BusinessError } 202 - Caller is not a system application. 739 * @throws { BusinessError } 401 - Parameter error. Possible causes: 740 * 1.Mandatory parameters are left unspecified; 741 * 2.Incorrect parameter types. 742 * @throws { BusinessError } 5400103 - I/O error. 743 * @syscap SystemCapability.Multimedia.SystemSound.Core 744 * @systemapi 745 * @since 12 746 */ 747 getDefaultAlarmToneAttrs(context: BaseContext): Promise<ToneAttrs>; 748 749 /** 750 * Sets uri of the current alarm tone. 751 * 752 * @param { BaseContext } context - Current application context. 753 * @param { string } uri - Alarm tone uri. 754 * @returns { Promise<void> } Promise used to return result of set alarm tone. 755 * @throws { BusinessError } 202 - Caller is not a system application. 756 * @throws { BusinessError } 401 - Parameter error. Possible causes: 757 * 1.Mandatory parameters are left unspecified; 758 * 2.Incorrect parameter types. 759 * @throws { BusinessError } 5400103 - I/O error. 760 * @throws { BusinessError } 20700001 - Tone type mismatch, e.g. tone of input uri is not an alarm tone. 761 * @syscap SystemCapability.Multimedia.SystemSound.Core 762 * @systemapi 763 * @since 12 764 */ 765 setAlarmToneUri(context: BaseContext, uri: string): Promise<void>; 766 767 /** 768 * Gets uri of the current alarm tone. 769 * 770 * @param { BaseContext } context - Current application context. 771 * @returns { Promise<string> } Promise used to return uri of current alarm tone. 772 * @throws { BusinessError } 202 - Caller is not a system application. 773 * @throws { BusinessError } 401 - Parameter error. Possible causes: 774 * 1.Mandatory parameters are left unspecified; 775 * 2.Incorrect parameter types. 776 * @throws { BusinessError } 5400103 - I/O error. 777 * @syscap SystemCapability.Multimedia.SystemSound.Core 778 * @systemapi 779 * @since 12 780 */ 781 getAlarmToneUri(context: BaseContext): Promise<string>; 782 783 /** 784 * Gets attribute list of alarm tones. 785 * @param { BaseContext } context - Current application context. 786 * @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of system tone. 787 * @throws { BusinessError } 202 - Caller is not a system application. 788 * @throws { BusinessError } 401 - Parameter error. Possible causes: 789 * 1.Mandatory parameters are left unspecified; 790 * 2.Incorrect parameter types. 791 * @throws { BusinessError } 5400103 - I/O error. 792 * @syscap SystemCapability.Multimedia.SystemSound.Core 793 * @systemapi 794 * @since 12 795 */ 796 getAlarmToneAttrList(context: BaseContext): Promise<ToneAttrsArray>; 797 798 /** 799 * Open alarm tone file. 800 * @param { BaseContext } context - Current application context. 801 * @param { string } uri - Uri of alarm tone to open. 802 * @returns { Promise<number> } Promise used to return fd. 803 * @throws { BusinessError } 202 - Caller is not a system application. 804 * @throws { BusinessError } 401 - Parameter error. Possible causes: 805 * 1.Mandatory parameters are left unspecified; 806 * 2.Incorrect parameter types. 807 * @throws { BusinessError } 5400103 - I/O error. 808 * @throws { BusinessError } 20700001 - Tone type mismatch, e.g. tone of uri is notification instead of alarm. 809 * @syscap SystemCapability.Multimedia.SystemSound.Core 810 * @systemapi 811 * @since 12 812 */ 813 openAlarmTone(context: BaseContext, uri: string): Promise<number> 814 815 /** 816 * Close fd. 817 * @param { number } fd - File descriptor to close. 818 * @returns { Promise<void> } Promise used to return the result of close fd. 819 * @throws { BusinessError } 202 - Caller is not a system application. 820 * @throws { BusinessError } 401 - Parameter error. Possible causes: 821 * 1.Mandatory parameters are left unspecified; 822 * 2.Incorrect parameter types. 823 * @throws { BusinessError } 5400103 - I/O error. 824 * @syscap SystemCapability.Multimedia.SystemSound.Core 825 * @systemapi 826 * @since 12 827 */ 828 close(fd: number): Promise<void>; 829 830 /** 831 * Add customized tone into ringtone library. 832 * @permission ohos.permission.WRITE_RINGTONE 833 * @param { BaseContext } context - Current application context. 834 * @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}. 835 * @param { string } externalUri - Tone uri in external storage. 836 * @returns { Promise<string> } Tone uri after adding into ringtone library. 837 * @throws { BusinessError } 201 - Permission denied. 838 * @throws { BusinessError } 202 - Caller is not a system application. 839 * @throws { BusinessError } 401 - Parameter error. Possible causes: 840 * 1.Mandatory parameters are left unspecified; 841 * 2.Incorrect parameter types. 842 * @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized. 843 * @throws { BusinessError } 5400103 - I/O error. 844 * @syscap SystemCapability.Multimedia.SystemSound.Core 845 * @systemapi 846 * @since 12 847 */ 848 addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, externalUri: string): Promise<string>; 849 850 /** 851 * Add customized tone into ringtone library. 852 * @permission ohos.permission.WRITE_RINGTONE 853 * @param { BaseContext } context - Current application context. 854 * @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}. 855 * @param { number } fd - File descriptor. 856 * @param { number } [offset] - The offset in the file where the data to be read, in bytes. By default, the offset 857 * is zero. 858 * @param { number } [length] - The length in bytes of the data to be read. By default, the length is the rest of 859 * bytes in the file from the offset. 860 * @returns { Promise<string> } Tone uri after adding into ringtone library. 861 * @throws { BusinessError } 201 - Permission denied. 862 * @throws { BusinessError } 202 - Caller is not a system application. 863 * @throws { BusinessError } 401 - Parameter error. Possible causes: 864 * 1.Mandatory parameters are left unspecified; 865 * 2.Incorrect parameter types. 866 * @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized. 867 * @throws { BusinessError } 5400103 - I/O error. 868 * @syscap SystemCapability.Multimedia.SystemSound.Core 869 * @systemapi 870 * @since 12 871 */ 872 addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, fd: number, offset?: number, length?: number) 873 : Promise<string>; 874 875 /** 876 * Remove customized tone in ringtone library. 877 * @permission ohos.permission.WRITE_RINGTONE 878 * @param { BaseContext } context - Current application context. 879 * @param { string } uri - Tone uri. 880 * @returns { Promise<void> } Promise used to return removing result. 881 * @throws { BusinessError } 201 - Permission denied. 882 * @throws { BusinessError } 202 - Caller is not a system application. 883 * @throws { BusinessError } 401 - Parameter error. Possible causes: 884 * 1.Mandatory parameters are left unspecified; 885 * 2.Incorrect parameter types. 886 * @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone of this uri is not customized. 887 * @throws { BusinessError } 5400103 - I/O error. 888 * @syscap SystemCapability.Multimedia.SystemSound.Core 889 * @systemapi 890 * @since 12 891 */ 892 removeCustomizedTone(context: BaseContext, uri:string): Promise<void>; 893 894 /** 895 * Get haptics settings. 896 * @param { BaseContext } context - Current application context. 897 * @param { ToneHapticsType } type - Tone haptics type. 898 * @returns { Promise<ToneHapticsSettings> } Promise used to return results of this call. 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 14 908 */ 909 getToneHapticsSettings(context: BaseContext, type: ToneHapticsType): Promise<ToneHapticsSettings>; 910 911 /** 912 * Set haptics settings. 913 * @param { BaseContext } context - Current application context. 914 * @param { ToneHapticsType } type - Tone haptics type. 915 * @param { ToneHapticsSettings } settings - Tone haptics settings. 916 * @returns { Promise<void> } Promise used to return results of this call. 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 valid. 922 * @throws { BusinessError } 5400103 - I/O error. 923 * @throws { BusinessError } 20700003 - Unsupported operation. 924 * @syscap SystemCapability.Multimedia.SystemSound.Core 925 * @systemapi 926 * @since 14 927 */ 928 setToneHapticsSettings(context: BaseContext, type: ToneHapticsType, settings: ToneHapticsSettings): Promise<void>; 929 930 /** 931 * Get haptics list. 932 * @param { BaseContext } context - Current application context. 933 * @param { boolean } isSynced - The queried haptics is synchronized with tone or not. 934 * @returns { Promise<ToneHapticsAttrsArray> } Promise used to return ToneHapticsAttrsArray. 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 } 5400103 - I/O error. 940 * @throws { BusinessError } 20700003 - Unsupported operation. 941 * @syscap SystemCapability.Multimedia.SystemSound.Core 942 * @systemapi 943 * @since 14 944 */ 945 getToneHapticsList(context: BaseContext, isSynced: boolean): Promise<ToneHapticsAttrsArray>; 946 947 /** 948 * Get attributes of haptics which is synchronized with one tone. If no haptics is found, then the attributes in 949 * the returned ToneHapticsAttrs is empty. 950 * @param { BaseContext } context - Current application context. 951 * @param { string } toneUri - Uri of tone to query. 952 * @returns { Promise<ToneHapticsAttrs> } Promise used to return ToneHapticsAttrs. 953 * @throws { BusinessError } 202 - Caller is not a system application. 954 * @throws { BusinessError } 401 - Parameter error. Possible causes: 955 * 1.Mandatory parameters are left unspecified; 956 * 2.Incorrect parameter types. 957 * @throws { BusinessError } 5400102 - Operation not allowed. For example, the input URI is not used for tones. 958 * @throws { BusinessError } 5400103 - I/O error. 959 * @throws { BusinessError } 20700003 - Unsupported operation. 960 * @syscap SystemCapability.Multimedia.SystemSound.Core 961 * @systemapi 962 * @since 14 963 */ 964 getHapticsAttrsSyncedWithTone(context: BaseContext, toneUri: string): Promise<ToneHapticsAttrs>; 965 966 /** 967 * Open haptics. 968 * @param { BaseContext } context - Current application context. 969 * @param { string } hapticsUri - Uri of haptics to open. 970 * @returns { Promise<number> } Promise used to return fd. 971 * @throws { BusinessError } 202 - Caller is not a system application. 972 * @throws { BusinessError } 401 - Parameter error. Possible causes: 973 * 1.Mandatory parameters are left unspecified; 974 * 2.Incorrect parameter types. 975 * @throws { BusinessError } 5400102 - Operation not allowed. For example, the input URI is not one for haptics. 976 * @throws { BusinessError } 5400103 - I/O error. 977 * @throws { BusinessError } 20700003 - Unsupported operation. 978 * @syscap SystemCapability.Multimedia.SystemSound.Core 979 * @systemapi 980 * @since 14 981 */ 982 openToneHaptics(context: BaseContext, hapticsUri: string): Promise<number>; 983 } 984 985 /** 986 * Ringtone player object. 987 * @typedef { _RingtonePlayer } RingtonePlayer 988 * @syscap SystemCapability.Multimedia.SystemSound.Core 989 * @systemapi 990 * @since 10 991 */ 992 type RingtonePlayer = _RingtonePlayer; 993 994 /** 995 * SystemTone player object. 996 * @typedef { _SystemTonePlayer } SystemTonePlayer 997 * @syscap SystemCapability.Multimedia.SystemSound.Core 998 * @systemapi 999 * @since 11 1000 */ 1001 type SystemTonePlayer = _SystemTonePlayer; 1002 1003 /** 1004 * Interface for ringtone options. 1005 * @typedef { _RingtoneOptions } RingtoneOptions 1006 * @syscap SystemCapability.Multimedia.SystemSound.Core 1007 * @systemapi 1008 * @since 10 1009 */ 1010 type RingtoneOptions = _RingtoneOptions; 1011 1012 /** 1013 * System tone options. 1014 * @typedef { _SystemToneOptions } SystemToneOptions 1015 * @syscap SystemCapability.Multimedia.SystemSound.Core 1016 * @systemapi 1017 * @since 11 1018 */ 1019 type SystemToneOptions = _SystemToneOptions; 1020} 1021 1022export default systemSoundManager;