1 /*
2  * Copyright 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  *      https://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  */
18 
19 package com.android.healthconnect.controller.tests.utils.di
20 
21 import android.content.Context
22 import android.content.Intent
23 import androidx.fragment.app.FragmentActivity
24 import com.android.healthconnect.controller.utils.DeviceInfoUtils
25 
26 class FakeDeviceInfoUtils : DeviceInfoUtils {
27     private var sendFeedbackAvailable = false
28 
29     private var playStoreAvailable = false
30 
31     private var isHealthConnectAvailable = true
32 
33     private var isIntentHandlerAvailable = false
34 
35     var helpCenterInvoked = false
36     var backupAndRestoreHelpCenterInvoked = false
37 
resetnull38     fun reset() {
39         sendFeedbackAvailable = false
40         playStoreAvailable = false
41         isHealthConnectAvailable = true
42         helpCenterInvoked = false
43         backupAndRestoreHelpCenterInvoked = false
44     }
45 
setSendFeedbackAvailabilitynull46     fun setSendFeedbackAvailability(available: Boolean) {
47         sendFeedbackAvailable = available
48     }
49 
setPlayStoreAvailabilitynull50     fun setPlayStoreAvailability(available: Boolean) {
51         playStoreAvailable = available
52     }
53 
setHealthConnectAvailablenull54     fun setHealthConnectAvailable(isAvailable: Boolean) {
55         isHealthConnectAvailable = isAvailable
56     }
57 
setIntentHandlerAvailabilitynull58     fun setIntentHandlerAvailability(available: Boolean) {
59         isIntentHandlerAvailable = available
60     }
61 
isHealthConnectAvailablenull62     override fun isHealthConnectAvailable(context: Context): Boolean {
63         return isHealthConnectAvailable
64     }
65 
isSendFeedbackAvailablenull66     override fun isSendFeedbackAvailable(context: Context): Boolean {
67         return sendFeedbackAvailable
68     }
69 
isPlayStoreAvailablenull70     override fun isPlayStoreAvailable(context: Context): Boolean {
71         return playStoreAvailable
72     }
73 
openHCGetStartedLinknull74     override fun openHCGetStartedLink(activity: FragmentActivity) {
75         helpCenterInvoked = true
76     }
77 
openHCBackupAndRestoreLinknull78     override fun openHCBackupAndRestoreLink(activity: FragmentActivity) {
79         backupAndRestoreHelpCenterInvoked = true
80     }
81 
openSendFeedbackActivitynull82     override fun openSendFeedbackActivity(activity: FragmentActivity) {}
83 
isIntentHandlerAvailablenull84     override fun isIntentHandlerAvailable(context: Context, intent: Intent): Boolean {
85         return isIntentHandlerAvailable
86     }
87 
isOnWatchnull88     override fun isOnWatch(context: Context): Boolean {
89         return false
90     }
91 }
92