Loading core/api/test-current.txt +10 −2 Original line number Diff line number Diff line Loading @@ -1047,8 +1047,16 @@ package android.graphics.fonts { package android.hardware { public final class SensorPrivacyManager { method @RequiresPermission(android.Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacy(int, boolean); method @RequiresPermission(android.Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacyForProfileGroup(int, boolean); method @RequiresPermission(android.Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacy(int, int, boolean); method @RequiresPermission(android.Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacyForProfileGroup(int, int, boolean); } public static class SensorPrivacyManager.Sources { field public static final int DIALOG = 3; // 0x3 field public static final int OTHER = 5; // 0x5 field public static final int QS_TILE = 1; // 0x1 field public static final int SETTINGS = 2; // 0x2 field public static final int SHELL = 4; // 0x4 } } Loading core/java/android/hardware/ISensorPrivacyManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -41,9 +41,9 @@ interface ISensorPrivacyManager { void setSensorPrivacy(boolean enable); void setIndividualSensorPrivacy(int userId, int sensor, boolean enable); void setIndividualSensorPrivacy(int userId, int source, int sensor, boolean enable); void setIndividualSensorPrivacyForProfileGroup(int userId, int sensor, boolean enable); void setIndividualSensorPrivacyForProfileGroup(int userId, int source, int sensor, boolean enable); // =============== End of transactions used on native side as well ============================ void suppressIndividualSensorPrivacyReminders(int userId, String packageName, IBinder token, Loading core/java/android/hardware/SensorPrivacyManager.java +65 −12 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.service.SensorPrivacyIndividualEnabledSensorProto; import android.service.SensorPrivacyToggleSourceProto; import android.util.ArrayMap; import android.util.Pair; import android.util.SparseArray; Loading Loading @@ -102,6 +103,56 @@ public final class SensorPrivacyManager { public @interface Sensor {} } /** * Source through which Privacy Sensor was toggled. * @hide */ @TestApi public static class Sources { private Sources() {} /** * Constant for the Quick Setting Tile. */ public static final int QS_TILE = SensorPrivacyToggleSourceProto.QS_TILE; /** * Constant for the Settings. */ public static final int SETTINGS = SensorPrivacyToggleSourceProto.SETTINGS; /** * Constant for Dialog. */ public static final int DIALOG = SensorPrivacyToggleSourceProto.DIALOG; /** * Constant for SHELL. */ public static final int SHELL = SensorPrivacyToggleSourceProto.SHELL; /** * Constant for OTHER. */ public static final int OTHER = SensorPrivacyToggleSourceProto.OTHER; /** * Source for toggling sensors * * @hide */ @IntDef(value = { QS_TILE, SETTINGS, DIALOG, SHELL, OTHER }) @Retention(RetentionPolicy.SOURCE) public @interface Source {} } /** * A class implementing this interface can register with the {@link * android.hardware.SensorPrivacyManager} to receive notification when the sensor privacy Loading Loading @@ -343,8 +394,9 @@ public final class SensorPrivacyManager { */ @TestApi @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacy(@Sensors.Sensor int sensor, boolean enable) { setSensorPrivacy(sensor, enable, mContext.getUserId()); public void setSensorPrivacy(@Sources.Source int source, @Sensors.Sensor int sensor, boolean enable) { setSensorPrivacy(source, sensor, enable, mContext.getUserId()); } /** Loading @@ -357,10 +409,10 @@ public final class SensorPrivacyManager { * @hide */ @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacy(@Sensors.Sensor int sensor, boolean enable, @UserIdInt int userId) { public void setSensorPrivacy(@Sources.Source int source, @Sensors.Sensor int sensor, boolean enable, @UserIdInt int userId) { try { mService.setIndividualSensorPrivacy(userId, sensor, enable); mService.setIndividualSensorPrivacy(userId, source, sensor, enable); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -370,6 +422,7 @@ public final class SensorPrivacyManager { * Sets sensor privacy to the specified state for an individual sensor for the profile group of * context's user. * * @param source the source using which the sensor is toggled. * @param sensor the sensor which to change the state for * @param enable the state to which sensor privacy should be set. * Loading @@ -377,15 +430,16 @@ public final class SensorPrivacyManager { */ @TestApi @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacyForProfileGroup(@Sensors.Sensor int sensor, boolean enable) { setSensorPrivacyForProfileGroup(sensor, enable, mContext.getUserId()); public void setSensorPrivacyForProfileGroup(@Sources.Source int source, @Sensors.Sensor int sensor, boolean enable) { setSensorPrivacyForProfileGroup(source , sensor, enable, mContext.getUserId()); } /** * Sets sensor privacy to the specified state for an individual sensor for the profile group of * context's user. * * @param source the source using which the sensor is toggled. * @param sensor the sensor which to change the state for * @param enable the state to which sensor privacy should be set. * @param userId the user's id Loading @@ -393,11 +447,10 @@ public final class SensorPrivacyManager { * @hide */ @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacyForProfileGroup(@Sensors.Sensor int sensor, boolean enable, @UserIdInt int userId) { public void setSensorPrivacyForProfileGroup(@Sources.Source int source, @Sensors.Sensor int sensor, boolean enable, @UserIdInt int userId) { try { mService.setIndividualSensorPrivacyForProfileGroup(userId, sensor, enable); mService.setIndividualSensorPrivacyForProfileGroup(userId, source, sensor, enable); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/proto/android/hardware/sensorprivacy.proto +18 −0 Original line number Diff line number Diff line Loading @@ -66,3 +66,21 @@ message SensorPrivacyIndividualEnabledSensorProto { // If sensor privacy is enabled for this sensor optional bool is_enabled = 2; } message SensorPrivacyToggleSourceProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; enum Source { UNKNOWN = 0; QS_TILE = 1; SETTINGS = 2; DIALOG = 3; SHELL = 4; OTHER = 5; } // Source for which sensor privacy was toggled. optional Source source = 1; } No newline at end of file packages/SystemUI/src/com/android/systemui/qs/tiles/SensorPrivacyToggleTile.java +4 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.qs.tiles; import static android.hardware.SensorPrivacyManager.Sources.QS_TILE; import android.content.Intent; import android.hardware.SensorPrivacyManager.Sensors.Sensor; import android.os.Handler; Loading Loading @@ -87,12 +89,12 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS protected void handleClick(@Nullable View view) { if (mKeyguard.isMethodSecure() && mKeyguard.isShowing()) { mActivityStarter.postQSRunnableDismissingKeyguard(() -> { mSensorPrivacyController.setSensorBlocked(getSensorId(), mSensorPrivacyController.setSensorBlocked(QS_TILE, getSensorId(), !mSensorPrivacyController.isSensorBlocked(getSensorId())); }); return; } mSensorPrivacyController.setSensorBlocked(getSensorId(), mSensorPrivacyController.setSensorBlocked(QS_TILE, getSensorId(), !mSensorPrivacyController.isSensorBlocked(getSensorId())); } Loading Loading
core/api/test-current.txt +10 −2 Original line number Diff line number Diff line Loading @@ -1047,8 +1047,16 @@ package android.graphics.fonts { package android.hardware { public final class SensorPrivacyManager { method @RequiresPermission(android.Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacy(int, boolean); method @RequiresPermission(android.Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacyForProfileGroup(int, boolean); method @RequiresPermission(android.Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacy(int, int, boolean); method @RequiresPermission(android.Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacyForProfileGroup(int, int, boolean); } public static class SensorPrivacyManager.Sources { field public static final int DIALOG = 3; // 0x3 field public static final int OTHER = 5; // 0x5 field public static final int QS_TILE = 1; // 0x1 field public static final int SETTINGS = 2; // 0x2 field public static final int SHELL = 4; // 0x4 } } Loading
core/java/android/hardware/ISensorPrivacyManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -41,9 +41,9 @@ interface ISensorPrivacyManager { void setSensorPrivacy(boolean enable); void setIndividualSensorPrivacy(int userId, int sensor, boolean enable); void setIndividualSensorPrivacy(int userId, int source, int sensor, boolean enable); void setIndividualSensorPrivacyForProfileGroup(int userId, int sensor, boolean enable); void setIndividualSensorPrivacyForProfileGroup(int userId, int source, int sensor, boolean enable); // =============== End of transactions used on native side as well ============================ void suppressIndividualSensorPrivacyReminders(int userId, String packageName, IBinder token, Loading
core/java/android/hardware/SensorPrivacyManager.java +65 −12 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.service.SensorPrivacyIndividualEnabledSensorProto; import android.service.SensorPrivacyToggleSourceProto; import android.util.ArrayMap; import android.util.Pair; import android.util.SparseArray; Loading Loading @@ -102,6 +103,56 @@ public final class SensorPrivacyManager { public @interface Sensor {} } /** * Source through which Privacy Sensor was toggled. * @hide */ @TestApi public static class Sources { private Sources() {} /** * Constant for the Quick Setting Tile. */ public static final int QS_TILE = SensorPrivacyToggleSourceProto.QS_TILE; /** * Constant for the Settings. */ public static final int SETTINGS = SensorPrivacyToggleSourceProto.SETTINGS; /** * Constant for Dialog. */ public static final int DIALOG = SensorPrivacyToggleSourceProto.DIALOG; /** * Constant for SHELL. */ public static final int SHELL = SensorPrivacyToggleSourceProto.SHELL; /** * Constant for OTHER. */ public static final int OTHER = SensorPrivacyToggleSourceProto.OTHER; /** * Source for toggling sensors * * @hide */ @IntDef(value = { QS_TILE, SETTINGS, DIALOG, SHELL, OTHER }) @Retention(RetentionPolicy.SOURCE) public @interface Source {} } /** * A class implementing this interface can register with the {@link * android.hardware.SensorPrivacyManager} to receive notification when the sensor privacy Loading Loading @@ -343,8 +394,9 @@ public final class SensorPrivacyManager { */ @TestApi @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacy(@Sensors.Sensor int sensor, boolean enable) { setSensorPrivacy(sensor, enable, mContext.getUserId()); public void setSensorPrivacy(@Sources.Source int source, @Sensors.Sensor int sensor, boolean enable) { setSensorPrivacy(source, sensor, enable, mContext.getUserId()); } /** Loading @@ -357,10 +409,10 @@ public final class SensorPrivacyManager { * @hide */ @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacy(@Sensors.Sensor int sensor, boolean enable, @UserIdInt int userId) { public void setSensorPrivacy(@Sources.Source int source, @Sensors.Sensor int sensor, boolean enable, @UserIdInt int userId) { try { mService.setIndividualSensorPrivacy(userId, sensor, enable); mService.setIndividualSensorPrivacy(userId, source, sensor, enable); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -370,6 +422,7 @@ public final class SensorPrivacyManager { * Sets sensor privacy to the specified state for an individual sensor for the profile group of * context's user. * * @param source the source using which the sensor is toggled. * @param sensor the sensor which to change the state for * @param enable the state to which sensor privacy should be set. * Loading @@ -377,15 +430,16 @@ public final class SensorPrivacyManager { */ @TestApi @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacyForProfileGroup(@Sensors.Sensor int sensor, boolean enable) { setSensorPrivacyForProfileGroup(sensor, enable, mContext.getUserId()); public void setSensorPrivacyForProfileGroup(@Sources.Source int source, @Sensors.Sensor int sensor, boolean enable) { setSensorPrivacyForProfileGroup(source , sensor, enable, mContext.getUserId()); } /** * Sets sensor privacy to the specified state for an individual sensor for the profile group of * context's user. * * @param source the source using which the sensor is toggled. * @param sensor the sensor which to change the state for * @param enable the state to which sensor privacy should be set. * @param userId the user's id Loading @@ -393,11 +447,10 @@ public final class SensorPrivacyManager { * @hide */ @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) public void setSensorPrivacyForProfileGroup(@Sensors.Sensor int sensor, boolean enable, @UserIdInt int userId) { public void setSensorPrivacyForProfileGroup(@Sources.Source int source, @Sensors.Sensor int sensor, boolean enable, @UserIdInt int userId) { try { mService.setIndividualSensorPrivacyForProfileGroup(userId, sensor, enable); mService.setIndividualSensorPrivacyForProfileGroup(userId, source, sensor, enable); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/proto/android/hardware/sensorprivacy.proto +18 −0 Original line number Diff line number Diff line Loading @@ -66,3 +66,21 @@ message SensorPrivacyIndividualEnabledSensorProto { // If sensor privacy is enabled for this sensor optional bool is_enabled = 2; } message SensorPrivacyToggleSourceProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; enum Source { UNKNOWN = 0; QS_TILE = 1; SETTINGS = 2; DIALOG = 3; SHELL = 4; OTHER = 5; } // Source for which sensor privacy was toggled. optional Source source = 1; } No newline at end of file
packages/SystemUI/src/com/android/systemui/qs/tiles/SensorPrivacyToggleTile.java +4 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.qs.tiles; import static android.hardware.SensorPrivacyManager.Sources.QS_TILE; import android.content.Intent; import android.hardware.SensorPrivacyManager.Sensors.Sensor; import android.os.Handler; Loading Loading @@ -87,12 +89,12 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS protected void handleClick(@Nullable View view) { if (mKeyguard.isMethodSecure() && mKeyguard.isShowing()) { mActivityStarter.postQSRunnableDismissingKeyguard(() -> { mSensorPrivacyController.setSensorBlocked(getSensorId(), mSensorPrivacyController.setSensorBlocked(QS_TILE, getSensorId(), !mSensorPrivacyController.isSensorBlocked(getSensorId())); }); return; } mSensorPrivacyController.setSensorBlocked(getSensorId(), mSensorPrivacyController.setSensorBlocked(QS_TILE, getSensorId(), !mSensorPrivacyController.isSensorBlocked(getSensorId())); } Loading