• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 <cstdint>
20 #include <functional>
21 #include <mutex>
22 #include <optional>
23 #include <string>
24 
25 namespace android {
26 // Manages flags for SurfaceFlinger, including default values, system properties, and Mendel
27 // experiment configuration values. Can be called from any thread.
28 class FlagManager {
29 private:
30     // Effectively making the constructor private, while allowing std::make_unique to work
31     struct ConstructorTag {};
32 
33 public:
34     static const FlagManager& getInstance();
35     static FlagManager& getMutableInstance();
36 
37     FlagManager(ConstructorTag);
38     virtual ~FlagManager();
39 
40     void markBootCompleted();
41     void dump(std::string& result) const;
42 
43     void setUnitTestMode();
44 
45     /// Debug sysprop flags ///
46     bool disable_sched_fifo_sf() const;
47     bool disable_sched_fifo_sf_binder() const;
48     bool disable_sched_fifo_sf_sched() const;
49     bool disable_sched_fifo_re() const;
50     bool disable_sched_fifo_composer() const;
51     bool disable_sched_fifo_composer_callback() const;
52 
53     /// Legacy server flags ///
54     bool test_flag() const;
55     bool use_adpf_cpu_hint() const;
56     bool use_skia_tracing() const;
57 
58     /// Trunk stable server (R/W) flags ///
59     bool adpf_gpu_sf() const;
60     bool adpf_native_session_manager() const;
61     bool adpf_use_fmq_channel() const;
62     bool adpf_use_fmq_channel_fixed() const;
63     bool correct_virtual_display_power_state() const;
64     bool graphite_renderengine_preview_rollout() const;
65     bool increase_missed_frame_jank_threshold() const;
66     bool monitor_buffer_fences() const;
67     bool refresh_rate_overlay_on_external_display() const;
68     bool vsync_predictor_recovery() const;
69 
70     /// Trunk stable readonly flags ///
71     /// IMPORTANT - please keep alphabetize to reduce merge conflicts
72     bool add_sf_skipped_frames_to_trace() const;
73     bool adpf_fmq_sf() const;
74     bool allow_n_vsyncs_in_targeter() const;
75     bool arr_setframerate_gte_enum() const;
76     bool begone_bright_hlg() const;
77     bool cache_when_source_crop_layer_only_moved() const;
78     bool commit_not_composited() const;
79     bool connected_display_hdr() const;
80     bool correct_dpi_with_display_size() const;
81     bool deprecate_frame_tracker() const;
82     bool deprecate_vsync_sf() const;
83     bool detached_mirror() const;
84     bool display_config_error_hal() const;
85     bool display_protected() const;
86     bool dont_skip_on_early_ro() const;
87     bool enable_fro_dependent_features() const;
88     bool enable_layer_command_batching() const;
89     bool enable_small_area_detection() const;
90     bool filter_frames_before_trace_starts() const;
91     bool flush_buffer_slots_to_uncache() const;
92     bool force_compile_graphite_renderengine() const;
93     bool fp16_client_target() const;
94     bool frame_rate_category_mrr() const;
95     bool game_default_frame_rate() const;
96     bool graphite_renderengine() const;
97     bool hdcp_level_hal() const;
98     bool hdcp_negotiation() const;
99     bool idle_screen_refresh_rate_timeout() const;
100     bool latch_unsignaled_with_auto_refresh_changed() const;
101     bool local_tonemap_screenshots() const;
102     bool luts_api() const;
103     bool misc1() const;
104     bool no_vsyncs_on_screen_off() const;
105     bool override_trusted_overlay() const;
106     bool protected_if_client() const;
107     bool reject_dupe_layerstacks() const;
108     bool renderable_buffer_usage() const;
109     bool restore_blur_step() const;
110     bool skip_invisible_windows_in_input() const;
111     bool stable_edid_ids() const;
112     bool synced_resolution_switch() const;
113     bool trace_frame_rate_override() const;
114     bool true_hdr_screenshots() const;
115     bool use_known_refresh_rate_for_fps_consistency() const;
116     bool vrr_bugfix_24q4() const;
117     bool vrr_bugfix_dropped_frame() const;
118     bool vrr_config() const;
119     bool vulkan_renderengine() const;
120     bool window_blur_kawase2() const;
121     /// IMPORTANT - please keep alphabetize to reduce merge conflicts
122 
123 protected:
124     // overridden for unit tests
125     virtual std::optional<bool> getBoolProperty(const char*) const;
126     virtual bool getServerConfigurableFlag(const char*) const;
127 
128 private:
129     friend class TestableFlagManager;
130 
131     FlagManager(const FlagManager&) = delete;
132 
133     void dumpFlag(std::string& result, bool readonly, const char* name,
134                   std::function<bool()> getter) const;
135 
136     std::atomic_bool mBootCompleted = false;
137     std::atomic_bool mUnitTestMode = false;
138 
139     static std::unique_ptr<FlagManager> mInstance;
140     static std::once_flag mOnce;
141 };
142 } // namespace android
143