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

Commit c8d3d1ad authored by Beverly's avatar Beverly
Browse files

Add support dual display support doze tap gesture

Test: manual, atest DozeSensorsTest
Bug: 192805135
Change-Id: I08a98bf16753631afd31cb750c541c7443df1b9e
parent 89f022ac
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.Build;
import android.os.SystemProperties;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;

import com.android.internal.R;

@@ -32,7 +33,7 @@ import com.android.internal.R;
 */
@TestApi
public class AmbientDisplayConfiguration {

    private static final String TAG = "AmbientDisplayConfig";
    private final Context mContext;
    private final boolean mAlwaysOnByDefault;

@@ -141,10 +142,19 @@ public class AmbientDisplayConfiguration {
    }

    /** {@hide} */
    public String tapSensorType() {
    private String tapSensorType() {
        return mContext.getResources().getString(R.string.config_dozeTapSensorType);
    }

    /** {@hide} */
    public String tapSensorType(int posture) {
        return getSensorTypeForPosture(
                mContext.getResources().getStringArray(R.array.config_dozeTapSensorPostureMapping),
                tapSensorType(),
                posture
        );
    }

    /** {@hide} */
    public String longPressSensorType() {
        return mContext.getResources().getString(R.string.config_dozeLongPressSensorType);
@@ -241,4 +251,18 @@ public class AmbientDisplayConfiguration {
    private boolean boolSetting(String name, int user, int def) {
        return Settings.Secure.getIntForUser(mContext.getContentResolver(), name, def, user) != 0;
    }

    private String getSensorTypeForPosture(
            String[] postureMapping,
            String defaultSensorType,
            int posture) {
        String sensorType = defaultSensorType;
        if (posture < postureMapping.length) {
            sensorType = postureMapping[posture];
        } else {
            Log.e(TAG, "Unsupported doze posture " + posture);
        }

        return TextUtils.isEmpty(sensorType) ? defaultSensorType : sensorType;
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -2323,6 +2323,15 @@
    <!-- Type of the tap sensor. Empty if tap is not supported. -->
    <string name="config_dozeTapSensorType" translatable="false"></string>

    <!-- Type of the ambient tap sensor per device posture (defined by WM Jetpack posture).
         Unspecified values use config_dozeTapSensor -->
    <string-array name="config_dozeTapSensorPostureMapping" translatable="false">
        <item></item> <!-- UNKNOWN -->
        <item></item> <!-- CLOSED -->
        <item></item> <!-- HALF_OPENED -->
        <item></item> <!-- OPENED -->
    </string-array>

    <!-- Type of the long press sensor. Empty if long press is not supported. -->
    <string name="config_dozeLongPressSensorType" translatable="false"></string>

+1 −0
Original line number Diff line number Diff line
@@ -3255,6 +3255,7 @@

  <java-symbol type="string" name="config_dozeDoubleTapSensorType" />
  <java-symbol type="string" name="config_dozeTapSensorType" />
  <java-symbol type="array" name="config_dozeTapSensorPostureMapping" />
  <java-symbol type="bool" name="config_dozePulsePickup" />

  <!-- Used for MimeIconUtils. -->
+9 −0
Original line number Diff line number Diff line
@@ -191,6 +191,15 @@
     low powered state yet. -->
    <bool name="doze_single_tap_uses_prox">true</bool>

    <!-- Doze: whether the single tap sensor uses the proximity sensor in the given posture.
        See doze_single_tap_uses_prox for usage. -->
    <integer-array name="doze_single_tap_uses_prox_posture_mapping">
        <item>1</item> <!-- UNKNOWN -->
        <item>1</item> <!-- CLOSED -->
        <item>1</item> <!-- HALF_OPENED -->
        <item>1</item> <!-- OPENED -->
    </integer-array>

    <!-- Doze: whether the long press sensor uses the proximity sensor.
     If both this parameter and doze_selectively_register_prox are true, registration for the
     sensor will be delayed when the device first enters dozing but the device has not entered its
+11 −3
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.plugins.SensorManagerPlugin;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.util.sensors.AsyncSensorManager;
import com.android.systemui.util.sensors.ProximitySensor;
import com.android.systemui.util.settings.SecureSettings;
@@ -82,6 +83,9 @@ public class DozeSensors {
    private boolean mListeningTouchScreenSensors;
    private boolean mListeningProxSensors;

    @DevicePostureController.DevicePostureInt
    private int mDevicePosture;

    // whether to only register sensors that use prox when the display state is dozing or off
    private boolean mSelectivelyRegisterProxSensors;

@@ -106,7 +110,8 @@ public class DozeSensors {
            DozeParameters dozeParameters, AmbientDisplayConfiguration config, WakeLock wakeLock,
            Callback callback, Consumer<Boolean> proxCallback, DozeLog dozeLog,
            ProximitySensor proximitySensor, SecureSettings secureSettings,
            AuthController authController) {
            AuthController authController,
            int devicePosture) {
        mContext = context;
        mSensorManager = sensorManager;
        mConfig = config;
@@ -120,6 +125,7 @@ public class DozeSensors {
        mListeningProxSensors = !mSelectivelyRegisterProxSensors;
        mScreenOffUdfpsEnabled =
                config.screenOffUdfpsEnabled(KeyguardUpdateMonitor.getCurrentUser());
        mDevicePosture = devicePosture;

        boolean udfpsEnrolled =
                authController.isUdfpsEnrolled(KeyguardUpdateMonitor.getCurrentUser());
@@ -150,7 +156,7 @@ public class DozeSensors {
                        true /* touchscreen */,
                        dozeLog),
                new TriggerSensor(
                        findSensorWithType(config.tapSensorType()),
                        findSensorWithType(config.tapSensorType(mDevicePosture)),
                        Settings.Secure.DOZE_TAP_SCREEN_GESTURE,
                        true /* settingDef */,
                        true /* configured */,
@@ -158,7 +164,7 @@ public class DozeSensors {
                        false /* reports touch coordinates */,
                        true /* touchscreen */,
                        false /* ignoresSetting */,
                        dozeParameters.singleTapUsesProx() /* requiresProx */,
                        dozeParameters.singleTapUsesProx(mDevicePosture) /* requiresProx */,
                        dozeLog),
                new TriggerSensor(
                        findSensorWithType(config.longPressSensorType()),
@@ -370,6 +376,8 @@ public class DozeSensors {
    /** Dump current state */
    public void dump(PrintWriter pw) {
        pw.println("mListening=" + mListening);
        pw.println("mDevicePosture="
                + DevicePostureController.devicePostureToString(mDevicePosture));
        pw.println("mListeningTouchScreenSensors=" + mListeningTouchScreenSensors);
        pw.println("mSelectivelyRegisterProxSensors=" + mSelectivelyRegisterProxSensors);
        pw.println("mListeningProxSensors=" + mListeningProxSensors);
Loading