MotoActions: Drop camera activation action
authordianlujitao <dianlujitao@lineageos.org>
Fri, 28 Oct 2022 10:38:55 +0000 (18:38 +0800)
committerdianlujitao <dianlujitao@lineageos.org>
Fri, 28 Oct 2022 10:38:55 +0000 (18:38 +0800)
AOSP has exact the same built-in feature.

Change-Id: Ib508cddc74498a3eba507e1b1962c53c7b591e6e

MotoActions/res/drawable/ic_settings_twist.xml [deleted file]
MotoActions/res/xml/actions_panel.xml
MotoActions/src/org/lineageos/settings/device/ActionsPreferenceFragment.java
MotoActions/src/org/lineageos/settings/device/MotoActionsService.java
MotoActions/src/org/lineageos/settings/device/MotoActionsSettings.java
MotoActions/src/org/lineageos/settings/device/SensorHelper.java
MotoActions/src/org/lineageos/settings/device/actions/CameraActivationAction.java [deleted file]
MotoActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java [deleted file]

diff --git a/MotoActions/res/drawable/ic_settings_twist.xml b/MotoActions/res/drawable/ic_settings_twist.xml
deleted file mode 100644 (file)
index f04e77f..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="46.0dip"
-    android:height="46.0dip"
-    android:autoMirrored="true"
-    android:viewportWidth="46.0"
-    android:viewportHeight="46.0">
-    <path android:fillColor="?android:attr/colorAccent" android:pathData="M20,20m-19.5,0a19.5,19.5 0,1 1,39 0a19.5,19.5 0,1 1,-39 0" />
-    <path android:fillColor="#00000000" android:pathData="M20.0003,20.0038m-16.3277,6.4349a17.55,17.55 113.49,1 1,32.6554 -12.8699a17.55,17.55 113.49,1 1,-32.6554 12.8699" android:strokeColor="#ff0bbbef" android:strokeWidth="0.28" android:strokeAlpha="0.0" android:fillAlpha="0.0" />
-    <path android:fillColor="#00000000" android:pathData="M20.0003,20.0062m-6.4349,16.3277a17.55,17.55 66.51,1 1,12.8699 -32.6554a17.55,17.55 66.51,1 1,-12.8699 32.6554" android:strokeColor="#ff0bbbef" android:strokeWidth="0.28" android:strokeAlpha="0.0" android:fillAlpha="0.0" />
-    <path android:fillColor="?android:attr/colorAccent" android:pathData="M14.2,13.79c0.15,-0.13 0.27,-0.17 0.48,0A1.49,1.49 0,0 1,15.23 15a1.55,1.55 0,0 1,-0.27 0.88c-0.48,0.75 -1,1.54 -1.67,2.51a1.71,1.71 0,0 0,-0.35 1,1.36 1.36,0 0,0 0.17,0.64 1.48,1.48 0,0 0,1.41 0.73s-1.68,10.62 -4,10.53a5.17,5.17 0,0 1,-4.75 -4.49c-0.07,-0.7 -0.08,-1.4 -0.08,-2 0,-0.24 0,-0.47 0,-0.71v-0.85a3.42,3.42 0,0 1,1.13 -2.62c2,-1.86 4.07,-3.74 6.07,-5.56Z" />
-    <path android:fillColor="#ffffffff" android:pathData="M4.59,24.73L4.59,24c0,-0.24 0,-0.48 0,-0.72v-0.11a4.56,4.56 0,0 1,1.48 -3.44c2,-1.86 4.08,-3.74 6.07,-5.56L13.46,13a1.4,1.4 0,0 1,1.92 0,2.59 2.59,0 0,1 0.94,2 2.72,2.72 0,0 1,-0.44 1.48c-0.48,0.75 -1,1.55 -1.69,2.53a0.71,0.71 0,0 0,-0.15 0.34,0.25 0.25,0 0,0 0,0.12c0,0.07 0.09,0.15 0.45,0.15 0,0 -1.69,12.81 -4,12.73a6.24,6.24 0,0 1,-5.8 -5.49C4.6,26.09 4.59,25.35 4.59,24.73ZM5.69,23.3L5.69,24c0,0.24 0,0.47 0,0.71 0,0.6 0,1.3 0.08,2a5.17,5.17 0,0 0,4.75 4.49c2.33,0.09 4,-10.53 4,-10.53A1.48,1.48 0,0 1,13.11 20a1.36,1.36 0,0 1,-0.17 -0.64,1.71 1.71,0 0,1 0.35,-1c0.66,-1 1.19,-1.76 1.67,-2.51a1.55,1.55 0,0 0,0.27 -0.88,1.49 1.49,0 0,0 -0.55,-1.17c-0.21,-0.18 -0.33,-0.14 -0.48,0L12.89,15c-2,1.82 -4.05,3.7 -6.07,5.56a3.42,3.42 0,0 0,-1.13 2.62Z" />
-    <path android:fillColor="#ffffffff" android:pathData="M24.49,23.31m-1.05,0a1.05,1.05 0,1 1,2.1 0a1.05,1.05 0,1 1,-2.1 0" />
-    <path android:fillColor="?android:attr/colorAccent" android:pathData="M20,20.22l6.84,-0.29h0.07A1.61,1.61 0,0 1,27 23.15l-10.35,0.44Z" />
-    <path android:fillColor="#ffffffff" android:pathData="M26.94,20.63a0.91,0.91 0,0 1,0 1.82l-7.07,0.3h0l-1.49,0.06 1.91,-1.91 6.57,-0.27h0m0,-1.4h-0.1l-6.57,0.28 -0.54,0 -0.39,0.38 -1.91,1.91L14.9,24.36l3.58,-0.15L20,24.14l7.07,-0.3a2.31,2.31 0,0 0,-0.1 -4.61Z" />
-    <path android:fillColor="#ffffffff" android:pathData="M5.9285,25.595L19.0736,12.4499A2.11,2.11 90,0 1,22.0576 12.4499L27.5094,17.9017A2.11,2.11 90,0 1,27.5094 20.8857L14.3643,34.0308A2.11,2.11 90,0 1,11.3803 34.0308L5.9285,28.579A2.11,2.11 90,0 1,5.9285 25.595z" />
-    <path android:fillColor="?android:attr/colorAccent" android:pathData="M6.6909,26.0646l12.9047,-12.9047l7.1983,7.1983l-12.9047,12.9047z" />
-    <path android:fillColor="?android:attr/colorAccent" android:pathData="M20.11,29.48a1.58,1.58 0,0 1,-1.47 -1A1.6,1.6 0,0 1,19 26.75a1.74,1.74 0,0 1,1.12 -0.49l0.69,-0.06h0.1a1.65,1.65 0,0 1,1.62 1.26,1.62 1.62,0 0,1 -0.3,1.33 1.6,1.6 0,0 1,-1.2 0.63l-0.8,0.06Z" />
-    <path android:fillColor="#ffffffff" android:pathData="M20.89,26.9a1,1 0,0 1,0.94 0.71A0.91,0.91 0,0 1,21 28.72l-0.83,0.07h0a0.9,0.9 0,0 1,-0.63 -1.54,0.93 0.93,0 0,1 0.65,-0.29l0.72,-0.06h0m0,-1.4h-0.16l-0.7,0.06a2.36,2.36 0,0 0,-1.54 0.69,2.3 2.3,0 0,0 1.62,3.92h0.15l0.81,-0.07a2.31,2.31 0,0 0,2.12 -2.8,2.35 2.35,0 0,0 -2.3,-1.81Z" />
-    <path android:fillColor="#ff00a09b" android:pathData="M17.13,32.46A1.6,1.6 0,0 1,16 29.73a1.67,1.67 0,0 1,1.11 -0.49l0.69,-0.06h0.1a1.61,1.61 0,0 1,1.33 2.59,1.62 1.62,0 0,1 -1.21,0.62l-0.8,0.07Z" />
-    <path android:fillColor="#ffffffff" android:pathData="M17.91,29.87a1,1 0,0 1,0.94 0.71A0.92,0.92 0,0 1,18 31.7l-0.82,0.06h-0.05a0.9,0.9 0,0 1,-0.63 -1.54,1 1,0 0,1 0.65,-0.28l0.72,-0.06h0m0,-1.39h-0.16l-0.69,0.06a2.34,2.34 0,0 0,-1.55 0.69,2.3 2.3,0 0,0 1.62,3.92h0.16l0.8,-0.06a2.29,2.29 0,0 0,1.7 -0.9,2.33 2.33,0 0,0 0.42,-1.91 2.35,2.35 0,0 0,-2.3 -1.8Z" />
-    <path android:fillColor="?android:attr/colorAccent" android:pathData="M23.18,26.42a1.6,1.6 0,0 1,-1.13 -2.73,1.67 1.67,0 0,1 1.11,-0.49l0.69,-0.06H24a1.64,1.64 0,0 1,1.62 1.25,1.61 1.61,0 0,1 -0.29,1.34 1.62,1.62 0,0 1,-1.21 0.62l-0.8,0.07Z" />
-    <path android:fillColor="#ffffffff" android:pathData="M24,23.83a0.94,0.94 0,0 1,0.94 0.71A0.92,0.92 0,0 1,24 25.66l-0.82,0.06h0a0.9,0.9 0,0 1,-0.64 -1.54,1 1,0 0,1 0.65,-0.28l0.72,-0.07h0m0,-1.39h-0.16l-0.69,0.06a2.31,2.31 0,0 0,-1.54 0.69,2.3 2.3,0 0,0 1.62,3.92h0.15l0.8,-0.06a2.33,2.33 0,0 0,1.7 -0.9,2.29 2.29,0 0,0 0.42,-1.91 2.34,2.34 0,0 0,-2.3 -1.8Z" />
-    <path android:strokeColor="@color/quick" android:pathData="M29.44,16.46a1,1 0,0 1,-0.53 -0.15A26.91,26.91 0,0 1,24.82 13c-2.7,-2.63 -4.82,-6.46 -3.54,-8 0.74,-0.92 2,-0.79 3.78,0.38A1,1 0,1 1,24 7a5.43,5.43 0,0 0,-1.09 -0.58,11.45 11.45,0 0,0 3.32,5.18 23.86,23.86 0,0 0,3.78 3,1 1,0 0,1 0.3,1.37A1,1 0,0 1,29.44 16.46Z" />
-    <path android:pathData="M34.25,18.78a6.07,6.07 0,0 1,-1.57 -0.23,1 1,0 1,1 0.52,-1.92 3.44,3.44 0,0 0,1.23 0.17c0,-0.55 -0.83,-2.31 -3.33,-5a22.89,22.89 0,0 0,-3.92 -3.41,1 1,0 0,1 1.09,-1.65 24.54,24.54 0,0 1,4.28 3.71c4,4.36 4.18,6.45 3.59,7.43A2,2 0,0 1,34.25 18.78Z" />
-</vector>
index c4ced85a027c8b16e8a153c99b41d144310c3693..edf70564b5ef0bd864b9ec1995586b2ec01ec91a 100644 (file)
     <PreferenceCategory
         android:key="actions_key">
 
-        <SwitchPreference
-            android:key="gesture_camera_action"
-            android:defaultValue="true"
-            android:title="@string/camera_gesture_title"
-            android:summary="@string/camera_gesture_summary"
-            android:icon="@drawable/ic_settings_twist" />
-
         <SwitchPreference
             android:key="gesture_chop_chop"
             android:defaultValue="true"
index ea83bb165523852fd793f0c9dfca02ee6db9cbea..eab7ca45d1af6eeca30b55abebbe359b65452a87 100644 (file)
@@ -23,21 +23,13 @@ import android.view.MenuItem;
 import androidx.preference.PreferenceCategory;
 import androidx.preference.PreferenceFragment;
 
-import org.lineageos.settings.device.actions.CameraActivationSensor;
-
 public class ActionsPreferenceFragment extends PreferenceFragment {
 
     private static final String KEY_ACTIONS_CATEGORY = "actions_key";
-    private static final String KEY_GESTURE_CAMERA_ACTION = "gesture_camera_action";
 
     @Override
     public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
         addPreferencesFromResource(R.xml.actions_panel);
-
-        if (!CameraActivationSensor.hasSensor(getContext())) {
-            PreferenceCategory category = findPreference(KEY_ACTIONS_CATEGORY);
-            category.removePreferenceRecursively(KEY_GESTURE_CAMERA_ACTION);
-        }
     }
 
     @Override
index 95073877cf1e09c9babb3d2e7bbefa887ff187e7..740fd649705d3ce0769bd9dce0a6d887a4cedc4f 100644 (file)
@@ -26,7 +26,6 @@ import android.os.IBinder;
 import android.os.PowerManager;
 import android.util.Log;
 
-import org.lineageos.settings.device.actions.CameraActivationSensor;
 import org.lineageos.settings.device.actions.ChopChopSensor;
 import org.lineageos.settings.device.actions.FlipToMute;
 import org.lineageos.settings.device.actions.LiftToSilence;
@@ -64,7 +63,6 @@ public class MotoActionsService extends Service implements ScreenStateNotifier,
         mScreenStateNotifiers.add(new FlatUpSensor(actionsSettings, sensorHelper, dozePulseAction));
 
         // Other actions that are always enabled
-        mUpdatedStateNotifiers.add(new CameraActivationSensor(actionsSettings, sensorHelper));
         mUpdatedStateNotifiers.add(new ChopChopSensor(actionsSettings, sensorHelper));
         mUpdatedStateNotifiers.add(new ProximitySilencer(actionsSettings, this, sensorHelper));
         mUpdatedStateNotifiers.add(new FlipToMute(actionsSettings, this, sensorHelper));
index 5f654fd73ef45d3a841a70047066288e01d38436..fcd05b06d15c876acdf0be5a646b686e3be452a9 100644 (file)
@@ -28,12 +28,10 @@ import android.provider.Settings;
 
 import androidx.preference.PreferenceManager;
 
-import org.lineageos.settings.device.actions.CameraActivationAction;
 import org.lineageos.settings.device.actions.TorchAction;
 import org.lineageos.settings.device.actions.UpdatedStateNotifier;
 
 public class MotoActionsSettings {
-    private static final String GESTURE_CAMERA_ACTION_KEY = "gesture_camera_action";
     private static final String GESTURE_CHOP_CHOP_KEY = "gesture_chop_chop";
     private static final String GESTURE_IR_SILENCER_KEY = "gesture_ir_silencer";
     private static final String GESTURE_FLIP_TO_MUTE_KEY = "gesture_flip_to_mute";
@@ -49,7 +47,6 @@ public class MotoActionsSettings {
     private final Context mContext;
     private final UpdatedStateNotifier mUpdatedStateNotifier;
 
-    private boolean mCameraGestureEnabled;
     private boolean mChopChopEnabled;
     private boolean mPickUpGestureEnabled;
     private boolean mPocketGestureEnabled;
@@ -66,10 +63,6 @@ public class MotoActionsSettings {
         mUpdatedStateNotifier = updatedStateNotifier;
     }
 
-    public boolean isCameraGestureEnabled() {
-        return mCameraGestureEnabled;
-    }
-
     public boolean isChopChopGestureEnabled() {
         return mChopChopEnabled;
     }
@@ -130,16 +123,11 @@ public class MotoActionsSettings {
         return mLiftToSilenceEnabled;
     }
 
-    public void cameraAction() {
-        new CameraActivationAction(mContext).action();
-    }
-
     public void chopChopAction() {
         new TorchAction(mContext).action();
     }
 
     private void loadPreferences(SharedPreferences sharedPreferences) {
-        mCameraGestureEnabled = sharedPreferences.getBoolean(GESTURE_CAMERA_ACTION_KEY, true);
         mChopChopEnabled = sharedPreferences.getBoolean(GESTURE_CHOP_CHOP_KEY, true);
         mIrWakeUpEnabled = sharedPreferences.getBoolean(GESTURE_IR_WAKEUP_KEY, true);
         mPickUpGestureEnabled = sharedPreferences.getBoolean(GESTURE_PICK_UP_KEY, true);
@@ -155,9 +143,7 @@ public class MotoActionsSettings {
                 public void onSharedPreferenceChanged(SharedPreferences sharedPrefs, String key) {
                     boolean updated = true;
 
-                    if (GESTURE_CAMERA_ACTION_KEY.equals(key)) {
-                        mCameraGestureEnabled = sharedPrefs.getBoolean(GESTURE_CAMERA_ACTION_KEY, true);
-                    } else if (GESTURE_CHOP_CHOP_KEY.equals(key)) {
+                    if (GESTURE_CHOP_CHOP_KEY.equals(key)) {
                         mChopChopEnabled = sharedPrefs.getBoolean(GESTURE_CHOP_CHOP_KEY, true);
                     } else if (GESTURE_IR_WAKEUP_KEY.equals(key)) {
                         mIrWakeUpEnabled = sharedPrefs.getBoolean(GESTURE_IR_WAKEUP_KEY, true);
index a4d2a3322f32f7b9e0a4749360fd3324aa2eec06..3457bd31c1a9ca9bec3159047f0af49f13bb5f2c 100644 (file)
@@ -31,7 +31,6 @@ import java.util.List;
 public class SensorHelper {
     private static final String TAG = "MotoActions";
 
-    private static final int SENSOR_TYPE_MMI_CAMERA_ACTIVATION = 65540;
     private static final int SENSOR_TYPE_MMI_CHOP_CHOP = 65546;
     private static final int SENSOR_TYPE_MMI_FLAT_UP = 65537;
     private static final int SENSOR_TYPE_MMI_FLAT_DOWN = 65538;
@@ -65,10 +64,6 @@ public class SensorHelper {
         }
     }
 
-    public Sensor getCameraActivationSensor() {
-        return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_CAMERA_ACTIVATION, true);
-    }
-
     public Sensor getChopChopSensor() {
         return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_CHOP_CHOP, true);
     }
diff --git a/MotoActions/src/org/lineageos/settings/device/actions/CameraActivationAction.java b/MotoActions/src/org/lineageos/settings/device/actions/CameraActivationAction.java
deleted file mode 100644 (file)
index d8ab174..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2015 The CyanogenMod Project
- * Copyright (c) 2017-2022 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.actions;
-
-import android.app.KeyguardManager;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.os.PowerManager;
-import android.os.UserHandle;
-import android.os.VibrationEffect;
-import android.os.Vibrator;
-import android.provider.MediaStore;
-
-import org.lineageos.settings.device.SensorAction;
-
-import java.util.List;
-
-public class CameraActivationAction implements SensorAction {
-    private static final String TAG = "CameraActivationAction";
-
-    private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
-
-    private final Context mContext;
-    private final KeyguardManager mKeyguardManager;
-    private final PackageManager mPackageManager;
-    private final PowerManager mPowerManager;
-    private final PowerManager.WakeLock mScreenWakelock;
-
-    public CameraActivationAction(Context context) {
-        mContext = context;
-        mKeyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
-        mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
-        mPackageManager = context.getPackageManager();
-        mScreenWakelock = mPowerManager.newWakeLock(
-                PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
-                TAG + ":Wakelock");
-    }
-
-    @Override
-    public void action() {
-        vibrate();
-        turnScreenOn();
-        if (mKeyguardManager.inKeyguardRestrictedInputMode()) {
-            launchSecureCamera();
-        } else {
-            launchCamera();
-        }
-    }
-
-    private void vibrate() {
-        Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
-        v.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE));
-    }
-
-    private void turnScreenOn() {
-        mScreenWakelock.acquire(TURN_SCREEN_ON_WAKE_LOCK_MS);
-    }
-
-    private void launchCamera() {
-        Intent intent = createIntent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
-        if (getBestActivityInfo(intent) != null) {
-            // Only launch if we can succeed, but let the user pick the action
-            mContext.startActivityAsUser(intent, UserHandle.CURRENT);
-        }
-    }
-
-    private void launchSecureCamera() {
-        // Keyguard won't allow a picker, try to pick the secure intent in the package
-        // that would be the one used for a default action of launching the camera
-        Intent normalIntent = createIntent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
-        Intent secureIntent = createIntent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE);
-        ActivityInfo normalActivity = getBestActivityInfo(normalIntent);
-        ActivityInfo secureActivity = getBestActivityInfo(secureIntent, normalActivity);
-        if (secureActivity != null) {
-            secureIntent.setComponent(componentName(secureActivity));
-            mContext.startActivityAsUser(secureIntent, UserHandle.CURRENT);
-        }
-    }
-
-    private Intent createIntent(String intentName) {
-        Intent intent = new Intent(intentName);
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
-        return intent;
-    }
-
-    private ActivityInfo getBestActivityInfo(Intent intent) {
-        ResolveInfo resolveInfo = mPackageManager.resolveActivity(intent, 0);
-        if (resolveInfo != null) {
-            return resolveInfo.activityInfo;
-        } else {
-            // If the resolving failed, just find our own best match
-            return getBestActivityInfo(intent, null);
-        }
-    }
-
-    private ActivityInfo getBestActivityInfo(Intent intent, ActivityInfo match) {
-        List<ResolveInfo> activities = mPackageManager.queryIntentActivities(intent, 0);
-        ActivityInfo best = null;
-        if (activities.size() > 0) {
-            best = activities.get(0).activityInfo;
-            if (match != null) {
-                String packageName = match.applicationInfo.packageName;
-                for (int i = activities.size() - 1; i >= 0; i--) {
-                    ActivityInfo activityInfo = activities.get(i).activityInfo;
-                    if (packageName.equals(activityInfo.applicationInfo.packageName)) {
-                        best = activityInfo;
-                    }
-                }
-            }
-        }
-        return best;
-    }
-
-    private ComponentName componentName(ActivityInfo activity) {
-        return new ComponentName(activity.applicationInfo.packageName, activity.name);
-    }
-}
diff --git a/MotoActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java b/MotoActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java
deleted file mode 100644 (file)
index 847777c..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2015 The CyanogenMod Project
- * Copyright (c) 2017-2022 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.actions;
-
-import android.content.Context;
-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.SensorHelper;
-
-public class CameraActivationSensor implements SensorEventListener, UpdatedStateNotifier {
-    private static final String TAG = "MotoActions-CameraSensor";
-
-    private final MotoActionsSettings mMotoActionsSettings;
-
-    private boolean mIsEnabled;
-
-    public CameraActivationSensor(MotoActionsSettings motoActionsSettings,
-                                  SensorHelper sensorHelper) {
-        mMotoActionsSettings = motoActionsSettings;
-        Sensor sensor = sensorHelper.getCameraActivationSensor();
-        sensorHelper.registerListener(sensor, this);
-    }
-
-    @Override
-    public synchronized void updateState() {
-        if (mMotoActionsSettings.isCameraGestureEnabled() && !mIsEnabled) {
-            Log.d(TAG, "Enabling");
-            mIsEnabled = true;
-        } else if (!mMotoActionsSettings.isCameraGestureEnabled() && mIsEnabled) {
-            Log.d(TAG, "Disabling");
-            mIsEnabled = false;
-        }
-    }
-
-    @Override
-    public void onSensorChanged(SensorEvent event) {
-        Log.d(TAG, "activate camera");
-        if (mIsEnabled) {
-            mMotoActionsSettings.cameraAction();
-        }
-    }
-
-    @Override
-    public void onAccuracyChanged(Sensor sensor, int accuracy) {
-    }
-
-    public static boolean hasSensor(Context context) {
-        SensorHelper sensorHelper = new SensorHelper(context);
-        return sensorHelper.getCameraActivationSensor() != null;
-    }
-}