MotoActions: Drop glance sensor for doze
* This sensor gets triggered by any physical movements of the device. Slight shakes of your table could even wake up the device, which is clearly undesired. * The ordinary pick up gesture is detected by the flat up sensor. Change-Id: I1fe492e8e23f09adebab38f123f6bb497cc7a0f4
This commit is contained in:
parent
2c77e9bb68
commit
9201be6534
@ -35,7 +35,6 @@ import org.lineageos.settings.device.actions.LiftToSilence;
|
|||||||
import org.lineageos.settings.device.actions.ProximitySilencer;
|
import org.lineageos.settings.device.actions.ProximitySilencer;
|
||||||
|
|
||||||
import org.lineageos.settings.device.doze.DozePulseAction;
|
import org.lineageos.settings.device.doze.DozePulseAction;
|
||||||
import org.lineageos.settings.device.doze.GlanceSensor;
|
|
||||||
import org.lineageos.settings.device.doze.ProximitySensor;
|
import org.lineageos.settings.device.doze.ProximitySensor;
|
||||||
import org.lineageos.settings.device.doze.FlatUpSensor;
|
import org.lineageos.settings.device.doze.FlatUpSensor;
|
||||||
import org.lineageos.settings.device.doze.ScreenReceiver;
|
import org.lineageos.settings.device.doze.ScreenReceiver;
|
||||||
@ -72,7 +71,6 @@ public class MotoActionsService extends IntentService implements ScreenStateNoti
|
|||||||
mScreenStateNotifiers.add(mDozePulseAction);
|
mScreenStateNotifiers.add(mDozePulseAction);
|
||||||
|
|
||||||
// Actionable sensors get screen on/off notifications
|
// Actionable sensors get screen on/off notifications
|
||||||
mScreenStateNotifiers.add(new GlanceSensor(MotoActionsSettings, mSensorHelper, mDozePulseAction));
|
|
||||||
mScreenStateNotifiers.add(new ProximitySensor(MotoActionsSettings, mSensorHelper, mDozePulseAction));
|
mScreenStateNotifiers.add(new ProximitySensor(MotoActionsSettings, mSensorHelper, mDozePulseAction));
|
||||||
mScreenStateNotifiers.add(new StowSensor(MotoActionsSettings, mSensorHelper, mDozePulseAction));
|
mScreenStateNotifiers.add(new StowSensor(MotoActionsSettings, mSensorHelper, mDozePulseAction));
|
||||||
mScreenStateNotifiers.add(new FlatUpSensor(MotoActionsSettings, mSensorHelper, mDozePulseAction));
|
mScreenStateNotifiers.add(new FlatUpSensor(MotoActionsSettings, mSensorHelper, mDozePulseAction));
|
||||||
|
@ -37,8 +37,6 @@ public class SensorHelper {
|
|||||||
private static final int SENSOR_TYPE_MMI_FLAT_UP = 65537;
|
private static final int SENSOR_TYPE_MMI_FLAT_UP = 65537;
|
||||||
private static final int SENSOR_TYPE_MMI_FLAT_DOWN = 65538;
|
private static final int SENSOR_TYPE_MMI_FLAT_DOWN = 65538;
|
||||||
private static final int SENSOR_TYPE_MMI_STOW = 65539;
|
private static final int SENSOR_TYPE_MMI_STOW = 65539;
|
||||||
private static final int SENSOR_TYPE_MMI_GLANCE = 65548;
|
|
||||||
private static final int SENSOR_TYPE_MMI_GLANCE_APPROACH = 65555;
|
|
||||||
|
|
||||||
private static final int BATCH_LATENCY_IN_MS = 100;
|
private static final int BATCH_LATENCY_IN_MS = 100;
|
||||||
|
|
||||||
@ -83,14 +81,6 @@ public class SensorHelper {
|
|||||||
return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_FLAT_DOWN, true);
|
return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_FLAT_DOWN, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sensor getGlanceSensor() {
|
|
||||||
return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_GLANCE, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Sensor getApproachGlanceSensor() {
|
|
||||||
return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_GLANCE_APPROACH, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Sensor getProximitySensor() {
|
public Sensor getProximitySensor() {
|
||||||
return mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true);
|
return mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true);
|
||||||
}
|
}
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017 The LineageOS Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lineageos.settings.device.doze;
|
|
||||||
|
|
||||||
import android.hardware.Sensor;
|
|
||||||
import android.hardware.SensorEvent;
|
|
||||||
import android.hardware.SensorEventListener;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.lineageos.settings.device.MotoActionsSettings;
|
|
||||||
import org.lineageos.settings.device.SensorAction;
|
|
||||||
import org.lineageos.settings.device.SensorHelper;
|
|
||||||
|
|
||||||
public class GlanceSensor implements ScreenStateNotifier {
|
|
||||||
private static final String TAG = "MotoActions-GlanceSensor";
|
|
||||||
|
|
||||||
private final MotoActionsSettings mMotoActionsSettings;
|
|
||||||
private final SensorHelper mSensorHelper;
|
|
||||||
private final SensorAction mSensorAction;
|
|
||||||
|
|
||||||
private final Sensor mSensor;
|
|
||||||
private final Sensor mApproachSensor;
|
|
||||||
|
|
||||||
private boolean mEnabled;
|
|
||||||
|
|
||||||
public GlanceSensor(MotoActionsSettings MotoActionsSettings, SensorHelper sensorHelper,
|
|
||||||
SensorAction action) {
|
|
||||||
mMotoActionsSettings = MotoActionsSettings;
|
|
||||||
mSensorHelper = sensorHelper;
|
|
||||||
mSensorAction = action;
|
|
||||||
|
|
||||||
mSensor = sensorHelper.getGlanceSensor();
|
|
||||||
mApproachSensor = sensorHelper.getApproachGlanceSensor();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void screenTurnedOn() {
|
|
||||||
if (mEnabled) {
|
|
||||||
Log.d(TAG, "Disabling");
|
|
||||||
mSensorHelper.unregisterListener(mGlanceListener);
|
|
||||||
mSensorHelper.unregisterListener(mApproachGlanceListener);
|
|
||||||
mEnabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void screenTurnedOff() {
|
|
||||||
if (mMotoActionsSettings.isPickUpEnabled() && !mEnabled) {
|
|
||||||
Log.d(TAG, "Enabling");
|
|
||||||
mSensorHelper.registerListener(mSensor, mGlanceListener);
|
|
||||||
mSensorHelper.registerListener(mApproachSensor, mApproachGlanceListener);
|
|
||||||
mEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private SensorEventListener mGlanceListener = new SensorEventListener() {
|
|
||||||
@Override
|
|
||||||
public synchronized void onSensorChanged(SensorEvent event) {
|
|
||||||
Log.d(TAG, "Changed");
|
|
||||||
mSensorAction.action();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccuracyChanged(Sensor mSensor, int accuracy) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private SensorEventListener mApproachGlanceListener = new SensorEventListener() {
|
|
||||||
@Override
|
|
||||||
public synchronized void onSensorChanged(SensorEvent event) {
|
|
||||||
Log.d(TAG, "Approach: Changed");
|
|
||||||
mSensorAction.action();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccuracyChanged(Sensor mSensor, int accuracy) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user