1 /*
2  * Copyright (C) 2024 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 com.android.settings.biometrics.fingerprint2.data.repository
18 
19 import android.os.Build
20 
21 /** Indicates if the developer has debugging features enabled. */
22 interface DebuggingRepository {
23 
24   /** A function that will return if a build is debuggable */
isDebuggingEnablednull25   fun isDebuggingEnabled(): Boolean
26 
27   /** A function that will return if udfps enrollment should be swapped with debug repos */
28   fun isUdfpsEnrollmentDebuggingEnabled(): Boolean
29 }
30 
31 class DebuggingRepositoryImpl : DebuggingRepository {
32   /**
33    * This flag can be flipped by the engineer which should allow for certain debugging features to
34    * be enabled.
35    */
36   private val isBuildDebuggable = Build.IS_DEBUGGABLE
37   /** This flag indicates if udfps should use debug repos to supply data to its various views. */
38   private val udfpsEnrollmentDebugEnabled = false
39 
40   override fun isDebuggingEnabled(): Boolean {
41     return isBuildDebuggable
42   }
43 
44   override fun isUdfpsEnrollmentDebuggingEnabled(): Boolean {
45     return isDebuggingEnabled() && udfpsEnrollmentDebugEnabled
46   }
47 }
48