• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 package com.android.quickstep
18 
19 import com.android.quickstep.util.DeviceConfigHelper
20 import com.android.quickstep.util.DeviceConfigHelper.PropReader
21 import java.io.PrintWriter
22 
23 /** Various configurations specific to nav-bar functionalities */
24 class DeviceConfigWrapper private constructor(propReader: PropReader) {
25 
26     val customLpnhThresholds =
27         propReader.get(
28             "CUSTOM_LPNH_THRESHOLDS",
29             true,
30             "Add dev options and server side control to customize the LPNH trigger slop and milliseconds"
31         )
32 
33     val customLphThresholds =
34         propReader.get(
35             "CUSTOM_LPH_THRESHOLDS",
36             true,
37             "Server side control to customize LPH timeout and touch slop"
38         )
39 
40     val customLpaaThresholds =
41         propReader.get(
42             "CUSTOM_LPAA_THRESHOLDS",
43             false,
44             "Server side control to customize LPAA timeout and touch slop"
45         )
46 
47     val overrideLpnhLphThresholds =
48         propReader.get(
49             "OVERRIDE_LPNH_LPH_THRESHOLDS",
50             false,
51             "Enable AGSA override for LPNH and LPH timeout and touch slop"
52         )
53 
54     val lpnhTimeoutMs =
55         propReader.get("LPNH_TIMEOUT_MS", 450, "Controls lpnh timeout in milliseconds")
56 
57     val lpnhSlopPercentage =
58         propReader.get("LPNH_SLOP_PERCENTAGE", 100, "Controls touch slop percentage for lpnh")
59 
60     val enableLpnhTwoStages =
61         propReader.get(
62             "ENABLE_LPNH_TWO_STAGES",
63             false,
64             "Enable two stage for LPNH duration and touch slop"
65         )
66 
67     val twoStageMultiplier =
68         propReader.get(
69             "TWO_STAGE_MULTIPLIER",
70             2,
71             "Extends the duration and touch slop if the initial slop is passed"
72         )
73 
74     val animateLpnh = propReader.get("ANIMATE_LPNH", false, "Animates navbar when long pressing")
75 
76     val shrinkNavHandleOnPress =
77         propReader.get(
78             "SHRINK_NAV_HANDLE_ON_PRESS",
79             false,
80             "Shrinks navbar when long pressing if ANIMATE_LPNH is enabled"
81         )
82 
83     val enableLongPressNavHandle =
84         propReader.get(
85             "ENABLE_LONG_PRESS_NAV_HANDLE",
86             true,
87             "Enables long pressing on the bottom bar nav handle to trigger events."
88         )
89 
90     val enableSearchHapticHint =
91         propReader.get(
92             "ENABLE_SEARCH_HAPTIC_HINT",
93             true,
94             "Enables haptic hint while long pressing on the bottom bar nav handle."
95         )
96 
97     val enableSearchHapticCommit =
98         propReader.get(
99             "ENABLE_SEARCH_HAPTIC_COMMIT",
100             true,
101             "Enables haptic hint at end of long pressing on the bottom bar nav handle."
102         )
103 
104     val lpnhHapticHintStartScalePercent =
105         propReader.get("LPNH_HAPTIC_HINT_START_SCALE_PERCENT", 0, "Haptic hint start scale.")
106 
107     val lpnhHapticHintEndScalePercent =
108         propReader.get("LPNH_HAPTIC_HINT_END_SCALE_PERCENT", 100, "Haptic hint end scale.")
109 
110     val lpnhHapticHintScaleExponent =
111         propReader.get("LPNH_HAPTIC_HINT_SCALE_EXPONENT", 1, "Haptic hint scale exponent.")
112 
113     val lpnhHapticHintIterations =
114         propReader.get("LPNH_HAPTIC_HINT_ITERATIONS", 50, "Haptic hint number of iterations.")
115 
116     val enableLpnhDeepPress =
117         propReader.get(
118             "ENABLE_LPNH_DEEP_PRESS",
119             true,
120             "Long press of nav handle is instantly triggered if deep press is detected."
121         )
122 
123     val lpnhHapticHintDelay =
124         propReader.get("LPNH_HAPTIC_HINT_DELAY", 0, "Delay before haptic hint starts.")
125 
126     val lpnhExtraTouchWidthDp =
127         propReader.get(
128             "LPNH_EXTRA_TOUCH_WIDTH_DP",
129             0,
130             "Controls extra dp on the nav bar sides to trigger LPNH. Can be negative for a smaller touch region."
131         )
132 
133     val allAppsOverviewThreshold =
134         propReader.get(
135             "ALL_APPS_OVERVIEW_THRESHOLD",
136             180,
137             "Threshold to open All Apps from Overview"
138         )
139 
140     /** Dump config values. */
dumpnull141     fun dump(prefix: String, writer: PrintWriter) {
142         writer.println("$prefix DeviceConfigWrapper:")
143         writer.println("$prefix\tcustomLpnhThresholds=$customLpnhThresholds")
144         writer.println("$prefix\tcustomLphThresholds=$customLphThresholds")
145         writer.println("$prefix\toverrideLpnhLphThresholds=$overrideLpnhLphThresholds")
146         writer.println("$prefix\tlpnhSlopPercentage=$lpnhSlopPercentage")
147         writer.println("$prefix\tanimateLpnh=$animateLpnh")
148         writer.println("$prefix\tshrinkNavHandleOnPress=$shrinkNavHandleOnPress")
149         writer.println("$prefix\tlpnhTimeoutMs=$lpnhTimeoutMs")
150         writer.println("$prefix\tenableLongPressNavHandle=$enableLongPressNavHandle")
151         writer.println("$prefix\tenableSearchHapticHint=$enableSearchHapticHint")
152         writer.println("$prefix\tenableSearchHapticCommit=$enableSearchHapticCommit")
153         writer.println("$prefix\tlpnhHapticHintStartScalePercent=$lpnhHapticHintStartScalePercent")
154         writer.println("$prefix\tlpnhHapticHintEndScalePercent=$lpnhHapticHintEndScalePercent")
155         writer.println("$prefix\tlpnhHapticHintScaleExponent=$lpnhHapticHintScaleExponent")
156         writer.println("$prefix\tlpnhHapticHintIterations=$lpnhHapticHintIterations")
157         writer.println("$prefix\tenableLpnhDeepPress=$enableLpnhDeepPress")
158         writer.println("$prefix\tlpnhHapticHintDelay=$lpnhHapticHintDelay")
159         writer.println("$prefix\tlpnhExtraTouchWidthDp=$lpnhExtraTouchWidthDp")
160         writer.println("$prefix\tallAppsOverviewThreshold=$allAppsOverviewThreshold")
161     }
162 
163     companion object {
<lambda>null164         @JvmStatic val configHelper by lazy { DeviceConfigHelper(::DeviceConfigWrapper) }
165 
getnull166         @JvmStatic fun get() = configHelper.config
167     }
168 }
169