• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.systemui.classifier;
18 
19 import android.content.res.Resources;
20 import android.view.ViewConfiguration;
21 
22 import com.android.systemui.R;
23 import com.android.systemui.dagger.SysUISingleton;
24 import com.android.systemui.dagger.qualifiers.Main;
25 import com.android.systemui.statusbar.phone.NotificationTapHelper;
26 
27 import java.util.Arrays;
28 import java.util.HashSet;
29 import java.util.Set;
30 
31 import javax.inject.Named;
32 
33 import dagger.Binds;
34 import dagger.Module;
35 import dagger.Provides;
36 import dagger.multibindings.ElementsIntoSet;
37 
38 /** Dagger Module for Falsing. */
39 @Module
40 public interface FalsingModule {
41     String BRIGHT_LINE_GESTURE_CLASSIFERS = "bright_line_gesture_classifiers";
42     String SINGLE_TAP_TOUCH_SLOP = "falsing_single_tap_touch_slop";
43     String DOUBLE_TAP_TOUCH_SLOP = "falsing_double_tap_touch_slop";
44     String DOUBLE_TAP_TIMEOUT_MS = "falsing_double_tap_timeout_ms";
45 
46     /** */
47     @Binds
48     @SysUISingleton
bindsFalsingCollector(FalsingCollectorImpl impl)49     FalsingCollector bindsFalsingCollector(FalsingCollectorImpl impl);
50 
51     /** */
52     @Provides
53     @ElementsIntoSet
54     @Named(BRIGHT_LINE_GESTURE_CLASSIFERS)
providesBrightLineGestureClassifiers( DistanceClassifier distanceClassifier, ProximityClassifier proximityClassifier, PointerCountClassifier pointerCountClassifier, TypeClassifier typeClassifier, DiagonalClassifier diagonalClassifier, ZigZagClassifier zigZagClassifier)55     static Set<FalsingClassifier> providesBrightLineGestureClassifiers(
56             DistanceClassifier distanceClassifier, ProximityClassifier proximityClassifier,
57             PointerCountClassifier pointerCountClassifier, TypeClassifier typeClassifier,
58             DiagonalClassifier diagonalClassifier, ZigZagClassifier zigZagClassifier) {
59         return new HashSet<>(Arrays.asList(
60                 pointerCountClassifier, typeClassifier, diagonalClassifier, distanceClassifier,
61                 proximityClassifier, zigZagClassifier));
62     }
63 
64     /** */
65     @Provides
66     @Named(DOUBLE_TAP_TIMEOUT_MS)
providesDoubleTapTimeoutMs()67     static long providesDoubleTapTimeoutMs() {
68         return NotificationTapHelper.DOUBLE_TAP_TIMEOUT_MS;
69     }
70 
71     /** */
72     @Provides
73     @Named(DOUBLE_TAP_TOUCH_SLOP)
providesDoubleTapTouchSlop(@ain Resources resources)74     static float providesDoubleTapTouchSlop(@Main Resources resources) {
75         return resources.getDimension(R.dimen.double_tap_slop);
76     }
77 
78     /** */
79     @Provides
80     @Named(SINGLE_TAP_TOUCH_SLOP)
providesSingleTapTouchSlop(ViewConfiguration viewConfiguration)81     static float providesSingleTapTouchSlop(ViewConfiguration viewConfiguration) {
82         return viewConfiguration.getScaledTouchSlop();
83     }
84 }
85