1 /* 2 * Copyright 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 17 #include <input/InputFlags.h> 18 19 #include <android-base/logging.h> 20 #include <com_android_input_flags.h> 21 #include <com_android_window_flags.h> 22 #include <cutils/properties.h> 23 24 #include <string> 25 26 namespace android { 27 connectedDisplaysCursorEnabled()28bool InputFlags::connectedDisplaysCursorEnabled() { 29 if (!com::android::window::flags::enable_desktop_mode_through_dev_option()) { 30 return com::android::input::flags::connected_displays_cursor(); 31 } 32 static std::optional<bool> cachedDevOption; 33 if (!cachedDevOption.has_value()) { 34 char value[PROPERTY_VALUE_MAX]; 35 constexpr static auto sysprop_name = "persist.wm.debug.desktop_experience_devopts"; 36 const int devOptionEnabled = 37 property_get(sysprop_name, value, nullptr) > 0 ? std::atoi(value) : 0; 38 cachedDevOption = devOptionEnabled == 1; 39 } 40 if (cachedDevOption.value_or(false)) { 41 return true; 42 } 43 return com::android::input::flags::connected_displays_cursor(); 44 } 45 connectedDisplaysCursorAndAssociatedDisplayCursorBugfixEnabled()46bool InputFlags::connectedDisplaysCursorAndAssociatedDisplayCursorBugfixEnabled() { 47 return connectedDisplaysCursorEnabled() && 48 com::android::input::flags::connected_displays_associated_display_cursor_bugfix(); 49 } 50 51 } // namespace android