MotoActions: Drop glance sensor for doze
authordianlujitao <dianlujitao@lineageos.org>
Wed, 2 Feb 2022 05:33:05 +0000 (13:33 +0800)
committerNolen Johnson <johnsonnolen@gmail.com>
Sun, 13 Feb 2022 04:27:54 +0000 (23:27 -0500)
 * 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

MotoActions/src/org/lineageos/settings/device/MotoActionsService.java
MotoActions/src/org/lineageos/settings/device/SensorHelper.java
MotoActions/src/org/lineageos/settings/device/doze/GlanceSensor.java [deleted file]

index 47427017b4fb72cc3394f6970806f28d4e0aebd5..3f8de813d016e4fdbe75b4826d4d38c2fc64de20 100644 (file)
@@ -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));
index 5d08a93f142fda17c03388e4ea2d98cbbbdc35f7..9ba0d993ef29cb5f65c37ce08864af95aa0d258b 100644 (file)
@@ -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 (file)
index db63c15..0000000
+++ /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) {
-        }
-    };
-}