@system.communicationkit.d.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright (c) 2020 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. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  17. */
  18. export interface GetCommunicationKitOptions {
  19. /**
  20. * Content index.
  21. * For liteWearable and smartVision, the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
  22. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  23. * @since 3
  24. */
  25. key: string;
  26. /**
  27. * Default value returned when the key does not exist.
  28. * If this parameter is not specified, an empty string is returned.
  29. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  30. * @since 3
  31. */
  32. default?: string;
  33. /**
  34. * Called when the stored content is read successfully.
  35. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  36. * @since 3
  37. */
  38. success?: (data: any) => void;
  39. /**
  40. * Called when the stored content fails to be read.
  41. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  42. * @since 3
  43. */
  44. fail?: (data: string, code: number) => void;
  45. /**
  46. * Called when the execution is completed.
  47. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  48. * @since 3
  49. */
  50. complete?: () => void;
  51. }
  52. /**
  53. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  54. */
  55. export interface SetCommunicationKitOptions {
  56. /**
  57. * Index of the stored content to be modified.
  58. * For liteWearable and smartVision, the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
  59. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  60. * @since 3
  61. */
  62. key: string;
  63. /**
  64. * Target storage content. If the content is an empty string, the data item with the key as the index will be deleted.
  65. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  66. * @since 3
  67. */
  68. value: string;
  69. /**
  70. * Called when the stored content is modified successfully.
  71. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  72. * @since 3
  73. */
  74. success?: () => void;
  75. /**
  76. * Called when the stored content fails to be modified.
  77. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  78. * @since 3
  79. */
  80. fail?: (data: string, code: number) => void;
  81. /**
  82. * Called when the execution is completed.
  83. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  84. * @since 3
  85. */
  86. complete?: () => void;
  87. }
  88. /**
  89. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  90. */
  91. export default class CommunicationKit {
  92. /**
  93. * Reads the stored content.
  94. * @param options Options.
  95. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  96. */
  97. static get(options: GetCommunicationKitOptions): void;
  98. /**
  99. * Modifies the stored content.
  100. * @param options Options.
  101. * @devices tv, phone, tablet, wearable, liteWearable, smartVision
  102. */
  103. static set(options: SetCommunicationKitOptions): void;
  104. }