diff --git a/BUILD.gn b/BUILD.gn index 69b5e80e5c8dc360be6c4f94d79f590f9b871e48..f7d21c2b719f1c13aeff64807f7f9667bf0501ae 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -18,6 +18,7 @@ import("//build/templates/metadata/module_info.gni") ohos_copy("ets_internal_api") { sources = [ "api/@internal/ets/index.d.ts", + "api/@internal/ets/lifecycle.d.ts", "api/@internal/global.d.ts", ] outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] diff --git a/api/@internal/ets/index.d.ts b/api/@internal/ets/index.d.ts index cdff441484a5e789e5fd46d592d43d15a0cdcce2..4a9e2b6b33809e76eb91f12c8ba4779d2bb51a1b 100644 --- a/api/@internal/ets/index.d.ts +++ b/api/@internal/ets/index.d.ts @@ -13,4 +13,5 @@ * limitations under the License. */ -export * from './global'; \ No newline at end of file +export * from './global'; +export * from './lifecycle'; diff --git a/api/@internal/ets/lifecycle.d.ts b/api/@internal/ets/lifecycle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..96929a8a535f55fc905e2ecc6f54c97a5c80f798 --- /dev/null +++ b/api/@internal/ets/lifecycle.d.ts @@ -0,0 +1,514 @@ +/* + * Copyright (c) 2021 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 { Want } from "../ability/want"; +import { ResultSet } from "../data/rdb/resultSet"; +import { AbilityInfo } from "../bundle/abilityInfo"; +import { DataAbilityResult } from "../ability/dataAbilityResult"; +import { DataAbilityOperation } from "../ability/dataAbilityOperation"; +import dataAbility from "../@ohos.data.dataAbility"; +import formBindingData from "../@ohos.ability.formBindingData"; +import formManager from "../@ohos.ability.formManager"; +import rdb from "../@ohos.data.rdb"; +import rpc from "../@ohos.rpc"; +import resourceManager from "../@ohos.resourceManager"; + +/** + * interface of form lifecycle. + * @name LifecycleForm + * @since 7 + * @sysCap AAFwk + * @devices phone, tablet + * @permission N/A + */ +export declare interface LifecycleForm { + /** + * Called to return a {@link formBindingData.FormBindingData} object. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param intent Indicates the detailed information for creating a {@link formBindingData.FormBindingData}. + * The {@code Want} object must include the form ID, form name, and grid style of the form, + * which can be obtained from {@link formManager.FormParam#IDENTITY_KEY}, + * {@link formManager.FormParam#NAME_KEY}, and {@link formManager.FormParam#DIMENSION_KEY}, + * respectively. Such form information must be managed as persistent data for further form + * acquisition, update, and deletion. + * @return Returns the created {@link formBindingData.FormBindingData} object. + */ + onCreate?(want: Want): formBindingData.FormBindingData; + + /** + * Called when the form provider is notified that a temporary form is successfully converted to a normal form. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param formId Indicates the ID of the form. + * @return - + */ + onCastTempToNormal?(formId: string): void; + + /** + * Called to notify the form provider to update a specified form. + * + *
The Service ability must have been started but not been destroyed, that is, {@link #startAbility} has been + * called but {@link #terminateSelf} has not.
+ * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param formId Indicates the ID of the deleted form. + * @return - + */ + onUpdate?(formId: string): void; + + /** + * Called when the form provider receives form events from the system. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param newStatus Indicates the form events occurred. The key in the {@code Map} object indicates the form ID, + * and the value indicates the event type, which can be either {@link #FORM_VISIBLE} + * or {@link #FORM_INVISIBLE}. {@link #FORM_VISIBLE} means that the form becomes visible, + * and {@link #FORM_INVISIBLE} means that the form becomes invisible. + * @return - + */ + onVisibilityChanged?(newStatus: { [key: number]: number }): void; + + /** + * Called when a specified message event defined by the form provider is triggered. This method is valid only for + * JS forms. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param formId Indicates the ID of the form on which the message event is triggered, which is provided by + * the client to the form provider. + * @param message Indicates the value of the {@code params} field of the message event. This parameter is + * used to identify the specific component on which the event is triggered. + * @return - + */ + onTriggerEvent?(formId: string, message: string): void; + + /** + * Called to notify the form provider that a specified form has been deleted. Override this method if + * you want your application, as the form provider, to be notified of form deletion. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param formId Indicates the ID of the deleted form. + * @return - + */ + onDelete?(formId: string): void; + + /** + * Called to return a {@link FormState} object. + * + *You must override this callback if you want this ability to return the actual form state. Otherwise, + * this method returns {@link FormState#DEFAULT} by default.
+ * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param want Indicates the description of the form for which the {@link FormState} is obtained. The description + * covers the bundle name, ability name, module name, form name, and form dimensions. + * @return Returns the {@link formManager.FormState} object. + */ + onAcquireFormState?(want: Want): formManager.FormState; +} + +/** + * interface of app lifecycle. + * @name LifecycleApp + * @since 7 + * @sysCap AAFwk + * @devices phone, tablet + * @permission N/A + */ +export declare interface LifecycleApp { + /** + * Called back when the state of an ability changes from BACKGROUND to INACTIVE. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @return - + */ + onShow?(): void; + + /** + * Called back when an ability enters the BACKGROUND state. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @return - + */ + onHide?(): void; + + /** + * Called back before an ability is destroyed. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @return - + */ + onDestroy?(): void; + + /** + * Called back when an ability is started for initialization. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @return - + */ + onCreate?(): void; + + /** + * Called when the window display mode of this ability changes, for example, from fullscreen mode + * to multi-window mode or from multi-window mode to fullscreen mode. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param isShownInMultiWindow Specifies whether this ability is currently in multi-window mode. + * The value {@code true} indicates the multi-window mode, and {@code false} indicates another mode. + * @param newConfig Indicates the new configuration information about this Page ability. + * @return - + */ + onWindowDisplayModeChanged?(isShownInMultiWindow: boolean, newConfig: resourceManager.Configuration): void; + + /** + * Asks a user whether to start the migration. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @return Returns {@code true} if the user allows the migration; returns {@code false} otherwise. + */ + onStartContinuation?(): boolean; + + /** + * Saves the user data of a local ability generated during runtime. + * After the migration is triggered and the local ability is ready, this method is called when the Distributed + * Scheduler Service requests data from the local ability. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param data Indicates the user data to save. + * @return Returns {@code true} if the data is successfully saved; returns {@code false} otherwise. + */ + onSaveData?(data: Object): boolean; + + /** + * Called back when a local ability migration is complete. + * + *You can define the processing logic after the migration is complete. For example, you can display a prompt to + * notify the user of the successful migration and then exit the local ability.
+ * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param result Indicates the migration result code. The value {@code 0} indicates that the migration is + * successful, and {@code -1} indicates that the migration fails. + * @return - + */ + onCompleteContinuation?(result: number): void; + + /** + * Restores the user data saved during the migration for an ability on the remote device immediately after the + * ability is created on the remote device. Lifecycle scheduling for the ability starts only after the user data + * is restored. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param data Indicates the user data to restore. + * @return - + */ + onRestoreData?(data: Object): void; + + /** + * Called to notify the local device when a running ability on the remote device is destroyed after a reversible + * migration is performed for the ability from the local device to the remote device. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param data Indicates the user data to restore. + * @return - + */ + onRemoteTerminated?(): void; +} + +/** + * interface of service lifecycle. + * @name LifecycleService + * @since 7 + * @sysCap AAFwk + * @devices phone, tablet + * @permission N/A + */ +export declare interface LifecycleService { + /** + * Called back when an ability is started for initialization (it can be called only once in the entire lifecycle of + * an ability). + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @return - + */ + onStart?(): void; + + /** + * Called back when Service is started. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param want Indicates the want of Service to start. + * @param startId Indicates the number of times the Service ability has been started. The {@code startId} is + * incremented by 1 every time the ability is started. For example, if the ability has been started + * for six times. + * @return - + */ + onCommand?(want: Want, startId: number): void; + + /** + * Called back when a Service ability is first connected to an ability. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param want Indicates connection information about the Service ability. + * @return Returns the proxy of the Service ability. + */ + onConnect?(want: Want): rpc.RemoteObject; + + /** + * Called back when all abilities connected to a Service ability are disconnected. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param want Indicates disconnection information about the Service ability. + * @return - + */ + onDisconnect?(want: Want): void; + + /** + * Called when a new client attempts to connect to a Service ability after all previous client connections to it + * are disconnected. + * + *The Service ability must have been started but not been destroyed, that is, {@link #startAbility} has been + * called but {@link #terminateSelf} has not.
+ * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param want Indicates the want of the Service ability being connected. + * @return - + */ + onReconnect?(want: Want): void; + + /** + * Called back before an ability is destroyed. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @return - + */ + onStop?(): void; +} + +/** + * interface of data lifecycle. + * @name LifecycleData + * @since 7 + * @sysCap AAFwk + * @devices phone, tablet + * @permission N/A + */ +export declare interface LifecycleData { + /** + * Updates one or more data records in the database. This method should be implemented by a Data ability. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param uri Indicates the database table storing the data to update. + * @param valueBucket Indicates the data to update. This parameter can be null. + * @param predicates Indicates filter criteria. If this parameter is null, all data records will be updated by + * default. + * @return Returns the number of data records updated. + * @return - + */ + update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): number; + + /** + * Queries one or more data records in the database. This method should be implemented by a Data ability. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @param uri Indicates the database table storing the data to query. + * @param columns Indicates the columns to be queried, in array, for example, {"name","age"}. You should define + * the processing logic when this parameter is null. + * @param predicates Indicates filter criteria. If this parameter is null, all data records will be queried by + * default. + * @return Returns the queried data. + */ + query?(uri: string, columns: Array1. "*/*": Obtains all types supported by a Data ability. + *
2. "image/*": Obtains files whose main type is image of any subtype. + *
3. "*/jpg": Obtains files whose subtype is JPG of any main type.
+ * @return Returns the MIME type of the matched files; returns null if there is no type that matches the Data
+ */
+ getFileTypes?(uri: string, mimeTypeFilter: string): Array Data abilities supports general data types, including text, HTML, and JPEG.