161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit AbilityKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport Want from '../../@ohos.app.ability.Want';
2261847f8eSopenharmony_ciimport { ResultSet } from '../../data/rdb/resultSet';
2361847f8eSopenharmony_ciimport { AbilityInfo } from '../../bundle/abilityInfo';
2461847f8eSopenharmony_ciimport { DataAbilityResult } from '../../ability/dataAbilityResult';
2561847f8eSopenharmony_ciimport { DataAbilityOperation } from '../../ability/dataAbilityOperation';
2661847f8eSopenharmony_ciimport dataAbility from '../../@ohos.data.dataAbility';
2761847f8eSopenharmony_ciimport formBindingData from '../../@ohos.application.formBindingData';
2861847f8eSopenharmony_ciimport formInfo from '../../@ohos.app.form.formInfo';
2961847f8eSopenharmony_ciimport rdb from '../../@ohos.data.rdb';
3061847f8eSopenharmony_ciimport rpc from '../../@ohos.rpc';
3161847f8eSopenharmony_ciimport resourceManager from '../../@ohos.resourceManager';
3261847f8eSopenharmony_ciimport { PacMap } from '../../ability/dataAbilityHelper';
3361847f8eSopenharmony_ciimport { AsyncCallback } from '../../@ohos.base';
3461847f8eSopenharmony_ci
3561847f8eSopenharmony_ci/**
3661847f8eSopenharmony_ci * interface of form lifecycle.
3761847f8eSopenharmony_ci *
3861847f8eSopenharmony_ci * @interface LifecycleForm
3961847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
4061847f8eSopenharmony_ci * @FAModelOnly
4161847f8eSopenharmony_ci * @since 7
4261847f8eSopenharmony_ci */
4361847f8eSopenharmony_ciexport declare interface LifecycleForm {
4461847f8eSopenharmony_ci  /**
4561847f8eSopenharmony_ci   * Called to return a {@link formBindingData.FormBindingData} object.
4661847f8eSopenharmony_ci   *
4761847f8eSopenharmony_ci   * @param { Want } want - Indicates the detailed information for creating a {@link formBindingData#FormBindingData}.
4861847f8eSopenharmony_ci   *                        The {@code Want} object must include the form ID, form name, and grid style of the form,
4961847f8eSopenharmony_ci   *                        which can be obtained from {@link formInfo#FormParam#IDENTITY_KEY},
5061847f8eSopenharmony_ci   *                        {@link formInfo#FormParam#NAME_KEY}, and {@link formInfo#FormParam#DIMENSION_KEY},
5161847f8eSopenharmony_ci   *              	        respectively. Such form information must be managed as persistent data for further form
5261847f8eSopenharmony_ci   *               	        acquisition, update, and deletion.
5361847f8eSopenharmony_ci   * @returns { formBindingData.FormBindingData } Returns the created {@link formBindingData#FormBindingData} object.
5461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
5561847f8eSopenharmony_ci   * @FAModelOnly
5661847f8eSopenharmony_ci   * @since 8
5761847f8eSopenharmony_ci   */
5861847f8eSopenharmony_ci  onCreate?(want: Want): formBindingData.FormBindingData;
5961847f8eSopenharmony_ci
6061847f8eSopenharmony_ci  /**
6161847f8eSopenharmony_ci   * Called when the form provider is notified that a temporary form is successfully converted to a normal form.
6261847f8eSopenharmony_ci   *
6361847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form.
6461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
6561847f8eSopenharmony_ci   * @FAModelOnly
6661847f8eSopenharmony_ci   * @since 8
6761847f8eSopenharmony_ci   */
6861847f8eSopenharmony_ci  onCastToNormal?(formId: string): void;
6961847f8eSopenharmony_ci
7061847f8eSopenharmony_ci  /**
7161847f8eSopenharmony_ci   * Called to notify the form provider to update a specified form.
7261847f8eSopenharmony_ci   *
7361847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form to update.
7461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
7561847f8eSopenharmony_ci   * @FAModelOnly
7661847f8eSopenharmony_ci   * @since 8
7761847f8eSopenharmony_ci   */
7861847f8eSopenharmony_ci  onUpdate?(formId: string): void;
7961847f8eSopenharmony_ci
8061847f8eSopenharmony_ci  /**
8161847f8eSopenharmony_ci   * Called when the form provider receives form events from the system.
8261847f8eSopenharmony_ci   *
8361847f8eSopenharmony_ci   * @param { object } newStatus - Indicates the form events occurred. The key in the {@code Map} object indicates
8461847f8eSopenharmony_ci   *                               form ID,and the value indicates the event type, which can be either
8561847f8eSopenharmony_ci   *                               {@link formInfo#VisibilityType#FORM_VISIBLE} or
8661847f8eSopenharmony_ci   *                               {@link formInfo#VisibilityType#FORM_INVISIBLE}.
8761847f8eSopenharmony_ci   *                               {@link formInfo#VisibilityType#FORM_VISIBLE}
8861847f8eSopenharmony_ci   *                               means that the form becomes visible, and
8961847f8eSopenharmony_ci   *                               {@link formInfo#VisibilityType#FORM_INVISIBLE}
9061847f8eSopenharmony_ci   *                               means that the form becomes invisible.
9161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
9261847f8eSopenharmony_ci   * @FAModelOnly
9361847f8eSopenharmony_ci   * @since 8
9461847f8eSopenharmony_ci   */
9561847f8eSopenharmony_ci  /**
9661847f8eSopenharmony_ci   * Called when the form provider receives form events from the system.
9761847f8eSopenharmony_ci   *
9861847f8eSopenharmony_ci   * @param { Record<string, number> } newStatus - Indicates the form events occurred. The key in the {@code Map}
9961847f8eSopenharmony_ci   *                                               object indicates form ID,and the value indicates the event type,
10061847f8eSopenharmony_ci   *                                               which can be either
10161847f8eSopenharmony_ci   *                                               {@link formInfo#VisibilityType#FORM_VISIBLE} or
10261847f8eSopenharmony_ci   *                                               {@link formInfo#VisibilityType#FORM_INVISIBLE}.
10361847f8eSopenharmony_ci   *                                               {@link formInfo#VisibilityType#FORM_VISIBLE}
10461847f8eSopenharmony_ci   *                                               means that the form becomes visible, and
10561847f8eSopenharmony_ci   *                                               {@link formInfo#VisibilityType#FORM_INVISIBLE}
10661847f8eSopenharmony_ci   *                                               means that the form becomes invisible.
10761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
10861847f8eSopenharmony_ci   * @FAModelOnly
10961847f8eSopenharmony_ci   * @since 11
11061847f8eSopenharmony_ci   */
11161847f8eSopenharmony_ci  onVisibilityChange?(newStatus: Record<string, number>): void;
11261847f8eSopenharmony_ci
11361847f8eSopenharmony_ci  /**
11461847f8eSopenharmony_ci   * Called when a specified message event defined by the form provider is triggered. This method is valid only for
11561847f8eSopenharmony_ci   * JS forms.
11661847f8eSopenharmony_ci   *
11761847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form on which the message event is triggered, which is
11861847f8eSopenharmony_ci   *                            provided by the client to the form provider.
11961847f8eSopenharmony_ci   * @param { string } message - Indicates the value of the {@code params} field of the message event. This parameter
12061847f8eSopenharmony_ci   *                            is used to identify the specific component on which the event is triggered.
12161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
12261847f8eSopenharmony_ci   * @FAModelOnly
12361847f8eSopenharmony_ci   * @since 8
12461847f8eSopenharmony_ci   */
12561847f8eSopenharmony_ci  onEvent?(formId: string, message: string): void;
12661847f8eSopenharmony_ci
12761847f8eSopenharmony_ci  /**
12861847f8eSopenharmony_ci   * Called to notify the form provider that a specified form has been deleted. Override this method if
12961847f8eSopenharmony_ci   * you want your application, as the form provider, to be notified of form deletion.
13061847f8eSopenharmony_ci   *
13161847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the deleted form.
13261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
13361847f8eSopenharmony_ci   * @FAModelOnly
13461847f8eSopenharmony_ci   * @since 8
13561847f8eSopenharmony_ci   */
13661847f8eSopenharmony_ci  onDestroy?(formId: string): void;
13761847f8eSopenharmony_ci
13861847f8eSopenharmony_ci  /**
13961847f8eSopenharmony_ci   * Called to return a {@link FormState} object.
14061847f8eSopenharmony_ci   * <p>You must override this callback if you want this ability to return the actual form state. Otherwise,
14161847f8eSopenharmony_ci   * this method returns {@link FormState#DEFAULT} by default.</p>
14261847f8eSopenharmony_ci   *
14361847f8eSopenharmony_ci   * @param { Want } want - Indicates the description of the form for which the {@link formInfo#FormState} is obtained.
14461847f8eSopenharmony_ci   *                        The description covers the bundle name, ability name, module name, form name, form
14561847f8eSopenharmony_ci   *                        dimensions.
14661847f8eSopenharmony_ci   * @returns { formInfo.FormState } Returns the {@link formInfo#FormState} object.
14761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
14861847f8eSopenharmony_ci   * @FAModelOnly
14961847f8eSopenharmony_ci   * @since 8
15061847f8eSopenharmony_ci   */
15161847f8eSopenharmony_ci  onAcquireFormState?(want: Want): formInfo.FormState;
15261847f8eSopenharmony_ci
15361847f8eSopenharmony_ci  /**
15461847f8eSopenharmony_ci   * Called when the system shares the form.
15561847f8eSopenharmony_ci   *
15661847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the deleted form.
15761847f8eSopenharmony_ci   * @returns { object } Returns the wantParams object.
15861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
15961847f8eSopenharmony_ci   * @systemapi
16061847f8eSopenharmony_ci   * @FAModelOnly
16161847f8eSopenharmony_ci   * @since 9
16261847f8eSopenharmony_ci   */
16361847f8eSopenharmony_ci  onShare?(formId: string): { [key: string]: any };
16461847f8eSopenharmony_ci
16561847f8eSopenharmony_ci  /**
16661847f8eSopenharmony_ci   * Called when the system shares the form.
16761847f8eSopenharmony_ci   * The ability of this function is same as onShare. If both are set, this function will be called.
16861847f8eSopenharmony_ci   *
16961847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the deleted form.
17061847f8eSopenharmony_ci   * @returns { Record<string, Object> } Returns the wantParams object.
17161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
17261847f8eSopenharmony_ci   * @systemapi
17361847f8eSopenharmony_ci   * @FAModelOnly
17461847f8eSopenharmony_ci   * @since 11
17561847f8eSopenharmony_ci   */
17661847f8eSopenharmony_ci  onShareForm?(formId: string): Record<string, Object>;
17761847f8eSopenharmony_ci}
17861847f8eSopenharmony_ci
17961847f8eSopenharmony_ci/**
18061847f8eSopenharmony_ci * interface of app lifecycle.
18161847f8eSopenharmony_ci *
18261847f8eSopenharmony_ci * @interface LifecycleApp
18361847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
18461847f8eSopenharmony_ci * @FAModelOnly
18561847f8eSopenharmony_ci * @since 7
18661847f8eSopenharmony_ci */
18761847f8eSopenharmony_ciexport declare interface LifecycleApp {
18861847f8eSopenharmony_ci  /**
18961847f8eSopenharmony_ci   * Called back when the state of an ability changes from <b>BACKGROUND</b> to <b>INACTIVE</b>.
19061847f8eSopenharmony_ci   *
19161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
19261847f8eSopenharmony_ci   * @FAModelOnly
19361847f8eSopenharmony_ci   * @since 7
19461847f8eSopenharmony_ci   */
19561847f8eSopenharmony_ci  onShow?(): void;
19661847f8eSopenharmony_ci
19761847f8eSopenharmony_ci  /**
19861847f8eSopenharmony_ci   * Called back when an ability enters the <b>BACKGROUND</b> state.
19961847f8eSopenharmony_ci   *
20061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
20161847f8eSopenharmony_ci   * @FAModelOnly
20261847f8eSopenharmony_ci   * @since 7
20361847f8eSopenharmony_ci   */
20461847f8eSopenharmony_ci  onHide?(): void;
20561847f8eSopenharmony_ci
20661847f8eSopenharmony_ci  /**
20761847f8eSopenharmony_ci   * Called back before an ability is destroyed.
20861847f8eSopenharmony_ci   *
20961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
21061847f8eSopenharmony_ci   * @FAModelOnly
21161847f8eSopenharmony_ci   * @since 7
21261847f8eSopenharmony_ci   */
21361847f8eSopenharmony_ci  onDestroy?(): void;
21461847f8eSopenharmony_ci
21561847f8eSopenharmony_ci  /**
21661847f8eSopenharmony_ci   * Called back when an ability is started for initialization.
21761847f8eSopenharmony_ci   *
21861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
21961847f8eSopenharmony_ci   * @FAModelOnly
22061847f8eSopenharmony_ci   * @since 7
22161847f8eSopenharmony_ci   */
22261847f8eSopenharmony_ci  onCreate?(): void;
22361847f8eSopenharmony_ci
22461847f8eSopenharmony_ci  /**
22561847f8eSopenharmony_ci   * Called when the window display mode of this ability changes, for example, from fullscreen mode
22661847f8eSopenharmony_ci   *     to multi-window mode or from multi-window mode to fullscreen mode.
22761847f8eSopenharmony_ci   *
22861847f8eSopenharmony_ci   * @param { boolean } isShownInMultiWindow - Specifies whether this ability is currently in multi-window mode.The
22961847f8eSopenharmony_ci   *                                           value {@code true} indicates the multi-window mode, and {@code false}
23061847f8eSopenharmony_ci   *                                           indicates another mode.
23161847f8eSopenharmony_ci   * @param { resourceManager.Configuration } newConfig - Indicates the new configuration information about Page ability.
23261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
23361847f8eSopenharmony_ci   * @systemapi
23461847f8eSopenharmony_ci   * @FAModelOnly
23561847f8eSopenharmony_ci   * @since 7
23661847f8eSopenharmony_ci   */
23761847f8eSopenharmony_ci  onWindowDisplayModeChanged?(isShownInMultiWindow: boolean, newConfig: resourceManager.Configuration): void;
23861847f8eSopenharmony_ci
23961847f8eSopenharmony_ci  /**
24061847f8eSopenharmony_ci   * Asks a user whether to start the migration.
24161847f8eSopenharmony_ci   *
24261847f8eSopenharmony_ci   * @returns { boolean } Returns {@code true} if the user allows the migration; returns {@code false} otherwise.
24361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
24461847f8eSopenharmony_ci   * @FAModelOnly
24561847f8eSopenharmony_ci   * @since 7
24661847f8eSopenharmony_ci   */
24761847f8eSopenharmony_ci  onStartContinuation?(): boolean;
24861847f8eSopenharmony_ci
24961847f8eSopenharmony_ci  /**
25061847f8eSopenharmony_ci   * Saves the user data of a local ability generated during runtime.
25161847f8eSopenharmony_ci   * After the migration is triggered and the local ability is ready, this method is called when the Distributed
25261847f8eSopenharmony_ci   * Scheduler Service requests data from the local ability.
25361847f8eSopenharmony_ci   *
25461847f8eSopenharmony_ci   * @param { Object } data - Indicates the user data to save.
25561847f8eSopenharmony_ci   * @returns { boolean } Returns {@code true} if the data is successfully saved; returns {@code false} otherwise.
25661847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
25761847f8eSopenharmony_ci   * @FAModelOnly
25861847f8eSopenharmony_ci   * @since 7
25961847f8eSopenharmony_ci   */
26061847f8eSopenharmony_ci  onSaveData?(data: Object): boolean;
26161847f8eSopenharmony_ci
26261847f8eSopenharmony_ci  /**
26361847f8eSopenharmony_ci   * Called back when a local ability migration is complete.
26461847f8eSopenharmony_ci   * <p>You can define the processing logic after the migration is complete. For example, you can display a prompt to
26561847f8eSopenharmony_ci   * notify the user of the successful migration and then exit the local ability.</p>
26661847f8eSopenharmony_ci   *
26761847f8eSopenharmony_ci   * @param { number } result - Indicates the migration result code. The value {@code 0} indicates that the migration is
26861847f8eSopenharmony_ci   *                            successful, and {@code -1} indicates that the migration fails.
26961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
27061847f8eSopenharmony_ci   * @FAModelOnly
27161847f8eSopenharmony_ci   * @since 7
27261847f8eSopenharmony_ci   */
27361847f8eSopenharmony_ci  onCompleteContinuation?(result: number): void;
27461847f8eSopenharmony_ci
27561847f8eSopenharmony_ci  /**
27661847f8eSopenharmony_ci   * Restores the user data saved during the migration for an ability on the remote device immediately after the
27761847f8eSopenharmony_ci   * ability is created on the remote device. Lifecycle scheduling for the ability starts only after the user data
27861847f8eSopenharmony_ci   * is restored.
27961847f8eSopenharmony_ci   *
28061847f8eSopenharmony_ci   * @param { Object } data - Indicates the user data to restore.
28161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
28261847f8eSopenharmony_ci   * @FAModelOnly
28361847f8eSopenharmony_ci   * @since 7
28461847f8eSopenharmony_ci   */
28561847f8eSopenharmony_ci  onRestoreData?(data: Object): void;
28661847f8eSopenharmony_ci
28761847f8eSopenharmony_ci  /**
28861847f8eSopenharmony_ci   * Called to notify the local device when a running ability on the remote device is destroyed after a reversible
28961847f8eSopenharmony_ci   * migration is performed for the ability from the local device to the remote device.
29061847f8eSopenharmony_ci   *
29161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
29261847f8eSopenharmony_ci   * @FAModelOnly
29361847f8eSopenharmony_ci   * @since 7
29461847f8eSopenharmony_ci   */
29561847f8eSopenharmony_ci  onRemoteTerminated?(): void;
29661847f8eSopenharmony_ci
29761847f8eSopenharmony_ci  /**
29861847f8eSopenharmony_ci   * This method is called when the system determines that the ability may be destroyed in an unexpected
29961847f8eSopenharmony_ci   * situation, for example, when the screen orientation changes or the user touches the Home key. Generally,
30061847f8eSopenharmony_ci   * this method is used only to save temporary states.
30161847f8eSopenharmony_ci   *
30261847f8eSopenharmony_ci   * @param { PacMap } outState - Indicates the {@code PacMap} object used for storing user data and states. This
30361847f8eSopenharmony_ci   *                              parameter cannot be null.
30461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
30561847f8eSopenharmony_ci   * @FAModelOnly
30661847f8eSopenharmony_ci   * @since 7
30761847f8eSopenharmony_ci   */
30861847f8eSopenharmony_ci  onSaveAbilityState?(outState: PacMap): void;
30961847f8eSopenharmony_ci
31061847f8eSopenharmony_ci  /**
31161847f8eSopenharmony_ci   * This method is called if an ability was destroyed at a certain time due to resource reclaim or was
31261847f8eSopenharmony_ci   * unexpectedly destroyed and the {@link #onSaveAbilityState(PacMap)} method was called to save its user data and
31361847f8eSopenharmony_ci   * states. Generally, this method is called after the {@link #onStart(Want)} method.
31461847f8eSopenharmony_ci   *
31561847f8eSopenharmony_ci   * @param { PacMap } inState - Indicates the {@code PacMap} object used for storing data and states. This
31661847f8eSopenharmony_ci   *                             parameter can not be null.
31761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
31861847f8eSopenharmony_ci   * @FAModelOnly
31961847f8eSopenharmony_ci   * @since 7
32061847f8eSopenharmony_ci   */
32161847f8eSopenharmony_ci  onRestoreAbilityState?(inState: PacMap): void;
32261847f8eSopenharmony_ci
32361847f8eSopenharmony_ci  /**
32461847f8eSopenharmony_ci   * Called back when an ability enters the <b>INACTIVE</b> state (an ability in this state is not interactive and may
32561847f8eSopenharmony_ci   * change to the <b>BACKGROUND</b> or <b>ACTIVE</b> state).
32661847f8eSopenharmony_ci   *
32761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
32861847f8eSopenharmony_ci   * @FAModelOnly
32961847f8eSopenharmony_ci   * @since 7
33061847f8eSopenharmony_ci   */
33161847f8eSopenharmony_ci  onInactive?(): void;
33261847f8eSopenharmony_ci
33361847f8eSopenharmony_ci  /**
33461847f8eSopenharmony_ci   * Called back when an ability enters the <b>ACTIVE</b> state.
33561847f8eSopenharmony_ci   *
33661847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
33761847f8eSopenharmony_ci   * @FAModelOnly
33861847f8eSopenharmony_ci   * @since 7
33961847f8eSopenharmony_ci   */
34061847f8eSopenharmony_ci  onActive?(): void;
34161847f8eSopenharmony_ci
34261847f8eSopenharmony_ci  /**
34361847f8eSopenharmony_ci   * Called when the launch mode of an ability is set to singleton.
34461847f8eSopenharmony_ci   *
34561847f8eSopenharmony_ci   * @param { Want } want - Indicates the new {@code want} containing information about the ability.
34661847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
34761847f8eSopenharmony_ci   * @FAModelOnly
34861847f8eSopenharmony_ci   * @since 7
34961847f8eSopenharmony_ci   */
35061847f8eSopenharmony_ci  onNewWant?(want: Want): void;
35161847f8eSopenharmony_ci
35261847f8eSopenharmony_ci  /**
35361847f8eSopenharmony_ci   * Called when the system has determined to trim the memory, for example, when the ability is running in the
35461847f8eSopenharmony_ci   * background and there is no enough memory for running as many background processes as possible.
35561847f8eSopenharmony_ci   *
35661847f8eSopenharmony_ci   * @param { number } level - Indicates the memory trim level, which shows the current memory usage status.
35761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
35861847f8eSopenharmony_ci   * @FAModelOnly
35961847f8eSopenharmony_ci   * @since 7
36061847f8eSopenharmony_ci   */
36161847f8eSopenharmony_ci  onMemoryLevel?(level: number): void;
36261847f8eSopenharmony_ci}
36361847f8eSopenharmony_ci
36461847f8eSopenharmony_ci/**
36561847f8eSopenharmony_ci * interface of service lifecycle.
36661847f8eSopenharmony_ci *
36761847f8eSopenharmony_ci * @interface LifecycleService
36861847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
36961847f8eSopenharmony_ci * @FAModelOnly
37061847f8eSopenharmony_ci * @since 7
37161847f8eSopenharmony_ci */
37261847f8eSopenharmony_ciexport declare interface LifecycleService {
37361847f8eSopenharmony_ci  /**
37461847f8eSopenharmony_ci   * Called back when an ability is started for initialization (it can be called only once in the entire lifecycle of
37561847f8eSopenharmony_ci   * an ability).
37661847f8eSopenharmony_ci   *
37761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
37861847f8eSopenharmony_ci   * @FAModelOnly
37961847f8eSopenharmony_ci   * @since 7
38061847f8eSopenharmony_ci   */
38161847f8eSopenharmony_ci  onStart?(): void;
38261847f8eSopenharmony_ci
38361847f8eSopenharmony_ci  /**
38461847f8eSopenharmony_ci   * Called back when Service is started.
38561847f8eSopenharmony_ci   *
38661847f8eSopenharmony_ci   * @param { Want } want - Indicates the want of Service to start.
38761847f8eSopenharmony_ci   * @param { number } startId - Indicates the number of times the Service ability has been started. {@code startId} is
38861847f8eSopenharmony_ci   *                             incremented by 1 every time the ability is started. For example, if the ability
38961847f8eSopenharmony_ci   *                             has been started for six times.
39061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
39161847f8eSopenharmony_ci   * @FAModelOnly
39261847f8eSopenharmony_ci   * @since 7
39361847f8eSopenharmony_ci   */
39461847f8eSopenharmony_ci  onCommand?(want: Want, startId: number): void;
39561847f8eSopenharmony_ci
39661847f8eSopenharmony_ci  /**
39761847f8eSopenharmony_ci   * Called back before an ability is destroyed.
39861847f8eSopenharmony_ci   *
39961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
40061847f8eSopenharmony_ci   * @FAModelOnly
40161847f8eSopenharmony_ci   * @since 7
40261847f8eSopenharmony_ci   */
40361847f8eSopenharmony_ci  onStop?(): void;
40461847f8eSopenharmony_ci
40561847f8eSopenharmony_ci  /**
40661847f8eSopenharmony_ci   * Called back when a Service ability is first connected to an ability.
40761847f8eSopenharmony_ci   *
40861847f8eSopenharmony_ci   * @param { Want } want - Indicates connection information about the Service ability.
40961847f8eSopenharmony_ci   * @returns { rpc.RemoteObject } Returns the proxy of the Service ability.
41061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
41161847f8eSopenharmony_ci   * @FAModelOnly
41261847f8eSopenharmony_ci   * @since 7
41361847f8eSopenharmony_ci   */
41461847f8eSopenharmony_ci  onConnect?(want: Want): rpc.RemoteObject;
41561847f8eSopenharmony_ci
41661847f8eSopenharmony_ci  /**
41761847f8eSopenharmony_ci   * Called back when all abilities connected to a Service ability are disconnected.
41861847f8eSopenharmony_ci   *
41961847f8eSopenharmony_ci   * @param { Want } want - Indicates disconnection information about the Service ability.
42061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
42161847f8eSopenharmony_ci   * @FAModelOnly
42261847f8eSopenharmony_ci   * @since 7
42361847f8eSopenharmony_ci   */
42461847f8eSopenharmony_ci  onDisconnect?(want: Want): void;
42561847f8eSopenharmony_ci
42661847f8eSopenharmony_ci  /**
42761847f8eSopenharmony_ci   * Called when a new client attempts to connect to a Service ability after all previous client connections to it
42861847f8eSopenharmony_ci   * are disconnected.
42961847f8eSopenharmony_ci   * <p>The Service ability must have been started but not been destroyed, that is, {@link #startAbility} has been
43061847f8eSopenharmony_ci   * called but {@link #terminateSelf} has not.</p>
43161847f8eSopenharmony_ci   *
43261847f8eSopenharmony_ci   * @param { Want } want - Indicates the want of the Service ability being connected.
43361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
43461847f8eSopenharmony_ci   * @FAModelOnly
43561847f8eSopenharmony_ci   * @since 7
43661847f8eSopenharmony_ci   */
43761847f8eSopenharmony_ci  onReconnect?(want: Want): void;
43861847f8eSopenharmony_ci}
43961847f8eSopenharmony_ci
44061847f8eSopenharmony_ci/**
44161847f8eSopenharmony_ci * interface of data lifecycle.
44261847f8eSopenharmony_ci *
44361847f8eSopenharmony_ci * @interface LifecycleData
44461847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
44561847f8eSopenharmony_ci * @FAModelOnly
44661847f8eSopenharmony_ci * @since 7
44761847f8eSopenharmony_ci */
44861847f8eSopenharmony_ciexport declare interface LifecycleData {
44961847f8eSopenharmony_ci  /**
45061847f8eSopenharmony_ci   * Updates one or more data records in the database. This method should be implemented by a Data ability.
45161847f8eSopenharmony_ci   *
45261847f8eSopenharmony_ci   * @param { string } uri - Indicates the database table storing the data to update.
45361847f8eSopenharmony_ci   * @param { rdb.ValuesBucket } valueBucket - Indicates the data to update. This parameter can be null.
45461847f8eSopenharmony_ci   * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. If this parameter is null,
45561847f8eSopenharmony_ci   *                                                           all data records will be updated by default.
45661847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer should
45761847f8eSopenharmony_ci   *                                             call this function to return the result to framework.
45861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
45961847f8eSopenharmony_ci   * @FAModelOnly
46061847f8eSopenharmony_ci   * @since 7
46161847f8eSopenharmony_ci   */
46261847f8eSopenharmony_ci  update?(
46361847f8eSopenharmony_ci    uri: string,
46461847f8eSopenharmony_ci    valueBucket: rdb.ValuesBucket,
46561847f8eSopenharmony_ci    predicates: dataAbility.DataAbilityPredicates,
46661847f8eSopenharmony_ci    callback: AsyncCallback<number>
46761847f8eSopenharmony_ci  ): void;
46861847f8eSopenharmony_ci
46961847f8eSopenharmony_ci  /**
47061847f8eSopenharmony_ci   * Queries one or more data records in the database. This method should be implemented by a Data ability.
47161847f8eSopenharmony_ci   *
47261847f8eSopenharmony_ci   * @param { string } uri - Indicates the database table storing the data to query.
47361847f8eSopenharmony_ci   * @param { Array<string> } columns - Indicates the columns to be queried, in array, for example, {"name","age"}.
47461847f8eSopenharmony_ci   *                                    You should define the processing logic when this parameter is null.
47561847f8eSopenharmony_ci   * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. If this parameter is null,
47661847f8eSopenharmony_ci   *                                                           all data records will be queried by default.
47761847f8eSopenharmony_ci   * @param { AsyncCallback<ResultSet> } callback - function specified by framework to receive the result, developer
47861847f8eSopenharmony_ci   *                                                should call this function to return the result to framework.
47961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
48061847f8eSopenharmony_ci   * @FAModelOnly
48161847f8eSopenharmony_ci   * @since 7
48261847f8eSopenharmony_ci   */
48361847f8eSopenharmony_ci  query?(
48461847f8eSopenharmony_ci    uri: string,
48561847f8eSopenharmony_ci    columns: Array<string>,
48661847f8eSopenharmony_ci    predicates: dataAbility.DataAbilityPredicates,
48761847f8eSopenharmony_ci    callback: AsyncCallback<ResultSet>
48861847f8eSopenharmony_ci  ): void;
48961847f8eSopenharmony_ci
49061847f8eSopenharmony_ci  /**
49161847f8eSopenharmony_ci   * Deletes one or more data records. This method should be implemented by a Data ability.
49261847f8eSopenharmony_ci   *
49361847f8eSopenharmony_ci   * @param { string } uri - Indicates the database table storing the data to delete.
49461847f8eSopenharmony_ci   * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. If this parameter is null,
49561847f8eSopenharmony_ci   *                                                           all data records will be deleted by default.
49661847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer should
49761847f8eSopenharmony_ci   *                                             call this function to return the result to framework.
49861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
49961847f8eSopenharmony_ci   * @FAModelOnly
50061847f8eSopenharmony_ci   * @since 7
50161847f8eSopenharmony_ci   */
50261847f8eSopenharmony_ci  delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<number>): void;
50361847f8eSopenharmony_ci
50461847f8eSopenharmony_ci  /**
50561847f8eSopenharmony_ci   * Converts the given {@code uri} that refer to the Data ability into a normalized URI. A normalized URI can be
50661847f8eSopenharmony_ci   * used across devices, persisted, backed up, and restored. It can refer to the same item in the Data ability
50761847f8eSopenharmony_ci   * even if the context has changed.
50861847f8eSopenharmony_ci   *
50961847f8eSopenharmony_ci   * @param { string } uri - Indicates the uri to normalize.
51061847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - function specified by framework to receive the result, developer
51161847f8eSopenharmony_ci   *                                             should call this function to return the result to framework.
51261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
51361847f8eSopenharmony_ci   * @FAModelOnly
51461847f8eSopenharmony_ci   * @since 7
51561847f8eSopenharmony_ci   */
51661847f8eSopenharmony_ci  normalizeUri?(uri: string, callback: AsyncCallback<string>): void;
51761847f8eSopenharmony_ci
51861847f8eSopenharmony_ci  /**
51961847f8eSopenharmony_ci   * Inserts multiple data records into the database. This method should be implemented by a Data ability.
52061847f8eSopenharmony_ci   *
52161847f8eSopenharmony_ci   * @param { string } uri - Indicates the position where the data is to insert.
52261847f8eSopenharmony_ci   * @param { Array<rdb.ValuesBucket> } valueBuckets - Indicates the data to insert.
52361847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer should
52461847f8eSopenharmony_ci   *                                             call this function to return the result to framework.
52561847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
52661847f8eSopenharmony_ci   * @FAModelOnly
52761847f8eSopenharmony_ci   * @since 7
52861847f8eSopenharmony_ci   */
52961847f8eSopenharmony_ci  batchInsert?(uri: string, valueBuckets: Array<rdb.ValuesBucket>, callback: AsyncCallback<number>): void;
53061847f8eSopenharmony_ci
53161847f8eSopenharmony_ci  /**
53261847f8eSopenharmony_ci   * Converts the given normalized {@code uri} generated by {@link #normalizeUri(uri)} into a denormalized one.
53361847f8eSopenharmony_ci   * The default implementation of this method returns the original uri passed to it.
53461847f8eSopenharmony_ci   *
53561847f8eSopenharmony_ci   * @param { string } uri - Indicates the uri to denormalize.
53661847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - function specified by framework to receive the result, developer
53761847f8eSopenharmony_ci   *                                             should call this function to return the result to framework.
53861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
53961847f8eSopenharmony_ci   * @FAModelOnly
54061847f8eSopenharmony_ci   * @since 7
54161847f8eSopenharmony_ci   */
54261847f8eSopenharmony_ci  denormalizeUri?(uri: string, callback: AsyncCallback<string>): void;
54361847f8eSopenharmony_ci
54461847f8eSopenharmony_ci  /**
54561847f8eSopenharmony_ci   * Inserts a data record into the database. This method should be implemented by a Data ability.
54661847f8eSopenharmony_ci   *
54761847f8eSopenharmony_ci   * @param { string } uri - Indicates the position where the data is to insert.
54861847f8eSopenharmony_ci   * @param { rdb.ValuesBucket } valueBucket - Indicates the data to insert.
54961847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer
55061847f8eSopenharmony_ci   *                                             should call this function to return the result to framework.
55161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
55261847f8eSopenharmony_ci   * @FAModelOnly
55361847f8eSopenharmony_ci   * @since 7
55461847f8eSopenharmony_ci   */
55561847f8eSopenharmony_ci  insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback<number>): void;
55661847f8eSopenharmony_ci
55761847f8eSopenharmony_ci  /**
55861847f8eSopenharmony_ci   * Opens a file. This method should be implemented by a Data ability.
55961847f8eSopenharmony_ci   *
56061847f8eSopenharmony_ci   * @param { string } uri - Indicates the path of the file to open.
56161847f8eSopenharmony_ci   * @param { string } mode - Indicates the open mode, which can be "r" for read-only access, "w" for write-only access
56261847f8eSopenharmony_ci   *                          (erasing whatever data is currently in the file), "wt" for write access that truncates any
56361847f8eSopenharmony_ci   *                          existing file,"wa" for write-only access to append to any existing data, "rw" for read and
56461847f8eSopenharmony_ci   *                          write access on any existing data, or "rwt" for read and write access that truncates any
56561847f8eSopenharmony_ci   *                          existing file.
56661847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer should
56761847f8eSopenharmony_ci   *                                             call this function to return the result to framework.
56861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
56961847f8eSopenharmony_ci   * @FAModelOnly
57061847f8eSopenharmony_ci   * @since 7
57161847f8eSopenharmony_ci   */
57261847f8eSopenharmony_ci  openFile?(uri: string, mode: string, callback: AsyncCallback<number>): void;
57361847f8eSopenharmony_ci
57461847f8eSopenharmony_ci  /**
57561847f8eSopenharmony_ci   * Obtains the MIME type of files. This method should be implemented by a Data ability.
57661847f8eSopenharmony_ci   *
57761847f8eSopenharmony_ci   * @param { string } uri - Indicates the path of the files to obtain.
57861847f8eSopenharmony_ci   * @param { string } mimeTypeFilter - Indicates the MIME type of the files to obtain. This parameter cannot be set to
57961847f8eSopenharmony_ci   *                                    {@code null}.
58061847f8eSopenharmony_ci   *                                    <p>1. "&ast;/*": Obtains all types supported by a Data ability.
58161847f8eSopenharmony_ci   *                                    <p>2. "image/*": Obtains files whose main type is image of any subtype.
58261847f8eSopenharmony_ci   *                                    <p>3. "&ast;/jpg": Obtains files whose subtype is JPG of any main type.
58361847f8eSopenharmony_ci   * @param { AsyncCallback<Array<string>> } callback - function specified by framework to receive the result, developer
58461847f8eSopenharmony_ci   *                                                    should call this function to return the result to framework.
58561847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
58661847f8eSopenharmony_ci   * @FAModelOnly
58761847f8eSopenharmony_ci   * @since 7
58861847f8eSopenharmony_ci   */
58961847f8eSopenharmony_ci  getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array<string>>): void;
59061847f8eSopenharmony_ci
59161847f8eSopenharmony_ci  /**
59261847f8eSopenharmony_ci   * Called to carry {@code AbilityInfo} to this ability after the ability is initialized.
59361847f8eSopenharmony_ci   *
59461847f8eSopenharmony_ci   * @param { AbilityInfo } info - Indicates the {@code AbilityInfo} object containing information about this ability.
59561847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
59661847f8eSopenharmony_ci   * @FAModelOnly
59761847f8eSopenharmony_ci   * @since 7
59861847f8eSopenharmony_ci   */
59961847f8eSopenharmony_ci  onInitialized?(info: AbilityInfo): void;
60061847f8eSopenharmony_ci
60161847f8eSopenharmony_ci  /**
60261847f8eSopenharmony_ci   * Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be
60361847f8eSopenharmony_ci   * implemented by a Data ability.
60461847f8eSopenharmony_ci   * <p>Data abilities supports general data types, including text, HTML, and JPEG.</p>
60561847f8eSopenharmony_ci   *
60661847f8eSopenharmony_ci   * @param { string } uri - Indicates the uri of the data.
60761847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - function specified by framework to receive the result, developer should
60861847f8eSopenharmony_ci   *                                             call this function to return the result to framework.
60961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
61061847f8eSopenharmony_ci   * @FAModelOnly
61161847f8eSopenharmony_ci   * @since 7
61261847f8eSopenharmony_ci   */
61361847f8eSopenharmony_ci  getType?(uri: string, callback: AsyncCallback<string>): void;
61461847f8eSopenharmony_ci
61561847f8eSopenharmony_ci  /**
61661847f8eSopenharmony_ci   * Performs batch operations on the database. This method should be implemented by a Data ability.
61761847f8eSopenharmony_ci   *
61861847f8eSopenharmony_ci   * @param { Array<DataAbilityOperation> } ops - Indicates the data operation list, which can contain multiple operations
61961847f8eSopenharmony_ci   *                                              on the database.
62061847f8eSopenharmony_ci   * @param { AsyncCallback<Array<DataAbilityResult>> } callback - specified by framework to receive the result,
62161847f8eSopenharmony_ci   *                                                               developer should call this function to return
62261847f8eSopenharmony_ci   *                                                               the result to framework.
62361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
62461847f8eSopenharmony_ci   * @FAModelOnly
62561847f8eSopenharmony_ci   * @since 7
62661847f8eSopenharmony_ci   */
62761847f8eSopenharmony_ci  executeBatch?(ops: Array<DataAbilityOperation>, callback: AsyncCallback<Array<DataAbilityResult>>): void;
62861847f8eSopenharmony_ci
62961847f8eSopenharmony_ci  /**
63061847f8eSopenharmony_ci   * Defines a method in this Data ability (implementation depending on child classes).
63161847f8eSopenharmony_ci   *
63261847f8eSopenharmony_ci   * @param { string } method - Indicates the method name.
63361847f8eSopenharmony_ci   * @param { string } arg - Indicates the parameter transferred by the method.
63461847f8eSopenharmony_ci   * @param { PacMap } extras - Indicates the parameter transferred by the method.
63561847f8eSopenharmony_ci   * @param { AsyncCallback<PacMap> } callback - function specified by framework to receive the result, developer
63661847f8eSopenharmony_ci   *                                             should call this function to return the result to framework.
63761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
63861847f8eSopenharmony_ci   * @FAModelOnly
63961847f8eSopenharmony_ci   * @since 7
64061847f8eSopenharmony_ci   */
64161847f8eSopenharmony_ci  call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback<PacMap>): void;
64261847f8eSopenharmony_ci}
643