Loading core/java/android/hardware/ISensorPrivacyManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -52,4 +52,6 @@ interface ISensorPrivacyManager { void addUserGlobalIndividualSensorPrivacyListener(int sensor, in ISensorPrivacyListener listener); void removeUserGlobalIndividualSensorPrivacyListener(int sensor, in ISensorPrivacyListener listener); void showSensorUseDialog(int sensor); } No newline at end of file core/java/android/hardware/SensorPrivacyManager.java +22 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.os.UserHandle; import android.service.SensorPrivacyIndividualEnabledSensorProto; import android.service.SensorPrivacyToggleSourceProto; import android.util.ArrayMap; import android.util.Log; import android.util.Pair; import android.util.SparseArray; Loading @@ -48,6 +49,8 @@ import java.util.concurrent.Executor; @SystemService(Context.SENSOR_PRIVACY_SERVICE) public final class SensorPrivacyManager { private static final String LOG_TAG = SensorPrivacyManager.class.getSimpleName(); /** * Unique Id of this manager to identify to the service * @hide Loading Loading @@ -504,6 +507,25 @@ public final class SensorPrivacyManager { } } /** * If sensor privacy for the provided sensor is enabled then this call will show the user the * dialog which is shown when an application attempts to use that sensor. If privacy isn't * enabled then this does nothing. * * This call can only be made by the system uid. * * @throws SecurityException when called by someone other than system uid. * * @hide */ public void showSensorUseDialog(int sensor) { try { mService.showSensorUseDialog(sensor); } catch (RemoteException e) { Log.e(LOG_TAG, "Received exception while trying to show sensor use dialog", e); } } /** * A class implementing this interface can register with the {@link * android.hardware.SensorPrivacyManager} to receive notification when the all-sensor privacy Loading services/core/java/com/android/server/SensorPrivacyService.java +18 −5 Original line number Diff line number Diff line Loading @@ -413,6 +413,12 @@ public final class SensorPrivacyService extends SystemService { return; } if (uid == Process.SYSTEM_UID) { // If the system uid is being blamed for sensor access, the ui must be shown // explicitly using SensorPrivacyManager#showSensorUseDialog return; } synchronized (mLock) { if (mSuppressReminders.containsKey(new Pair<>(sensor, user))) { Log.d(TAG, Loading @@ -421,11 +427,6 @@ public final class SensorPrivacyService extends SystemService { } } if (uid == Process.SYSTEM_UID) { enqueueSensorUseReminderDialogAsync(-1, user, packageName, sensor); return; } // TODO: Handle reminders with multiple sensors // - If we have a likely activity that triggered the sensor use overlay a dialog over Loading Loading @@ -1241,6 +1242,18 @@ public final class SensorPrivacyService extends SystemService { } } @Override public void showSensorUseDialog(int sensor) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { throw new SecurityException("Can only be called by the system uid"); } if (!isIndividualSensorPrivacyEnabled(mCurrentUser, sensor)) { return; } enqueueSensorUseReminderDialogAsync( -1, UserHandle.of(mCurrentUser), "android", sensor); } private void userSwitching(int from, int to) { boolean micState; boolean camState; Loading Loading
core/java/android/hardware/ISensorPrivacyManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -52,4 +52,6 @@ interface ISensorPrivacyManager { void addUserGlobalIndividualSensorPrivacyListener(int sensor, in ISensorPrivacyListener listener); void removeUserGlobalIndividualSensorPrivacyListener(int sensor, in ISensorPrivacyListener listener); void showSensorUseDialog(int sensor); } No newline at end of file
core/java/android/hardware/SensorPrivacyManager.java +22 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.os.UserHandle; import android.service.SensorPrivacyIndividualEnabledSensorProto; import android.service.SensorPrivacyToggleSourceProto; import android.util.ArrayMap; import android.util.Log; import android.util.Pair; import android.util.SparseArray; Loading @@ -48,6 +49,8 @@ import java.util.concurrent.Executor; @SystemService(Context.SENSOR_PRIVACY_SERVICE) public final class SensorPrivacyManager { private static final String LOG_TAG = SensorPrivacyManager.class.getSimpleName(); /** * Unique Id of this manager to identify to the service * @hide Loading Loading @@ -504,6 +507,25 @@ public final class SensorPrivacyManager { } } /** * If sensor privacy for the provided sensor is enabled then this call will show the user the * dialog which is shown when an application attempts to use that sensor. If privacy isn't * enabled then this does nothing. * * This call can only be made by the system uid. * * @throws SecurityException when called by someone other than system uid. * * @hide */ public void showSensorUseDialog(int sensor) { try { mService.showSensorUseDialog(sensor); } catch (RemoteException e) { Log.e(LOG_TAG, "Received exception while trying to show sensor use dialog", e); } } /** * A class implementing this interface can register with the {@link * android.hardware.SensorPrivacyManager} to receive notification when the all-sensor privacy Loading
services/core/java/com/android/server/SensorPrivacyService.java +18 −5 Original line number Diff line number Diff line Loading @@ -413,6 +413,12 @@ public final class SensorPrivacyService extends SystemService { return; } if (uid == Process.SYSTEM_UID) { // If the system uid is being blamed for sensor access, the ui must be shown // explicitly using SensorPrivacyManager#showSensorUseDialog return; } synchronized (mLock) { if (mSuppressReminders.containsKey(new Pair<>(sensor, user))) { Log.d(TAG, Loading @@ -421,11 +427,6 @@ public final class SensorPrivacyService extends SystemService { } } if (uid == Process.SYSTEM_UID) { enqueueSensorUseReminderDialogAsync(-1, user, packageName, sensor); return; } // TODO: Handle reminders with multiple sensors // - If we have a likely activity that triggered the sensor use overlay a dialog over Loading Loading @@ -1241,6 +1242,18 @@ public final class SensorPrivacyService extends SystemService { } } @Override public void showSensorUseDialog(int sensor) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { throw new SecurityException("Can only be called by the system uid"); } if (!isIndividualSensorPrivacyEnabled(mCurrentUser, sensor)) { return; } enqueueSensorUseReminderDialogAsync( -1, UserHandle.of(mCurrentUser), "android", sensor); } private void userSwitching(int from, int to) { boolean micState; boolean camState; Loading