blob: edbfc423754778663f910aad5d2ed648ef75fbf3 [file] [log] [blame]
Jared Duke2d1a8322024-08-23 22:17:09 +00001// This file is auto-generated. DO NOT MODIFY.
2// Args: com.android.systemfeatures.RoFeatures \
3// --readonly=true \
4// --feature=WATCH:1 \
5// --feature=WIFI:0 \
Jared Duke90e43632024-09-20 17:05:02 +00006// --feature=VULKAN:UNAVAILABLE \
Jared Duke2d1a8322024-08-23 22:17:09 +00007// --feature=AUTO: \
8// --feature-apis=WATCH,PC
9package com.android.systemfeatures;
10
Jared Duke568adec2024-09-20 21:11:17 +000011import android.annotation.NonNull;
Jared Duke2d1a8322024-08-23 22:17:09 +000012import android.annotation.Nullable;
13import android.content.Context;
Jared Duke568adec2024-09-20 21:11:17 +000014import android.content.pm.FeatureInfo;
Jared Duke2d1a8322024-08-23 22:17:09 +000015import android.content.pm.PackageManager;
16import com.android.aconfig.annotations.AssumeFalseForR8;
17import com.android.aconfig.annotations.AssumeTrueForR8;
Jared Duke568adec2024-09-20 21:11:17 +000018import java.util.HashMap;
19import java.util.Map;
Jared Duke2d1a8322024-08-23 22:17:09 +000020
21/**
22 * @hide
23 */
24public final class RoFeatures {
25 /**
26 * Check for FEATURE_WATCH.
27 *
28 * @hide
29 */
30 @AssumeTrueForR8
31 public static boolean hasFeatureWatch(Context context) {
32 return true;
33 }
34
35 /**
36 * Check for FEATURE_PC.
37 *
38 * @hide
39 */
40 public static boolean hasFeaturePc(Context context) {
41 return hasFeatureFallback(context, PackageManager.FEATURE_PC);
42 }
43
44 /**
45 * Check for FEATURE_WIFI.
46 *
47 * @hide
48 */
49 @AssumeTrueForR8
50 public static boolean hasFeatureWifi(Context context) {
51 return true;
52 }
53
54 /**
55 * Check for FEATURE_VULKAN.
56 *
57 * @hide
58 */
59 @AssumeFalseForR8
60 public static boolean hasFeatureVulkan(Context context) {
61 return false;
62 }
63
64 /**
65 * Check for FEATURE_AUTO.
66 *
67 * @hide
68 */
Jared Duke2d1a8322024-08-23 22:17:09 +000069 public static boolean hasFeatureAuto(Context context) {
Jared Duke90e43632024-09-20 17:05:02 +000070 return hasFeatureFallback(context, PackageManager.FEATURE_AUTO);
Jared Duke2d1a8322024-08-23 22:17:09 +000071 }
72
73 private static boolean hasFeatureFallback(Context context, String featureName) {
74 return context.getPackageManager().hasSystemFeature(featureName, 0);
75 }
76
77 /**
78 * @hide
79 */
80 @Nullable
81 public static Boolean maybeHasFeature(String featureName, int version) {
82 switch (featureName) {
83 case PackageManager.FEATURE_WATCH: return 1 >= version;
84 case PackageManager.FEATURE_WIFI: return 0 >= version;
Jared Duke90e43632024-09-20 17:05:02 +000085 case PackageManager.FEATURE_VULKAN: return false;
Jared Duke2d1a8322024-08-23 22:17:09 +000086 default: break;
87 }
88 return null;
89 }
Jared Duke568adec2024-09-20 21:11:17 +000090
91 /**
92 * Gets features marked as available at compile-time, keyed by name.
93 *
94 * @hide
95 */
96 @NonNull
97 public static Map<String, FeatureInfo> getCompileTimeAvailableFeatures() {
98 Map<String, FeatureInfo> features = new HashMap<>(2);
99 FeatureInfo fi = new FeatureInfo();
100 fi.name = PackageManager.FEATURE_WATCH;
101 fi.version = 1;
102 features.put(fi.name, new FeatureInfo(fi));
103 fi.name = PackageManager.FEATURE_WIFI;
104 fi.version = 0;
105 features.put(fi.name, new FeatureInfo(fi));
106 return features;
107 }
Jared Duke2d1a8322024-08-23 22:17:09 +0000108}