17c804472Sopenharmony_ci/* 27c804472Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 37c804472Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47c804472Sopenharmony_ci * you may not use this file except in compliance with the License. 57c804472Sopenharmony_ci * You may obtain a copy of the License at 67c804472Sopenharmony_ci * 77c804472Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87c804472Sopenharmony_ci * 97c804472Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107c804472Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117c804472Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127c804472Sopenharmony_ci * See the License for the specific language governing permissions and 137c804472Sopenharmony_ci * limitations under the License. 147c804472Sopenharmony_ci */ 157c804472Sopenharmony_ci 167c804472Sopenharmony_ciimport Want from '../../@ohos.app.ability.Want'; 177c804472Sopenharmony_ciimport { ResultSet } from '../../data/rdb/resultSet'; 187c804472Sopenharmony_ciimport { AbilityInfo } from '../../bundle/abilityInfo'; 197c804472Sopenharmony_ciimport { DataAbilityResult } from '../../ability/dataAbilityResult'; 207c804472Sopenharmony_ciimport { DataAbilityOperation } from '../../ability/dataAbilityOperation'; 217c804472Sopenharmony_ciimport dataAbility from '../../@ohos.data.dataAbility'; 227c804472Sopenharmony_ciimport formBindingData from '../../@ohos.application.formBindingData'; 237c804472Sopenharmony_ciimport formInfo from '../../@ohos.app.form.formInfo'; 247c804472Sopenharmony_ciimport rdb from '../../@ohos.data.rdb'; 257c804472Sopenharmony_ciimport rpc from '../../@ohos.rpc'; 267c804472Sopenharmony_ciimport resourceManager from '../../@ohos.resourceManager'; 277c804472Sopenharmony_ciimport { PacMap } from '../../ability/dataAbilityHelper'; 287c804472Sopenharmony_ciimport { AsyncCallback } from '../../@ohos.base'; 297c804472Sopenharmony_ci 307c804472Sopenharmony_ci/** 317c804472Sopenharmony_ci * interface of form lifecycle. 327c804472Sopenharmony_ci * 337c804472Sopenharmony_ci * @interface LifecycleForm 347c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 357c804472Sopenharmony_ci * @FAModelOnly 367c804472Sopenharmony_ci * @since 7 377c804472Sopenharmony_ci */ 387c804472Sopenharmony_ciexport declare interface LifecycleForm { 397c804472Sopenharmony_ci /** 407c804472Sopenharmony_ci * Called to return a {@link formBindingData.FormBindingData} object. 417c804472Sopenharmony_ci * 427c804472Sopenharmony_ci * @param { Want } want - Indicates the detailed information for creating a {@link formBindingData#FormBindingData}. 437c804472Sopenharmony_ci * The {@code Want} object must include the form ID, form name, and grid style of the form, 447c804472Sopenharmony_ci * which can be obtained from {@link formInfo#FormParam#IDENTITY_KEY}, 457c804472Sopenharmony_ci * {@link formInfo#FormParam#NAME_KEY}, and {@link formInfo#FormParam#DIMENSION_KEY}, 467c804472Sopenharmony_ci * respectively. Such form information must be managed as persistent data for further form 477c804472Sopenharmony_ci * acquisition, update, and deletion. 487c804472Sopenharmony_ci * @returns { formBindingData.FormBindingData } Returns the created {@link formBindingData#FormBindingData} object. 497c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 507c804472Sopenharmony_ci * @FAModelOnly 517c804472Sopenharmony_ci * @since 8 527c804472Sopenharmony_ci */ 537c804472Sopenharmony_ci onCreate?(want: Want): formBindingData.FormBindingData; 547c804472Sopenharmony_ci 557c804472Sopenharmony_ci /** 567c804472Sopenharmony_ci * Called when the form provider is notified that a temporary form is successfully converted to a normal form. 577c804472Sopenharmony_ci * 587c804472Sopenharmony_ci * @param { string } formId - Indicates the ID of the form. 597c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 607c804472Sopenharmony_ci * @FAModelOnly 617c804472Sopenharmony_ci * @since 8 627c804472Sopenharmony_ci */ 637c804472Sopenharmony_ci onCastToNormal?(formId: string): void; 647c804472Sopenharmony_ci 657c804472Sopenharmony_ci /** 667c804472Sopenharmony_ci * Called to notify the form provider to update a specified form. 677c804472Sopenharmony_ci * 687c804472Sopenharmony_ci * @param { string } formId - Indicates the ID of the form to update. 697c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 707c804472Sopenharmony_ci * @FAModelOnly 717c804472Sopenharmony_ci * @since 8 727c804472Sopenharmony_ci */ 737c804472Sopenharmony_ci onUpdate?(formId: string): void; 747c804472Sopenharmony_ci 757c804472Sopenharmony_ci /** 767c804472Sopenharmony_ci * Called when the form provider receives form events from the system. 777c804472Sopenharmony_ci * 787c804472Sopenharmony_ci * @param { object } newStatus - Indicates the form events occurred. The key in the {@code Map} object indicates 797c804472Sopenharmony_ci * form ID,and the value indicates the event type, which can be either 807c804472Sopenharmony_ci * {@link formInfo#VisibilityType#FORM_VISIBLE} or 817c804472Sopenharmony_ci * {@link formInfo#VisibilityType#FORM_INVISIBLE}. 827c804472Sopenharmony_ci * {@link formInfo#VisibilityType#FORM_VISIBLE} 837c804472Sopenharmony_ci * means that the form becomes visible, and 847c804472Sopenharmony_ci * {@link formInfo#VisibilityType#FORM_INVISIBLE} 857c804472Sopenharmony_ci * means that the form becomes invisible. 867c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 877c804472Sopenharmony_ci * @FAModelOnly 887c804472Sopenharmony_ci * @since 8 897c804472Sopenharmony_ci */ 907c804472Sopenharmony_ci /** 917c804472Sopenharmony_ci * Called when the form provider receives form events from the system. 927c804472Sopenharmony_ci * 937c804472Sopenharmony_ci * @param { Record<string, number> } newStatus - Indicates the form events occurred. The key in the {@code Map} 947c804472Sopenharmony_ci * object indicates form ID,and the value indicates the event type, 957c804472Sopenharmony_ci * which can be either 967c804472Sopenharmony_ci * {@link formInfo#VisibilityType#FORM_VISIBLE} or 977c804472Sopenharmony_ci * {@link formInfo#VisibilityType#FORM_INVISIBLE}. 987c804472Sopenharmony_ci * {@link formInfo#VisibilityType#FORM_VISIBLE} 997c804472Sopenharmony_ci * means that the form becomes visible, and 1007c804472Sopenharmony_ci * {@link formInfo#VisibilityType#FORM_INVISIBLE} 1017c804472Sopenharmony_ci * means that the form becomes invisible. 1027c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 1037c804472Sopenharmony_ci * @FAModelOnly 1047c804472Sopenharmony_ci * @since 11 1057c804472Sopenharmony_ci */ 1067c804472Sopenharmony_ci onVisibilityChange?(newStatus: Record<string, number>): void; 1077c804472Sopenharmony_ci 1087c804472Sopenharmony_ci /** 1097c804472Sopenharmony_ci * Called when a specified message event defined by the form provider is triggered. This method is valid only for 1107c804472Sopenharmony_ci * JS forms. 1117c804472Sopenharmony_ci * 1127c804472Sopenharmony_ci * @param { string } formId - Indicates the ID of the form on which the message event is triggered, which is 1137c804472Sopenharmony_ci * provided by the client to the form provider. 1147c804472Sopenharmony_ci * @param { string } message - Indicates the value of the {@code params} field of the message event. This parameter 1157c804472Sopenharmony_ci * is used to identify the specific component on which the event is triggered. 1167c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 1177c804472Sopenharmony_ci * @FAModelOnly 1187c804472Sopenharmony_ci * @since 8 1197c804472Sopenharmony_ci */ 1207c804472Sopenharmony_ci onEvent?(formId: string, message: string): void; 1217c804472Sopenharmony_ci 1227c804472Sopenharmony_ci /** 1237c804472Sopenharmony_ci * Called to notify the form provider that a specified form has been deleted. Override this method if 1247c804472Sopenharmony_ci * you want your application, as the form provider, to be notified of form deletion. 1257c804472Sopenharmony_ci * 1267c804472Sopenharmony_ci * @param { string } formId - Indicates the ID of the deleted form. 1277c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 1287c804472Sopenharmony_ci * @FAModelOnly 1297c804472Sopenharmony_ci * @since 8 1307c804472Sopenharmony_ci */ 1317c804472Sopenharmony_ci onDestroy?(formId: string): void; 1327c804472Sopenharmony_ci 1337c804472Sopenharmony_ci /** 1347c804472Sopenharmony_ci * Called to return a {@link FormState} object. 1357c804472Sopenharmony_ci * <p>You must override this callback if you want this ability to return the actual form state. Otherwise, 1367c804472Sopenharmony_ci * this method returns {@link FormState#DEFAULT} by default.</p> 1377c804472Sopenharmony_ci * 1387c804472Sopenharmony_ci * @param { Want } want - Indicates the description of the form for which the {@link formInfo#FormState} is obtained. 1397c804472Sopenharmony_ci * The description covers the bundle name, ability name, module name, form name, form 1407c804472Sopenharmony_ci * dimensions. 1417c804472Sopenharmony_ci * @returns { formInfo.FormState } Returns the {@link formInfo#FormState} object. 1427c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 1437c804472Sopenharmony_ci * @FAModelOnly 1447c804472Sopenharmony_ci * @since 8 1457c804472Sopenharmony_ci */ 1467c804472Sopenharmony_ci onAcquireFormState?(want: Want): formInfo.FormState; 1477c804472Sopenharmony_ci 1487c804472Sopenharmony_ci /** 1497c804472Sopenharmony_ci * Called when the system shares the form. 1507c804472Sopenharmony_ci * 1517c804472Sopenharmony_ci * @param { string } formId - Indicates the ID of the deleted form. 1527c804472Sopenharmony_ci * @returns { object } Returns the wantParams object. 1537c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 1547c804472Sopenharmony_ci * @systemapi 1557c804472Sopenharmony_ci * @FAModelOnly 1567c804472Sopenharmony_ci * @since 9 1577c804472Sopenharmony_ci */ 1587c804472Sopenharmony_ci onShare?(formId: string): { [key: string]: any }; 1597c804472Sopenharmony_ci 1607c804472Sopenharmony_ci /** 1617c804472Sopenharmony_ci * Called when the system shares the form. 1627c804472Sopenharmony_ci * The ability of this function is same as onShare. If both are set, this function will be called. 1637c804472Sopenharmony_ci * 1647c804472Sopenharmony_ci * @param { string } formId - Indicates the ID of the deleted form. 1657c804472Sopenharmony_ci * @returns { Record<string, Object> } Returns the wantParams object. 1667c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 1677c804472Sopenharmony_ci * @systemapi 1687c804472Sopenharmony_ci * @FAModelOnly 1697c804472Sopenharmony_ci * @since 11 1707c804472Sopenharmony_ci */ 1717c804472Sopenharmony_ci onShareForm?(formId: string): Record<string, Object>; 1727c804472Sopenharmony_ci} 1737c804472Sopenharmony_ci 1747c804472Sopenharmony_ci/** 1757c804472Sopenharmony_ci * interface of app lifecycle. 1767c804472Sopenharmony_ci * 1777c804472Sopenharmony_ci * @interface LifecycleApp 1787c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 1797c804472Sopenharmony_ci * @FAModelOnly 1807c804472Sopenharmony_ci * @since 7 1817c804472Sopenharmony_ci */ 1827c804472Sopenharmony_ciexport declare interface LifecycleApp { 1837c804472Sopenharmony_ci /** 1847c804472Sopenharmony_ci * Called back when the state of an ability changes from <b>BACKGROUND</b> to <b>INACTIVE</b>. 1857c804472Sopenharmony_ci * 1867c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 1877c804472Sopenharmony_ci * @FAModelOnly 1887c804472Sopenharmony_ci * @since 7 1897c804472Sopenharmony_ci */ 1907c804472Sopenharmony_ci onShow?(): void; 1917c804472Sopenharmony_ci 1927c804472Sopenharmony_ci /** 1937c804472Sopenharmony_ci * Called back when an ability enters the <b>BACKGROUND</b> state. 1947c804472Sopenharmony_ci * 1957c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 1967c804472Sopenharmony_ci * @FAModelOnly 1977c804472Sopenharmony_ci * @since 7 1987c804472Sopenharmony_ci */ 1997c804472Sopenharmony_ci onHide?(): void; 2007c804472Sopenharmony_ci 2017c804472Sopenharmony_ci /** 2027c804472Sopenharmony_ci * Called back before an ability is destroyed. 2037c804472Sopenharmony_ci * 2047c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 2057c804472Sopenharmony_ci * @FAModelOnly 2067c804472Sopenharmony_ci * @since 7 2077c804472Sopenharmony_ci */ 2087c804472Sopenharmony_ci onDestroy?(): void; 2097c804472Sopenharmony_ci 2107c804472Sopenharmony_ci /** 2117c804472Sopenharmony_ci * Called back when an ability is started for initialization. 2127c804472Sopenharmony_ci * 2137c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 2147c804472Sopenharmony_ci * @FAModelOnly 2157c804472Sopenharmony_ci * @since 7 2167c804472Sopenharmony_ci */ 2177c804472Sopenharmony_ci onCreate?(): void; 2187c804472Sopenharmony_ci 2197c804472Sopenharmony_ci /** 2207c804472Sopenharmony_ci * Called when the window display mode of this ability changes, for example, from fullscreen mode 2217c804472Sopenharmony_ci * to multi-window mode or from multi-window mode to fullscreen mode. 2227c804472Sopenharmony_ci * 2237c804472Sopenharmony_ci * @param { boolean } isShownInMultiWindow - Specifies whether this ability is currently in multi-window mode.The 2247c804472Sopenharmony_ci * value {@code true} indicates the multi-window mode, and {@code false} 2257c804472Sopenharmony_ci * indicates another mode. 2267c804472Sopenharmony_ci * @param { resourceManager.Configuration } newConfig - Indicates the new configuration information about Page ability. 2277c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 2287c804472Sopenharmony_ci * @systemapi 2297c804472Sopenharmony_ci * @FAModelOnly 2307c804472Sopenharmony_ci * @since 7 2317c804472Sopenharmony_ci */ 2327c804472Sopenharmony_ci onWindowDisplayModeChanged?(isShownInMultiWindow: boolean, newConfig: resourceManager.Configuration): void; 2337c804472Sopenharmony_ci 2347c804472Sopenharmony_ci /** 2357c804472Sopenharmony_ci * Asks a user whether to start the migration. 2367c804472Sopenharmony_ci * 2377c804472Sopenharmony_ci * @returns { boolean } Returns {@code true} if the user allows the migration; returns {@code false} otherwise. 2387c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 2397c804472Sopenharmony_ci * @FAModelOnly 2407c804472Sopenharmony_ci * @since 7 2417c804472Sopenharmony_ci */ 2427c804472Sopenharmony_ci onStartContinuation?(): boolean; 2437c804472Sopenharmony_ci 2447c804472Sopenharmony_ci /** 2457c804472Sopenharmony_ci * Saves the user data of a local ability generated during runtime. 2467c804472Sopenharmony_ci * After the migration is triggered and the local ability is ready, this method is called when the Distributed 2477c804472Sopenharmony_ci * Scheduler Service requests data from the local ability. 2487c804472Sopenharmony_ci * 2497c804472Sopenharmony_ci * @param { Object } data - Indicates the user data to save. 2507c804472Sopenharmony_ci * @returns { boolean } Returns {@code true} if the data is successfully saved; returns {@code false} otherwise. 2517c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 2527c804472Sopenharmony_ci * @FAModelOnly 2537c804472Sopenharmony_ci * @since 7 2547c804472Sopenharmony_ci */ 2557c804472Sopenharmony_ci onSaveData?(data: Object): boolean; 2567c804472Sopenharmony_ci 2577c804472Sopenharmony_ci /** 2587c804472Sopenharmony_ci * Called back when a local ability migration is complete. 2597c804472Sopenharmony_ci * <p>You can define the processing logic after the migration is complete. For example, you can display a prompt to 2607c804472Sopenharmony_ci * notify the user of the successful migration and then exit the local ability.</p> 2617c804472Sopenharmony_ci * 2627c804472Sopenharmony_ci * @param { number } result - Indicates the migration result code. The value {@code 0} indicates that the migration is 2637c804472Sopenharmony_ci * successful, and {@code -1} indicates that the migration fails. 2647c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 2657c804472Sopenharmony_ci * @FAModelOnly 2667c804472Sopenharmony_ci * @since 7 2677c804472Sopenharmony_ci */ 2687c804472Sopenharmony_ci onCompleteContinuation?(result: number): void; 2697c804472Sopenharmony_ci 2707c804472Sopenharmony_ci /** 2717c804472Sopenharmony_ci * Restores the user data saved during the migration for an ability on the remote device immediately after the 2727c804472Sopenharmony_ci * ability is created on the remote device. Lifecycle scheduling for the ability starts only after the user data 2737c804472Sopenharmony_ci * is restored. 2747c804472Sopenharmony_ci * 2757c804472Sopenharmony_ci * @param { Object } data - Indicates the user data to restore. 2767c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 2777c804472Sopenharmony_ci * @FAModelOnly 2787c804472Sopenharmony_ci * @since 7 2797c804472Sopenharmony_ci */ 2807c804472Sopenharmony_ci onRestoreData?(data: Object): void; 2817c804472Sopenharmony_ci 2827c804472Sopenharmony_ci /** 2837c804472Sopenharmony_ci * Called to notify the local device when a running ability on the remote device is destroyed after a reversible 2847c804472Sopenharmony_ci * migration is performed for the ability from the local device to the remote device. 2857c804472Sopenharmony_ci * 2867c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 2877c804472Sopenharmony_ci * @FAModelOnly 2887c804472Sopenharmony_ci * @since 7 2897c804472Sopenharmony_ci */ 2907c804472Sopenharmony_ci onRemoteTerminated?(): void; 2917c804472Sopenharmony_ci 2927c804472Sopenharmony_ci /** 2937c804472Sopenharmony_ci * This method is called when the system determines that the ability may be destroyed in an unexpected 2947c804472Sopenharmony_ci * situation, for example, when the screen orientation changes or the user touches the Home key. Generally, 2957c804472Sopenharmony_ci * this method is used only to save temporary states. 2967c804472Sopenharmony_ci * 2977c804472Sopenharmony_ci * @param { PacMap } outState - Indicates the {@code PacMap} object used for storing user data and states. This 2987c804472Sopenharmony_ci * parameter cannot be null. 2997c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3007c804472Sopenharmony_ci * @FAModelOnly 3017c804472Sopenharmony_ci * @since 7 3027c804472Sopenharmony_ci */ 3037c804472Sopenharmony_ci onSaveAbilityState?(outState: PacMap): void; 3047c804472Sopenharmony_ci 3057c804472Sopenharmony_ci /** 3067c804472Sopenharmony_ci * This method is called if an ability was destroyed at a certain time due to resource reclaim or was 3077c804472Sopenharmony_ci * unexpectedly destroyed and the {@link #onSaveAbilityState(PacMap)} method was called to save its user data and 3087c804472Sopenharmony_ci * states. Generally, this method is called after the {@link #onStart(Want)} method. 3097c804472Sopenharmony_ci * 3107c804472Sopenharmony_ci * @param { PacMap } inState - Indicates the {@code PacMap} object used for storing data and states. This 3117c804472Sopenharmony_ci * parameter can not be null. 3127c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3137c804472Sopenharmony_ci * @FAModelOnly 3147c804472Sopenharmony_ci * @since 7 3157c804472Sopenharmony_ci */ 3167c804472Sopenharmony_ci onRestoreAbilityState?(inState: PacMap): void; 3177c804472Sopenharmony_ci 3187c804472Sopenharmony_ci /** 3197c804472Sopenharmony_ci * Called back when an ability enters the <b>INACTIVE</b> state (an ability in this state is not interactive and may 3207c804472Sopenharmony_ci * change to the <b>BACKGROUND</b> or <b>ACTIVE</b> state). 3217c804472Sopenharmony_ci * 3227c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3237c804472Sopenharmony_ci * @FAModelOnly 3247c804472Sopenharmony_ci * @since 7 3257c804472Sopenharmony_ci */ 3267c804472Sopenharmony_ci onInactive?(): void; 3277c804472Sopenharmony_ci 3287c804472Sopenharmony_ci /** 3297c804472Sopenharmony_ci * Called back when an ability enters the <b>ACTIVE</b> state. 3307c804472Sopenharmony_ci * 3317c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3327c804472Sopenharmony_ci * @FAModelOnly 3337c804472Sopenharmony_ci * @since 7 3347c804472Sopenharmony_ci */ 3357c804472Sopenharmony_ci onActive?(): void; 3367c804472Sopenharmony_ci 3377c804472Sopenharmony_ci /** 3387c804472Sopenharmony_ci * Called when the launch mode of an ability is set to singleton. 3397c804472Sopenharmony_ci * 3407c804472Sopenharmony_ci * @param { Want } want - Indicates the new {@code want} containing information about the ability. 3417c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3427c804472Sopenharmony_ci * @FAModelOnly 3437c804472Sopenharmony_ci * @since 7 3447c804472Sopenharmony_ci */ 3457c804472Sopenharmony_ci onNewWant?(want: Want): void; 3467c804472Sopenharmony_ci 3477c804472Sopenharmony_ci /** 3487c804472Sopenharmony_ci * Called when the system has determined to trim the memory, for example, when the ability is running in the 3497c804472Sopenharmony_ci * background and there is no enough memory for running as many background processes as possible. 3507c804472Sopenharmony_ci * 3517c804472Sopenharmony_ci * @param { number } level - Indicates the memory trim level, which shows the current memory usage status. 3527c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3537c804472Sopenharmony_ci * @FAModelOnly 3547c804472Sopenharmony_ci * @since 7 3557c804472Sopenharmony_ci */ 3567c804472Sopenharmony_ci onMemoryLevel?(level: number): void; 3577c804472Sopenharmony_ci} 3587c804472Sopenharmony_ci 3597c804472Sopenharmony_ci/** 3607c804472Sopenharmony_ci * interface of service lifecycle. 3617c804472Sopenharmony_ci * 3627c804472Sopenharmony_ci * @interface LifecycleService 3637c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3647c804472Sopenharmony_ci * @FAModelOnly 3657c804472Sopenharmony_ci * @since 7 3667c804472Sopenharmony_ci */ 3677c804472Sopenharmony_ciexport declare interface LifecycleService { 3687c804472Sopenharmony_ci /** 3697c804472Sopenharmony_ci * Called back when an ability is started for initialization (it can be called only once in the entire lifecycle of 3707c804472Sopenharmony_ci * an ability). 3717c804472Sopenharmony_ci * 3727c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3737c804472Sopenharmony_ci * @FAModelOnly 3747c804472Sopenharmony_ci * @since 7 3757c804472Sopenharmony_ci */ 3767c804472Sopenharmony_ci onStart?(): void; 3777c804472Sopenharmony_ci 3787c804472Sopenharmony_ci /** 3797c804472Sopenharmony_ci * Called back when Service is started. 3807c804472Sopenharmony_ci * 3817c804472Sopenharmony_ci * @param { Want } want - Indicates the want of Service to start. 3827c804472Sopenharmony_ci * @param { number } startId - Indicates the number of times the Service ability has been started. {@code startId} is 3837c804472Sopenharmony_ci * incremented by 1 every time the ability is started. For example, if the ability 3847c804472Sopenharmony_ci * has been started for six times. 3857c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3867c804472Sopenharmony_ci * @FAModelOnly 3877c804472Sopenharmony_ci * @since 7 3887c804472Sopenharmony_ci */ 3897c804472Sopenharmony_ci onCommand?(want: Want, startId: number): void; 3907c804472Sopenharmony_ci 3917c804472Sopenharmony_ci /** 3927c804472Sopenharmony_ci * Called back before an ability is destroyed. 3937c804472Sopenharmony_ci * 3947c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3957c804472Sopenharmony_ci * @FAModelOnly 3967c804472Sopenharmony_ci * @since 7 3977c804472Sopenharmony_ci */ 3987c804472Sopenharmony_ci onStop?(): void; 3997c804472Sopenharmony_ci 4007c804472Sopenharmony_ci /** 4017c804472Sopenharmony_ci * Called back when a Service ability is first connected to an ability. 4027c804472Sopenharmony_ci * 4037c804472Sopenharmony_ci * @param { Want } want - Indicates connection information about the Service ability. 4047c804472Sopenharmony_ci * @returns { rpc.RemoteObject } Returns the proxy of the Service ability. 4057c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 4067c804472Sopenharmony_ci * @FAModelOnly 4077c804472Sopenharmony_ci * @since 7 4087c804472Sopenharmony_ci */ 4097c804472Sopenharmony_ci onConnect?(want: Want): rpc.RemoteObject; 4107c804472Sopenharmony_ci 4117c804472Sopenharmony_ci /** 4127c804472Sopenharmony_ci * Called back when all abilities connected to a Service ability are disconnected. 4137c804472Sopenharmony_ci * 4147c804472Sopenharmony_ci * @param { Want } want - Indicates disconnection information about the Service ability. 4157c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 4167c804472Sopenharmony_ci * @FAModelOnly 4177c804472Sopenharmony_ci * @since 7 4187c804472Sopenharmony_ci */ 4197c804472Sopenharmony_ci onDisconnect?(want: Want): void; 4207c804472Sopenharmony_ci 4217c804472Sopenharmony_ci /** 4227c804472Sopenharmony_ci * Called when a new client attempts to connect to a Service ability after all previous client connections to it 4237c804472Sopenharmony_ci * are disconnected. 4247c804472Sopenharmony_ci * <p>The Service ability must have been started but not been destroyed, that is, {@link #startAbility} has been 4257c804472Sopenharmony_ci * called but {@link #terminateSelf} has not.</p> 4267c804472Sopenharmony_ci * 4277c804472Sopenharmony_ci * @param { Want } want - Indicates the want of the Service ability being connected. 4287c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 4297c804472Sopenharmony_ci * @FAModelOnly 4307c804472Sopenharmony_ci * @since 7 4317c804472Sopenharmony_ci */ 4327c804472Sopenharmony_ci onReconnect?(want: Want): void; 4337c804472Sopenharmony_ci} 4347c804472Sopenharmony_ci 4357c804472Sopenharmony_ci/** 4367c804472Sopenharmony_ci * interface of data lifecycle. 4377c804472Sopenharmony_ci * 4387c804472Sopenharmony_ci * @interface LifecycleData 4397c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 4407c804472Sopenharmony_ci * @FAModelOnly 4417c804472Sopenharmony_ci * @since 7 4427c804472Sopenharmony_ci */ 4437c804472Sopenharmony_ciexport declare interface LifecycleData { 4447c804472Sopenharmony_ci /** 4457c804472Sopenharmony_ci * Updates one or more data records in the database. This method should be implemented by a Data ability. 4467c804472Sopenharmony_ci * 4477c804472Sopenharmony_ci * @param { string } uri - Indicates the database table storing the data to update. 4487c804472Sopenharmony_ci * @param { rdb.ValuesBucket } valueBucket - Indicates the data to update. This parameter can be null. 4497c804472Sopenharmony_ci * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. If this parameter is null, 4507c804472Sopenharmony_ci * all data records will be updated by default. 4517c804472Sopenharmony_ci * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer should 4527c804472Sopenharmony_ci * call this function to return the result to framework. 4537c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 4547c804472Sopenharmony_ci * @FAModelOnly 4557c804472Sopenharmony_ci * @since 7 4567c804472Sopenharmony_ci */ 4577c804472Sopenharmony_ci update?( 4587c804472Sopenharmony_ci uri: string, 4597c804472Sopenharmony_ci valueBucket: rdb.ValuesBucket, 4607c804472Sopenharmony_ci predicates: dataAbility.DataAbilityPredicates, 4617c804472Sopenharmony_ci callback: AsyncCallback<number> 4627c804472Sopenharmony_ci ): void; 4637c804472Sopenharmony_ci 4647c804472Sopenharmony_ci /** 4657c804472Sopenharmony_ci * Queries one or more data records in the database. This method should be implemented by a Data ability. 4667c804472Sopenharmony_ci * 4677c804472Sopenharmony_ci * @param { string } uri - Indicates the database table storing the data to query. 4687c804472Sopenharmony_ci * @param { Array<string> } columns - Indicates the columns to be queried, in array, for example, {"name","age"}. 4697c804472Sopenharmony_ci * You should define the processing logic when this parameter is null. 4707c804472Sopenharmony_ci * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. If this parameter is null, 4717c804472Sopenharmony_ci * all data records will be queried by default. 4727c804472Sopenharmony_ci * @param { AsyncCallback<ResultSet> } callback - function specified by framework to receive the result, developer 4737c804472Sopenharmony_ci * should call this function to return the result to framework. 4747c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 4757c804472Sopenharmony_ci * @FAModelOnly 4767c804472Sopenharmony_ci * @since 7 4777c804472Sopenharmony_ci */ 4787c804472Sopenharmony_ci query?( 4797c804472Sopenharmony_ci uri: string, 4807c804472Sopenharmony_ci columns: Array<string>, 4817c804472Sopenharmony_ci predicates: dataAbility.DataAbilityPredicates, 4827c804472Sopenharmony_ci callback: AsyncCallback<ResultSet> 4837c804472Sopenharmony_ci ): void; 4847c804472Sopenharmony_ci 4857c804472Sopenharmony_ci /** 4867c804472Sopenharmony_ci * Deletes one or more data records. This method should be implemented by a Data ability. 4877c804472Sopenharmony_ci * 4887c804472Sopenharmony_ci * @param { string } uri - Indicates the database table storing the data to delete. 4897c804472Sopenharmony_ci * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. If this parameter is null, 4907c804472Sopenharmony_ci * all data records will be deleted by default. 4917c804472Sopenharmony_ci * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer should 4927c804472Sopenharmony_ci * call this function to return the result to framework. 4937c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 4947c804472Sopenharmony_ci * @FAModelOnly 4957c804472Sopenharmony_ci * @since 7 4967c804472Sopenharmony_ci */ 4977c804472Sopenharmony_ci delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<number>): void; 4987c804472Sopenharmony_ci 4997c804472Sopenharmony_ci /** 5007c804472Sopenharmony_ci * Converts the given {@code uri} that refer to the Data ability into a normalized URI. A normalized URI can be 5017c804472Sopenharmony_ci * used across devices, persisted, backed up, and restored. It can refer to the same item in the Data ability 5027c804472Sopenharmony_ci * even if the context has changed. 5037c804472Sopenharmony_ci * 5047c804472Sopenharmony_ci * @param { string } uri - Indicates the uri to normalize. 5057c804472Sopenharmony_ci * @param { AsyncCallback<string> } callback - function specified by framework to receive the result, developer 5067c804472Sopenharmony_ci * should call this function to return the result to framework. 5077c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 5087c804472Sopenharmony_ci * @FAModelOnly 5097c804472Sopenharmony_ci * @since 7 5107c804472Sopenharmony_ci */ 5117c804472Sopenharmony_ci normalizeUri?(uri: string, callback: AsyncCallback<string>): void; 5127c804472Sopenharmony_ci 5137c804472Sopenharmony_ci /** 5147c804472Sopenharmony_ci * Inserts multiple data records into the database. This method should be implemented by a Data ability. 5157c804472Sopenharmony_ci * 5167c804472Sopenharmony_ci * @param { string } uri - Indicates the position where the data is to insert. 5177c804472Sopenharmony_ci * @param { Array<rdb.ValuesBucket> } valueBuckets - Indicates the data to insert. 5187c804472Sopenharmony_ci * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer should 5197c804472Sopenharmony_ci * call this function to return the result to framework. 5207c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 5217c804472Sopenharmony_ci * @FAModelOnly 5227c804472Sopenharmony_ci * @since 7 5237c804472Sopenharmony_ci */ 5247c804472Sopenharmony_ci batchInsert?(uri: string, valueBuckets: Array<rdb.ValuesBucket>, callback: AsyncCallback<number>): void; 5257c804472Sopenharmony_ci 5267c804472Sopenharmony_ci /** 5277c804472Sopenharmony_ci * Converts the given normalized {@code uri} generated by {@link #normalizeUri(uri)} into a denormalized one. 5287c804472Sopenharmony_ci * The default implementation of this method returns the original uri passed to it. 5297c804472Sopenharmony_ci * 5307c804472Sopenharmony_ci * @param { string } uri - Indicates the uri to denormalize. 5317c804472Sopenharmony_ci * @param { AsyncCallback<string> } callback - function specified by framework to receive the result, developer 5327c804472Sopenharmony_ci * should call this function to return the result to framework. 5337c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 5347c804472Sopenharmony_ci * @FAModelOnly 5357c804472Sopenharmony_ci * @since 7 5367c804472Sopenharmony_ci */ 5377c804472Sopenharmony_ci denormalizeUri?(uri: string, callback: AsyncCallback<string>): void; 5387c804472Sopenharmony_ci 5397c804472Sopenharmony_ci /** 5407c804472Sopenharmony_ci * Inserts a data record into the database. This method should be implemented by a Data ability. 5417c804472Sopenharmony_ci * 5427c804472Sopenharmony_ci * @param { string } uri - Indicates the position where the data is to insert. 5437c804472Sopenharmony_ci * @param { rdb.ValuesBucket } valueBucket - Indicates the data to insert. 5447c804472Sopenharmony_ci * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer 5457c804472Sopenharmony_ci * should call this function to return the result to framework. 5467c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 5477c804472Sopenharmony_ci * @FAModelOnly 5487c804472Sopenharmony_ci * @since 7 5497c804472Sopenharmony_ci */ 5507c804472Sopenharmony_ci insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback<number>): void; 5517c804472Sopenharmony_ci 5527c804472Sopenharmony_ci /** 5537c804472Sopenharmony_ci * Opens a file. This method should be implemented by a Data ability. 5547c804472Sopenharmony_ci * 5557c804472Sopenharmony_ci * @param { string } uri - Indicates the path of the file to open. 5567c804472Sopenharmony_ci * @param { string } mode - Indicates the open mode, which can be "r" for read-only access, "w" for write-only access 5577c804472Sopenharmony_ci * (erasing whatever data is currently in the file), "wt" for write access that truncates any 5587c804472Sopenharmony_ci * existing file,"wa" for write-only access to append to any existing data, "rw" for read and 5597c804472Sopenharmony_ci * write access on any existing data, or "rwt" for read and write access that truncates any 5607c804472Sopenharmony_ci * existing file. 5617c804472Sopenharmony_ci * @param { AsyncCallback<number> } callback - function specified by framework to receive the result, developer should 5627c804472Sopenharmony_ci * call this function to return the result to framework. 5637c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 5647c804472Sopenharmony_ci * @FAModelOnly 5657c804472Sopenharmony_ci * @since 7 5667c804472Sopenharmony_ci */ 5677c804472Sopenharmony_ci openFile?(uri: string, mode: string, callback: AsyncCallback<number>): void; 5687c804472Sopenharmony_ci 5697c804472Sopenharmony_ci /** 5707c804472Sopenharmony_ci * Obtains the MIME type of files. This method should be implemented by a Data ability. 5717c804472Sopenharmony_ci * 5727c804472Sopenharmony_ci * @param { string } uri - Indicates the path of the files to obtain. 5737c804472Sopenharmony_ci * @param { string } mimeTypeFilter - Indicates the MIME type of the files to obtain. This parameter cannot be set to 5747c804472Sopenharmony_ci * {@code null}. 5757c804472Sopenharmony_ci * <p>1. "*/*": Obtains all types supported by a Data ability. 5767c804472Sopenharmony_ci * <p>2. "image/*": Obtains files whose main type is image of any subtype. 5777c804472Sopenharmony_ci * <p>3. "*/jpg": Obtains files whose subtype is JPG of any main type. 5787c804472Sopenharmony_ci * @param { AsyncCallback<Array<string>> } callback - function specified by framework to receive the result, developer 5797c804472Sopenharmony_ci * should call this function to return the result to framework. 5807c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 5817c804472Sopenharmony_ci * @FAModelOnly 5827c804472Sopenharmony_ci * @since 7 5837c804472Sopenharmony_ci */ 5847c804472Sopenharmony_ci getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array<string>>): void; 5857c804472Sopenharmony_ci 5867c804472Sopenharmony_ci /** 5877c804472Sopenharmony_ci * Called to carry {@code AbilityInfo} to this ability after the ability is initialized. 5887c804472Sopenharmony_ci * 5897c804472Sopenharmony_ci * @param { AbilityInfo } info - Indicates the {@code AbilityInfo} object containing information about this ability. 5907c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 5917c804472Sopenharmony_ci * @FAModelOnly 5927c804472Sopenharmony_ci * @since 7 5937c804472Sopenharmony_ci */ 5947c804472Sopenharmony_ci onInitialized?(info: AbilityInfo): void; 5957c804472Sopenharmony_ci 5967c804472Sopenharmony_ci /** 5977c804472Sopenharmony_ci * Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be 5987c804472Sopenharmony_ci * implemented by a Data ability. 5997c804472Sopenharmony_ci * <p>Data abilities supports general data types, including text, HTML, and JPEG.</p> 6007c804472Sopenharmony_ci * 6017c804472Sopenharmony_ci * @param { string } uri - Indicates the uri of the data. 6027c804472Sopenharmony_ci * @param { AsyncCallback<string> } callback - function specified by framework to receive the result, developer should 6037c804472Sopenharmony_ci * call this function to return the result to framework. 6047c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 6057c804472Sopenharmony_ci * @FAModelOnly 6067c804472Sopenharmony_ci * @since 7 6077c804472Sopenharmony_ci */ 6087c804472Sopenharmony_ci getType?(uri: string, callback: AsyncCallback<string>): void; 6097c804472Sopenharmony_ci 6107c804472Sopenharmony_ci /** 6117c804472Sopenharmony_ci * Performs batch operations on the database. This method should be implemented by a Data ability. 6127c804472Sopenharmony_ci * 6137c804472Sopenharmony_ci * @param { Array<DataAbilityOperation> } ops - Indicates the data operation list, which can contain multiple operations 6147c804472Sopenharmony_ci * on the database. 6157c804472Sopenharmony_ci * @param { AsyncCallback<Array<DataAbilityResult>> } callback - specified by framework to receive the result, 6167c804472Sopenharmony_ci * developer should call this function to return 6177c804472Sopenharmony_ci * the result to framework. 6187c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 6197c804472Sopenharmony_ci * @FAModelOnly 6207c804472Sopenharmony_ci * @since 7 6217c804472Sopenharmony_ci */ 6227c804472Sopenharmony_ci executeBatch?(ops: Array<DataAbilityOperation>, callback: AsyncCallback<Array<DataAbilityResult>>): void; 6237c804472Sopenharmony_ci 6247c804472Sopenharmony_ci /** 6257c804472Sopenharmony_ci * Defines a method in this Data ability (implementation depending on child classes). 6267c804472Sopenharmony_ci * 6277c804472Sopenharmony_ci * @param { string } method - Indicates the method name. 6287c804472Sopenharmony_ci * @param { string } arg - Indicates the parameter transferred by the method. 6297c804472Sopenharmony_ci * @param { PacMap } extras - Indicates the parameter transferred by the method. 6307c804472Sopenharmony_ci * @param { AsyncCallback<PacMap> } callback - function specified by framework to receive the result, developer 6317c804472Sopenharmony_ci * should call this function to return the result to framework. 6327c804472Sopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 6337c804472Sopenharmony_ci * @FAModelOnly 6347c804472Sopenharmony_ci * @since 7 6357c804472Sopenharmony_ci */ 6367c804472Sopenharmony_ci call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback<PacMap>): void; 6377c804472Sopenharmony_ci} 638