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

Commit a6462134 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topic "dozeTapGesture_dualDisplaySupport" into sc-v2-dev...

Merge changes from topic "dozeTapGesture_dualDisplaySupport" into sc-v2-dev am: a2fb7496 am: fa69d149

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15933708

Change-Id: Ie7a182b3694401a2cbbb223831425cf69e961fdc
parents 46da85a3 fa69d149
Loading
Loading
Loading
Loading
+27 −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 getSensorFromPostureMapping(
                mContext.getResources().getStringArray(R.array.config_dozeTapSensorPostureMapping),
                tapSensorType(),
                posture
        );
    }

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

    /** {@hide} */
    public static String getSensorFromPostureMapping(
            String[] postureMapping,
            String defaultValue,
            int posture) {
        String sensorType = defaultValue;
        if (posture < postureMapping.length) {
            sensorType = postureMapping[posture];
        } else {
            Log.e(TAG, "Unsupported doze posture " + posture);
        }

        return TextUtils.isEmpty(sensorType) ? defaultValue : sensorType;
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -2316,6 +2316,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
@@ -3259,6 +3259,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. -->
+19 −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
@@ -211,6 +220,16 @@
         always-on display) -->
    <string name="doze_brightness_sensor_type" translatable="false"></string>

    <!-- Name of a sensor per posture state that provides a low-power estimate of the desired
         display brightness, suitable to listen to while the device is asleep (e.g. during
         always-on display) -->
    <string-array name="doze_brightness_sensor_name_posture_mapping" translatable="false">
        <item></item> <!-- UNKNOWN -->
        <item></item> <!-- CLOSED -->
        <item></item> <!-- HALF_OPENED -->
        <item></item> <!-- OPENED -->
    </string-array>

    <!-- Override value to use for proximity sensor.  -->
    <string name="proximity_sensor_type" translatable="false"></string>

+34 −18
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());
@@ -142,7 +148,7 @@ public class DozeSensors {
                        false /* requires prox */,
                        dozeLog),
                new TriggerSensor(
                        findSensorWithType(config.doubleTapSensorType()),
                        findSensor(config.doubleTapSensorType()),
                        Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
                        true /* configured */,
                        DozeLog.REASON_SENSOR_DOUBLE_TAP,
@@ -150,7 +156,7 @@ public class DozeSensors {
                        true /* touchscreen */,
                        dozeLog),
                new TriggerSensor(
                        findSensorWithType(config.tapSensorType()),
                        findSensor(config.tapSensorType(mDevicePosture)),
                        Settings.Secure.DOZE_TAP_SCREEN_GESTURE,
                        true /* settingDef */,
                        true /* configured */,
@@ -158,10 +164,10 @@ public class DozeSensors {
                        false /* reports touch coordinates */,
                        true /* touchscreen */,
                        false /* ignoresSetting */,
                        dozeParameters.singleTapUsesProx() /* requiresProx */,
                        dozeParameters.singleTapUsesProx(mDevicePosture) /* requiresProx */,
                        dozeLog),
                new TriggerSensor(
                        findSensorWithType(config.longPressSensorType()),
                        findSensor(config.longPressSensorType()),
                        Settings.Secure.DOZE_PULSE_ON_LONG_PRESS,
                        false /* settingDef */,
                        true /* configured */,
@@ -172,7 +178,7 @@ public class DozeSensors {
                        dozeParameters.longPressUsesProx() /* requiresProx */,
                        dozeLog),
                new TriggerSensor(
                        findSensorWithType(config.udfpsLongPressSensorType()),
                        findSensor(config.udfpsLongPressSensorType()),
                        "doze_pulse_on_auth",
                        true /* settingDef */,
                        udfpsEnrolled && (alwaysOn || mScreenOffUdfpsEnabled),
@@ -200,7 +206,7 @@ public class DozeSensors {
                        mConfig.getWakeLockScreenDebounce(),
                        dozeLog),
                new TriggerSensor(
                        findSensorWithType(config.quickPickupSensorType()),
                        findSensor(config.quickPickupSensorType()),
                        Settings.Secure.DOZE_QUICK_PICKUP_GESTURE,
                        true /* setting default */,
                        config.quickPickupSensorEnabled(KeyguardUpdateMonitor.getCurrentUser())
@@ -238,21 +244,29 @@ public class DozeSensors {
        mDebounceFrom = SystemClock.uptimeMillis();
    }

    private Sensor findSensorWithType(String type) {
        return findSensorWithType(mSensorManager, type);
    private Sensor findSensor(String type) {
        return findSensor(mSensorManager, type, null);
    }

    /**
     * Utility method to find a {@link Sensor} for the supplied string type.
     * Utility method to find a {@link Sensor} for the supplied string type and string name.
     *
     * Return the first sensor in the list that matches the specified inputs. Ignores type or name
     * if the input is null or empty.
     *
     * @param type sensorType
     * @parm name sensorName, to differentiate between sensors with the same type
     */
    public static Sensor findSensorWithType(SensorManager sensorManager, String type) {
        if (TextUtils.isEmpty(type)) {
            return null;
    public static Sensor findSensor(SensorManager sensorManager, String type, String name) {
        final boolean isNameSpecified = !TextUtils.isEmpty(name);
        final boolean isTypeSpecified = !TextUtils.isEmpty(type);
        if (isNameSpecified || isTypeSpecified) {
            final List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ALL);
            for (Sensor sensor : sensors) {
                if ((!isNameSpecified || name.equals(sensor.getName()))
                        && (!isTypeSpecified || type.equals(sensor.getStringType()))) {
                    return sensor;
                }
        List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL);
        for (Sensor s : sensorList) {
            if (type.equals(s.getStringType())) {
                return s;
            }
        }
        return null;
@@ -370,6 +384,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