summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/location/contexthub/ContextHubService.java34
-rw-r--r--services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java35
2 files changed, 69 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubService.java b/services/core/java/com/android/server/location/contexthub/ContextHubService.java
index 63a42f845cee..dc1a26ae6fea 100644
--- a/services/core/java/com/android/server/location/contexthub/ContextHubService.java
+++ b/services/core/java/com/android/server/location/contexthub/ContextHubService.java
@@ -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;
@@ -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();
@@ -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);
+ }
}
/**
@@ -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());
}
diff --git a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java
index 4242d72239e2..c11e289c116b 100644
--- a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java
+++ b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java
@@ -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;
@@ -152,6 +164,10 @@ public abstract class IContextHubWrapper {
return false;
}
+ public boolean supportsMicrophoneDisableSettingNotifications() {
+ return false;
+ }
+
public void onLocationSettingChanged(boolean enabled) {
}
@@ -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 {
@@ -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,
@@ -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 {
@@ -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);
@@ -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);