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 package com.android.systemui.util.sensors;
18 
19 /**
20  * Wrapper class for a dual ProximitySensor which supports a secondary sensor gated upon the
21  * primary).
22  */
23 public interface ProximitySensor extends ThresholdSensor {
24     /**
25      * Returns true if we are registered with the SensorManager.
26      */
isRegistered()27     boolean isRegistered();
28 
29     /**
30      * Whether the proximity sensor reports near. Can return null if no information has been
31      * received yet.
32      */
isNear()33     Boolean isNear();
34 
35     /** Update all listeners with the last value this class received from the sensor. */
alertListeners()36     void alertListeners();
37 
38     /**
39      * Sets that it is safe to leave the secondary sensor on indefinitely.
40      *
41      * The secondary sensor will be turned on if there are any registered listeners, regardless
42      * of what is reported by the primary sensor.
43      */
setSecondarySafe(boolean safe)44     void setSecondarySafe(boolean safe);
45 
46     /**
47      * Called when the proximity sensor is no longer needed. All listeners should
48      * be unregistered and cleaned up.
49      */
destroy()50     void destroy();
51 }
52