1 /*
2  * Copyright 2022 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.diagnose
18 
19 import android.content.Context
20 import android.os.Build
21 import androidx.camera.view.LifecycleCameraController
22 
23 /**
24  * Diagnosis task that collect basic device information
25  *
26  * TODO: unit tests for this task (have only tested in end-to-end)
27  */
28 class CollectDeviceInfoTask : DiagnosisTask("CollectDeviceInfoTask") {
29 
30     /** Collect device information into a text file */
31     @Override
runDiagnosisTasknull32     override suspend fun runDiagnosisTask(
33         cameraController: LifecycleCameraController,
34         dataStore: DataStore,
35         context: Context
36     ) {
37         // write file/section header
38         dataStore.appendTitle(this.getTaskName())
39 
40         dataStore.appendText("Manufacturer: ${Build.MANUFACTURER}")
41         dataStore.appendText("Model: ${Build.MODEL}")
42         dataStore.appendText("Device: ${Build.DEVICE}")
43         dataStore.appendText("Version code name: ${Build.VERSION.CODENAME}")
44         dataStore.appendText("Version SDK: ${Build.VERSION.SDK_INT}")
45         dataStore.appendText("Fingerprint: ${Build.FINGERPRINT}")
46     }
47 }
48