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

Commit 8bec8708 authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "Add posture support for prox sensor" into sc-v2-dev am: 37001f99 am: e6991841

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

Change-Id: I63b66d9d12f92ea5945b9e0d10c9f97d4abb9f20
parents 7d9957d1 e6991841
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;

import java.util.Arrays;

import com.android.internal.R;

/**
@@ -258,10 +260,11 @@ public class AmbientDisplayConfiguration {
            String defaultValue,
            int posture) {
        String sensorType = defaultValue;
        if (posture < postureMapping.length) {
        if (postureMapping != null && posture < postureMapping.length) {
            sensorType = postureMapping[posture];
        } else {
            Log.e(TAG, "Unsupported doze posture " + posture);
            Log.e(TAG, "Unsupported doze posture " + posture
                  + " postureMapping=" + Arrays.toString(postureMapping));
        }

        return TextUtils.isEmpty(sensorType) ? defaultValue : sensorType;
+21 −4
Original line number Diff line number Diff line
@@ -224,15 +224,23 @@
         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 -->
        <!-- UNKNOWN -->
        <!-- CLOSED -->
        <!-- HALF_OPENED -->
        <!-- OPENED -->
    </string-array>

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

    <!-- Sensor type per posture state to use for proximity sensor -->
    <string-array name="proximity_sensor_posture_mapping" translatable="false">
        <!-- UNKNOWN -->
        <!-- CLOSED -->
        <!-- HALF_OPENED -->
        <!-- OPENED -->
    </string-array>

    <!-- If using proximity_sensor_type, specifies a threshold value to distinguish near and
         far break points. A sensor value less than this is considered "near". -->
    <item name="proximity_sensor_threshold" translatable="false" format="float" type="dimen"></item>
@@ -246,6 +254,15 @@
    <!-- Override value to use for proximity sensor as confirmation for proximity_sensor_type. -->
    <string name="proximity_sensor_secondary_type" translatable="false"></string>

    <!-- Sensor type per posture state to use for proximity sensor as a confirmation for
        proximity_sensor_type. -->
    <string-array name="proximity_sensor_secondary_posture_mapping" translatable="false">
        <!-- UNKNOWN -->
        <!-- CLOSED -->
        <!-- HALF_OPENED -->
        <!-- OPENED -->
    </string-array>

    <!-- If using proximity_sensor_secondary_type, specifies a threshold value to distinguish
         near and far break points. A sensor value less than this is considered "near". -->
    <item name="proximity_sensor_secondary_threshold" translatable="false" format="float"
+4 −3
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.sensors.ProximitySensor;
import com.android.systemui.util.sensors.ThresholdSensor;
import com.android.systemui.util.sensors.ThresholdSensorEvent;
import com.android.systemui.util.time.SystemClock;

import java.util.Collections;
@@ -405,7 +406,7 @@ class FalsingCollectorImpl implements FalsingCollector {
        mProximitySensor.unregister(mSensorEventListener);
    }

    private void onProximityEvent(ThresholdSensor.ThresholdSensorEvent proximityEvent) {
    private void onProximityEvent(ThresholdSensorEvent proximityEvent) {
        // TODO: some of these classifiers might allow us to abort early, meaning we don't have to
        // make these calls.
        mFalsingManager.onProximityEvent(new ProximityEventImpl(proximityEvent));
@@ -423,9 +424,9 @@ class FalsingCollectorImpl implements FalsingCollector {
    }

    private static class ProximityEventImpl implements FalsingManager.ProximityEvent {
        private ThresholdSensor.ThresholdSensorEvent mThresholdSensorEvent;
        private ThresholdSensorEvent mThresholdSensorEvent;

        ProximityEventImpl(ThresholdSensor.ThresholdSensorEvent thresholdSensorEvent) {
        ProximityEventImpl(ThresholdSensorEvent thresholdSensorEvent) {
            mThresholdSensorEvent = thresholdSensorEvent;
        }
        @Override
+4 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.Assert;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.sensors.AsyncSensorManager;
import com.android.systemui.util.sensors.ProximityCheck;
import com.android.systemui.util.sensors.ProximitySensor;
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.util.wakelock.WakeLock;
@@ -90,7 +91,7 @@ public class DozeTriggers implements DozeMachine.Part {
    private final TriggerReceiver mBroadcastReceiver = new TriggerReceiver();
    private final DockEventListener mDockEventListener = new DockEventListener();
    private final DockManager mDockManager;
    private final ProximitySensor.ProximityCheck mProxCheck;
    private final ProximityCheck mProxCheck;
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final AuthController mAuthController;
    private final DelayableExecutor mMainExecutor;
@@ -181,7 +182,8 @@ public class DozeTriggers implements DozeMachine.Part {
            AmbientDisplayConfiguration config,
            DozeParameters dozeParameters, AsyncSensorManager sensorManager,
            WakeLock wakeLock, DockManager dockManager,
            ProximitySensor proximitySensor, ProximitySensor.ProximityCheck proxCheck,
            ProximitySensor proximitySensor,
            ProximityCheck proxCheck,
            DozeLog dozeLog, BroadcastDispatcher broadcastDispatcher,
            SecureSettings secureSettings, AuthController authController,
            @Main DelayableExecutor mainExecutor,
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public interface DevicePostureController extends CallbackController<Callback> {
    int DEVICE_POSTURE_HALF_OPENED = 2;
    int DEVICE_POSTURE_OPENED = 3;
    int DEVICE_POSTURE_FLIPPED = 4;
    int SUPPORTED_POSTURES_SIZE = DEVICE_POSTURE_FLIPPED + 1;

    /** Return the current device posture. */
    @DevicePostureInt int getDevicePosture();
Loading