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

Commit 8157e9b0 authored by Iavor-Valentin Iftime's avatar Iavor-Valentin Iftime Committed by Android (Google) Code Review
Browse files

Merge "Set HW toggle states"

parents 6da7744f 28dac743
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -61,4 +61,9 @@ public abstract class SensorPrivacyManagerInternal {
     */
    public abstract void addSensorPrivacyListenerForAllUsers(int sensor,
            OnUserSensorPrivacyChangedListener listener);

    /**
     *  Set the HW toggle sensor value based on HW switch states, called from InputManagerService
     */
    public abstract void setPhysicalToggleSensorPrivacy(int userId, int sensor, boolean enable);
}
+6 −0
Original line number Diff line number Diff line
@@ -57,6 +57,12 @@
        com.android.systemui/com.android.systemui.sensorprivacy.television.TvUnblockSensorActivity
    </string>

    <!-- Component name of the activity used to inform a user about a sensory being blocked because
     of hardware privacy switches. -->
    <string name="config_sensorUseStartedActivity_hwToggle" translatable="false">
        com.android.systemui/com.android.systemui.sensorprivacy.television.TvUnblockSensorActivity
    </string>

    <!-- Component name of the activity that shows the request for access to a usb device. -->
    <string name="config_usbPermissionActivity" translatable="false">
        com.android.systemui/com.android.systemui.usb.tv.TvUsbPermissionActivity
+7 −0
Original line number Diff line number Diff line
@@ -2902,6 +2902,11 @@
    <string name="config_sensorUseStartedActivity" translatable="false"
            >com.android.systemui/com.android.systemui.sensorprivacy.SensorUseStartedActivity</string>

    <!-- Component name of the activity used to inform a user about a sensory being blocked because
     of hardware privacy switches. -->
    <string name="config_sensorUseStartedActivity_hwToggle" translatable="false"
            >com.android.systemui/com.android.systemui.sensorprivacy.SensorUseStartedActivity</string>

    <!-- Component name of the activity used to ask a user to confirm system language change after
         receiving <Set Menu Language> CEC message. -->
    <string name="config_hdmiCecSetMenuLanguageActivity"
@@ -5481,6 +5486,8 @@
    <bool name="config_supportsHardwareMicToggle">false</bool>
    <!-- Whether this device is supporting the hardware camera toggle -->
    <bool name="config_supportsHardwareCamToggle">false</bool>
    <!-- Whether a camera intent is launched when the lens cover is toggled -->
    <bool name="config_launchCameraOnCameraLensCoverToggle">true</bool>

    <!-- List containing the allowed install sources for accessibility service. -->
    <string-array name="config_accessibility_allowed_install_source" translatable="false"/>
+2 −0
Original line number Diff line number Diff line
@@ -375,6 +375,7 @@
  <java-symbol type="string" name="config_usbConfirmActivity" />
  <java-symbol type="string" name="config_usbResolverActivity" />
  <java-symbol type="string" name="config_sensorUseStartedActivity" />
  <java-symbol type="string" name="config_sensorUseStartedActivity_hwToggle" />
  <java-symbol type="string" name="config_hdmiCecSetMenuLanguageActivity" />
  <java-symbol type="integer" name="config_minNumVisibleRecentTasks_lowRam" />
  <java-symbol type="integer" name="config_maxNumVisibleRecentTasks_lowRam" />
@@ -4651,6 +4652,7 @@
  <java-symbol type="bool" name="config_supportsCamToggle" />
  <java-symbol type="bool" name="config_supportsHardwareMicToggle" />
  <java-symbol type="bool" name="config_supportsHardwareCamToggle" />
  <java-symbol type="bool" name="config_launchCameraOnCameraLensCoverToggle" />

  <java-symbol type="dimen" name="starting_surface_icon_size" />
  <java-symbol type="dimen" name="starting_surface_default_icon_size" />
+29 −0
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.database.ContentObserver;
import android.graphics.PointF;
import android.hardware.SensorPrivacyManager;
import android.hardware.SensorPrivacyManager.Sensors;
import android.hardware.SensorPrivacyManagerInternal;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayViewport;
import android.hardware.input.IInputDevicesChangedListener;
@@ -550,6 +553,19 @@ public class InputManagerService extends IInputManager.Stub
            }
        }

        // Set the HW mic toggle switch state
        final int micMuteState = getSwitchState(-1 /* deviceId */, InputDevice.SOURCE_ANY,
                SW_MUTE_DEVICE);
        if (micMuteState != InputManager.SWITCH_STATE_UNKNOWN) {
            setSensorPrivacy(Sensors.MICROPHONE, micMuteState != InputManager.SWITCH_STATE_OFF);
        }
        // Set the HW camera toggle switch state
        final int cameraMuteState = getSwitchState(-1 /* deviceId */, InputDevice.SOURCE_ANY,
                SW_CAMERA_LENS_COVER);
        if (cameraMuteState != InputManager.SWITCH_STATE_UNKNOWN) {
            setSensorPrivacy(Sensors.CAMERA, cameraMuteState != InputManager.SWITCH_STATE_OFF);
        }

        IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
@@ -2816,6 +2832,8 @@ public class InputManagerService extends IInputManager.Stub
        if ((switchMask & SW_CAMERA_LENS_COVER_BIT) != 0) {
            final boolean lensCovered = ((switchValues & SW_CAMERA_LENS_COVER_BIT) != 0);
            mWindowManagerCallbacks.notifyCameraLensCoverSwitchChanged(whenNanos, lensCovered);
            // Use SW_CAMERA_LENS_COVER code for camera privacy toggles
            setSensorPrivacy(Sensors.CAMERA, lensCovered);
        }

        if (mUseDevInputEventForAudioJack && (switchMask & SW_JACK_BITS) != 0) {
@@ -2836,7 +2854,18 @@ public class InputManagerService extends IInputManager.Stub
            final boolean micMute = ((switchValues & SW_MUTE_DEVICE_BIT) != 0);
            AudioManager audioManager = mContext.getSystemService(AudioManager.class);
            audioManager.setMicrophoneMuteFromSwitch(micMute);

            setSensorPrivacy(Sensors.MICROPHONE, micMute);
        }
    }

    // Set the sensor privacy state based on the hardware toggles switch states
    private void setSensorPrivacy(@SensorPrivacyManager.Sensors.Sensor int sensor,
            boolean enablePrivacy) {
        final SensorPrivacyManagerInternal sensorPrivacyManagerInternal =
                LocalServices.getService(SensorPrivacyManagerInternal.class);
        sensorPrivacyManagerInternal.setPhysicalToggleSensorPrivacy(UserHandle.USER_CURRENT, sensor,
                enablePrivacy);
    }

    // Native callback.
Loading