Loading services/core/java/com/android/server/location/contexthub/ContextHubService.java +34 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.database.ContentObserver; import android.hardware.SensorPrivacyManager; import android.hardware.contexthub.V1_0.AsyncEventType; import android.hardware.contexthub.V1_0.ContextHub; import android.hardware.contexthub.V1_0.ContextHubMsg; Loading Loading @@ -117,6 +118,9 @@ public class ContextHubService extends IContextHubService.Stub { // True if WiFi is available for the Context Hub private boolean mIsWifiAvailable = false; // True if audio is disabled for the ContextHub private boolean mIsAudioDisabled = false; // Lock object for sendWifiSettingUpdate() private final Object mSendWifiSettingUpdateLock = new Object(); Loading Loading @@ -256,6 +260,21 @@ public class ContextHubService extends IContextHubService.Stub { } }, UserHandle.USER_ALL); } if (mContextHubWrapper.supportsMicrophoneDisableSettingNotifications()) { sendMicrophoneDisableSettingUpdate(); SensorPrivacyManager.OnSensorPrivacyChangedListener listener = new SensorPrivacyManager.OnSensorPrivacyChangedListener() { @Override public void onSensorPrivacyChanged(boolean enabled) { sendMicrophoneDisableSettingUpdate(); } }; SensorPrivacyManager manager = SensorPrivacyManager.getInstance(mContext); manager.addSensorPrivacyListener( SensorPrivacyManager.INDIVIDUAL_SENSOR_MICROPHONE, listener); } } /** Loading Loading @@ -999,6 +1018,21 @@ public class ContextHubService extends IContextHubService.Stub { mContextHubWrapper.onAirplaneModeSettingChanged(enabled); } /** * Obtains the latest microphone disable setting value and notifies the * Context Hub. */ private void sendMicrophoneDisableSettingUpdate() { SensorPrivacyManager manager = SensorPrivacyManager.getInstance(mContext); boolean disabled = manager.isIndividualSensorPrivacyEnabled( SensorPrivacyManager.INDIVIDUAL_SENSOR_MICROPHONE); if (mIsAudioDisabled != disabled) { mIsAudioDisabled = disabled; mContextHubWrapper.onMicrophoneDisableSettingChanged(disabled); } } private String getCallingPackageName() { return mContext.getPackageManager().getNameForUid(Binder.getCallingUid()); } Loading services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +35 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,18 @@ public abstract class IContextHubWrapper { */ public abstract void onAirplaneModeSettingChanged(boolean enabled); /** * @return True if this version of the Contexthub HAL supports microphone * disable setting notifications. */ public abstract boolean supportsMicrophoneDisableSettingNotifications(); /** * Notifies the Contexthub implementation of a microphone disable setting * change. */ public abstract void onMicrophoneDisableSettingChanged(boolean enabled); private static class ContextHubWrapperV1_0 extends IContextHubWrapper { private android.hardware.contexthub.V1_0.IContexthub mHub; Loading @@ -152,6 +164,10 @@ public abstract class IContextHubWrapper { return false; } public boolean supportsMicrophoneDisableSettingNotifications() { return false; } public void onLocationSettingChanged(boolean enabled) { } Loading @@ -160,6 +176,9 @@ public abstract class IContextHubWrapper { public void onAirplaneModeSettingChanged(boolean enabled) { } public void onMicrophoneDisableSettingChanged(boolean enabled) { } } private static class ContextHubWrapperV1_1 extends IContextHubWrapper { Loading @@ -185,6 +204,10 @@ public abstract class IContextHubWrapper { return false; } public boolean supportsMicrophoneDisableSettingNotifications() { return false; } public void onLocationSettingChanged(boolean enabled) { try { mHub.onSettingChanged(Setting.LOCATION, Loading @@ -199,6 +222,9 @@ public abstract class IContextHubWrapper { public void onAirplaneModeSettingChanged(boolean enabled) { } public void onMicrophoneDisableSettingChanged(boolean enabled) { } } private static class ContextHubWrapperV1_2 extends IContextHubWrapper { Loading @@ -224,6 +250,10 @@ public abstract class IContextHubWrapper { return true; } public boolean supportsMicrophoneDisableSettingNotifications() { return true; } public void onLocationSettingChanged(boolean enabled) { sendSettingChanged(Setting.LOCATION, enabled ? SettingValue.ENABLED : SettingValue.DISABLED); Loading @@ -239,6 +269,11 @@ public abstract class IContextHubWrapper { enabled ? SettingValue.ENABLED : SettingValue.DISABLED); } public void onMicrophoneDisableSettingChanged(boolean enabled) { sendSettingChanged(android.hardware.contexthub.V1_2.Setting.GLOBAL_MIC_DISABLE, enabled ? SettingValue.ENABLED : SettingValue.DISABLED); } private void sendSettingChanged(byte setting, byte newValue) { try { mHub.onSettingChanged_1_2(setting, newValue); Loading Loading
services/core/java/com/android/server/location/contexthub/ContextHubService.java +34 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.database.ContentObserver; import android.hardware.SensorPrivacyManager; import android.hardware.contexthub.V1_0.AsyncEventType; import android.hardware.contexthub.V1_0.ContextHub; import android.hardware.contexthub.V1_0.ContextHubMsg; Loading Loading @@ -117,6 +118,9 @@ public class ContextHubService extends IContextHubService.Stub { // True if WiFi is available for the Context Hub private boolean mIsWifiAvailable = false; // True if audio is disabled for the ContextHub private boolean mIsAudioDisabled = false; // Lock object for sendWifiSettingUpdate() private final Object mSendWifiSettingUpdateLock = new Object(); Loading Loading @@ -256,6 +260,21 @@ public class ContextHubService extends IContextHubService.Stub { } }, UserHandle.USER_ALL); } if (mContextHubWrapper.supportsMicrophoneDisableSettingNotifications()) { sendMicrophoneDisableSettingUpdate(); SensorPrivacyManager.OnSensorPrivacyChangedListener listener = new SensorPrivacyManager.OnSensorPrivacyChangedListener() { @Override public void onSensorPrivacyChanged(boolean enabled) { sendMicrophoneDisableSettingUpdate(); } }; SensorPrivacyManager manager = SensorPrivacyManager.getInstance(mContext); manager.addSensorPrivacyListener( SensorPrivacyManager.INDIVIDUAL_SENSOR_MICROPHONE, listener); } } /** Loading Loading @@ -999,6 +1018,21 @@ public class ContextHubService extends IContextHubService.Stub { mContextHubWrapper.onAirplaneModeSettingChanged(enabled); } /** * Obtains the latest microphone disable setting value and notifies the * Context Hub. */ private void sendMicrophoneDisableSettingUpdate() { SensorPrivacyManager manager = SensorPrivacyManager.getInstance(mContext); boolean disabled = manager.isIndividualSensorPrivacyEnabled( SensorPrivacyManager.INDIVIDUAL_SENSOR_MICROPHONE); if (mIsAudioDisabled != disabled) { mIsAudioDisabled = disabled; mContextHubWrapper.onMicrophoneDisableSettingChanged(disabled); } } private String getCallingPackageName() { return mContext.getPackageManager().getNameForUid(Binder.getCallingUid()); } Loading
services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +35 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,18 @@ public abstract class IContextHubWrapper { */ public abstract void onAirplaneModeSettingChanged(boolean enabled); /** * @return True if this version of the Contexthub HAL supports microphone * disable setting notifications. */ public abstract boolean supportsMicrophoneDisableSettingNotifications(); /** * Notifies the Contexthub implementation of a microphone disable setting * change. */ public abstract void onMicrophoneDisableSettingChanged(boolean enabled); private static class ContextHubWrapperV1_0 extends IContextHubWrapper { private android.hardware.contexthub.V1_0.IContexthub mHub; Loading @@ -152,6 +164,10 @@ public abstract class IContextHubWrapper { return false; } public boolean supportsMicrophoneDisableSettingNotifications() { return false; } public void onLocationSettingChanged(boolean enabled) { } Loading @@ -160,6 +176,9 @@ public abstract class IContextHubWrapper { public void onAirplaneModeSettingChanged(boolean enabled) { } public void onMicrophoneDisableSettingChanged(boolean enabled) { } } private static class ContextHubWrapperV1_1 extends IContextHubWrapper { Loading @@ -185,6 +204,10 @@ public abstract class IContextHubWrapper { return false; } public boolean supportsMicrophoneDisableSettingNotifications() { return false; } public void onLocationSettingChanged(boolean enabled) { try { mHub.onSettingChanged(Setting.LOCATION, Loading @@ -199,6 +222,9 @@ public abstract class IContextHubWrapper { public void onAirplaneModeSettingChanged(boolean enabled) { } public void onMicrophoneDisableSettingChanged(boolean enabled) { } } private static class ContextHubWrapperV1_2 extends IContextHubWrapper { Loading @@ -224,6 +250,10 @@ public abstract class IContextHubWrapper { return true; } public boolean supportsMicrophoneDisableSettingNotifications() { return true; } public void onLocationSettingChanged(boolean enabled) { sendSettingChanged(Setting.LOCATION, enabled ? SettingValue.ENABLED : SettingValue.DISABLED); Loading @@ -239,6 +269,11 @@ public abstract class IContextHubWrapper { enabled ? SettingValue.ENABLED : SettingValue.DISABLED); } public void onMicrophoneDisableSettingChanged(boolean enabled) { sendSettingChanged(android.hardware.contexthub.V1_2.Setting.GLOBAL_MIC_DISABLE, enabled ? SettingValue.ENABLED : SettingValue.DISABLED); } private void sendSettingChanged(byte setting, byte newValue) { try { mHub.onSettingChanged_1_2(setting, newValue); Loading