1//@ts-nocheck 2/* 3 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16import Window from '@ohos.window'; 17import parameter from '@ohos.systemparameter'; 18import parameter from '@ohos.systemparameter'; 19import settings from '@ohos.settings'; 20 21export interface Rect { 22 left: number; 23 top: number; 24 width: number; 25 height: number; 26}; 27 28export type WindowType = 'status' | 'navigation' | 'volume'; 29 30export function getWindowName(windowType): WindowType { 31 switch (windowType) { 32 case Window.WindowType.TYPE_NAVIGATION_BAR: 33 return 'navigation'; 34 case Window.WindowType.TYPE_STATUS_BAR: 35 return 'status'; 36 case Window.WindowType.TYPE_VOLUME_OVERLAY: 37 return 'volume'; 38 } 39} 40 41export default class Constants { 42 static readonly URI_VAR: string = 'datashare:///com.ohos.settingsdata.DataAbility'; 43 static readonly KEY_BRIGHTNESS_STATUS = settings.display.SCREEN_BRIGHTNESS_STATUS; 44 static readonly KEY_TIME_FORMAT = settings.date.TIME_FORMAT; 45 static readonly KEY_NAVIGATIONBAR_STATUS = 'settings.display.navigationbar_status'; 46 static readonly KEY_AIRPLANE_MODE_STATUS = 'settings.telephony.airplanemode'; 47 48 /** 49 * 获取拼接后的uri,适配settingsdata去常驻 50 * 51 * @param key settings key 52 */ 53 static getUriSync(key: string): string { 54 return "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=" + key; 55 } 56} 57 58export enum FASlotName { 59 AUTO_ROTATE = 'auto_rotate', 60 AIR_PLANE = 'air_plane', 61 BATTERY = 'battery', 62 BLUETOOTH = 'bluetooth', 63 CAPSULE = 'capsule', 64 CLOCK = 'clock', 65 EMPTY = 'empty', 66 LOCATION = 'location', 67 NOTIFICATION = 'notification', 68 RING_MODE = 'ring_mode', 69 SIGNAL = 'signal', 70 WIFI = 'wifi', 71 NFC = 'nfc', 72} 73 74export function isNfcAvailable(){ 75 if (parameter.getSync("const.SystemCapability.Communication.NFC.Core", "false") == "false"){ 76 return false 77 } else { 78 return true 79 } 80 } 81