Merge "Add support for Global Mic Disable user setting"
This commit is contained in:
committed by
Android (Google) Code Review
commit
86af49b5d0
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user