• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 package android.healthconnect.cts.utils;
17 
18 import android.content.Context;
19 import android.content.pm.PackageManager;
20 
21 import androidx.test.core.app.ApplicationProvider;
22 
23 /**
24  * Helper class to check if HealthConnect is supported on this device, to enable tests to be skipped
25  * if not.
26  */
27 public class DeviceSupportUtils {
28 
29     /** Returns true if HealthConnect is fully supported on this device. */
isHealthConnectFullySupported()30     public static boolean isHealthConnectFullySupported() {
31         return isHealthConnectFullySupported(ApplicationProvider.getApplicationContext());
32     }
33 
34     /** Returns true if HealthConnect is fully supported using information from this context. */
isHealthConnectFullySupported(Context context)35     public static boolean isHealthConnectFullySupported(Context context) {
36         PackageManager pm = context.getPackageManager();
37         return (!pm.hasSystemFeature(PackageManager.FEATURE_EMBEDDED)
38                 && !pm.hasSystemFeature(PackageManager.FEATURE_WATCH)
39                 && !pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
40                 && !pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE));
41     }
42 }
43