From b8278b355035d13f7d8934a7a6b4200c7e258093 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 May 2022 20:42:33 +0800 Subject: [PATCH 01/10] add user Signed-off-by: unknown --- api/@ohos.application.errorManager.d.ts | 51 +++++++++++++++++++++++++ api/application/ErrorObserver.d.ts | 33 ++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 api/@ohos.application.errorManager.d.ts create mode 100644 api/application/ErrorObserver.d.ts diff --git a/api/@ohos.application.errorManager.d.ts b/api/@ohos.application.errorManager.d.ts new file mode 100644 index 0000000000..490cac91f4 --- /dev/null +++ b/api/@ohos.application.errorManager.d.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback } from './basic'; +import ErrorObserver from './application/ErrorObserver'; + +/** + * This module provides the function of error manager. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import errorManager from '@ohos.application.errorManager' + * @permission N/A + */ +declare namespace errorManager { + /** + * Register error observer. + * + * @default - + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param observer The error observer. + * @return Returns the number code of the observer. + */ + function registerErrorObserver(observer: ErrorObserver): number; + + /** + * Unregister error observer. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param observerId Indicates the number code of the observer. + * @return - + */ + function unregisterErrorObserver(observerId: number, callback: AsyncCallback): void; + function unregisterErrorObserver(observerId: number): Promise; +} + +export default errorManager; diff --git a/api/application/ErrorObserver.d.ts b/api/application/ErrorObserver.d.ts new file mode 100644 index 0000000000..4765185428 --- /dev/null +++ b/api/application/ErrorObserver.d.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The observer will be called by system when an error occurs. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + */ +export default class ErrorObserver { + /** + * Will be called when the js runtime throws an exception which doesn't caught by user. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param errMsg the message and error stacktrace about the exception. + * @return - + */ + onUnhandledException(errMsg: string): void; +} \ No newline at end of file -- Gitee From 5a05a0b25ab4b0700abbd119ecbc3da74d9fe4c8 Mon Sep 17 00:00:00 2001 From: xuchenghua09 Date: Mon, 30 May 2022 10:16:49 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E3=80=90=E6=B5=8B=E8=AF=95=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E3=80=91d.ts=20=E6=96=B0=E5=A2=9E=20printSync?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=89=93=E5=8D=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuchenghua09 --- api/application/abilityDelegator.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/api/application/abilityDelegator.d.ts b/api/application/abilityDelegator.d.ts index a5fc7926d3..72408dd34b 100644 --- a/api/application/abilityDelegator.d.ts +++ b/api/application/abilityDelegator.d.ts @@ -132,6 +132,7 @@ export interface AbilityDelegator { * @syscap SystemCapability.Ability.AbilityRuntime.Core * @param msg Log information */ + printSync(msg: string): void; print(msg: string, callback: AsyncCallback): void; print(msg: string): Promise; -- Gitee From 238a408cabafef4a0e25908dca56f793f12824e8 Mon Sep 17 00:00:00 2001 From: shilei Date: Mon, 6 Jun 2022 14:39:02 +0800 Subject: [PATCH 03/10] obtain profile Signed-off-by: shilei Change-Id: I592531e04f849dd79e9ea772ff8ab80011f30cc9 --- api/@ohos.bundle.d.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/api/@ohos.bundle.d.ts b/api/@ohos.bundle.d.ts index 8acdf81e38..d595998c13 100644 --- a/api/@ohos.bundle.d.ts +++ b/api/@ohos.bundle.d.ts @@ -734,6 +734,32 @@ declare namespace bundle { */ function getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback): void; function getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Promise; + + /** + * Obtains the profile designated by metadata name, abilityName and moduleName from the current application. + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param moduleName Indicates the moduleName of the application. + * @param abilityName Indicates the abilityName of the application. + * @param metadataName Indicates the name of metadata in ability. + * @return Returns string in json-format of the corresponding config file. + */ + function getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback>): void; + function getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise>; + + /** + * Obtains the profile designated by metadata name, extensionAbilityName and moduleName from the current application. + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param moduleName Indicates the moduleName of the application. + * @param extensionAbilityName Indicates the extensionAbilityName of the application. + * @param metadataName Indicates the name of metadata in ability. + * @return Returns string in json-format of the corresponding config file. + */ + function getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback>): void; + function getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise>; } export default bundle; -- Gitee From 0e51cb3a545cf4681fea92768886a0f007c3ec5c Mon Sep 17 00:00:00 2001 From: kangchongtao Date: Tue, 7 Jun 2022 14:21:29 +0800 Subject: [PATCH 04/10] =?UTF-8?q?AbilityComponent=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kangchongtao Change-Id: Iac1df4524d25bcb5eb7410de314523081b225fa1 --- api/@internal/component/ets/ability_component.d.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/@internal/component/ets/ability_component.d.ts b/api/@internal/component/ets/ability_component.d.ts index 43524e4129..359bba5297 100644 --- a/api/@internal/component/ets/ability_component.d.ts +++ b/api/@internal/component/ets/ability_component.d.ts @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Want } from '../../../ability/want'; /** * Provides an interface for the ability component. @@ -44,5 +43,5 @@ declare class AbilityComponentAttribute extends CommonMethod void): AbilityComponentAttribute; } -declare const abilityComponent: AbilityComponentInterface; -declare const abilityComponentInstance: AbilityComponentAttribute; +declare const AbilityComponent: AbilityComponentInterface; +declare const AbilityComponentInstance: AbilityComponentAttribute; -- Gitee From 3f55bf36349e28e52b44fd679882d54f9f4a1ce2 Mon Sep 17 00:00:00 2001 From: lizhouze Date: Tue, 7 Jun 2022 14:19:50 +0800 Subject: [PATCH 05/10] lizhouze@huawei.com Signed-off-by: lizhouze --- BUILD.gn | 1 + .../component/ets/common_ts_ets_api.d.ts | 501 ++++++++++++++++++ .../component/ets/state_management.d.ts | 493 +---------------- 3 files changed, 503 insertions(+), 492 deletions(-) create mode 100644 api/@internal/component/ets/common_ts_ets_api.d.ts diff --git a/BUILD.gn b/BUILD.gn index 96aa78f91e..6ee98ed20e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -44,6 +44,7 @@ ohos_copy("ets_component") { "api/@internal/component/ets/column.d.ts", "api/@internal/component/ets/column_split.d.ts", "api/@internal/component/ets/common.d.ts", + "api/@internal/component/ets/common_ts_ets_api.d.ts", "api/@internal/component/ets/context_menu.d.ts", "api/@internal/component/ets/counter.d.ts", "api/@internal/component/ets/custom_dialog_controller.d.ts", diff --git a/api/@internal/component/ets/common_ts_ets_api.d.ts b/api/@internal/component/ets/common_ts_ets_api.d.ts new file mode 100644 index 0000000000..1416b44d75 --- /dev/null +++ b/api/@internal/component/ets/common_ts_ets_api.d.ts @@ -0,0 +1,501 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Defines the AppStorage interface. + * @since 7 + */ +declare class AppStorage { + /** + * Called when a link is set. + * @since 7 + */ + static Link(propName: string): any; + + /** + * Called when a hyperlink is set. + * @since 7 + */ + static SetAndLink(propName: string, defaultValue: T): SubscribedAbstractProperty; + + /** + * Called when a property is set. + * @since 7 + */ + static Prop(propName: string): any; + + /** + * Called when dynamic properties are set. + * @since 7 + */ + static SetAndProp(propName: string, defaultValue: S): SubscribedAbstractProperty; + + /** + * Called when owning or not. + * @since 7 + */ + static Has(propName: string): boolean; + + /** + * Called when data is obtained. + * @since 7 + */ + static Get(propName: string): T | undefined; + + /** + * Called when setting. + * @since 7 + */ + static Set(propName: string, newValue: T): boolean; + + /** + * Called when setting or creating. + * @since 7 + */ + static SetOrCreate(propName: string, newValue: T): void; + + /** + * Called when a deletion is made. + * @since 7 + */ + static Delete(propName: string): boolean; + + /** + * Called when a dictionary is sorted. + * @since 7 + */ + static Keys(): IterableIterator; + + /** + * Called when a cleanup occurs. + * @since 7 + */ + static staticClear(): boolean; + + /** + * Called when the data can be changed. + * @since 7 + */ + static IsMutable(propName: string): boolean; + + /** + * Called when you check how much data is stored. + * @since 7 + */ + static Size(): number; +} + +/** + * Defines the subscribed abstract property. + * @since 7 + * @systemapi + */ +declare abstract class SubscribedAbstractProperty { + /** + * Setting Subscribers. + * @since 7 + * @systemapi + */ + protected subscribers_: Set; + + /** + * Private user ID. + * @since 7 + * @systemapi + */ + private id_; + + /** + * Private user information. + * @since 7 + * @systemapi + */ + private info_?; + + /** + * @since 7 + * @systemapi + */ + constructor( + /** + * Subscriber IPropertySubscriber. + * @since 7 + * @systemapi + */ + subscribeMe?: IPropertySubscriber, + /** + * Subscriber info. + * @since 7 + * @systemapi + */ + info?: string, + ); + + /** + * Called when the subscriber ID is entered. + * @since 7 + * @systemapi + */ + id(): number; + + /** + * Called when a subscriber information description is entered. + * @since 7 + * @systemapi + */ + info(): string; + + /** + * Called when data is obtained. + * @since 7 + * @systemapi + */ + abstract get(): T; + + /** + * Called when data is created. + * @since 7 + * @systemapi + */ + abstract set(newValue: T): void; + + /** + * Called when a two-way synchronization is created. + * @since 7 + * @systemapi + */ + createTwoWaySync(subscribeMe?: IPropertySubscriber, info?: string): SyncedPropertyTwoWay; + + /** + * Called when a one-way synchronization is created. + * @since 7 + * @systemapi + */ + createOneWaySync(subscribeMe?: IPropertySubscriber, info?: string): SyncedPropertyOneWay; + + /** + * Called when the subscriber is unlinked. + * @since 7 + * @systemapi + */ + unlinkSuscriber(subscriberId: number): void; + + /** + * Called when the notification has changed. + * @since 7 + * @systemapi + */ + protected notifyHasChanged(newValue: T): void; + + /** + * Called when the notification property is read. + * @since 7 + * @systemapi + */ + protected notifyPropertyRead(): void; + + /** + * Called when the number of users is queried. + * @since 7 + * @systemapi + */ + numberOfSubscrbers(): number; +} + +/** + * Provides an interface for attribute subscribers. + * @since 7 + * @systemapi + */ +interface IPropertySubscriber { + /** + * Called when the ID of the property subscriber is queried. + * @since 7 + * @systemapi + */ + id(): number; + + /** + * Provides a single attribute change user interface. + * @since 7 + * @systemapi + */ + aboutToBeDeleted(owningView?: IPropertySubscriber): void; +} + +/** + * Defines the state value. + * @since 7 + * @systemapi + */ +declare class SyncedPropertyTwoWay extends SubscribedAbstractProperty + implements ISinglePropertyChangeSubscriber { + /** + * Sources of synchronization attributes bidirectionally. + * @since 7 + * @systemapi + */ + private source_; + + /** + * constructor parameters. + * @since 7 + * @systemapi + */ + constructor(source: SubscribedAbstractProperty, subscribeMe?: IPropertySubscriber, info?: string); + + /** + * Called when processing information about to be deleted. + * @since 7 + * @systemapi + */ + aboutToBeDeleted(unsubscribeMe?: IPropertySubscriber): void; + + /** + * Information Changed. + * @since 7 + * @systemapi + */ + hasChanged(newValue: T): void; + + /** + * Called when data is obtained. + * @since 7 + * @systemapi + */ + get(): T; + + /** + * Called when data is created. + * @since 7 + * @systemapi + */ + set(newValue: T): void; +} + +/** +* Defines the prop state value. +* @since 7 +* @systemapi +*/ +declare class SyncedPropertyOneWay extends SubscribedAbstractProperty + implements ISinglePropertyChangeSubscriber { + /** + * Pack value for single-item binding. + * @since 7 + * @systemapi + */ + private wrappedValue_; + + /** + * Sources of synchronization attributes bidirectionally. + * @since 7 + * @systemapi + */ + private source_; + + /** + * Constructor parameters. + * @since 7 + * @systemapi + */ + constructor(source: SubscribedAbstractProperty, subscribeMe?: IPropertySubscriber, info?: string); + + /** + * Called when processing information about to be deleted. + * @since 7 + * @systemapi + */ + aboutToBeDeleted(unsubscribeMe?: IPropertySubscriber): void; + + /** + * Information Changed. + * @since 7 + * @systemapi + */ + hasChanged(newValue: T): void; + + /** + * Called when data is obtained. + * @since 7 + * @systemapi + */ + get(): T; + + /** + * Called when data is created. + * @since 7 + * @systemapi + */ + set(newValue: T): void; +} + +/** + * Defines the subscriber. + * @since 7 + * @systemapi + */ +interface ISinglePropertyChangeSubscriber extends IPropertySubscriber { + /** + * Provides a single attribute change user interface. + * @since 7 + * @systemapi + */ + hasChanged(newValue: T): void; +} + +/** + * Defines the Subscribale base class. + * @since 7 + * @systemapi + * @hide + */ +declare abstract class SubscribaleAbstract { + /** + * Returns the ownership attribute set by the. + * @since 7 + * @systemapi + * @hide + */ + private owningProperties_: Set; + + /** + * Constructor. + * @since 7 + * @systemapi + * @hide + */ + constructor(); + + /** + * Called when the notification property has changed. + * @since 7 + * @systemapi + * @hide + */ + protected notifyPropertyHasChanged(propName: string, newValue: any): void; + + /** + * Called when adding an already owned property. + * @since 7 + * @systemapi + * @hide + */ + public addOwningProperty(subscriber: IPropertySubscriber): void; + + /** + * Called when an already owned property is deleted. + * @since 7 + * @systemapi + * @hide + */ + public removeOwningProperty(property: IPropertySubscriber): void; + + /** + * Called when an already owned property is deleted by ID + * @since 7 + * @systemapi + * @hide + */ + public removeOwningPropertyById(subscriberId: number): void; +} + +/** + * Defines the Environment interface. + * @since 7 + */ +declare class Environment { + /** + * Constructor. + * @since 7 + * @systemapi + * @hide + */ + constructor(); + + /** + * Called when a property value is checked. + * @since 7 + */ + static EnvProp(key: string, value: S): boolean; + + /** + * Called when multiple property values are checked. + * @since 7 + */ + static EnvProps( + props: { + key: string; + defaultValue: any; + }[], + ): void; + + /** + * Set the key value. + * @since 7 + */ + static Keys(): Array; +} + +/** + * Defines the PersistentStorage interface. + * @since 7 + */ +declare class PersistentStorage { + /** + * Constructor parameters. + * @since 7 + * @systemapi + * @hide + */ + constructor(appStorage: AppStorage, storage: Storage); + + /** + * Called when a persistence property is stored. + * @since 7 + */ + static PersistProp(key: string, defaultValue: T): void; + + /** + * Called when a property is deleted. + * @since 7 + */ + static DeleteProp(key: string): void; + + /** + * Called when multiple persistence properties are stored. + * @since 7 + */ + static PersistProps( + properties: { + key: string; + defaultValue: any; + }[], + ): void; + + /** + * Set the key value. + * @since 7 + */ + static Keys(): Array; +} + +/** + * Used for ide. + * @since 7 + * @systemapi + * @hide + */ +declare const appStorage: AppStorage; \ No newline at end of file diff --git a/api/@internal/component/ets/state_management.d.ts b/api/@internal/component/ets/state_management.d.ts index 7054019e1a..fbbbef9b4e 100644 --- a/api/@internal/component/ets/state_management.d.ts +++ b/api/@internal/component/ets/state_management.d.ts @@ -13,390 +13,6 @@ * limitations under the License. */ -/** - * Provides an interface for attribute subscribers. - * @since 7 - * @systemapi - */ -interface IPropertySubscriber { - /** - * Called when the ID of the property subscriber is queried. - * @since 7 - * @systemapi - */ - id(): number; - - /** - * Provides a single attribute change user interface. - * @since 7 - * @systemapi - */ - aboutToBeDeleted(owningView?: IPropertySubscriber): void; -} - -/** - * Defines the subscriber. - * @since 7 - * @systemapi - */ -interface ISinglePropertyChangeSubscriber extends IPropertySubscriber { - /** - * Provides a single attribute change user interface. - * @since 7 - * @systemapi - */ - hasChanged(newValue: T): void; -} - -/** - * Defines the subscribed abstract property. - * @since 7 - * @systemapi - */ -declare abstract class SubscribedAbstractProperty { - /** - * Setting Subscribers. - * @since 7 - * @systemapi - */ - protected subscribers_: Set; - - /** - * Private user ID. - * @since 7 - * @systemapi - */ - private id_; - - /** - * Private user information. - * @since 7 - * @systemapi - */ - private info_?; - - /** - * @since 7 - * @systemapi - */ - constructor( - /** - * Subscriber IPropertySubscriber. - * @since 7 - * @systemapi - */ - subscribeMe?: IPropertySubscriber, - /** - * Subscriber info. - * @since 7 - * @systemapi - */ - info?: string, - ); - - /** - * Called when the subscriber ID is entered. - * @since 7 - * @systemapi - */ - id(): number; - - /** - * Called when a subscriber information description is entered. - * @since 7 - * @systemapi - */ - info(): string; - - /** - * Called when data is obtained. - * @since 7 - * @systemapi - */ - abstract get(): T; - - /** - * Called when data is created. - * @since 7 - * @systemapi - */ - abstract set(newValue: T): void; - - /** - * Called when a two-way synchronization is created. - * @since 7 - * @systemapi - */ - createTwoWaySync(subscribeMe?: IPropertySubscriber, info?: string): SyncedPropertyTwoWay; - - /** - * Called when a one-way synchronization is created. - * @since 7 - * @systemapi - */ - createOneWaySync(subscribeMe?: IPropertySubscriber, info?: string): SyncedPropertyOneWay; - - /** - * Called when the subscriber is unlinked. - * @since 7 - * @systemapi - */ - unlinkSuscriber(subscriberId: number): void; - - /** - * Called when the notification has changed. - * @since 7 - * @systemapi - */ - protected notifyHasChanged(newValue: T): void; - - /** - * Called when the notification property is read. - * @since 7 - * @systemapi - */ - protected notifyPropertyRead(): void; - - /** - * Called when the number of users is queried. - * @since 7 - * @systemapi - */ - numberOfSubscrbers(): number; -} - -/** - * Defines the state value. - * @since 7 - * @systemapi - */ -declare class SyncedPropertyTwoWay - extends SubscribedAbstractProperty - implements ISinglePropertyChangeSubscriber -{ - /** - * Sources of synchronization attributes bidirectionally. - * @since 7 - * @systemapi - */ - private source_; - - /** - * constructor parameters. - * @since 7 - * @systemapi - */ - constructor(source: SubscribedAbstractProperty, subscribeMe?: IPropertySubscriber, info?: string); - - /** - * Called when processing information about to be deleted. - * @since 7 - * @systemapi - */ - aboutToBeDeleted(unsubscribeMe?: IPropertySubscriber): void; - - /** - * Information Changed. - * @since 7 - * @systemapi - */ - hasChanged(newValue: T): void; - - /** - * Called when data is obtained. - * @since 7 - * @systemapi - */ - get(): T; - - /** - * Called when data is created. - * @since 7 - * @systemapi - */ - set(newValue: T): void; -} - -/** - * Defines the prop state value. - * @since 7 - * @systemapi - */ -declare class SyncedPropertyOneWay - extends SubscribedAbstractProperty - implements ISinglePropertyChangeSubscriber -{ - /** - * Pack value for single-item binding. - * @since 7 - * @systemapi - */ - private wrappedValue_; - - /** - * Sources of synchronization attributes bidirectionally. - * @since 7 - * @systemapi - */ - private source_; - - /** - * Constructor parameters. - * @since 7 - * @systemapi - */ - constructor(source: SubscribedAbstractProperty, subscribeMe?: IPropertySubscriber, info?: string); - - /** - * Called when processing information about to be deleted. - * @since 7 - * @systemapi - */ - aboutToBeDeleted(unsubscribeMe?: IPropertySubscriber): void; - - /** - * Information Changed. - * @since 7 - * @systemapi - */ - hasChanged(newValue: T): void; - - /** - * Called when data is obtained. - * @since 7 - * @systemapi - */ - get(): T; - - /** - * Called when data is created. - * @since 7 - * @systemapi - */ - set(newValue: T): void; -} - -/** - * Defines the AppStorage interface. - * @since 7 - */ -declare class AppStorage { - /** - * Called when a link is set. - * @since 7 - */ - static Link(propName: string): any; - - /** - * Called when a hyperlink is set. - * @since 7 - */ - static SetAndLink(propName: string, defaultValue: T): SubscribedAbstractProperty; - - /** - * Called when a property is set. - * @since 7 - */ - static Prop(propName: string): any; - - /** - * Called when dynamic properties are set. - * @since 7 - */ - static SetAndProp(propName: string, defaultValue: S): SubscribedAbstractProperty; - - /** - * Called when owning or not. - * @since 7 - */ - static Has(propName: string): boolean; - - /** - * Called when data is obtained. - * @since 7 - */ - static Get(propName: string): T | undefined; - - /** - * Called when setting. - * @since 7 - */ - static Set(propName: string, newValue: T): boolean; - - /** - * Called when setting or creating. - * @since 7 - */ - static SetOrCreate(propName: string, newValue: T): void; - - /** - * Called when a deletion is made. - * @since 7 - */ - static Delete(propName: string): boolean; - - /** - * Called when a dictionary is sorted. - * @since 7 - */ - static Keys(): IterableIterator; - - /** - * Called when a cleanup occurs. - * @since 7 - */ - static staticClear(): boolean; - - /** - * Called when the data can be changed. - * @since 7 - */ - static IsMutable(propName: string): boolean; - - /** - * Called when you check how much data is stored. - * @since 7 - */ - static Size(): number; -} - -/** - * Defines the Environment interface. - * @since 7 - */ -declare class Environment { - /** - * Constructor. - * @since 7 - * @systemapi - * @hide - */ - constructor(); - - /** - * Called when a property value is checked. - * @since 7 - */ - static EnvProp(key: string, value: S): boolean; - - /** - * Called when multiple property values are checked. - * @since 7 - */ - static EnvProps( - props: { - key: string; - defaultValue: any; - }[], - ): void; - - /** - * Set the key value. - * @since 7 - */ - static Keys(): Array; -} - /** * Defines the ColorMode of device. * @since 7 @@ -439,49 +55,6 @@ declare enum LayoutDirection { Auto, } -/** - * Defines the PersistentStorage interface. - * @since 7 - */ -declare class PersistentStorage { - /** - * Constructor parameters. - * @since 7 - * @systemapi - * @hide - */ - constructor(appStorage: AppStorage, storage: Storage); - - /** - * Called when a persistence property is stored. - * @since 7 - */ - static PersistProp(key: string, defaultValue: T): void; - - /** - * Called when a property is deleted. - * @since 7 - */ - static DeleteProp(key: string): void; - - /** - * Called when multiple persistence properties are stored. - * @since 7 - */ - static PersistProps( - properties: { - key: string; - defaultValue: any; - }[], - ): void; - - /** - * Set the key value. - * @since 7 - */ - static Keys(): Array; -} - /** * Defines the base class of storage. * @since 7 @@ -529,62 +102,6 @@ declare class Storage { delete(key: string): void; } -/** - * Defines the Subscribale base class. - * @since 7 - * @systemapi - * @hide - */ -declare abstract class SubscribaleAbstract { - /** - * Returns the ownership attribute set by the. - * @since 7 - * @systemapi - * @hide - */ - private owningProperties_: Set; - - /** - * Constructor. - * @since 7 - * @systemapi - * @hide - */ - constructor(); - - /** - * Called when the notification property has changed. - * @since 7 - * @systemapi - * @hide - */ - protected notifyPropertyHasChanged(propName: string, newValue: any): void; - - /** - * Called when adding an already owned property. - * @since 7 - * @systemapi - * @hide - */ - public addOwningProperty(subscriber: IPropertySubscriber): void; - - /** - * Called when an already owned property is deleted. - * @since 7 - * @systemapi - * @hide - */ - public removeOwningProperty(property: IPropertySubscriber): void; - - /** - * Called when an already owned property is deleted by ID - * @since 7 - * @systemapi - * @hide - */ - public removeOwningPropertyById(subscriberId: number): void; -} - /** * Defining LocalStorage. * @since 9 @@ -675,12 +192,4 @@ declare class LocalStorage { * @since 9 */ clear(): boolean; -} - -/** - * Used for ide. - * @since 7 - * @systemapi - * @hide - */ -declare const appStorage: AppStorage; +} \ No newline at end of file -- Gitee From 3daf997f591a84c1091c57d8ed7215b54cb776c0 Mon Sep 17 00:00:00 2001 From: zhuxiang Date: Wed, 1 Jun 2022 16:53:04 +0800 Subject: [PATCH 06/10] add resource manager js interface for resource object Signed-off-by: zhuxiang --- api/@ohos.resourceManager.d.ts | 125 +++++++++++++++++++++++++++++++++ api/global/resource.d.ts | 44 ++++++++++++ 2 files changed, 169 insertions(+) create mode 100755 api/global/resource.d.ts diff --git a/api/@ohos.resourceManager.d.ts b/api/@ohos.resourceManager.d.ts index 7f2a2105f9..cde1e62a77 100644 --- a/api/@ohos.resourceManager.d.ts +++ b/api/@ohos.resourceManager.d.ts @@ -14,6 +14,7 @@ */ import { RawFileDescriptor } from './global/rawFileDescriptor'; +import { Resource } from './global/resource'; /** * Provides resource related APIs. @@ -253,6 +254,24 @@ export interface ResourceManager { */ getString(resId: number): Promise; + /** + * Obtains the character string corresponding to a specified resource object in callback mode. + * + * @param resource Indicates the resource object. + * @param callback Indicates the asynchronous callback used to return the obtained character string. + * @since 9 + */ + getString(resource: Resource, callback: AsyncCallback): void; + + /** + * Obtains string resources associated with a specified resource object in Promise mode. + * + * @param resource Indicates the resource object. + * @return Returns the character string corresponding to the resource object. + * @since 9 + */ + getString(resource: Resource): Promise; + /** * Obtains the array of character strings corresponding to a specified resource ID in callback mode. * @@ -271,6 +290,24 @@ export interface ResourceManager { */ getStringArray(resId: number): Promise>; + /** + * Obtains the array of character strings corresponding to a specified resource object in callback mode. + * + * @param resource Indicates the resource object. + * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. + * @since 9 + */ + getStringArray(resource: Resource, callback: AsyncCallback>): void; + + /** + * Obtains the array of character strings corresponding to a specified resource object in Promise mode. + * + * @param resource Indicates the resource object. + * @return Returns the array of character strings corresponding to the specified resource object. + * @since 9 + */ + getStringArray(resource: Resource): Promise>; + /** * Obtains the content of the media file corresponding to a specified resource ID in callback mode. * @@ -289,6 +326,24 @@ export interface ResourceManager { */ getMedia(resId: number): Promise; + /** + * Obtains the content of the media file corresponding to a specified resource object in callback mode. + * + * @param resource Indicates the resource object. + * @param callback Indicates the asynchronous callback used to return the obtained media file content. + * @since 9 + */ + getMedia(resource: Resource, callback: AsyncCallback): void; + + /** + * Obtains the content of the media file corresponding to a specified resource object in Promise mode. + * + * @param resource Indicates the resource object. + * @return Returns the content of the media file corresponding to the specified resource object. + * @since 9 + */ + getMedia(resource: Resource): Promise; + /** * Obtains the Base64 code of the image resource corresponding to the specified resource ID in callback mode. * @@ -308,6 +363,25 @@ export interface ResourceManager { */ getMediaBase64(resId: number): Promise; + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource object in callback mode. + * + * @param resource Indicates the resource object. + * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image + * resource. + * @since 9 + */ + getMediaBase64(resource: Resource, callback: AsyncCallback): void; + + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource object in Promise mode. + * + * @param resource Indicates the resource object. + * @return Returns the Base64 code of the image resource corresponding to the specified resource object. + * @since 9 + */ + getMediaBase64(resource: Resource): Promise; + /** * Obtains the device capability in callback mode. * @@ -365,6 +439,30 @@ export interface ResourceManager { */ getPluralString(resId: number, num: number): Promise; + /** + * Obtains the singular-plural character string represented by the resource object string corresponding to the + * specified number in callback mode. + * + * @param resource Indicates the resource object. + * @param num Indicates the number. + * @param callback Indicates the asynchronous callback used to return the singular-plural character + * string represented by the resource object string corresponding to the specified number. + * @since 9 + */ + getPluralString(resource: Resource, num: number, callback: AsyncCallback): void; + + /** + * Obtains the singular-plural character string represented by the resource object string corresponding to + * the specified number in Promise mode. + * + * @param resource Indicates the resource object. + * @param num Indicates the number. + * @return Returns the singular-plural character string represented by the resource object string + * corresponding to the specified number. + * @since 9 + */ + getPluralString(resource: Resource, num: number): Promise; + /** * Obtains the raw file resource corresponding to the specified resource path in callback mode. * @@ -525,6 +623,15 @@ export interface ResourceManager { */ getStringSync(resId: number): string; + /** + * Obtains string resources associated with a specified resource object. + * + * @param resource Indicates the resource object. + * @return Returns the character string corresponding to the resource object. + * @since 9 + */ + getStringSync(resource: Resource): string; + /** * Obtains string resources associated with a specified resource name. * @@ -543,6 +650,15 @@ export interface ResourceManager { */ getBoolean(resId: number): boolean; + /** + * Obtains the boolean result with a specified resource object. + * + * @param resource Indicates the resource object. + * @return Returns the boolean resource corresponding to the resource object. + * @since 9 + */ + getBoolean(resource: Resource): boolean; + /** * Obtains the boolean result with a specified resource name. * @@ -561,6 +677,15 @@ export interface ResourceManager { */ getNumber(resId: number): number; + /** + * Obtains the number result with a specified resource object. + * + * @param resource Indicates the resource object. + * @return Returns the number resource corresponding to the resource object. + * @since 9 + */ + getNumber(resource: Resource): number; + /** * Obtains the number result with a specified resource name. * diff --git a/api/global/resource.d.ts b/api/global/resource.d.ts new file mode 100755 index 0000000000..269ec392bd --- /dev/null +++ b/api/global/resource.d.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Contains resource descriptor information. + * @name Contains resource descriptor information + * @since 9 + * @syscap SystemCapability.Global.ResourceManager + * + */ + export interface Resource { + /** + * bundle name in hap + * + * @since 9 + */ + bundleName: string; + + /** + * module name in hap + * + * @since 9 + */ + moduleName: string; + + /** + * resource id in hap + * + * @since 9 + */ + id: number; +} -- Gitee From af939cb01b7908864864bd7bfc45ead84a4778e1 Mon Sep 17 00:00:00 2001 From: zhujie81 Date: Wed, 8 Jun 2022 17:50:26 +0800 Subject: [PATCH 07/10] update sdk for audio.d.ts Signed-off-by: zhujie81 --- api/@ohos.multimedia.audio.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index a95de6ec26..e7392a5ebf 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -1274,7 +1274,7 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Renderer * @systemapi */ - abandonIndependentInterrupt(focusType: FocusType): Promise; + abandonIndependentInterrupt(focusType: FocusType): Promise; /** * Listens for independent interruption events. When the audio of an application is interrupted by another application, -- Gitee From c7b9f44f43984982072fbc00dbf7b38a5ae26877 Mon Sep 17 00:00:00 2001 From: zhangxiuping Date: Fri, 13 May 2022 16:24:25 +0800 Subject: [PATCH 08/10] Add js apis for nfc tag read and write. Signed-off-by: zhangxiuping --- api/@ohos.connectedTag.d.ts | 4 +- api/@ohos.nfc.cardEmulation.d.ts | 3 +- api/@ohos.nfc.controller.d.ts | 2 - api/@ohos.nfc.tag.d.ts | 131 +++++++- api/tag/nfctech.d.ts | 540 +++++++++++++++++++++++++++++++ api/tag/tagSession.d.ts | 16 +- 6 files changed, 668 insertions(+), 28 deletions(-) mode change 100755 => 100644 api/@ohos.nfc.tag.d.ts mode change 100755 => 100644 api/tag/nfctech.d.ts diff --git a/api/@ohos.connectedTag.d.ts b/api/@ohos.connectedTag.d.ts index 96fb3d93c9..23eaa844f7 100755 --- a/api/@ohos.connectedTag.d.ts +++ b/api/@ohos.connectedTag.d.ts @@ -98,10 +98,10 @@ declare namespace connectedTag { */ enum NfcRfType { /** NFC RF LEAVE */ - NFC_RF_LEAVE = 0; + NFC_RF_LEAVE = 0, /** NFC RF ENTER */ - NFC_RF_ENTER = 1; + NFC_RF_ENTER = 1, } } diff --git a/api/@ohos.nfc.cardEmulation.d.ts b/api/@ohos.nfc.cardEmulation.d.ts index dbf97d6257..a31e736692 100755 --- a/api/@ohos.nfc.cardEmulation.d.ts +++ b/api/@ohos.nfc.cardEmulation.d.ts @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { AsyncCallback } from './basic'; /** * Provides methods to operate or manage NFC card emulation. @@ -76,7 +77,6 @@ declare namespace cardEmulation { */ stopHCE(): boolean; - /** * register HCE event to receive the APDU data. * @@ -86,7 +86,6 @@ declare namespace cardEmulation { * * @since 8 */ - on(type: "hceCmd", callback: AsyncCallback): void; /** diff --git a/api/@ohos.nfc.controller.d.ts b/api/@ohos.nfc.controller.d.ts index c0fd42b065..0074db7b24 100755 --- a/api/@ohos.nfc.controller.d.ts +++ b/api/@ohos.nfc.controller.d.ts @@ -55,7 +55,6 @@ declare namespace nfcController { * * @since 7 */ - function on(type: "nfcStateChange", callback: Callback): void /** @@ -66,7 +65,6 @@ declare namespace nfcController { * * @since 7 */ - function off(type: "nfcStateChange", callback?: Callback): void /** diff --git a/api/@ohos.nfc.tag.d.ts b/api/@ohos.nfc.tag.d.ts old mode 100755 new mode 100644 index d98f18c716..21f2efb9ec --- a/api/@ohos.nfc.tag.d.ts +++ b/api/@ohos.nfc.tag.d.ts @@ -14,6 +14,10 @@ */ import { NfcATag, NfcBTag, NfcFTag, NfcVTag } from './tag/nfctech'; +import { IsoDepTag, NdefTag, MifareClassicTag, MifareUltralightTag, NdefFormatableTag } from './tag/nfctech'; +import { PacMap } from "./ability/dataAbilityHelper"; +import rpc from "./@ohos.rpc"; +import { AsyncCallback, Callback } from './basic'; /** * Provides methods to operate or manage NFC tag. @@ -48,10 +52,13 @@ declare namespace tag { /** Indicates a MifareUltralight tag. */ const MIFARE_ULTRALIGHT = 9; + /** Indicates a NdefFormatable tag. */ + const NDEF_FORMATABLE = 10; + /** - * Obtains an {@code NfcATag} object based on the tag information. + * Obtains an {@link NfcATag} object based on the tag information. * - *

During tag reading, if the tag supports the NFC-A technology, an {@code NfcATag} object + *

During tag reading, if the tag supports the NFC-A technology, an {@link NfcATag} object * will be created based on the tag information. * * @param tagInfo Indicates the tag information. @@ -62,9 +69,9 @@ declare namespace tag { function getNfcATag(tagInfo: TagInfo): NfcATag /** - * Obtains an {@code NfcBTag} object based on the tag information. + * Obtains an {@link NfcBTag} object based on the tag information. * - *

During tag reading, if the tag supports the NFC-B technology, an {@code NfcBTag} object + *

During tag reading, if the tag supports the NFC-B technology, an {@link NfcBTag} object * will be created based on the tag information. * * @param tagInfo Indicates the tag information. @@ -75,9 +82,9 @@ declare namespace tag { function getNfcBTag(tagInfo: TagInfo): NfcBTag /** - * Obtains an {@code NfcFTag} object based on the tag information. + * Obtains an {@link NfcFTag} object based on the tag information. * - *

During tag reading, if the tag supports the NFC-F technology, an {@code NfcFTag} object + *

During tag reading, if the tag supports the NFC-F technology, an {@link NfcFTag} object * will be created based on the tag information. * * @param tagInfo Indicates the tag information. @@ -88,9 +95,9 @@ declare namespace tag { function getNfcFTag(tagInfo: TagInfo): NfcFTag /** - * Obtains an {@code NfcVTag} object based on the tag information. + * Obtains an {@link NfcVTag} object based on the tag information. * - *

During tag reading, if the tag supports the NFC-V technology, an {@code NfcVTag} object + *

During tag reading, if the tag supports the NFC-V technology, an {@link NfcVTag} object * will be created based on the tag information. * * @param tagInfo Indicates the tag information. @@ -100,6 +107,70 @@ declare namespace tag { */ function getNfcVTag(tagInfo: TagInfo): NfcVTag + /** + * Obtains an {@link IsoDepTag} object based on the tag information. + * + *

During tag reading, if the tag supports the IsoDep technology, an {@link IsoDepTag} object + * will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getIsoDepTag(tagInfo: TagInfo): IsoDepTag + + /** + * Obtains an {@link NdefTag} object based on the tag information. + * + *

During tag reading, if the tag supports the NDEF technology, an {@link NdefTag} object + * will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getNdefTag(tagInfo: TagInfo): NdefTag + + /** + * Obtains an {@link MifareClassicTag} object based on the tag information. + * + *

During tag reading, if the tag supports the MifareClassic technology, + * an {@link MifareClassicTag} object will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getMifareClassicTag(tagInfo: TagInfo): MifareClassicTag + + /** + * Obtains an {@link MifareUltralightTag} object based on the tag information. + * + *

During tag reading, if the tag supports the MifareUltralight technology, + * an {@link MifareUltralightTag} object will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getMifareUltralightTag(tagInfo: TagInfo): MifareUltralightTag + + /** + * Obtains an {@link NdefFormatableTag} object based on the tag information. + * + *

During tag reading, if the tag supports the NdefFormatable technology, + * an {@link NdefFormatableTag} object will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getNdefFormatableTag(tagInfo: TagInfo): NdefFormatableTag /** * Provides tag information. @@ -112,6 +183,50 @@ declare namespace tag { * @permission ohos.permission.NFC_TAG */ export interface TagInfo { + /** + * The uid of this tag, it. + * + * @since 9 + */ + uid: string; + + /** + * The supported technology list of this tag. + * + * @since 9 + */ + technology: number[]; + + /** + * The extra data for each technology of this tag. + * + * @since 9 + * @systemapi hide for inner use. + */ + extrasData: PacMap[]; + + /** + * The the RF discovery id of this tag. + * + * @since 9 + * @systemapi hide for inner use. + */ + tagRfDiscId: number; + + /** + * The extra data for the technology of this tag. + * + * @since 9 + * @systemapi hide for inner use. + */ + remoteTagService: rpc.RemoteObject; + + /** + * The supported technology list of this tag. + * + * @since 7 + * @deprecated since 9 + */ supportedProfiles: number[]; } } diff --git a/api/tag/nfctech.d.ts b/api/tag/nfctech.d.ts old mode 100755 new mode 100644 index 782b2aa51d..2cec52f28c --- a/api/tag/nfctech.d.ts +++ b/api/tag/nfctech.d.ts @@ -13,6 +13,7 @@ * limitations under the License. */ import { TagSession } from './tagSession'; +import { AsyncCallback, Callback } from '../basic'; /** * Provides interfaces to control the read and write of tags that support the NFC-A technology. @@ -137,3 +138,542 @@ export interface NfcVTag extends TagSession { */ getDsfId(): number; } + +/** + * Provides methods for accessing IsoDep tag. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ +export interface IsoDepTag extends TagSession { + /** + * Get Historical bytes of the tag. + * @return the Historical bytes. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getHistoricalBytes(): string; + + /** + * Get HiLayerResponse bytes of the tag. + * @return HiLayerResponse bytes + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getHiLayerResponse(): string; + + /** + * Check if externded apdu length supported or not. + * @return return true if externded apdu length supported, otherwise false. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + isExtendedApduSupported(): Promise; + isExtendedApduSupported(callback: AsyncCallback): void; +} + +/** + * NDEF records definition, see NFCForum-TS-NDEF_1.0. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ +export interface NdefRecord { + /** tnf of NdefRecord */ + tnf: number; + + /** RTD type of NdefRecord */ + rtdType: string; + + /** id of NdefRecord */ + id: string; + + /** payload of NdefRecord */ + payload: string; +} + +/** + * TNF types definitions, see NFCForum-TS-NDEF_1.0. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ +export enum TnfType { + /** Empty */ + TNF_EMPTY = 0x0, + + /** NFC Forum well-known type [NFC RTD] */ + TNF_WELL_KNOWN = 0x1, + + /** Media-type as defined in RFC 2046 [RFC 2046] */ + TNF_MEDIA = 0x2, + + /** Absolute URI as defined in RFC 3986 [RFC 3986] */ + TNF_ABSOLUTE_URI = 0x3, + + /** NFC Forum external type [NFC RTD] */ + TNF_EXT_APP = 0x4, + + /** Unknown */ + TNF_UNKNOWN = 0x5, + + /** Unchanged (see section 2.3.3) */ + TNF_UNCHANGED = 0x6, +} + +/** + * RTD types definitions, see NFC Record Type Definition (RTD) Specification. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ + export interface RtdType { + /** RTD type text */ + RTD_TEXT: 'T'; + + /** RTD type URI */ + RTD_URI: 'U'; +} + +export interface NdefMessage { + /** + * Get all records of a ndef message. + * @return record list of a ndef message + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getNdefRecords(): NdefRecord[]; + + /** + * Create a ndef record with uri data. + * @param uri uri data for new a ndef record + * @return the instance of NdefRecord + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + makeUriRecord(uri: string): NdefMessage; + + /** + * Create a ndef record with text data. + * @param text text data for new a ndef record + * @param locale language code for the ndef record. if locale is null, use default locale + * @return the instance of NdefRecord + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + makeTextRecord(text: string, locale: string): NdefMessage; + + /** + * Create a ndef record with mime data. + * @param mimeType type of mime data for new a ndef record + * @param mimeData mime data for new a ndef record + * @return the instance of NdefRecord + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + makeMimeRecord(mimeType: string, mimeData: string): NdefMessage; + + /** + * Create a ndef record with external data. + * @param domainName domain name of issuing organization for the external data + * @param serviceName domain specific type of data for the external data + * @param externalData data payload of a ndef record + * @return the instance of NdefRecord + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + makeExternalRecord(domainName: string, serviceName: string, externalData: string): NdefMessage; + + /** + * Parse a ndef message into raw bytes. + * @param ndefMessage a ndef message to parse + * @return raw bytes of a ndef message + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + messageToString(ndefMessage: NdefMessage): string; +} + +/** + * NfcForum Type definition. The Ndef tag may use one of them. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ + export enum NfcForumType { + /** NFC FORUM TYPE 1 */ + NFC_FORUM_TYPE_1 = 1, + + /** NFC FORUM TYPE 2 */ + NFC_FORUM_TYPE_2 = 2, + + /** NFC FORUM TYPE 3 */ + NFC_FORUM_TYPE_3 = 3, + + /** NFC FORUM TYPE 4 */ + NFC_FORUM_TYPE_4 = 4, + + /** Mifare Classic */ + MIFARE_CLASSIC = 101, +} + +/** + * Provides methods for accessing NDEF tag. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ +export interface NdefTag extends TagSession { + /** + * Create a ndef message with raw bytes. + * @param data raw bytes to parse ndef message + * @return the instance of NdefMessage + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + createNdefMessage(data: string): NdefMessage; + + /** + * Create a ndef message with record list. + * @param ndefRecords record list to parse ndef message + * @return the instance of NdefMessage + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + createNdefMessage(ndefRecords: NdefRecord[]): NdefMessage; + + /** + * Get the type of the Ndef tag. + * @return type of Ndef tag. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getNdefTagType(): NfcForumType; + + /** + * Get the ndef message that was read from ndef tag when tag discovery. + * @return ndef message. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getNdefMessage(): NdefMessage; + + /** + * Check if ndef tag is writable. + * @return return true if the tag is writable, otherwise return false. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + isNdefWritable(): Promise; + isNdefWritable(callback: AsyncCallback): void; + + /** + * Read ndef message on this tag. + * @return ndef message in tag. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + readNdef(): Promise; + readNdef(callback: AsyncCallback): void; + + /** + * Write ndef message into this tag. + * @param msg ndef message to write + * @return Error code of write. if return 0, means successful. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + writeNdef(msg: NdefMessage): Promise; + writeNdef(msg: NdefMessage, callback: AsyncCallback): void; + + /** + * Check ndef tag can be set read-only + * @return return true if the tag can be set readonly, otherwise return false. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + canSetReadOnly(): Promise; + canSetReadOnly(callback: AsyncCallback): void; + + /** + * Set ndef tag read-only + * @return if return 0 means successful, otherwise the error code. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + setReadOnly(): Promise; + setReadOnly(callback: AsyncCallback): void; + + /** + * Convert the Nfc forum type into byte array defined in Nfc forum. + * @param type Nfc forum type of ndef tag + * @return Nfc forum type byte array + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getNdefTagTypeString(type: NfcForumType): string; +} + +/** + * MifareClassic Type definition + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ +export enum MifareClassicType { + /** Mifare Type unknown */ + TYPE_UNKNOWN = -1, + + /** Mifare Classic */ + TYPE_CLASSIC = 0, + + /** Mifare Plus */ + TYPE_PLUS = 1, + + /** Mifare Pro */ + TYPE_PRO = 2, +} + +/** + * MifareClassic Tag size. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ +export enum MifareTagSize { + /** 5 sectors per tag, 4 blocks per sector */ + MC_SIZE_MINI = 320, + + /** 16 sectors per tag, 4 blocks per sector */ + MC_SIZE_1K = 1024, + + /** 32 sectors per tag, 4 blocks per sector */ + MC_SIZE_2K = 2048, + + /** 40 sectors per tag, 4 blocks per sector */ + MC_SIZE_4K = 4096, +} + +/** + * Provides methods for accessing MifareClassic tag. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ +export interface MifareClassicTag extends TagSession { + /** + * Authenticate a sector with the key.Only successful authentication sector can be operated. + * @param sectorIndex Index of sector to authenticate + * @param key key(6-bytes) to authenticate + * @param isKeyA KeyA flag. true means KeyA, otherwise KeyB + * @return Result of authenticattion. if return ture, means successful. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise; + authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback: AsyncCallback): void; + + /** + * Read a block, one block size is 16 bytes. + * @param blockIndex index of block to read + * @return the block data + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + readSingleBlock(blockIndex: number): Promise; + readSingleBlock(blockIndex: number, callback: AsyncCallback): void; + + /** + * Write a block, one block size is 16 bytes. + * @param blockIndex index of block to write + * @param data block data to write + * @return Error code of write. if return 0, means successful. + * @since 9 + * @permission ohos.pemission.NFC_TAG + */ + writeSingleBlock(blockIndex: number, data: string): Promise; + writeSingleBlock(blockIndex: number, data: string, callback: AsyncCallback): void; + + /** + * Increment a value block + * @param blockIndex index of block to increment + * @param value value to increment, none-negative + * @return Error code of increment. if return 0, means successful. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + incrementBlock(blockIndex: number, value: number): Promise; + incrementBlock(blockIndex: number, value: number, callback: AsyncCallback): void; + + /** + * Decrement a value block + * @param blockIndex index of block to decrement + * @param value value to increment, none-negative + * @return Error code of decrement. if return 0, means successful. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + decrementBlock(blockIndex: number, value: number): Promise; + decrementBlock(blockIndex: number, value: number, callback: AsyncCallback): void; + + /** + * Copy from the value of register to the value block + * @param blockIndex index of value block to copy to + * @return if return 0, means successful. otherwise the error code + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + transferToBlock(blockIndex: number): Promise; + transferToBlock(blockIndex: number, callback: AsyncCallback): void; + + /** + * Copy from the value block to the register + * @param blockIndex index of value block to copy from + * @return if return 0, means successful. otherwise the error code + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + restoreFromBlock(blockIndex: number): Promise; + restoreFromBlock(blockIndex: number, callback: AsyncCallback): void; + + /** + * Get the number of sectors in mifareclassic tag + * @return the number of sectors. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getSectorCount(): number; + + /** + * Get the number of blocks in the sector. + * @param sectorIndex index of sector + * @return the number of blocks. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getBlockCountInSector(sectorIndex: number): number; + + /** + * Get the type of the MifareClassic tag. + * @return type of MifareClassic tag. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getType(): MifareClassicType; + + /** + * Get size of the tag in bytes, see {@code MifareTagSize}. + * @return size of the tag + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getTagSize(): number; + + /** + * check if if tag is emulated + * @return return true if tag is emulated, otherwise return false. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + isEmulatedTag(): boolean; + + /** + * Get the first block of the specific sector. + * @param sectorIndex index of sector + * @return index of first block in the sector + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getBlockIndex(sectorIndex: number): number; + + /** + * Get the sector index, that the sector contains the specific block. + * @param blockIndex index of block + * @return the sector index + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getSectorIndex(blockIndex: number): number; +} + +/** + * MifareUltralight Type definition + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ + export enum MifareUltralightType { + /** Mifare Type unknown */ + TYPE_UNKOWN = -1, + + /** Mifare Ultralight */ + TYPE_ULTRALIGHT = 1, + + /** Mifare UltralightC */ + TYPE_ULTRALIGHT_C = 2 +} + +/** + * Provides methods for accessing MifareUltralight tag. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ +export interface MifareUltralightTag extends TagSession { + /** + * Read 4 pages, total is 16 bytes. page size is 4bytes. + * @param pageIndex index of page to read + * @return 4 pages data + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + readMultiplePages(pageIndex: number): Promise; + readMultiplePages(pageIndex: number, callback: AsyncCallback): void; + + /** + * Write a page, total 4 bytes. + * @param pageIndex index of page to write + * @param data page data to write + * @return Error code of write. if return 0, means successful. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + writeSinglePages(pageIndex: number, data: string): Promise; + writeSinglePages(pageIndex: number, data: string, callback: AsyncCallback): void; + + /** + * Get the type of the MifareUltralight tag in bytes. + * @return type of MifareUltralight tag. + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + getType(): MifareUltralightType; +} + +/** + * Provides methods for accessing NdefFormatable tag. + * + * @since 9 + * @syscap SystemCapability.Communication.NFC.Core + */ +export interface NdefFormatableTag extends TagSession { + /** + * Format a tag as NDEF tag, then write Ndef message into the Ndef Tag + * @param message Ndef message to write while format successful. it can be null, then only format the tag. + * @return if return 0, means successful. otherwise the error code + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + format(message: NdefMessage): Promise; + format(message: NdefMessage, callback: AsyncCallback): void; + + /** + * Format a tag as NDEF tag, then write Ndef message into the Ndef Tag, then set the tag readonly + * @param message Ndef message to write while format successful. it can be null, then only format the tag. + * @return if return 0, means successful. otherwise the error code + * @since 9 + * @permission ohos.permission.NFC_TAG + */ + formatReadOnly(message: NdefMessage): Promise; + formatReadOnly(message: NdefMessage, callback: AsyncCallback): void; +} \ No newline at end of file diff --git a/api/tag/tagSession.d.ts b/api/tag/tagSession.d.ts index a1535c50bd..2d7d7f8cb3 100755 --- a/api/tag/tagSession.d.ts +++ b/api/tag/tagSession.d.ts @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import tag from '../ohos.nfc.tag'; -import { AsyncCallback } from './basic'; +import tag from '../@ohos.nfc.tag'; +import { AsyncCallback } from '../basic'; /** * Controls tag read and write. @@ -105,18 +105,6 @@ export interface TagSession { * @since 7 */ sendData(data: number[]): Promise; - - /** - * Writes data to a tag. - * - * @param data Indicates the data to be written to the tag. - * @return Returns bytes received in response. Or bytes with a length of 0 if the - * data fails to be written to the tag. - * - * @permission ohos.permission.NFC_TAG - * - * @since 7 - */ sendData(data: number[], callback: AsyncCallback): void; /** -- Gitee From 2443cecbc2b82fa33ec56793fb8b1998ddb33181 Mon Sep 17 00:00:00 2001 From: hungry_feiwei Date: Thu, 9 Jun 2022 15:23:04 +0800 Subject: [PATCH 09/10] touchMajor->toolMajor Signed-off-by: hungry_feiwei --- api/@ohos.multimodalInput.inputDevice.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.multimodalInput.inputDevice.d.ts b/api/@ohos.multimodalInput.inputDevice.d.ts index 3c21a3fd95..c053907fa7 100755 --- a/api/@ohos.multimodalInput.inputDevice.d.ts +++ b/api/@ohos.multimodalInput.inputDevice.d.ts @@ -32,7 +32,7 @@ declare namespace inputDevice { /** * @since 9 */ - type AxisType = 'touchMajor' | 'touchMinor' | 'orientation' | 'x' | 'y' | 'pressure' | 'toolMinor' | 'touchMajor' | 'NULL'; + type AxisType = 'touchMajor' | 'touchMinor' | 'orientation' | 'x' | 'y' | 'pressure' | 'toolMinor' | 'toolMajor' | 'NULL'; /** * @since 9 -- Gitee From a112a10ef7c2c288f934286830a6e1f0e988b647 Mon Sep 17 00:00:00 2001 From: haixiangw Date: Wed, 8 Jun 2022 20:29:58 -0700 Subject: [PATCH 10/10] modify enum since 9 Signed-off-by: haixiangw --- api/@ohos.security.huks.d.ts | 62 +++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/api/@ohos.security.huks.d.ts b/api/@ohos.security.huks.d.ts index e531bd71da..be039ffb05 100755 --- a/api/@ohos.security.huks.d.ts +++ b/api/@ohos.security.huks.d.ts @@ -19,7 +19,6 @@ import {AsyncCallback} from './basic'; * OpenHarmony Universal KeyStore * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ declare namespace huks { /** @@ -160,7 +159,6 @@ declare namespace huks { * Interface of huks param. * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export interface HuksParam { tag: HuksTag; @@ -171,7 +169,6 @@ declare namespace huks { * Interface of huks handle. * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export interface HuksHandle { errorCode: number; @@ -183,7 +180,6 @@ declare namespace huks { * Interface of huks option. * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export interface HuksOptions { properties?: Array; @@ -194,7 +190,6 @@ declare namespace huks { * Interface of huks result. * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export interface HuksResult { errorCode: number; @@ -207,7 +202,6 @@ declare namespace huks { * @name HuksErrorCode * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksErrorCode { HUKS_SUCCESS = 0, @@ -276,7 +270,17 @@ declare namespace huks { HUKS_ERROR_INVALID_SALT = -123, HUKS_ERROR_INVALID_ITERATION = -124, HUKS_ERROR_INVALID_OPERATION = -125, + /** + * @name HUKS_ERROR_INVALID_WRAPPED_FORMAT + * @since 9 + * @syscap SystemCapability.Security.Huks + */ HUKS_ERROR_INVALID_WRAPPED_FORMAT = -126, + /** + * @name HUKS_ERROR_INVALID_USAGE_OF_KEY + * @since 9 + * @syscap SystemCapability.Security.Huks + */ HUKS_ERROR_INVALID_USAGE_OF_KEY = -127, HUKS_ERROR_INTERNAL_ERROR = -999, @@ -287,7 +291,6 @@ declare namespace huks { * @name HuksKeyPurpose * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksKeyPurpose { HUKS_KEY_PURPOSE_ENCRYPT = 1, /* Usable with RSA, EC and AES keys. */ @@ -305,11 +308,15 @@ declare namespace huks { * @name HuksKeyDigest * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksKeyDigest { HUKS_DIGEST_NONE = 0, HUKS_DIGEST_MD5 = 1, + /** + * @name HUKS_DIGEST_SM3 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ HUKS_DIGEST_SM3 = 2, HUKS_DIGEST_SHA1 = 10, HUKS_DIGEST_SHA224 = 11, @@ -322,7 +329,6 @@ declare namespace huks { * @name HuksKeyPadding * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksKeyPadding { HUKS_PADDING_NONE = 0, @@ -337,7 +343,6 @@ declare namespace huks { * @name HuksCipherMode * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksCipherMode { HUKS_MODE_ECB = 1, @@ -352,7 +357,6 @@ declare namespace huks { * @name HuksKeySize * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksKeySize { HUKS_RSA_KEY_SIZE_512 = 512, @@ -378,7 +382,17 @@ declare namespace huks { HUKS_DH_KEY_SIZE_3072 = 3072, HUKS_DH_KEY_SIZE_4096 = 4096, + /** + * @name HUKS_SM2_KEY_SIZE_256 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ HUKS_SM2_KEY_SIZE_256 = 256, + /** + * @name HUKS_SM4_KEY_SIZE_128 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ HUKS_SM4_KEY_SIZE_128 = 128, } @@ -386,7 +400,6 @@ declare namespace huks { * @name HuksKeyAlg * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksKeyAlg { HUKS_ALG_RSA = 1, @@ -403,8 +416,23 @@ declare namespace huks { HUKS_ALG_ED25519 = 102, HUKS_ALG_DH = 103, + /** + * @name HUKS_ALG_SM2 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ HUKS_ALG_SM2 = 150, + /** + * @name HUKS_ALG_SM3 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ HUKS_ALG_SM3 = 151, + /** + * @name HUKS_ALG_SM4 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ HUKS_ALG_SM4 = 152, } @@ -412,7 +440,6 @@ declare namespace huks { * @name HuksUnwrapSuite * @since 9 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksUnwrapSuite { HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING = 1, @@ -423,7 +450,6 @@ declare namespace huks { * @name HuksKeyGenerateType * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksKeyGenerateType { HUKS_KEY_GENERATE_TYPE_DEFAULT = 0, @@ -435,7 +461,6 @@ declare namespace huks { * @name HuksKeyFlag * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksKeyFlag { HUKS_KEY_FLAG_IMPORT_KEY = 1, @@ -448,7 +473,6 @@ declare namespace huks { * @name HuksKeyStorageType * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksKeyStorageType { HUKS_STORAGE_TEMP = 0, @@ -459,7 +483,6 @@ declare namespace huks { * @name HuksImportKeyType * @since 9 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksImportKeyType { HUKS_KEY_TYPE_PUBLIC_KEY = 0, @@ -471,7 +494,6 @@ declare namespace huks { * @name HuksSendType * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksSendType { HUKS_SEND_TYPE_ASYNC = 0, @@ -482,7 +504,6 @@ declare namespace huks { * @name HuksTagType * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ declare enum HuksTagType { HUKS_TAG_TYPE_INVALID = 0 << 28, @@ -497,7 +518,6 @@ declare namespace huks { * @name HuksTag * @since 8 * @syscap SystemCapability.Security.Huks - * @permission N/A */ export enum HuksTag { /* Invalid TAG */ @@ -536,7 +556,6 @@ declare namespace huks { * @name HUKS_TAG_IMPORT_KEY_TYPE * @since 9 * @syscap SystemCapability.Security.Huks - * @permission N/A */ HUKS_TAG_IMPORT_KEY_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 25, /* choose from enum HuksImportKeyType */ @@ -544,7 +563,6 @@ declare namespace huks { * @name HUKS_TAG_UNWRAP_ALGORITHM_SUITE * @since 9 * @syscap SystemCapability.Security.Huks - * @permission N/A */ HUKS_TAG_UNWRAP_ALGORITHM_SUITE = HuksTagType.HUKS_TAG_TYPE_UINT | 26, -- Gitee