1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 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 */ 16 17 package androidx.camera.integration.antelope 18 19 import androidx.lifecycle.MutableLiveData 20 import androidx.lifecycle.ViewModel 21 22 /** 23 * ViewModel for keeping track of application state across resizes and configuration changes. This 24 * includes: 25 */ 26 class CamViewModel : ViewModel() { 27 private var cameraParams: HashMap<String, CameraParams> = HashMap<String, CameraParams>() <lambda>null28 private val currentAPI = MutableLiveData<CameraAPI>().apply { value = CameraAPI.CAMERA2 } <lambda>null29 private val currentCamera = MutableLiveData<Int>().apply { value = 0 } <lambda>null30 private val currentFocusMode = MutableLiveData<FocusMode>().apply { value = FocusMode.AUTO } 31 private val currentImageCaptureSize = <lambda>null32 MutableLiveData<ImageCaptureSize>().apply { value = ImageCaptureSize.MAX } <lambda>null33 private val shouldOutputLog = MutableLiveData<Boolean>().apply { value = false } 34 private val humanReadableReport = <lambda>null35 MutableLiveData<String>().apply { value = "Android Camera Performance Tool" } 36 37 /** Camera API of the current test */ getCurrentAPInull38 fun getCurrentAPI(): MutableLiveData<CameraAPI> { 39 return currentAPI 40 } 41 42 /** Camera ID of the current test */ getCurrentCameranull43 fun getCurrentCamera(): MutableLiveData<Int> { 44 return currentCamera 45 } 46 47 /** Focus mode of the current test */ getCurrentFocusModenull48 fun getCurrentFocusMode(): MutableLiveData<FocusMode> { 49 return currentFocusMode 50 } 51 52 /** Requested image capture size of the current test */ getCurrentImageCaptureSizenull53 fun getCurrentImageCaptureSize(): MutableLiveData<ImageCaptureSize> { 54 return currentImageCaptureSize 55 } 56 57 /** Hashmap of the CameraParams associated with all the cameras on the device */ getCameraParamsnull58 fun getCameraParams(): HashMap<String, CameraParams> { 59 return cameraParams 60 } 61 62 /** If the user has asked to output the debugging log */ getShouldOutputLognull63 fun getShouldOutputLog(): MutableLiveData<Boolean> { 64 return shouldOutputLog 65 } 66 67 /** Current value of the main output window on screen */ getHumanReadableReportnull68 fun getHumanReadableReport(): MutableLiveData<String> { 69 return humanReadableReport 70 } 71 } 72