diff --git a/api/@ohos.InputMethodExtensionAbility.d.ts b/api/@ohos.InputMethodExtensionAbility.d.ts index 26739d0d1609fca91a59f0c460890d425eb346f4..47cfd21d5d6d44f4a112cdf127830d287c1926c2 100644 --- a/api/@ohos.InputMethodExtensionAbility.d.ts +++ b/api/@ohos.InputMethodExtensionAbility.d.ts @@ -1,59 +1 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * @kit IMEKit - */ - -import Want from './@ohos.app.ability.Want'; -import type InputMethodExtensionContext from './@ohos.InputMethodExtensionContext'; - -/** - * The extension ability class of input method. - * - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly - * @since 9 - */ -export default class InputMethodExtensionAbility { - /** - * Indicates input method extension ability context. - * - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly - * @since 9 - */ - context: InputMethodExtensionContext; - - /** - * Called back when a input method extension is started for initialization. - * - * @param { Want } want - Indicates the want of created service extension. - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly - * @since 9 - */ - onCreate(want: Want): void; - - /** - * Called back before a input method extension is destroyed. - * - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly - * @since 9 - */ - onDestroy(): void; -} +fatal: path 'api/@ohos.InputMethodExtensionAbility.d.ts' does not exist in '35caeeadac2248109ec5d27737fbb0a73f272bcc' \ No newline at end of file diff --git a/api/@system.sensorHc.d.ts b/api/@system.sensorHc.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..eae6d87a6aaff8d723a42bd1d14ccfdd0b2d45fd --- /dev/null +++ b/api/@system.sensorHc.d.ts @@ -0,0 +1,940 @@ +/* + * 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. + */ + +/** + * @file + * @kit SensorServiceKit + */ + +/** + * @interface subscribeAccelerometerOptions + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#ACCELEROMETER + */ +export interface subscribeAccelerometerOptions { + + /** + * Execution frequency of the callback function for listening to acceleration sensor data. + * Available values are as follows: + * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. + * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. + * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. + * The default value is normal. + * + * @permission ohos.permission.ACCELEROMETER + * @type { string } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + interval: string; + + /** + * Called when the listening fails. + * + * @permission ohos.permission.ACCELEROMETER + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when acceleration sensor data changes. + * + * @permission ohos.permission.ACCELEROMETER + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + success: (data: AccelerometerResponse) => void; +} + +/** + * @interface LightResponse + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#LightResponse + */ +export interface LightResponse { + + /** + * Light intensity, in lux. + * + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + intensity: number; +} + +/** + * @interface CompassResponse + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#MagneticFieldResponse + */ +export interface CompassResponse { + + /** + * Direction of the device (in degrees). + * + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + direction: number; +} + +/** + * @interface ProximityResponse + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#ProximityResponse + */ +export interface ProximityResponse { + + /** + * Distance between a visible object and the device screen + * + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + distance: number; +} + +/** + * @interface DeviceOrientationResponse + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#OrientationResponse + */ +export interface DeviceOrientationResponse { + + /** + * alpha + * + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + alpha: number; + + /** + * gamma + * + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + gamma: number; + + /** + * beta + * + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + beta: number; +} + +/** + * @interface AccelerometerResponse + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#AccelerometerResponse + */ +export interface AccelerometerResponse { + + /** + * Y-coordinate + * + * @permission ohos.permission.ACCELEROMETER + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + y: number; + + /** + * Z-coordinate + * + * @permission ohos.permission.ACCELEROMETER + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + z: number; + + /** + * X-coordinate + * + * @permission ohos.permission.ACCELEROMETER + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + x: number; +} + +/** + * @interface SubscribeStepCounterOptions + * @permission ohos.permission.ACTIVITY_MOTION + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/SensorId#PEDOMETER + */ +export interface SubscribeStepCounterOptions { + + /** + * Called when step counter sensor data changes. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + success: (data: StepCounterResponse) => void; + + /** + * Called when the listening fails. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @interface GetOnBodyStateOptions + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION + */ +export interface GetOnBodyStateOptions { + + /** + * Called when the sensor wearing state is obtained + * + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + success: (data: OnBodyStateResponse) => void; + + /** + * Called when the execution is completed + * + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + complete?: () => void; + + /** + * Called when the sensor wearing state fails to be obtained + * + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @interface BarometerResponse + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#BarometerResponse + */ +export interface BarometerResponse { + + /** + * Pressure, in hpa. + * + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + pressure: number; +} + +/** + * @interface GyroscopeResponse + * @permission ohos.permission.GYROSCOPE + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#GyroscopeResponse + */ +export interface GyroscopeResponse { + + /** + * X-coordinate + * + * @permission ohos.permission.GYROSCOPE + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + x: number; + + /** + * Z-coordinate + * + * @permission ohos.permission.GYROSCOPE + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + z: number; + + /** + * Y-coordinate + * + * @permission ohos.permission.GYROSCOPE + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + y: number; +} + +/** + * @interface StepCounterResponse + * @permission ohos.permission.ACTIVITY_MOTION + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#PedometerResponse + */ +export interface StepCounterResponse { + + /** + * Number of steps counted. + * Each time the device restarts, the value is recalculated from 0 in phone, tablet. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + steps: number; +} + +/** + * @interface SubscribeGyroscopeOptions + * @permission ohos.permission.GYROSCOPE + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#GYROSCOPE + */ +export interface SubscribeGyroscopeOptions { + + /** + * Called when gyroscope sensor data changes. + * + * @permission ohos.permission.GYROSCOPE + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + success: (data: GyroscopeResponse) => void; + + /** + * Execution frequency of the callback function for listening to gyroscope sensor data. + * Available values are as follows: + * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. + * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. + * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. + * The default value is normal. + * + * @permission ohos.permission.GYROSCOPE + * @type { string } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + interval: string; + + /** + * Called when the listening fails. + * + * @permission ohos.permission.GYROSCOPE + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @interface SubscribeLightOptions + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#AMBIENT_LIGHT + */ +export interface SubscribeLightOptions { + + /** + * Called when ambient light sensor data changes. + * + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + success: (data: LightResponse) => void; + + /** + * Called when the listening fails. + * + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @interface SubscribeOnBodyStateOptions + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION + */ +export interface SubscribeOnBodyStateOptions { + + /** + * Called when the listening fails. + * + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the wearing status changes. + * + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + success: (data: OnBodyStateResponse) => void; +} + +/** + * @interface SubscribeHeartRateOptions + * @permission ohos.permission.READ_HEALTH_DATA + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#HEART_RATE + */ +export interface SubscribeHeartRateOptions { + + /** + * Called when the heart rate sensor data changes. + * + * @permission ohos.permission.READ_HEALTH_DATA + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + success: (data: HeartRateResponse) => void; + + /** + * Called when the listening fails + * + * @permission ohos.permission.READ_HEALTH_DATA + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @interface HeartRateResponse + * @permission ohos.permission.READ_HEALTH_DATA + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#HeartRateResponse + */ +export interface HeartRateResponse { + + /** + * Heart rate. + * 255 indicates an invalid value in lite wearable. + * + * @permission ohos.permission.READ_HEALTH_DATA + * @type { number } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + heartRate: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor + */ +export default class Sensor { + + /** + * Listens to changes of heart rate sensor data. + * If this API is called multiple times, the last call takes effect. + * + * @permission ohos.permission.READ_HEALTH_DATA + * @param { SubscribeHeartRateOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#HEART_RATE + */ + static subscribeHeartRate(options: SubscribeHeartRateOptions): void; + + /** + * Listens to gyroscope sensor data changes. + * If this API is called multiple times, the last call takes effect. + * + * @permission ohos.permission.GYROSCOPE + * @param { SubscribeGyroscopeOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#GYROSCOPE + */ + static subscribeGyroscope(options: SubscribeGyroscopeOptions): void; + + /** + * Listens to whether a sensor is worn. + * If this API is called multiple times, the last call takes effect. + * + * @param { SubscribeOnBodyStateOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION + */ + static subscribeOnBodyState(options: SubscribeOnBodyStateOptions): void; + + /** + * Cancels listening to compass sensor data. + * + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#MAGNETIC_FIELD + */ + static unsubscribeCompass(): void; + + /** + * Cancels listening to distance sensor data. + * + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#PROXIMITY + */ + static unsubscribeProximity(): void; + + /** + * Listens to device orientation sensor data changes. + * If this API is called multiple times, the last call takes effect. + * + * @param { SubscribeDeviceOrientationOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#ORIENTATION + */ + static subscribeDeviceOrientation(options: SubscribeDeviceOrientationOptions): void; + + /** + * Listens to ambient light sensor data changes. + * If this API is called multiple times, the last call takes effect. + * + * @param { SubscribeLightOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#AMBIENT_LIGHT + */ + static subscribeLight(options: SubscribeLightOptions): void; + + /** + * Cancels listening to step counter sensor data. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#PEDOMETER + */ + static unsubscribeStepCounter(): void; + + /** + * Obtains the sensor wearing state. + * + * @param { GetOnBodyStateOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION + */ + static getOnBodyState(options: GetOnBodyStateOptions): void; + + /** + * Cancels listening to device orientation sensor data. + * + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#ORIENTATION + */ + static unsubscribeDeviceOrientation(): void; + + /** + * Cancels listening to ambient light sensor data. + * + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#AMBIENT_LIGHT + */ + static unsubscribeLight(): void; + + /** + * Listens to barometer sensor data changes. + * If this API is called multiple times, the last call takes effect. + * + * @param { SubscribeBarometerOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#BAROMETER + */ + static subscribeBarometer(options: SubscribeBarometerOptions): void; + + /** + * Cancels listening to whether the sensor is worn. + * + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION + */ + static unsubscribeOnBodyState(): void; + + /** + * Listens to acceleration sensor data changes. + * If this API is called multiple times, the last call takes effect. + * + * @permission ohos.permission.ACCELEROMETER + * @param { subscribeAccelerometerOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#ACCELEROMETER + */ + static subscribeAccelerometer(options: subscribeAccelerometerOptions): void; + + /** + * Cancels listening to acceleration sensor data. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#ACCELEROMETER + */ + static unsubscribeAccelerometer(): void; + + /** + * Cancels listening to barometer sensor data. + * + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#BAROMETER + */ + static unsubscribeBarometer(): void; + + /** + * Listens to step counter sensor data changes. + * If this API is called multiple times, the last call takes effect. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @param { SubscribeStepCounterOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#PEDOMETER + */ + static subscribeStepCounter(options: SubscribeStepCounterOptions): void; + + /** + * Cancels listening to gyroscope sensor data. + * + * @permission ohos.permission.GYROSCOPE + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#GYROSCOPE + */ + static unsubscribeGyroscope(): void; + + /** + * Listens to compass sensor data changes. + * If this API is called multiple times, the last call takes effect. + * + * @param { SubscribeCompassOptions } options - Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#MAGNETIC_FIELD + */ + static subscribeCompass(options: SubscribeCompassOptions): void; + + /** + * Cancels listening to heart rate sensor data. + * + * @permission ohos.permission.READ_HEALTH_DATA + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#HEART_RATE + */ + static unsubscribeHeartRate(): void; + + /** + * Listens to distance sensor data changes. + * If this API is called multiple times, the last call takes effect. + * + * @param { SubscribeProximityOptions } options - options Options. + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#PROXIMITY + */ + static subscribeProximity(options: SubscribeProximityOptions): void; +} + +/** + * @interface OnBodyStateResponse + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor#WearDetectionResponse + */ +export interface OnBodyStateResponse { + + /** + * Whether the sensor is worn. + * + * @type { boolean } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + value: boolean; +} + +/** + * @interface SubscribeCompassOptions + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#MAGNETIC_FIELD + */ +export interface SubscribeCompassOptions { + + /** + * Called when compass sensor data changes. + * + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + success: (data: CompassResponse) => void; + + /** + * Called when the listening fails. + * + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @interface SubscribeProximityOptions + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#PROXIMITY + */ +export interface SubscribeProximityOptions { + + /** + * Called when the listening fails. + * + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when distance sensor data changes. + * + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + success: (data: ProximityResponse) => void; +} + +/** + * @interface SubscribeBarometerOptions + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#BAROMETER + */ +export interface SubscribeBarometerOptions { + + /** + * Called when the listening fails. + * + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the barometer sensor data changes. + * + * @type { function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 3 + * @deprecated since 8 + */ + success: (data: BarometerResponse) => void; +} + +/** + * @interface SubscribeDeviceOrientationOptions + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + * @useinstead ohos.sensor/sensor.SensorId#ORIENTATION + */ +export interface SubscribeDeviceOrientationOptions { + + /** + * Called when the listening fails. + * + * @type { ?function } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when device orientation sensor data changes. + * + * @type { function} + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + success: (data: DeviceOrientationResponse) => void; + + /** + * Execution frequency of the callback function for listening to device orientation sensor data. + * Available values are as follows: + * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. + * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. + * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. + * The default value is normal. + * + * @type { string } + * @syscap SystemCapability.Sensors.Sensor.Lite + * @since 6 + * @deprecated since 8 + */ + interval: string; +} \ No newline at end of file diff --git a/api/ability/dataAbilityHelperHc.d.ts b/api/ability/dataAbilityHelperHc.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..632f36f5f55be86e90f9c53bb031dbde7274fd1c --- /dev/null +++ b/api/ability/dataAbilityHelperHc.d.ts @@ -0,0 +1,524 @@ +/* + * Copyright (c) 2021-2023 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. + */ + +/** + * @file + * @kit AbilityKit + */ + +import { AsyncCallback } from '../@ohos.base'; +import { ResultSet } from '../data/rdb/resultSet'; +import { DataAbilityOperation } from './dataAbilityOperation'; +import { DataAbilityResult } from './dataAbilityResult'; +import dataAbility from '../@ohos.data.dataAbility'; +import rdb from '../@ohos.data.rdb'; + +/** + * DataAbilityHelper + * + * @interface DataAbilityHelper + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ +export interface DataAbilityHelper { + /** + * Opens a file in a specified remote path. + * + * @param { string } uri - Indicates the path of the file to open. + * @param { string } mode - Indicates the file open mode, which can be "r" for read-only access, "w" for write-only + * access (erasing whatever data is currently in the file), "wt" for write access that truncates + * any existing file, "wa" for write-only access to append to any existing data, "rw" for read + * and write access on any existing data, or "rwt" for read and write access that truncates any + * existing file. + * @param { AsyncCallback } callback - Indicates the callback when openfile success + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + openFile(uri: string, mode: string, callback: AsyncCallback): void; + + /** + * Opens a file in a specified remote path. + * + * @param { string } uri - Indicates the path of the file to open. + * @param { string } mode - Indicates the file open mode, which can be "r" for read-only access, "w" for write-only + * access (erasing whatever data is currently in the file), "wt" for write access that truncates + * any existing file, "wa" for write-only access to append to any existing data, "rw" for read and + * write access on any existing data, or "rwt" for read and write access that truncates any + * existing file. + * @returns { Promise } Returns the file descriptor. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + openFile(uri: string, mode: string): Promise; + + /** + * Registers an observer to observe data specified by the given uri. + * + * @param { 'dataChange' } type - dataChange. + * @param { string } uri - Indicates the path of the data to operate. + * @param { AsyncCallback } callback - Indicates the callback when dataChange. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + on(type: 'dataChange', uri: string, callback: AsyncCallback): void; + + /** + * Deregisters all observers used for monitoring data specified by the given uri. + * + * @param { 'dataChange' } type - dataChange. + * @param { string } uri - Indicates the path of the data to operate. + * @param { AsyncCallback } [callback] - Indicates the registered callback. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + off(type: 'dataChange', uri: string, callback?: AsyncCallback): void; + + /** + * Obtains the MIME type of the date specified by the given URI. + * + * @param { string } uri - Indicates the path of the data to operate. + * @param { AsyncCallback } callback - Indicates the callback method for obtaining the type of media resource, + * returning the media resource type that matches the uri pointing data. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + getType(uri: string, callback: AsyncCallback): void; + + /** + * Obtains the MIME type of the date specified by the given URI. + * + * @param { string } uri - Indicates the path of the data to operate. + * @returns { Promise } Returns the MIME type that matches the data specified by uri. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + getType(uri: string): Promise; + + /** + * Obtains the MIME types of files supported. + * + * @param { string } uri - Indicates the path of the files to obtain. + * @param { string } mimeTypeFilter - Indicates the MIME types of the files to obtain. + * @param { AsyncCallback> } callback - Indicates the callback method for obtaining media resource + * types, returning an array of matching media resource types. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void; + + /** + * Obtains the MIME types of files supported. + * + * @param { string } uri - Indicates the path of the files to obtain. + * @param { string } mimeTypeFilter - Indicates the MIME types of the files to obtain. + * @returns { Promise> } Returns the matched MIME types Array. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + getFileTypes(uri: string, mimeTypeFilter: string): Promise>; + + /** + * Converts the given uri that refers to the Data ability into a normalized uri. + * + * @param { string } uri - Indicates the uri object to normalize. + * @param { AsyncCallback } callback - Indicates the callback method for uri normalization, and if the data + * function supports uri normalization, returns the normalized uri object; + * Otherwise return null. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + normalizeUri(uri: string, callback: AsyncCallback): void; + + /** + * Converts the given uri that refers to the Data ability into a normalized uri. + * + * @param { string } uri - Indicates the uri object to normalize. + * @returns { Promise } Returns normalized uri object if Data ability supports URI normalization or null. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + normalizeUri(uri: string): Promise; + + /** + * Converts the given normalized uri generated by normalizeUri(uri) into a denormalized one. + * + * @param { string } uri - Indicates the uri object to normalize. + * @param { AsyncCallback } callback - Indicates the callback method of denormalization uri.If + * denormalization succeeds,the denormalization uri object is returned. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + denormalizeUri(uri: string, callback: AsyncCallback): void; + + /** + * Converts the given normalized uri generated by normalizeUri(uri) into a denormalized one. + * + * @param { string } uri - Indicates the uri object to normalize. + * @returns { Promise } Returns the denormalized uri object if the denormalization is successful. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + denormalizeUri(uri: string): Promise; + + /** + * Notifies the registered observers of a change to the data resource specified by uri. + * + * @param { string } uri - Indicates the path of the data to operate. + * @param { AsyncCallback } callback - callback method. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + notifyChange(uri: string, callback: AsyncCallback): void; + + /** + * Notifies the registered observers of a change to the data resource specified by uri. + * + * @param { string } uri - Indicates the path of the data to operate. + * @returns { Promise } The promise returned by the function. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + notifyChange(uri: string): Promise; + + /** + * Inserts a single data record into the database. + * + * @param { string } uri - Indicates the path of the data to insert. + * @param { rdb.ValuesBucket } valuesBucket - Indicates the data record to insert. If this parameter is null, a blank + * row will be inserted. + * @param { AsyncCallback } callback - Indicates the callback method for data insertion, returning the index + * of the inserted data record. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback): void; + + /** + * Inserts a single data record into the database. + * + * @param { string } uri - Indicates the path of the data to insert. + * @param { rdb.ValuesBucket } valuesBucket - Indicates the data record to insert. If this parameter is null, + * a blank row will be inserted. + * @returns { Promise } Returns the index of the inserted data record. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise; + + /** + * Inserts multiple data records into the database. + * + * @param { string } uri - Indicates the path of the data to batchInsert. + * @param { Array } valuesBuckets - Indicates the data records to insert. + * @param { AsyncCallback } callback - Callback method indicating batch data insertion, returning the number + * of inserted data records. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + batchInsert(uri: string, valuesBuckets: Array, callback: AsyncCallback): void; + + /** + * Inserts multiple data records into the database. + * + * @param { string } uri - Indicates the path of the data to batchInsert. + * @param { Array } valuesBuckets - Indicates the data records to insert. + * @returns { Promise } Returns the number of data records inserted. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + batchInsert(uri: string, valuesBuckets: Array): Promise; + + /** + * Deletes one or more data records from the database. + * + * @param { string } uri - Indicates the path of the data to delete. + * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. You should define the + * processing logic when this parameter is null. + * @param { AsyncCallback } callback - A callback method that indicates data deletion, returning the number of + * deleted data records. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + + /** + * Deletes one or more data records from the database. + * + * @param { string } uri - Indicates the path of the data to delete. + * @param { dataAbility.DataAbilityPredicates } [predicates] - Indicates filter criteria. You should define the + * processing logic when this parameter is null. + * @returns { Promise } Returns the number of data records deleted. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise; + + /** + * Deletes one or more data records from the database. + * + * @param { string } uri - Indicates the path of the data to delete. + * @param { AsyncCallback } callback - A callback method that indicates data deletion, returning + * the number of deleted data records. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + delete(uri: string, callback: AsyncCallback): void; + + /** + * Updates data records in the database. + * + * @param { string } uri - Indicates the path of data to update. + * @param { rdb.ValuesBucket } valuesBucket - Indicates the data to update. + * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. You should define the + * processing logic when this parameter is null. + * @param { AsyncCallback } callback - A callback method that indicates data updates, returning the number of + * updated data records. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + update( + uri: string, + valuesBucket: rdb.ValuesBucket, + predicates: dataAbility.DataAbilityPredicates, + callback: AsyncCallback + ): void; + + /** + * Updates data records in the database. + * + * @param { string } uri - Indicates the path of data to update. + * @param { rdb.ValuesBucket } valuesBucket - Indicates the data to update. + * @param { dataAbility.DataAbilityPredicates } [predicates] - Indicates filter criteria. You should define the + * processing logic when this parameter is null. + * @returns { Promise } Returns the number of data records updated. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + update(uri: string, valuesBucket: rdb.ValuesBucket, predicates?: dataAbility.DataAbilityPredicates): Promise; + + /** + * Updates data records in the database. + * + * @param { string } uri - Indicates the path of data to update. + * @param { rdb.ValuesBucket } valuesBucket - Indicates the data to update. + * @param { AsyncCallback } callback - A callback method that indicates data updates, returning the number of + * updated data records. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + update(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback): void; + + /** + * Queries data in the database. + * + * @param { string } uri - Indicates the path of data to query. + * @param { Array } columns - Indicates columns to query. If this parameter is null, all columns are queried. + * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. You should define the + * processing logic when this parameter is null. + * @param { AsyncCallback } callback - Indicates the callback method for data queries, returning the + * number of queried data records. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + query( + uri: string, + columns: Array, + predicates: dataAbility.DataAbilityPredicates, + callback: AsyncCallback + ): void; + + /** + * Queries data in the database. + * + * @param { string } uri - Indicates the path of data to query. + * @param { AsyncCallback } callback - Indicates the callback method for data queries, returning the + * number of queried data records. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + query(uri: string, callback: AsyncCallback): void; + + /** + * Queries data in the database. + * + * @param { string } uri - Indicates the path of data to query. + * @param { Array } columns - Indicates columns to query. If this parameter is null, all columns are queried. + * @param { AsyncCallback } callback - Indicates the callback method for data queries, returning the + * number of queried data records. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + query(uri: string, columns: Array, callback: AsyncCallback): void; + + /** + * Queries data in the database. + * + * @param { string } uri - Indicates the path of data to query. + * @param { dataAbility.DataAbilityPredicates } predicates - Indicates filter criteria. You should define the + * processing logic when this parameter is null. + * @param { AsyncCallback } callback - Indicates the callback method for data queries, returning the + * number of queried data records. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + query(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + + /** + * Queries data in the database. + * + * @param { string } uri - Indicates the path of data to query. + * @param { Array } [columns] - Indicates columns to query. If this parameter is null, all columns are queried. + * @param { dataAbility.DataAbilityPredicates } [predicates] - Indicates filter criteria. You should define the + * processing logic when this parameter is null. + * @returns { Promise } Returns the query result {@link ResultSet}. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + query(uri: string, columns?: Array, predicates?: dataAbility.DataAbilityPredicates): Promise; + + /** + * Calls the extended API of the DataAbility. This method uses a promise to return the result. + * + * @param { string } uri - URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" + * @param { string } method - Indicates the method to call. + * @param { string } arg - Indicates the parameter of the String type. + * @param { PacMap } extras - Indicates the parameter of the PacMap type. + * @param { AsyncCallback } callback - A callback method that indicates a data operation and returns the + * result of the operation. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCallback): void; + + /** + * Calls the extended API of the DataAbility. This method uses a promise to return the result. + * + * @param { string } uri - URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" + * @param { string } method - Indicates the method to call. + * @param { string } arg - Indicates the parameter of the String type. + * @param { PacMap } extras - Indicates the parameter of the PacMap type. + * @returns { Promise } Returns the query result {@link PacMap}. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + call(uri: string, method: string, arg: string, extras: PacMap): Promise; + + /** + * Queries data in the database. + * + * @param { string } uri - Indicates the path of data to query. + * @param { Array } operations - Indicates the data operation list, which can contain multiple + * operations on the database. + * @param { AsyncCallback> } callback - Callback method indicating batch operations, + * returning the result of each operation in the + * DataAbilityResult array. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + executeBatch( + uri: string, + operations: Array, + callback: AsyncCallback> + ): void; + + /** + * Queries data in the database. + * + * @param { string } uri - Indicates the path of data to query. + * @param { Array } operations - Indicates the data operation list, which can contain multiple + * operations on the database. + * @returns { Promise> } Returns the result of each operation, + * in array {@link DataAbilityResult}. + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + executeBatch(uri: string, operations: Array): Promise>; +} + +/** + * Defines a PacMap object for storing a series of values. + * + * @typedef PacMap + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ +/** + * Defines a PacMap object for storing a series of values. + * + * @typedef PacMap + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @since 11 + */ +export interface PacMap { + /** + * Indicates the parameter of the PacMap type. + * If a custom Sequenceable object is put in the PacMap object and will be transferred across processes, + * you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. + * If the PacMap object is to be transferred to a non-OHOS process, + * values of primitive types are supported, but not custom Sequenceable objects. + * + * @type { number | string | boolean | Array | null } + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + * @since 7 + */ + /** + * Indicates the parameter of the PacMap type. + * If a custom Sequenceable object is put in the PacMap object and will be transferred across processes, + * you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. + * If the PacMap object is to be transferred to a non-OHOS process, + * values of primitive types are supported, but not custom Sequenceable objects. + * + * @type { number | string | boolean | Array | null } + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @since 11 + */ + [key: string]: number | string | boolean | Array | null; +} \ No newline at end of file