blob: 9438cbb6ebcdf73205e40efa51a8214e007c8ac4 [file] [log] [blame]
Adrian Roosd35d4ca2017-04-19 14:31:03 -07001/*
2 * Copyright (C) 2017 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
17package com.android.systemui.doze;
18
Issei Suzukica19e6e2019-02-26 12:39:11 +010019import android.hardware.display.AmbientDisplayConfiguration;
20
Adrian Roosd35d4ca2017-04-19 14:31:03 -070021import static org.mockito.ArgumentMatchers.anyInt;
22import static org.mockito.Mockito.mock;
23import static org.mockito.Mockito.when;
24import static org.mockito.Mockito.withSettings;
25
Adrian Roosd35d4ca2017-04-19 14:31:03 -070026import com.android.systemui.statusbar.phone.DozeParameters;
27
28import org.mockito.Answers;
29import org.mockito.MockSettings;
30
31public class DozeConfigurationUtil {
32 public static DozeParameters createMockParameters() {
33 boolean[] doneHolder = new boolean[1];
34 DozeParameters params = mock(DozeParameters.class, noDefaultAnswer(doneHolder));
35
36 when(params.getPulseOnSigMotion()).thenReturn(false);
Adrian Roosd35d4ca2017-04-19 14:31:03 -070037 when(params.getPickupVibrationThreshold()).thenReturn(0);
38 when(params.getProxCheckBeforePulse()).thenReturn(true);
39 when(params.getPickupSubtypePerformsProxCheck(anyInt())).thenReturn(true);
lpeter8a5f4702019-01-18 16:53:07 +080040 when(params.getPolicy()).thenReturn(mock(AlwaysOnDisplayPolicy.class));
41 when(params.doubleTapReportsTouchCoordinates()).thenReturn(false);
Adrian Roosd35d4ca2017-04-19 14:31:03 -070042
43 doneHolder[0] = true;
44 return params;
45 }
46
47 public static AmbientDisplayConfiguration createMockConfig() {
48 boolean[] doneHolder = new boolean[1];
49 AmbientDisplayConfiguration config = mock(AmbientDisplayConfiguration.class,
50 noDefaultAnswer(doneHolder));
Lucas Dupin4359b552018-08-09 15:07:54 -070051 when(config.doubleTapGestureEnabled(anyInt())).thenReturn(false);
52 when(config.pickupGestureEnabled(anyInt())).thenReturn(false);
Adrian Roosd35d4ca2017-04-19 14:31:03 -070053 when(config.pulseOnNotificationEnabled(anyInt())).thenReturn(true);
lpeter8a5f4702019-01-18 16:53:07 +080054 when(config.alwaysOnEnabled(anyInt())).thenReturn(false);
Adrian Roosd35d4ca2017-04-19 14:31:03 -070055
56 when(config.doubleTapSensorType()).thenReturn(null);
lpeter8a5f4702019-01-18 16:53:07 +080057 when(config.tapSensorType()).thenReturn(null);
58 when(config.longPressSensorType()).thenReturn(null);
59
Lucas Dupin4359b552018-08-09 15:07:54 -070060 when(config.dozePickupSensorAvailable()).thenReturn(false);
lpeter8a5f4702019-01-18 16:53:07 +080061 when(config.wakeScreenGestureAvailable()).thenReturn(false);
Adrian Roosd35d4ca2017-04-19 14:31:03 -070062
63 doneHolder[0] = true;
64 return config;
65 }
66
67 private static MockSettings noDefaultAnswer(boolean[] setupDoneHolder) {
68 return withSettings().defaultAnswer((i) -> {
69 if (setupDoneHolder[0]) {
70 throw new IllegalArgumentException("not defined");
71 } else {
72 return Answers.RETURNS_DEFAULTS.answer(i);
73 }
74 });
75 }
76
77}