1/* 2 * Copyright (c) 2023 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, softwareEventsObj 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 */ 15import camera from '@ohos.multimedia.camera'; 16import context from '@ohos.app.ability.common'; 17import { BusinessError } from '@ohos.base'; 18import Logger from '../log/HiAdLog'; 19import common from '@ohos.app.ability.common'; 20 21const TAG = 'FullScreenAdPage'; 22 23@Entry 24@Component 25struct FullScreenAdPage { 26 @State message: string = 'FullScreenAdPage'; 27 private context = getContext(this) as context.UIAbilityContext; 28 29 aboutToAppear() { 30 Logger.i(TAG, '%{public}s', 'aboutToAppear'); 31 this.getCameraManager(this.context); 32 } 33 34 build() { 35 Row() { 36 Column() { 37 Text(this.message) 38 .fontSize(50) 39 .fontWeight(FontWeight.Bold) 40 } 41 .width('100%') 42 } 43 .height('100%') 44 } 45 46 private getCameraManager(context: common.Context): camera.CameraManager | undefined { 47 Logger.i(TAG, '%{public}s', 'getCameraManager'); 48 let cameraManager: camera.CameraManager | undefined = undefined; 49 try { 50 cameraManager = camera.getCameraManager(context); 51 } catch (error) { 52 let err = error as BusinessError; 53 console.error(`The getCameraManager call failed. error code: ${err.code}`); 54 } 55 return cameraManager; 56 } 57}