From 72312f447cacdc181b9972005feac27aea00eb55 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Wed, 2 Feb 2022 13:33:05 +0800 Subject: [PATCH] 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 --- .../settings/device/MotoActionsService.java | 2 - .../settings/device/SensorHelper.java | 10 -- .../settings/device/doze/GlanceSensor.java | 93 ------------------- 3 files changed, 105 deletions(-) delete mode 100644 MotoActions/src/org/lineageos/settings/device/doze/GlanceSensor.java diff --git a/MotoActions/src/org/lineageos/settings/device/MotoActionsService.java b/MotoActions/src/org/lineageos/settings/device/MotoActionsService.java index 4742701..3f8de81 100644 --- a/MotoActions/src/org/lineageos/settings/device/MotoActionsService.java +++ b/MotoActions/src/org/lineageos/settings/device/MotoActionsService.java @@ -35,7 +35,6 @@ import org.lineageos.settings.device.actions.LiftToSilence; import org.lineageos.settings.device.actions.ProximitySilencer; 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.FlatUpSensor; import org.lineageos.settings.device.doze.ScreenReceiver; @@ -72,7 +71,6 @@ public class MotoActionsService extends IntentService implements ScreenStateNoti mScreenStateNotifiers.add(mDozePulseAction); // Actionable sensors get screen on/off notifications - mScreenStateNotifiers.add(new GlanceSensor(MotoActionsSettings, mSensorHelper, mDozePulseAction)); mScreenStateNotifiers.add(new ProximitySensor(MotoActionsSettings, mSensorHelper, mDozePulseAction)); mScreenStateNotifiers.add(new StowSensor(MotoActionsSettings, mSensorHelper, mDozePulseAction)); mScreenStateNotifiers.add(new FlatUpSensor(MotoActionsSettings, mSensorHelper, mDozePulseAction)); diff --git a/MotoActions/src/org/lineageos/settings/device/SensorHelper.java b/MotoActions/src/org/lineageos/settings/device/SensorHelper.java index 5d08a93..9ba0d99 100644 --- a/MotoActions/src/org/lineageos/settings/device/SensorHelper.java +++ b/MotoActions/src/org/lineageos/settings/device/SensorHelper.java @@ -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_DOWN = 65538; 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; @@ -83,14 +81,6 @@ public class SensorHelper { 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() { return mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true); } diff --git a/MotoActions/src/org/lineageos/settings/device/doze/GlanceSensor.java b/MotoActions/src/org/lineageos/settings/device/doze/GlanceSensor.java deleted file mode 100644 index db63c15..0000000 --- a/MotoActions/src/org/lineageos/settings/device/doze/GlanceSensor.java +++ /dev/null @@ -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) { - } - }; -} -- 2.20.1