Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af389937 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Simplify Context Hub global setting update

Bug: 194285834
Test: Run mic settings test and verify pass
Change-Id: I03d0acb042805dcb2a8c371d72ee91a1ee3fa980
parent 1a1c6c87
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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);
    }

    /**
+13 −16
Original line number Diff line number Diff line
@@ -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 {