1 /*
2 * Copyright (C) 2016 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 #pragma once
18 
19 #include <stdbool.h>
20 
21 #include "aemu/base/c_header.h"
22 
23 ANDROID_BEGIN_HEADER
24 
25 typedef enum {
26 #define FEATURE_CONTROL_ITEM(item, idx) kFeature_##item = idx,
27 #include "FeatureControlDefHost.h"
28 #include "FeatureControlDefGuest.h"
29 #undef FEATURE_CONTROL_ITEM
30     kFeature_unknown = -1,
31 } Feature;
32 
33 // Call this function first to initialize the feature control.
34 void feature_initialize();
35 
36 // Get the access rules given by |name| if they exist, otherwise returns NULL
37 bool feature_is_enabled(Feature feature);
38 bool feature_is_enabled_by_guest(Feature feature);
39 void feature_set_enabled_override(Feature feature, bool isEnabled);
40 void feature_reset_enabled_to_default(Feature feature);
41 
42 // Set the feature if it is not user-overriden.
43 void feature_set_if_not_overridden(Feature feature, bool enable);
44 
45 // Set the feature if it is not user-overriden or disabled from the guest.
46 void feature_set_if_not_overridden_or_guest_disabled(Feature feature, bool enable);
47 
48 // Runs applyCachedServerFeaturePatterns then
49 // asyncUpdateServerFeaturePatterns. See FeatureControl.h
50 // for more info. To be called only once on startup.
51 void feature_update_from_server();
52 
53 const char* feature_name(Feature feature);
54 Feature feature_from_name(const char* name);
55 
56 ANDROID_END_HEADER
57