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.server.sensors; 18 19 import android.annotation.NonNull; 20 21 import java.util.concurrent.Executor; 22 23 /** 24 * Local system service interface for sensors. 25 * 26 * @hide Only for use within system server. 27 */ 28 public abstract class SensorManagerInternal { 29 /** 30 * Adds a listener for changes in proximity sensor state. 31 * @param executor The {@link Executor} to {@link Executor#execute invoke} the listener on. 32 * @param listener The listener to add. 33 * 34 * @throws IllegalArgumentException when adding a listener that is already listening 35 */ addProximityActiveListener(@onNull Executor executor, @NonNull ProximityActiveListener listener)36 public abstract void addProximityActiveListener(@NonNull Executor executor, 37 @NonNull ProximityActiveListener listener); 38 39 /** 40 * Removes a previously registered listener of proximity sensor state changes. 41 * @param listener The listener to remove. 42 */ removeProximityActiveListener(@onNull ProximityActiveListener listener)43 public abstract void removeProximityActiveListener(@NonNull ProximityActiveListener listener); 44 45 /** 46 * Listener for proximity sensor state changes. 47 */ 48 public interface ProximityActiveListener { 49 /** 50 * Callback invoked when the proximity sensor state changes 51 * @param isActive whether the sensor is being enabled or disabled. 52 */ onProximityActive(boolean isActive)53 void onProximityActive(boolean isActive); 54 } 55 } 56