1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import type { Callback } from '@ohos.base'; 17import { BusinessError } from '@ohos.base'; 18 19export default namespace sensor { 20 loadLibrary("sensor_ani"); 21 22 export native function on(type: 'orientationChange', callback: Callback<OrientationResponse>, options?: Options): void; 23 export native function off(type: 'orientationChange', callback?: Callback<OrientationResponse>): void; 24 export type SensorFrequency = 'game' | 'ui' | 'normal'; 25 export interface Options { 26 interval?: number | SensorFrequency; 27 } 28 29 export enum SensorAccuracy { 30 ACCURACY_UNRELIABLE = 0, 31 ACCURACY_LOW = 1, 32 ACCURACY_MEDIUM = 2, 33 ACCURACY_HIGH = 3 34 } 35 36 export interface Response { 37 timestamp: number; 38 accuracy: SensorAccuracy; 39 } 40 41 export interface OrientationResponse extends Response { 42 alpha: number; 43 beta: number; 44 gamma: number; 45 } 46 47 class OrientationResponseImpl implements OrientationResponse { 48 timestamp: number; 49 accuracy: SensorAccuracy; 50 alpha: number; 51 beta: number; 52 gamma: number; 53 } 54}