From af3899376911eaeabcef9fbd7e0bf422764d1297 Mon Sep 17 00:00:00 2001 From: Arthur Ishiguro Date: Wed, 22 Sep 2021 09:47:08 -0700 Subject: [PATCH] Simplify Context Hub global setting update Bug: 194285834 Test: Run mic settings test and verify pass Change-Id: I03d0acb042805dcb2a8c371d72ee91a1ee3fa980 --- .../contexthub/ContextHubService.java | 7 +++-- .../contexthub/IContextHubWrapper.java | 29 +++++++++---------- 2 files changed, 18 insertions(+), 18 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 a25392a0e1f4e..686926f592e37 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubService.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubService.java @@ -293,7 +293,7 @@ public class ContextHubService extends IContextHubService.Stub { }, UserHandle.USER_ALL); } - if (mContextHubWrapper.supportsMicrophoneDisableSettingNotifications()) { + if (mContextHubWrapper.supportsMicrophoneSettingNotifications()) { sendMicrophoneDisableSettingUpdateForCurrentUser(); mSensorPrivacyManagerInternal.addSensorPrivacyListenerForAllUsers( @@ -1100,7 +1100,10 @@ public class ContextHubService extends IContextHubService.Stub { */ private void sendMicrophoneDisableSettingUpdate(boolean enabled) { Log.d(TAG, "Mic Disabled Setting: " + enabled); - mContextHubWrapper.onMicrophoneDisableSettingChanged(enabled); + // The SensorPrivacyManager reports if microphone privacy was enabled, + // which translates to microphone access being disabled (and vice-versa). + // With this in mind, we flip the argument before piping it to CHRE. + mContextHubWrapper.onMicrophoneSettingChanged(!enabled); } /** 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 13bcc9b62b9bc..74630d1708a43 100644 --- a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +++ b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java @@ -228,15 +228,15 @@ public abstract class IContextHubWrapper { public abstract void onAirplaneModeSettingChanged(boolean enabled); /** - * @return True if this version of the Contexthub HAL supports microphone disable setting + * @return True if this version of the Contexthub HAL supports microphone setting * notifications. */ - public abstract boolean supportsMicrophoneDisableSettingNotifications(); + public abstract boolean supportsMicrophoneSettingNotifications(); /** - * Notifies the Contexthub implementation of a microphone disable setting change. + * Notifies the Contexthub implementation of a microphone setting change. */ - public abstract void onMicrophoneDisableSettingChanged(boolean enabled); + public abstract void onMicrophoneSettingChanged(boolean enabled); /** * Sends a message to the Context Hub. @@ -380,7 +380,7 @@ public abstract class IContextHubWrapper { return true; } - public boolean supportsMicrophoneDisableSettingNotifications() { + public boolean supportsMicrophoneSettingNotifications() { return true; } @@ -395,7 +395,7 @@ public abstract class IContextHubWrapper { onSettingChanged(android.hardware.contexthub.Setting.AIRPLANE_MODE, enabled); } - public void onMicrophoneDisableSettingChanged(boolean enabled) { + public void onMicrophoneSettingChanged(boolean enabled) { onSettingChanged(android.hardware.contexthub.Setting.MICROPHONE, enabled); } @@ -615,7 +615,7 @@ public abstract class IContextHubWrapper { return false; } - public boolean supportsMicrophoneDisableSettingNotifications() { + public boolean supportsMicrophoneSettingNotifications() { return false; } @@ -628,7 +628,7 @@ public abstract class IContextHubWrapper { public void onAirplaneModeSettingChanged(boolean enabled) { } - public void onMicrophoneDisableSettingChanged(boolean enabled) { + public void onMicrophoneSettingChanged(boolean enabled) { } } @@ -660,7 +660,7 @@ public abstract class IContextHubWrapper { return false; } - public boolean supportsMicrophoneDisableSettingNotifications() { + public boolean supportsMicrophoneSettingNotifications() { return false; } @@ -679,7 +679,7 @@ public abstract class IContextHubWrapper { public void onAirplaneModeSettingChanged(boolean enabled) { } - public void onMicrophoneDisableSettingChanged(boolean enabled) { + public void onMicrophoneSettingChanged(boolean enabled) { } } @@ -721,7 +721,7 @@ public abstract class IContextHubWrapper { return true; } - public boolean supportsMicrophoneDisableSettingNotifications() { + public boolean supportsMicrophoneSettingNotifications() { return true; } @@ -740,12 +740,9 @@ public abstract class IContextHubWrapper { enabled ? SettingValue.ENABLED : SettingValue.DISABLED); } - public void onMicrophoneDisableSettingChanged(boolean enabled) { - // The SensorPrivacyManager reports if microphone privacy was enabled, - // which translates to microphone access being disabled (and vice-versa). - // With this in mind, we flip the argument before piping it to CHRE. + public void onMicrophoneSettingChanged(boolean enabled) { sendSettingChanged(android.hardware.contexthub.V1_2.Setting.MICROPHONE, - enabled ? SettingValue.DISABLED : SettingValue.ENABLED); + enabled ? SettingValue.ENABLED : SettingValue.DISABLED); } public void registerCallback(int contextHubId, ICallback callback) throws RemoteException {