19b256929Sopenharmony_ci/* 29b256929Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 39b256929Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 49b256929Sopenharmony_ci * you may not use this file except in compliance with the License. 59b256929Sopenharmony_ci * You may obtain a copy of the License at 69b256929Sopenharmony_ci * 79b256929Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 89b256929Sopenharmony_ci * 99b256929Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 109b256929Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 119b256929Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 129b256929Sopenharmony_ci * See the License for the specific language governing permissions and 139b256929Sopenharmony_ci * limitations under the License. 149b256929Sopenharmony_ci */ 159b256929Sopenharmony_ciimport {Log} from './Log'; 169b256929Sopenharmony_ciimport {AbilityManager} from '../default/abilitymanager/abilityManager' 179b256929Sopenharmony_ci 189b256929Sopenharmony_ciconst TAG = 'ScreenLock-ScreenLockCommon'; 199b256929Sopenharmony_ciexport enum ScreenLockStatus { 209b256929Sopenharmony_ci Locking = 1, 219b256929Sopenharmony_ci Unlock = 2, 229b256929Sopenharmony_ci RecognizingFace = 3, 239b256929Sopenharmony_ci FaceNotRecognized = 4 249b256929Sopenharmony_ci} 259b256929Sopenharmony_ci 269b256929Sopenharmony_ciexport function ReadConfigFile(fileName, callBack:(data)=>void) { 279b256929Sopenharmony_ci Log.showInfo(TAG, `readConfigFile fileName:${fileName}`); 289b256929Sopenharmony_ci let jsonCfg : string = ""; 299b256929Sopenharmony_ci let context = AbilityManager.getContext(AbilityManager.ABILITY_NAME_SCREEN_LOCK); 309b256929Sopenharmony_ci Log.showInfo(TAG, `readConfigFile context:${context}`); 319b256929Sopenharmony_ci let resManager = context.resourceManager; 329b256929Sopenharmony_ci Log.showInfo(TAG, `readConfigFile resManager:${resManager}`); 339b256929Sopenharmony_ci resManager.getRawFile(fileName).then((data)=>{ 349b256929Sopenharmony_ci let content : string = String.fromCharCode.apply(null, data); 359b256929Sopenharmony_ci Log.showInfo(TAG, `readDefaultFile content length: ${content.length}`); 369b256929Sopenharmony_ci jsonCfg = JSON.parse(content); 379b256929Sopenharmony_ci callBack(jsonCfg); 389b256929Sopenharmony_ci }) 399b256929Sopenharmony_ci .catch((error)=>{ 409b256929Sopenharmony_ci Log.showError(TAG, `readDefaultFile filed: ${JSON.stringify(error)}`); 419b256929Sopenharmony_ci }); 429b256929Sopenharmony_ci}