1/* 2 * Copyright (c) 2021 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 16import { RawFileDescriptor as _RawFileDescriptor } from './global/rawFileDescriptor'; 17import { Resource as _Resource } from './global/resource'; 18import { AsyncCallback as _AsyncCallback } from './basic'; 19 20/** 21 * Provides resource related APIs. 22 * 23 * @since 6 24 * @syscap SystemCapability.Global.ResourceManager 25 */ 26declare namespace resourceManager { 27/** 28 * Enumerates screen directions. 29 * 30 * @since 6 31 */ 32export enum Direction { 33 /** 34 * Indicates the vertical direction. 35 * 36 * @since 6 37 */ 38 DIRECTION_VERTICAL = 0, 39 40 /** 41 * Indicates the horizontal direction. 42 * 43 * @since 6 44 */ 45 DIRECTION_HORIZONTAL = 1 46} 47 48/** 49 * Enumerates device types. 50 * 51 * @since 6 52 */ 53export enum DeviceType { 54 /** 55 * Indicates a phone. 56 * 57 * @since 6 58 */ 59 DEVICE_TYPE_PHONE = 0x00, 60 61 /** 62 * Indicates a tablet. 63 * 64 * @since 6 65 */ 66 DEVICE_TYPE_TABLET = 0x01, 67 68 /** 69 * Indicates a car. 70 * 71 * @since 6 72 */ 73 DEVICE_TYPE_CAR = 0x02, 74 75 /** 76 * Indicates a PC. 77 * 78 * @since 6 79 */ 80 DEVICE_TYPE_PC = 0x03, 81 82 /** 83 * Indicates a smart TV. 84 * 85 * @since 6 86 */ 87 DEVICE_TYPE_TV = 0x04, 88 89 /** 90 * Indicates a wearable device. 91 * 92 * @since 6 93 */ 94 DEVICE_TYPE_WEARABLE = 0x06 95} 96 97/** 98 * Enumerates screen density types. 99 * 100 * @since 6 101 */ 102export enum ScreenDensity { 103 /** 104 * Indicates small screen density. 105 * 106 * @since 6 107 */ 108 SCREEN_SDPI = 120, 109 110 /** 111 * Indicates medium screen density. 112 * 113 * @since 6 114 */ 115 SCREEN_MDPI = 160, 116 117 /** 118 * Indicates large screen density. 119 * 120 * @since 6 121 */ 122 SCREEN_LDPI = 240, 123 124 /** 125 * Indicates extra-large screen density. 126 * 127 * @since 6 128 */ 129 SCREEN_XLDPI = 320, 130 131 /** 132 * Indicates extra-extra-large screen density. 133 * 134 * @since 6 135 */ 136 SCREEN_XXLDPI = 480, 137 138 /** 139 * Indicates extra-extra-extra-large screen density. 140 * 141 * @since 6 142 */ 143 SCREEN_XXXLDPI = 640 144} 145 146/** 147 * Provides the device configuration. 148 * 149 * @since 6 150 */ 151export class Configuration { 152 /** 153 * Indicates the screen direction of the current device. 154 * 155 * @since 6 156 */ 157 direction: Direction 158 159 /** 160 * Indicates the current system language, for example, zh-Hans-CN. 161 * 162 * @since 6 163 */ 164 locale: string 165} 166 167/** 168 * Provides the device capability. 169 * 170 * @since 6 171 */ 172export class DeviceCapability { 173 /** 174 * Indicates the screen density of the current device. 175 * 176 * @since 6 177 */ 178 screenDensity: ScreenDensity 179 180 /** 181 * Indicates the type of the current device. 182 * 183 * @since 6 184 */ 185 deviceType: DeviceType 186} 187 188/** 189 * The ResourceManager callback. 190 * @since 6 191 * @deprecated since 9 192 */ 193 export interface AsyncCallback<T> { 194 (err: Error, data: T): void; 195} 196 197/** 198 * Obtains the ResourceManager object of the current application. 199 * 200 * @param callback Indicates the callback containing the ResourceManager object. 201 * @since 6 202 * @FAModelOnly 203 */ 204export function getResourceManager(callback: AsyncCallback<ResourceManager>): void; 205 206/** 207 * Obtains the ResourceManager object of the specified application. 208 * 209 * @param bundleName Indicates the bundle name of the specified application. 210 * @param callback Indicates the callback containing the ResourceManager object. 211 * @since 6 212 * @FAModelOnly 213 */ 214export function getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManager>): void; 215 216/** 217 * Obtains the ResourceManager object of the current application. 218 * 219 * @returns Returns that the ResourceManager object is returned in Promise mode. 220 * @since 6 221 * @FAModelOnly 222 */ 223export function getResourceManager(): Promise<ResourceManager>; 224 225/** 226 * Obtains the ResourceManager object of the specified application. 227 * 228 * @param bundleName Indicates the bundle name of the specified application. 229 * @returns Returns that the ResourceManager object is returned in Promise mode. 230 * @since 6 231 * @FAModelOnly 232 */ 233export function getResourceManager(bundleName: string): Promise<ResourceManager>; 234 235/** 236 * Provides the capability of accessing application resources. 237 * 238 * @since 6 239 */ 240export interface ResourceManager { 241 /** 242 * Obtains the character string corresponding to a specified resource ID in callback mode. 243 * 244 * @param resId Indicates the resource ID. 245 * @param callback Indicates the asynchronous callback used to return the obtained character string. 246 * @since 6 247 * @deprecated since 9 248 * @useinstead ohos.resourceManager.getStringValue 249 */ 250 getString(resId: number, callback: AsyncCallback<string>): void; 251 252 /** 253 * Obtains string resources associated with a specified resource ID in Promise mode. 254 * 255 * @param resId Indicates the resource ID. 256 * @returns Returns the character string corresponding to the resource ID. 257 * @since 6 258 * @deprecated since 9 259 * @useinstead ohos.resourceManager.getStringValue 260 */ 261 getString(resId: number): Promise<string>; 262 263 /** 264 * Obtains the character string corresponding to a specified resource object in callback mode. 265 * 266 * @param resource Indicates the resource object. 267 * @param callback Indicates the asynchronous callback used to return the obtained character string. 268 * @throws { BusinessError } 401 - If the input parameter invalid. 269 * @throws { BusinessError } 9001001 - If the module resId invalid. 270 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 271 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 272 * @since 9 273 */ 274 getStringValue(resource: Resource, callback: _AsyncCallback<string>): void; 275 276 /** 277 * Obtains string resources associated with a specified resource object in Promise mode. 278 * 279 * @param resource Indicates the resource object. 280 * @returns Returns the character string corresponding to the resource object. 281 * @throws { BusinessError } 401 - If the input parameter invalid. 282 * @throws { BusinessError } 9001001 - If the module resId invalid. 283 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 284 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 285 * @since 9 286 */ 287 getStringValue(resource: Resource): Promise<string>; 288 289 /** 290 * Obtains the array of character strings corresponding to a specified resource ID in callback mode. 291 * 292 * @param resId Indicates the resource ID. 293 * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. 294 * @since 6 295 * @deprecated since 9 296 * @useinstead ohos.resourceManager.getStringArrayValue 297 */ 298 getStringArray(resId: number, callback: AsyncCallback<Array<string>>): void; 299 300 /** 301 * Obtains the array of character strings corresponding to a specified resource ID in Promise mode. 302 * 303 * @param resId Indicates the resource ID. 304 * @returns Returns the array of character strings corresponding to the specified resource ID. 305 * @since 6 306 * @deprecated since 9 307 * @useinstead ohos.resourceManager.getStringArrayValue 308 */ 309 getStringArray(resId: number): Promise<Array<string>>; 310 311 /** 312 * Obtains the array of character strings corresponding to a specified resource object in callback mode. 313 * 314 * @param resource Indicates the resource object. 315 * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. 316 * @throws { BusinessError } 401 - If the input parameter invalid. 317 * @throws { BusinessError } 9001001 - If the module resId invalid. 318 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 319 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 320 * @since 9 321 */ 322 getStringArrayValue(resource: Resource, callback: _AsyncCallback<Array<string>>): void; 323 324 /** 325 * Obtains the array of character strings corresponding to a specified resource object in Promise mode. 326 * 327 * @param resource Indicates the resource object. 328 * @returns Returns the array of character strings corresponding to the specified resource object. 329 * @throws { BusinessError } 401 - If the input parameter invalid. 330 * @throws { BusinessError } 9001001 - If the module resId invalid. 331 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 332 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 333 * @since 9 334 */ 335 getStringArrayValue(resource: Resource): Promise<Array<string>>; 336 337 /** 338 * Obtains the content of the media file corresponding to a specified resource ID in callback mode. 339 * 340 * @param resId Indicates the resource ID. 341 * @param callback Indicates the asynchronous callback used to return the obtained media file content. 342 * @since 6 343 * @deprecated since 9 344 * @useinstead ohos.resourceManager.getMediaContent 345 */ 346 getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void; 347 348 /** 349 * Obtains the content of the media file corresponding to a specified resource ID in Promise mode. 350 * 351 * @param resId Indicates the resource ID. 352 * @returns Returns the content of the media file corresponding to the specified resource ID. 353 * @since 6 354 * @deprecated since 9 355 * @useinstead ohos.resourceManager.getMediaContent 356 */ 357 getMedia(resId: number): Promise<Uint8Array>; 358 359 /** 360 * Obtains the content of the media file corresponding to a specified resource object in callback mode. 361 * 362 * @param resource Indicates the resource object. 363 * @param callback Indicates the asynchronous callback used to return the obtained media file content. 364 * @throws { BusinessError } 401 - If the input parameter invalid. 365 * @throws { BusinessError } 9001001 - If the module resId invalid. 366 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 367 * @since 9 368 */ 369 getMediaContent(resource: Resource, callback: _AsyncCallback<Uint8Array>): void; 370 371 /** 372 * Obtains the content of the media file corresponding to a specified resource object in Promise mode. 373 * 374 * @param resource Indicates the resource object. 375 * @returns Returns the content of the media file corresponding to the specified resource object. 376 * @throws { BusinessError } 401 - If the input parameter invalid. 377 * @throws { BusinessError } 9001001 - If the module resId invalid. 378 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 379 * @since 9 380 */ 381 getMediaContent(resource: Resource): Promise<Uint8Array>; 382 383 /** 384 * Obtains the Base64 code of the image resource corresponding to the specified resource ID in callback mode. 385 * 386 * @param resId Indicates the resource ID. 387 * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image 388 * resource. 389 * @since 6 390 * @deprecated since 9 391 * @useinstead ohos.resourceManager.getMediaContentBase64 392 */ 393 getMediaBase64(resId: number, callback: AsyncCallback<string>): void; 394 395 /** 396 * Obtains the Base64 code of the image resource corresponding to the specified resource ID in Promise mode. 397 * 398 * @param resId Indicates the resource ID. 399 * @returns Returns the Base64 code of the image resource corresponding to the specified resource ID. 400 * @since 6 401 * @deprecated since 9 402 * @useinstead ohos.resourceManager.getMediaContentBase64 403 */ 404 getMediaBase64(resId: number): Promise<string>; 405 406 /** 407 * Obtains the Base64 code of the image resource corresponding to the specified resource object in callback mode. 408 * 409 * @param resource Indicates the resource object. 410 * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image 411 * resource. 412 * @throws { BusinessError } 401 - If the input parameter invalid. 413 * @throws { BusinessError } 9001001 - If the module resId invalid. 414 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 415 * @since 9 416 */ 417 getMediaContentBase64(resource: Resource, callback: _AsyncCallback<string>): void; 418 419 /** 420 * Obtains the Base64 code of the image resource corresponding to the specified resource object in Promise mode. 421 * 422 * @param resource Indicates the resource object. 423 * @returns Returns the Base64 code of the image resource corresponding to the specified resource object. 424 * @throws { BusinessError } 401 - If the input parameter invalid. 425 * @throws { BusinessError } 9001001 - If the module resId invalid. 426 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 427 * @since 9 428 */ 429 getMediaContentBase64(resource: Resource): Promise<string>; 430 431 /** 432 * Obtains the device capability in callback mode. 433 * 434 * @param callback Indicates the asynchronous callback used to return the obtained device capability. 435 * @since 6 436 */ 437 getDeviceCapability(callback: _AsyncCallback<DeviceCapability>): void; 438 439 /** 440 * Obtains the device capability in Promise mode. 441 * 442 * @returns Returns the device capability. 443 * @since 6 444 */ 445 getDeviceCapability(): Promise<DeviceCapability>; 446 447 /** 448 * Obtains the device configuration in callback mode. 449 * 450 * @param callback Indicates the asynchronous callback used to return the obtained device 451 * configuration. 452 * @since 6 453 */ 454 getConfiguration(callback: _AsyncCallback<Configuration>): void; 455 456 /** 457 * Obtains the device configuration in Promise mode. 458 * 459 * @returns Returns the device configuration. 460 * @since 6 461 */ 462 getConfiguration(): Promise<Configuration>; 463 464 /** 465 * Obtains the singular-plural character string represented by the ID string corresponding to the 466 * specified number in callback mode. 467 * 468 * @param resId Indicates the resource ID. 469 * @param num Indicates the number. 470 * @param callback Indicates the asynchronous callback used to return the singular-plural character 471 * string represented by the ID string corresponding to the specified number. 472 * @since 6 473 * @deprecated since 9 474 * @useinstead ohos.resourceManager.getPluralStringValue 475 */ 476 getPluralString(resId: number, num: number, callback: AsyncCallback<string>): void; 477 478 /** 479 * Obtains the singular-plural character string represented by the ID string corresponding to 480 * the specified number in Promise mode. 481 * 482 * @param resId Indicates the resource ID. 483 * @param num Indicates the number. 484 * @returns Returns the singular-plural character string represented by the ID string 485 * corresponding to the specified number. 486 * @since 6 487 * @deprecated since 9 488 * @useinstead ohos.resourceManager.getPluralStringValue 489 */ 490 getPluralString(resId: number, num: number): Promise<string>; 491 492 /** 493 * Obtains the singular-plural character string represented by the resource object string corresponding to the 494 * specified number in callback mode. 495 * 496 * @param resource Indicates the resource object. 497 * @param num Indicates the number. 498 * @param callback Indicates the asynchronous callback used to return the singular-plural character 499 * string represented by the resource object string corresponding to the specified number. 500 * @throws { BusinessError } 401 - If the input parameter invalid. 501 * @throws { BusinessError } 9001001 - If the resId invalid. 502 * @throws { BusinessError } 9001002 - If the resource not found by resId. 503 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 504 * @since 9 505 */ 506 getPluralStringValue(resource: Resource, num: number, callback: _AsyncCallback<string>): void; 507 508 /** 509 * Obtains the singular-plural character string represented by the resource object string corresponding to 510 * the specified number in Promise mode. 511 * 512 * @param resource Indicates the resource object. 513 * @param num Indicates the number. 514 * @returns Returns the singular-plural character string represented by the resource object string 515 * corresponding to the specified number. 516 * @throws { BusinessError } 401 - If the input parameter invalid. 517 * @throws { BusinessError } 9001001 - If the resId invalid. 518 * @throws { BusinessError } 9001002 - If the resource not found by resId. 519 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 520 * @since 9 521 */ 522 getPluralStringValue(resource: Resource, num: number): Promise<string>; 523 524 /** 525 * Obtains the raw file resource corresponding to the specified resource path in callback mode. 526 * 527 * @param path Indicates the resource relative path. 528 * @param callback Indicates the asynchronous callback used to return the raw file resource. 529 * @since 8 530 * @deprecated since 9 531 * @useinstead ohos.resourceManager.getRawFileContent 532 */ 533 getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void; 534 535 /** 536 * Obtains the raw file resource corresponding to the specified resource path in Promise mode. 537 * 538 * @param path Indicates the resource relative path. 539 * @returns Returns the raw file resource corresponding to the specified resource path. 540 * @since 8 541 * @deprecated since 9 542 * @useinstead ohos.resourceManager.getRawFileContent 543 */ 544 getRawFile(path: string): Promise<Uint8Array>; 545 546 /** 547 * Obtains the raw file resource descriptor corresponding to the specified resource path in callback mode. 548 * 549 * @param path Indicates the resource relative path. 550 * @param callback Indicates the asynchronous callback used to return the raw file resource descriptor. 551 * @since 8 552 * @deprecated since 9 553 * @useinstead ohos.resourceManager.getRawFd 554 */ 555 getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor>): void; 556 557 /** 558 * Obtains the raw file resource descriptor corresponding to the specified resource path in Promise mode. 559 * 560 * @param path Indicates the resource relative path. 561 * @returns Returns the raw file resource descriptor corresponding to the specified resource path. 562 * @since 8 563 * @deprecated since 9 564 * @useinstead ohos.resourceManager.getRawFd 565 */ 566 getRawFileDescriptor(path: string): Promise<RawFileDescriptor>; 567 568 /** 569 * Obtains close raw file resource descriptor corresponding to the specified resource path in callback mode. 570 * 571 * @param path Indicates the resource relative path. 572 * @param callback Indicates the asynchronous callback used to return result close raw file resource descriptor. 573 * @since 8 574 * @deprecated since 9 575 * @useinstead ohos.resourceManager.closeRawFd 576 */ 577 closeRawFileDescriptor(path: string, callback: AsyncCallback<void>): void; 578 579 /** 580 * Obtains close raw file resource descriptor corresponding to the specified resource path in Promise mode. 581 * 582 * @param path Indicates the resource relative path. 583 * @returns Returns result close raw file resource descriptor corresponding to the specified resource path. 584 * @since 8 585 * @deprecated since 9 586 * @useinstead ohos.resourceManager.closeRawFd 587 */ 588 closeRawFileDescriptor(path: string): Promise<void>; 589 590 /** 591 * Obtains the character string corresponding to a specified resource name in callback mode. 592 * 593 * @param resName Indicates the resource name. 594 * @param callback Indicates the asynchronous callback used to return the obtained character string. 595 * @throws { BusinessError } 401 - If the input parameter invalid. 596 * @throws { BusinessError } 9001003 - If the resName invalid. 597 * @throws { BusinessError } 9001004 - If the resource not found by resName. 598 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 599 * @since 9 600 */ 601 getStringByName(resName: string, callback: _AsyncCallback<string>): void; 602 603 /** 604 * Obtains string resources associated with a specified resource name in Promise mode. 605 * 606 * @param resName Indicates the resource name. 607 * @returns Returns the character string corresponding to the resource name. 608 * @throws { BusinessError } 401 - If the input parameter invalid. 609 * @throws { BusinessError } 9001003 - If the resName invalid. 610 * @throws { BusinessError } 9001004 - If the resource not found by resName. 611 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 612 * @since 9 613 */ 614 getStringByName(resName: string): Promise<string>; 615 616 /** 617 * Obtains the array of character strings corresponding to a specified resource name in callback mode. 618 * 619 * @param resName Indicates the resource name. 620 * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. 621 * @throws { BusinessError } 401 - If the input parameter invalid. 622 * @throws { BusinessError } 9001003 - If the resName invalid. 623 * @throws { BusinessError } 9001004 - If the resource not found by resName. 624 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 625 * @since 9 626 */ 627 getStringArrayByName(resName: string, callback: _AsyncCallback<Array<string>>): void; 628 629 /** 630 * Obtains the array of character strings corresponding to a specified resource name in Promise mode. 631 * 632 * @param resName Indicates the resource name. 633 * @returns Returns the array of character strings corresponding to the specified resource name. 634 * @throws { BusinessError } 401 - If the input parameter invalid. 635 * @throws { BusinessError } 9001003 - If the resName invalid. 636 * @throws { BusinessError } 9001004 - If the resource not found by resName. 637 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 638 * @since 9 639 */ 640 getStringArrayByName(resName: string): Promise<Array<string>>; 641 642 /** 643 * Obtains the content of the media file corresponding to a specified resource name in callback mode. 644 * 645 * @param resName Indicates the resource name. 646 * @param callback Indicates the asynchronous callback used to return the obtained media file content. 647 * @throws { BusinessError } 401 - If the input parameter invalid. 648 * @throws { BusinessError } 9001003 - If the resName invalid. 649 * @throws { BusinessError } 9001004 - If the resource not found by resName. 650 * @since 9 651 */ 652 getMediaByName(resName: string, callback: _AsyncCallback<Uint8Array>): void; 653 654 /** 655 * Obtains the content of the media file corresponding to a specified resource name in Promise mode. 656 * 657 * @param resName Indicates the resource name. 658 * @returns Returns the content of the media file corresponding to the specified resource name. 659 * @throws { BusinessError } 401 - If the input parameter invalid. 660 * @throws { BusinessError } 9001003 - If the resName invalid. 661 * @throws { BusinessError } 9001004 - If the resource not found by resName. 662 * @since 9 663 */ 664 getMediaByName(resName: string): Promise<Uint8Array>; 665 666 /** 667 * Obtains the Base64 code of the image resource corresponding to the specified resource name in callback mode. 668 * 669 * @param resName Indicates the resource name. 670 * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image 671 * resource. 672 * @throws { BusinessError } 401 - If the input parameter invalid. 673 * @throws { BusinessError } 9001003 - If the resName invalid. 674 * @throws { BusinessError } 9001004 - If the resource not found by resName. 675 * @since 9 676 */ 677 getMediaBase64ByName(resName: string, callback: _AsyncCallback<string>): void; 678 679 /** 680 * Obtains the Base64 code of the image resource corresponding to the specified resource name in Promise mode. 681 * 682 * @param resName Indicates the resource name. 683 * @returns Returns the Base64 code of the image resource corresponding to the specified resource name. 684 * @throws { BusinessError } 401 - If the input parameter invalid. 685 * @throws { BusinessError } 9001003 - If the resName invalid. 686 * @throws { BusinessError } 9001004 - If the resource not found by resName. 687 * @since 9 688 */ 689 getMediaBase64ByName(resName: string): Promise<string>; 690 691 /** 692 * Obtains the singular-plural character string represented by the name string corresponding to the 693 * specified number in callback mode. 694 * 695 * @param resName Indicates the resource name. 696 * @param num Indicates the number. 697 * @param callback Indicates the asynchronous callback used to return the singular-plural character 698 * string represented by the name string corresponding to the specified number. 699 * @throws { BusinessError } 401 - If the input parameter invalid. 700 * @throws { BusinessError } 9001003 - If the resName invalid. 701 * @throws { BusinessError } 9001004 - If the resource not found by resName. 702 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 703 * @since 9 704 */ 705 getPluralStringByName(resName: string, num: number, callback: _AsyncCallback<string>): void; 706 707 /** 708 * Obtains the singular-plural character string represented by the name string corresponding to 709 * the specified number in Promise mode. 710 * 711 * @param resName Indicates the resource name. 712 * @param num Indicates the number. 713 * @returns Returns the singular-plural character string represented by the name string 714 * corresponding to the specified number. 715 * @throws { BusinessError } 401 - If the input parameter invalid. 716 * @throws { BusinessError } 9001003 - If the resName invalid. 717 * @throws { BusinessError } 9001004 - If the resource not found by resName. 718 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 719 * @since 9 720 */ 721 getPluralStringByName(resName: string, num: number): Promise<string>; 722 723 /** 724 * Obtains string resources associated with a specified resource ID. 725 * 726 * @param resId Indicates the resource ID. 727 * @returns Returns the character string corresponding to the resource ID. 728 * @throws { BusinessError } 401 - If the input parameter invalid. 729 * @throws { BusinessError } 9001001 - If the resId invalid. 730 * @throws { BusinessError } 9001002 - If the resource not found by resId. 731 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 732 * @since 9 733 */ 734 getStringSync(resId: number): string; 735 736 /** 737 * Obtains string resources associated with a specified resource object. 738 * 739 * @param resource Indicates the resource object. 740 * @returns Returns the character string corresponding to the resource object. 741 * @throws { BusinessError } 401 - If the input parameter invalid. 742 * @throws { BusinessError } 9001001 - If the module resId invalid. 743 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 744 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 745 * @since 9 746 */ 747 getStringSync(resource: Resource): string; 748 749 /** 750 * Obtains string resources associated with a specified resource name. 751 * 752 * @param resName Indicates the resource name. 753 * @returns Returns the character string corresponding to the resource name. 754 * @throws { BusinessError } 401 - If the input parameter invalid. 755 * @throws { BusinessError } 9001003 - If the resName invalid. 756 * @throws { BusinessError } 9001004 - If the resource not found by resName. 757 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 758 * @since 9 759 */ 760 getStringByNameSync(resName: string): string; 761 762 /** 763 * Obtains the boolean result with a specified resource ID. 764 * 765 * @param resId Indicates the resource ID. 766 * @returns Returns the boolean resource corresponding to the resource ID. 767 * @throws { BusinessError } 401 - If the input parameter invalid. 768 * @throws { BusinessError } 9001001 - If the resId invalid. 769 * @throws { BusinessError } 9001002 - If the resource not found by resId. 770 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 771 * @since 9 772 */ 773 getBoolean(resId: number): boolean; 774 775 /** 776 * Obtains the boolean result with a specified resource object. 777 * 778 * @param resource Indicates the resource object. 779 * @returns Returns the boolean resource corresponding to the resource object. 780 * @throws { BusinessError } 401 - If the input parameter invalid. 781 * @throws { BusinessError } 9001001 - If the module resId invalid. 782 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 783 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 784 * @since 9 785 */ 786 getBoolean(resource: Resource): boolean; 787 788 /** 789 * Obtains the boolean result with a specified resource name. 790 * 791 * @param resName Indicates the resource name. 792 * @returns Returns the boolean resource corresponding to the resource name. 793 * @throws { BusinessError } 401 - If the input parameter invalid. 794 * @throws { BusinessError } 9001003 - If the resName invalid. 795 * @throws { BusinessError } 9001004 - If the resource not found by resName. 796 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 797 * @since 9 798 */ 799 getBooleanByName(resName: string): boolean; 800 801 /** 802 * Obtains the number result with a specified resource ID. 803 * 804 * @param resId Indicates the resource ID. 805 * @returns Returns the number resource corresponding to the resource ID. 806 * @throws { BusinessError } 401 - If the input parameter invalid. 807 * @throws { BusinessError } 9001001 - If the resId invalid. 808 * @throws { BusinessError } 9001002 - If the resource not found by resId. 809 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 810 * @since 9 811 */ 812 getNumber(resId: number): number; 813 814 /** 815 * Obtains the number result with a specified resource object. 816 * 817 * @param resource Indicates the resource object. 818 * @returns Returns the number resource corresponding to the resource object. 819 * @throws { BusinessError } 401 - If the input parameter invalid. 820 * @throws { BusinessError } 9001001 - If the module resId invalid. 821 * @throws { BusinessError } 9001002 - If the resource not found by module resId. 822 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 823 * @since 9 824 */ 825 getNumber(resource: Resource): number; 826 827 /** 828 * Obtains the number result with a specified resource name. 829 * 830 * @param resName Indicates the resource name. 831 * @returns Returns the number resource corresponding to the resource name. 832 * @throws { BusinessError } 401 - If the input parameter invalid. 833 * @throws { BusinessError } 9001003 - If the resName invalid. 834 * @throws { BusinessError } 9001004 - If the resource not found by resName. 835 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 836 * @since 9 837 */ 838 getNumberByName(resName: string): number; 839 840 /** 841 * Obtains release resourceManager. 842 * 843 * @since 7 844 */ 845 release(); 846 847 /** 848 * Obtains the character string corresponding to a specified resource ID in callback mode. 849 * 850 * @param resId Indicates the resource ID. 851 * @param callback Indicates the asynchronous callback used to return the obtained character string. 852 * @throws { BusinessError } 401 - If the input parameter invalid. 853 * @throws { BusinessError } 9001001 - If the resId invalid. 854 * @throws { BusinessError } 9001002 - If the resource not found by resId. 855 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 856 * @since 9 857 */ 858 getStringValue(resId: number, callback: _AsyncCallback<string>): void; 859 860 /** 861 * Obtains string resources associated with a specified resource ID in Promise mode. 862 * 863 * @param resId Indicates the resource ID. 864 * @returns Returns the character string corresponding to the resource ID. 865 * @throws { BusinessError } 401 - If the input parameter invalid. 866 * @throws { BusinessError } 9001001 - If the resId invalid. 867 * @throws { BusinessError } 9001002 - If the resource not found by resId. 868 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 869 * @since 9 870 */ 871 getStringValue(resId: number): Promise<string>; 872 873 /** 874 * Obtains the array of character strings corresponding to a specified resource ID in callback mode. 875 * 876 * @param resId Indicates the resource ID. 877 * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. 878 * @throws { BusinessError } 401 - If the input parameter invalid. 879 * @throws { BusinessError } 9001001 - If the resId invalid. 880 * @throws { BusinessError } 9001002 - If the resource not found by resId. 881 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 882 * @since 9 883 */ 884 getStringArrayValue(resId: number, callback: _AsyncCallback<Array<string>>): void; 885 886 /** 887 * Obtains the array of character strings corresponding to a specified resource ID in Promise mode. 888 * 889 * @param resId Indicates the resource ID. 890 * @returns Returns the array of character strings corresponding to the specified resource ID. 891 * @throws { BusinessError } 401 - If the input parameter invalid. 892 * @throws { BusinessError } 9001001 - If the resId invalid. 893 * @throws { BusinessError } 9001002 - If the resource not found by resId. 894 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 895 * @since 9 896 */ 897 getStringArrayValue(resId: number): Promise<Array<string>>; 898 899 /** 900 * Obtains the singular-plural character string represented by the ID string corresponding to the 901 * specified number in callback mode. 902 * 903 * @param resId Indicates the resource ID. 904 * @param num Indicates the number. 905 * @param callback Indicates the asynchronous callback used to return the singular-plural character 906 * string represented by the ID string corresponding to the specified number. 907 * @throws { BusinessError } 401 - If the input parameter invalid. 908 * @throws { BusinessError } 9001001 - If the resId invalid. 909 * @throws { BusinessError } 9001002 - If the resource not found by resId. 910 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 911 * @since 9 912 */ 913 getPluralStringValue(resId: number, num: number, callback: _AsyncCallback<string>): void; 914 915 /** 916 * Obtains the singular-plural character string represented by the ID string corresponding to 917 * the specified number in Promise mode. 918 * 919 * @param resId Indicates the resource ID. 920 * @param num Indicates the number. 921 * @returns Returns the singular-plural character string represented by the ID string 922 * corresponding to the specified number. 923 * @throws { BusinessError } 401 - If the input parameter invalid. 924 * @throws { BusinessError } 9001001 - If the resId invalid. 925 * @throws { BusinessError } 9001002 - If the resource not found by resId. 926 * @throws { BusinessError } 9001006 - If the resource re-ref too much. 927 * @since 9 928 */ 929 getPluralStringValue(resId: number, num: number): Promise<string>; 930 931 /** 932 * Obtains the content of the media file corresponding to a specified resource ID in callback mode. 933 * 934 * @param resId Indicates the resource ID. 935 * @param callback Indicates the asynchronous callback used to return the obtained media file content. 936 * @throws { BusinessError } 401 - If the input parameter invalid. 937 * @throws { BusinessError } 9001001 - If the resId invalid. 938 * @throws { BusinessError } 9001002 - If the resource not found by resId. 939 * @since 9 940 */ 941 getMediaContent(resId: number, callback: _AsyncCallback<Uint8Array>): void; 942 943 /** 944 * Obtains the content of the media file corresponding to a specified resource ID in Promise mode. 945 * 946 * @param resId Indicates the resource ID. 947 * @returns Returns the content of the media file corresponding to the specified resource ID. 948 * @throws { BusinessError } 401 - If the input parameter invalid. 949 * @throws { BusinessError } 9001001 - If the resId invalid. 950 * @throws { BusinessError } 9001002 - If the resource not found by resId. 951 * @since 9 952 */ 953 getMediaContent(resId: number): Promise<Uint8Array>; 954 955 /** 956 * Obtains the Base64 code of the image resource corresponding to the specified resource ID in callback mode. 957 * 958 * @param resId Indicates the resource ID. 959 * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image 960 * resource. 961 * @throws { BusinessError } 401 - If the input parameter invalid. 962 * @throws { BusinessError } 9001001 - If the resId invalid. 963 * @throws { BusinessError } 9001002 - If the resource not found by resId. 964 * @since 9 965 */ 966 getMediaContentBase64(resId: number, callback: _AsyncCallback<string>): void; 967 968 /** 969 * Obtains the Base64 code of the image resource corresponding to the specified resource ID in Promise mode. 970 * 971 * @param resId Indicates the resource ID. 972 * @returns Returns the Base64 code of the image resource corresponding to the specified resource ID. 973 * @throws { BusinessError } 401 - If the input parameter invalid. 974 * @throws { BusinessError } 9001001 - If the resId invalid. 975 * @throws { BusinessError } 9001002 - If the resource not found by resId. 976 * @since 9 977 */ 978 getMediaContentBase64(resId: number): Promise<string>; 979 980 /** 981 * Obtains the raw file resource corresponding to the specified resource path in callback mode. 982 * 983 * @param path Indicates the resource relative path. 984 * @param callback Indicates the asynchronous callback used to return the raw file resource. 985 * @throws { BusinessError } 401 - If the input parameter invalid. 986 * @throws { BusinessError } 9001005 - If the resource not found by path. 987 * @since 9 988 */ 989 getRawFileContent(path: string, callback: _AsyncCallback<Uint8Array>): void; 990 991 /** 992 * Obtains the raw file resource corresponding to the specified resource path in Promise mode. 993 * 994 * @param path Indicates the resource relative path. 995 * @returns Returns the raw file resource corresponding to the specified resource path. 996 * @throws { BusinessError } 401 - If the input parameter invalid. 997 * @throws { BusinessError } 9001005 - If the resource not found by path. 998 * @since 9 999 */ 1000 getRawFileContent(path: string): Promise<Uint8Array>; 1001 1002 /** 1003 * Obtains the raw file resource descriptor corresponding to the specified resource path in callback mode. 1004 * 1005 * @param path Indicates the resource relative path. 1006 * @param callback Indicates the asynchronous callback used to return the raw file resource descriptor. 1007 * @throws { BusinessError } 401 - If the input parameter invalid. 1008 * @throws { BusinessError } 9001005 - If the resource not found by path. 1009 * @since 9 1010 */ 1011 getRawFd(path: string, callback: _AsyncCallback<RawFileDescriptor>): void; 1012 1013 /** 1014 * Obtains the raw file resource descriptor corresponding to the specified resource path in Promise mode. 1015 * 1016 * @param path Indicates the resource relative path. 1017 * @returns Returns the raw file resource descriptor corresponding to the specified resource path. 1018 * @throws { BusinessError } 401 - If the input parameter invalid. 1019 * @throws { BusinessError } 9001005 - If the resource not found by path. 1020 * @since 9 1021 */ 1022 getRawFd(path: string): Promise<RawFileDescriptor>; 1023 1024 /** 1025 * Obtains close raw file resource descriptor corresponding to the specified resource path in callback mode. 1026 * 1027 * @param path Indicates the resource relative path. 1028 * @param callback Indicates the asynchronous callback used to return result close raw file resource descriptor. 1029 * @throws { BusinessError } 401 - If the input parameter invalid. 1030 * @throws { BusinessError } 9001005 - If the resource not found by path. 1031 * @since 9 1032 */ 1033 closeRawFd(path: string, callback: _AsyncCallback<void>): void; 1034 1035 /** 1036 * Obtains close raw file resource descriptor corresponding to the specified resource path in Promise mode. 1037 * 1038 * @param path Indicates the resource relative path. 1039 * @throws { BusinessError } 401 - If the input parameter invalid. 1040 * @throws { BusinessError } 9001005 - If the resource not found by path. 1041 * @since 9 1042 */ 1043 closeRawFd(path: string): Promise<void>; 1044} 1045 1046 /** 1047 * Contains rawFile descriptor information. 1048 * @name Contains rawFile descriptor information 1049 * @since 9 1050 * @syscap SystemCapability.Global.ResourceManager 1051 * 1052 */ 1053 export type RawFileDescriptor = _RawFileDescriptor; 1054 1055 /** 1056 * Contains resource descriptor information. 1057 * @name Contains resource descriptor information 1058 * @since 9 1059 * @syscap SystemCapability.Global.ResourceManager 1060 * 1061 */ 1062 export type Resource = _Resource; 1063} 1064export default resourceManager;