1/* 2 * Copyright (c) 2022 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 Ability from '@ohos.application.Ability' 17import Logger from '../data/Logger' 18import { dmsConst } from '../data/DmsConst' 19 20const TAG: string = 'MainAbility' 21 22export default class MainAbility extends Ability { 23 async onCreate(want, launchParam) { 24 Logger.info(TAG, `[Demo] MainAbility onCreate`) 25 await this.context.requestPermissionsFromUser([dmsConst.PERMISSION_NAME]) 26 let isFA = want.parameters.isFA 27 let deviceId = want.deviceId 28 Logger.info(`isFA =${isFA}, deviceId=${deviceId}`) 29 if(isFA){ 30 AppStorage.SetOrCreate('isFA', isFA) 31 } 32 if(deviceId){ 33 AppStorage.SetOrCreate('deviceId', deviceId) 34 } 35 } 36 37 onDestroy() { 38 Logger.info(TAG, `[Demo] MainAbility onDestroy`) 39 } 40 41 onWindowStageCreate(windowStage) { 42 Logger.info(TAG, `[Demo] MainAbility onWindowStageCreate`) 43 windowStage.setUIContent(this.context, 'pages/Index', null) 44 } 45 46 onWindowStageDestroy() { 47 Logger.info(TAG, `[Demo] MainAbility onWindowStageDestroy`) 48 } 49 50 onForeground() { 51 Logger.info(TAG, `[Demo] MainAbility onForeground`) 52 } 53 54 onBackground() { 55 Logger.info(TAG, `[Demo] MainAbility onBackground`) 56 } 57} 58