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 android.hardware; 18 19 /** 20 * SensorPrivacyManager calls for within the system server 21 * @hide 22 */ 23 public abstract class SensorPrivacyManagerInternal { 24 25 /** 26 * A class implementing this interface can register to receive a callback when state changes. 27 */ 28 public interface OnSensorPrivacyChangedListener { 29 /** 30 * The callback invoked when the state changes. 31 */ onSensorPrivacyChanged(boolean enabled)32 void onSensorPrivacyChanged(boolean enabled); 33 } 34 35 /** 36 * A class implementing this interface can register to receive a callback when state changes for 37 * any user. 38 */ 39 public interface OnUserSensorPrivacyChangedListener { 40 /** 41 * The callback invoked when the state changes. 42 */ onSensorPrivacyChanged(int userId, boolean enabled)43 void onSensorPrivacyChanged(int userId, boolean enabled); 44 } 45 46 /** 47 * Get the individual sensor privacy state for a given user. 48 */ isSensorPrivacyEnabled(int userId, int sensor)49 public abstract boolean isSensorPrivacyEnabled(int userId, int sensor); 50 51 /** 52 * Registers a new listener to receive notification when the state of sensor privacy 53 * changes. 54 */ addSensorPrivacyListener(int userId, int sensor, OnSensorPrivacyChangedListener listener)55 public abstract void addSensorPrivacyListener(int userId, int sensor, 56 OnSensorPrivacyChangedListener listener); 57 58 /** 59 * Registers a new listener to receive notification when the state of sensor privacy 60 * changes for any user. 61 */ addSensorPrivacyListenerForAllUsers(int sensor, OnUserSensorPrivacyChangedListener listener)62 public abstract void addSensorPrivacyListenerForAllUsers(int sensor, 63 OnUserSensorPrivacyChangedListener listener); 64 65 /** 66 * Set the HW toggle sensor value based on HW switch states, called from InputManagerService 67 */ setPhysicalToggleSensorPrivacy(int userId, int sensor, boolean enable)68 public abstract void setPhysicalToggleSensorPrivacy(int userId, int sensor, boolean enable); 69 } 70