• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "feature_control.h"
18 
19 #include <vector>
20 
21 struct FeatureState {
FeatureStateFeatureState22     FeatureState() {
23         enabled.resize(1024, 0);
24     }
25     std::vector<bool> enabled;
26 };
27 
28 static FeatureState sFeatureState;
29 
30 // Call this function first to initialize the feature control.
feature_initialize()31 void feature_initialize() { }
32 
33 // Get the access rules given by |name| if they exist, otherwise returns NULL
feature_is_enabled(Feature feature)34 bool feature_is_enabled(Feature feature) {
35     return sFeatureState.enabled[feature];
36 }
37 
feature_set_enabled_override(Feature feature,bool isEnabled)38 void feature_set_enabled_override(Feature feature, bool isEnabled) {
39     sFeatureState.enabled[feature] = isEnabled;
40 }
41 
feature_reset_enabled_to_default(Feature feature)42 void feature_reset_enabled_to_default(Feature feature) {
43     sFeatureState.enabled[feature] = false;
44 }
45 
46 // Set the feature if it is not user-overriden.
feature_set_if_not_overridden(Feature feature,bool enable)47 void feature_set_if_not_overridden(Feature feature, bool enable) {
48     sFeatureState.enabled[feature] = enable;
49 }
50 
51 // Set the feature if it is not user-overriden or disabled from the guest.
feature_set_if_not_overridden_or_guest_disabled(Feature feature,bool enable)52 void feature_set_if_not_overridden_or_guest_disabled(Feature feature, bool enable) {
53     sFeatureState.enabled[feature] = enable;
54 }
55 
56 // Runs applyCachedServerFeaturePatterns then
57 // asyncUpdateServerFeaturePatterns. See FeatureControl.h
58 // for more info. To be called only once on startup.
feature_update_from_server()59 void feature_update_from_server() { }
60