From 9910e9f435311d9df069705c5f69e66074c2bf91 Mon Sep 17 00:00:00 2001 From: chirayu19091997 Date: Sat, 15 Dec 2018 14:27:53 +0000 Subject: [PATCH] sanders: BRINGUP A NEW LINEAGE TREE Signed-off-by: ronaxdevil --- BoardConfig.mk | 3 + {MotoActions => LineageActions}/Android.mk | 14 +- .../AndroidManifest.xml | 31 +-- .../res/drawable/ic_gesture.png | Bin .../res/drawable/ic_settings_doze.xml | 0 .../res/drawable/ic_settings_fingerprint.xml | 0 .../res/drawable/ic_settings_gestures.xml | 0 .../ic_settings_screen_off_gestures.xml | 0 .../res/drawable/switchbar_background.xml | 0 .../res/layout/doze.xml | 0 .../res/layout/fp_gesture.xml | 0 .../res/layout/switch_bar.xml | 2 +- .../res/values-pt-rBR/strings.xml | 3 + .../res/values/array.xml | 0 .../res/values/strings.xml | 4 + .../res/values/styles.xml | 28 +-- .../res/xml/actions_panel.xml | 0 .../res/xml/doze_panel.xml | 2 +- .../res/xml/doze_panel_indexable.xml | 0 .../res/xml/fp_gesture_panel.xml | 7 + .../res/xml/fp_gesture_panel_indexable.xml | 0 .../res/xml/main_panel.xml | 22 ++- .../res/xml/screen_off_gesture_panel.xml | 5 + .../screen_off_gesture_panel_indexable.xml | 0 .../device}/ActionsPreferenceActivity.java | 10 +- .../device}/ActionsPreferenceFragment.java | 7 +- .../device}/BootCompletedReceiver.java | 27 ++- .../device}/DozeSettingsActivity.java | 12 +- .../device}/DozeSettingsFragment.java | 17 +- .../device}/FPGestureSettingsActivity.java | 10 +- .../device}/FPGestureSettingsFragment.java | 16 +- .../device}/GestureSettingsActivity.java | 9 +- .../device}/GestureSettingsFragment.java | 8 +- .../settings/device}/KeyHandler.java | 185 +++++++++++++++++- ...ineageActionsSearchIndexablesProvider.java | 15 +- .../device/LineageActionsService.java | 69 ++++--- .../device/LineageActionsSettings.java | 30 +-- .../ScreenOffGestureSettingsActivity.java | 32 +++ .../ScreenOffGestureSettingsFragment.java | 79 ++++++++ .../settings/device}/SensorAction.java | 4 +- .../settings/device}/SensorHelper.java | 24 ++- .../settings/device}/ServiceWrapper.java | 8 +- .../actions/CameraActivationAction.java | 25 ++- .../actions/CameraActivationSensor.java | 33 ++-- .../device}/actions/ChopChopSensor.java | 25 ++- .../settings/device}/actions/Constants.java | 67 ++++++- .../settings/device}/actions/FlipToMute.java | 37 +--- .../device}/actions/LiftToSilence.java | 16 +- .../device}/actions/ProximitySilencer.java | 26 +-- .../settings/device}/actions/TorchAction.java | 24 ++- .../device}/actions/UpdatedStateNotifier.java | 4 +- .../device}/doze/DozePulseAction.java | 8 +- .../device}/doze/ProximitySensor.java | 18 +- .../settings/device}/doze/ScreenReceiver.java | 6 +- .../device}/doze/ScreenStateNotifier.java | 6 +- .../settings/device/doze/StowSensor.java | 91 +++++++++ .../settings/device}/util/FileUtils.java | 2 +- .../ic_settings_gestures_dashboard.xml | 28 --- .../preference_category_material_settings.xml | 66 ------- .../layout/preference_material_settings.xml | 86 -------- .../com/moto/actions/doze/GlanceSensor.java | 76 ------- device.mk | 7 +- .../base/core/res/res/values/config.xml | 46 +++++ .../lineage/res/res/values/config.xml | 69 +++++++ .../dialer/callrecord}/res/values/config.xml | 18 +- .../base/core/res/res/values/config.xml | 155 +++++++-------- .../base/core/res/res/xml/power_profile.xml | 79 ++++---- .../packages/apps/Snap/res/values/config.xml | 4 + 68 files changed, 1035 insertions(+), 670 deletions(-) rename {MotoActions => LineageActions}/Android.mk (54%) rename {MotoActions => LineageActions}/AndroidManifest.xml (78%) rename {MotoActions => LineageActions}/res/drawable/ic_gesture.png (100%) rename {MotoActions => LineageActions}/res/drawable/ic_settings_doze.xml (100%) rename {MotoActions => LineageActions}/res/drawable/ic_settings_fingerprint.xml (100%) rename {MotoActions => LineageActions}/res/drawable/ic_settings_gestures.xml (100%) rename {MotoActions => LineageActions}/res/drawable/ic_settings_screen_off_gestures.xml (100%) rename {MotoActions => LineageActions}/res/drawable/switchbar_background.xml (100%) rename {MotoActions => LineageActions}/res/layout/doze.xml (100%) rename {MotoActions => LineageActions}/res/layout/fp_gesture.xml (100%) rename {MotoActions => LineageActions}/res/layout/switch_bar.xml (96%) rename {MotoActions => LineageActions}/res/values-pt-rBR/strings.xml (95%) rename {MotoActions => LineageActions}/res/values/array.xml (100%) rename {MotoActions => LineageActions}/res/values/strings.xml (95%) rename {MotoActions => LineageActions}/res/values/styles.xml (52%) rename {MotoActions => LineageActions}/res/xml/actions_panel.xml (100%) rename {MotoActions => LineageActions}/res/xml/doze_panel.xml (97%) rename {MotoActions => LineageActions}/res/xml/doze_panel_indexable.xml (100%) rename {MotoActions => LineageActions}/res/xml/fp_gesture_panel.xml (95%) rename {MotoActions => LineageActions}/res/xml/fp_gesture_panel_indexable.xml (100%) rename {MotoActions => LineageActions}/res/xml/main_panel.xml (63%) rename {MotoActions => LineageActions}/res/xml/screen_off_gesture_panel.xml (93%) rename {MotoActions => LineageActions}/res/xml/screen_off_gesture_panel_indexable.xml (100%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/ActionsPreferenceActivity.java (88%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/ActionsPreferenceFragment.java (79%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/BootCompletedReceiver.java (71%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/DozeSettingsActivity.java (73%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/DozeSettingsFragment.java (83%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/FPGestureSettingsActivity.java (83%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/FPGestureSettingsFragment.java (89%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/GestureSettingsActivity.java (88%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/GestureSettingsFragment.java (79%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/KeyHandler.java (77%) rename MotoActions/src/com/moto/actions/MotoActionsSearchIndexablesProvider.java => LineageActions/src/org/lineageos/settings/device/LineageActionsSearchIndexablesProvider.java (83%) rename MotoActions/src/com/moto/actions/MotoActionsService.java => LineageActions/src/org/lineageos/settings/device/LineageActionsService.java (51%) rename MotoActions/src/com/moto/actions/MotoActionsSettings.java => LineageActions/src/org/lineageos/settings/device/LineageActionsSettings.java (81%) create mode 100644 LineageActions/src/org/lineageos/settings/device/ScreenOffGestureSettingsActivity.java create mode 100644 LineageActions/src/org/lineageos/settings/device/ScreenOffGestureSettingsFragment.java rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/SensorAction.java (91%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/SensorHelper.java (83%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/ServiceWrapper.java (87%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/actions/CameraActivationAction.java (88%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/actions/CameraActivationSensor.java (56%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/actions/ChopChopSensor.java (74%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/actions/Constants.java (72%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/actions/FlipToMute.java (77%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/actions/LiftToSilence.java (87%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/actions/ProximitySilencer.java (81%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/actions/TorchAction.java (82%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/actions/UpdatedStateNotifier.java (89%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/doze/DozePulseAction.java (89%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/doze/ProximitySensor.java (77%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/doze/ScreenReceiver.java (92%) rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/doze/ScreenStateNotifier.java (86%) create mode 100644 LineageActions/src/org/lineageos/settings/device/doze/StowSensor.java rename {MotoActions/src/com/moto/actions => LineageActions/src/org/lineageos/settings/device}/util/FileUtils.java (98%) delete mode 100644 MotoActions/res/drawable/ic_settings_gestures_dashboard.xml delete mode 100644 MotoActions/res/layout/preference_category_material_settings.xml delete mode 100644 MotoActions/res/layout/preference_material_settings.xml delete mode 100644 MotoActions/src/com/moto/actions/doze/GlanceSensor.java create mode 100644 overlay-lineage/frameworks/base/core/res/res/values/config.xml create mode 100644 overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml rename {overlay/packages/apps/Settings => overlay-lineage/packages/apps/Dialer/java/com/android/dialer/callrecord}/res/values/config.xml (65%) diff --git a/BoardConfig.mk b/BoardConfig.mk index 5743097..1453032 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -241,3 +241,6 @@ WIFI_DRIVER_FW_PATH_AP := "ap" WIFI_DRIVER_FW_PATH_STA := "sta" WIFI_DRIVER_FW_PATH_P2P := "p2p" WPA_SUPPLICANT_VERSION := VER_0_8_X + +# Security patch level +VENDOR_SECURITY_PATCH := 2018-11-5 diff --git a/MotoActions/Android.mk b/LineageActions/Android.mk similarity index 54% rename from MotoActions/Android.mk rename to LineageActions/Android.mk index b301a7c..f474d46 100644 --- a/MotoActions/Android.mk +++ b/LineageActions/Android.mk @@ -5,20 +5,30 @@ LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-java-files-under, src) -LOCAL_PACKAGE_NAME := MotoActions +LOCAL_PACKAGE_NAME := LineageActions LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := true LOCAL_USE_AAPT2 := true +LOCAL_STATIC_JAVA_LIBRARIES := \ + android-support-v14-preference \ + android-support-v7-appcompat \ + android-support-v7-preference \ + android-support-v7-recyclerview \ + org.lineageos.platform.internal + LOCAL_PROGUARD_FLAG_FILES := proguard.flags LOCAL_RESOURCE_DIR := \ $(LOCAL_PATH)/res \ - $(TOP)/packages/resources/devicesettings/res + $(LOCAL_PATH)/../../../../packages/resources/devicesettings/res \ LOCAL_PROGUARD_ENABLED := disabled +LOCAL_DEX_PREOPT := false include frameworks/base/packages/SettingsLib/common.mk include $(BUILD_PACKAGE) + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/MotoActions/AndroidManifest.xml b/LineageActions/AndroidManifest.xml similarity index 78% rename from MotoActions/AndroidManifest.xml rename to LineageActions/AndroidManifest.xml index 3e0f13b..d8bc98d 100644 --- a/MotoActions/AndroidManifest.xml +++ b/LineageActions/AndroidManifest.xml @@ -1,13 +1,12 @@ - @@ -15,6 +14,10 @@ + + - + @@ -49,9 +52,9 @@ + android:theme="@style/LineageActions"> - + @@ -60,7 +63,7 @@ android:name=".ActionsPreferenceActivity" android:label="@string/moto_actions_title" android:summary="@string/device_gestures_summary" - android:theme="@style/MotoActions"> + android:theme="@style/LineageActions"> @@ -69,7 +72,7 @@ android:value="com.android.settings.category.ia.homepage" /> + android:resource="@drawable/ic_settings_gestures" /> @@ -78,13 +81,19 @@ + android:theme="@style/LineageActions"> + android:theme="@style/LineageActions"> + + + diff --git a/MotoActions/res/drawable/ic_gesture.png b/LineageActions/res/drawable/ic_gesture.png similarity index 100% rename from MotoActions/res/drawable/ic_gesture.png rename to LineageActions/res/drawable/ic_gesture.png diff --git a/MotoActions/res/drawable/ic_settings_doze.xml b/LineageActions/res/drawable/ic_settings_doze.xml similarity index 100% rename from MotoActions/res/drawable/ic_settings_doze.xml rename to LineageActions/res/drawable/ic_settings_doze.xml diff --git a/MotoActions/res/drawable/ic_settings_fingerprint.xml b/LineageActions/res/drawable/ic_settings_fingerprint.xml similarity index 100% rename from MotoActions/res/drawable/ic_settings_fingerprint.xml rename to LineageActions/res/drawable/ic_settings_fingerprint.xml diff --git a/MotoActions/res/drawable/ic_settings_gestures.xml b/LineageActions/res/drawable/ic_settings_gestures.xml similarity index 100% rename from MotoActions/res/drawable/ic_settings_gestures.xml rename to LineageActions/res/drawable/ic_settings_gestures.xml diff --git a/MotoActions/res/drawable/ic_settings_screen_off_gestures.xml b/LineageActions/res/drawable/ic_settings_screen_off_gestures.xml similarity index 100% rename from MotoActions/res/drawable/ic_settings_screen_off_gestures.xml rename to LineageActions/res/drawable/ic_settings_screen_off_gestures.xml diff --git a/MotoActions/res/drawable/switchbar_background.xml b/LineageActions/res/drawable/switchbar_background.xml similarity index 100% rename from MotoActions/res/drawable/switchbar_background.xml rename to LineageActions/res/drawable/switchbar_background.xml diff --git a/MotoActions/res/layout/doze.xml b/LineageActions/res/layout/doze.xml similarity index 100% rename from MotoActions/res/layout/doze.xml rename to LineageActions/res/layout/doze.xml diff --git a/MotoActions/res/layout/fp_gesture.xml b/LineageActions/res/layout/fp_gesture.xml similarity index 100% rename from MotoActions/res/layout/fp_gesture.xml rename to LineageActions/res/layout/fp_gesture.xml diff --git a/MotoActions/res/layout/switch_bar.xml b/LineageActions/res/layout/switch_bar.xml similarity index 96% rename from MotoActions/res/layout/switch_bar.xml rename to LineageActions/res/layout/switch_bar.xml index 408d8f0..201920b 100644 --- a/MotoActions/res/layout/switch_bar.xml +++ b/LineageActions/res/layout/switch_bar.xml @@ -43,6 +43,6 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:background="@null" - android:theme="@style/MotoActions.SwitchBar" /> + android:theme="@style/LineageActions.SwitchBar" /> diff --git a/MotoActions/res/values-pt-rBR/strings.xml b/LineageActions/res/values-pt-rBR/strings.xml similarity index 95% rename from MotoActions/res/values-pt-rBR/strings.xml rename to LineageActions/res/values-pt-rBR/strings.xml index 294b6ac..f9b4ee7 100644 --- a/MotoActions/res/values-pt-rBR/strings.xml +++ b/LineageActions/res/values-pt-rBR/strings.xml @@ -89,4 +89,7 @@ Retorno tátil Vibrar quando um gesto for detectado + + Habilitar o sensor de proximidade + Verificar o sensor de proximidade antes de executar a ação diff --git a/MotoActions/res/values/array.xml b/LineageActions/res/values/array.xml similarity index 100% rename from MotoActions/res/values/array.xml rename to LineageActions/res/values/array.xml diff --git a/MotoActions/res/values/strings.xml b/LineageActions/res/values/strings.xml similarity index 95% rename from MotoActions/res/values/strings.xml rename to LineageActions/res/values/strings.xml index c2191d8..74b9774 100644 --- a/MotoActions/res/values/strings.xml +++ b/LineageActions/res/values/strings.xml @@ -89,4 +89,8 @@ Haptic feedback Vibrate when a touchscreen gesture is detected + + Allow proximity sensor + Check the proximity sensor before performing the action + diff --git a/MotoActions/res/values/styles.xml b/LineageActions/res/values/styles.xml similarity index 52% rename from MotoActions/res/values/styles.xml rename to LineageActions/res/values/styles.xml index 5fe26b1..561c0b2 100644 --- a/MotoActions/res/values/styles.xml +++ b/LineageActions/res/values/styles.xml @@ -17,42 +17,42 @@ --> - - - - - - - - diff --git a/MotoActions/res/xml/actions_panel.xml b/LineageActions/res/xml/actions_panel.xml similarity index 100% rename from MotoActions/res/xml/actions_panel.xml rename to LineageActions/res/xml/actions_panel.xml diff --git a/MotoActions/res/xml/doze_panel.xml b/LineageActions/res/xml/doze_panel.xml similarity index 97% rename from MotoActions/res/xml/doze_panel.xml rename to LineageActions/res/xml/doze_panel.xml index a59085a..6363b99 100644 --- a/MotoActions/res/xml/doze_panel.xml +++ b/LineageActions/res/xml/doze_panel.xml @@ -25,7 +25,7 @@ diff --git a/MotoActions/res/xml/doze_panel_indexable.xml b/LineageActions/res/xml/doze_panel_indexable.xml similarity index 100% rename from MotoActions/res/xml/doze_panel_indexable.xml rename to LineageActions/res/xml/doze_panel_indexable.xml diff --git a/MotoActions/res/xml/fp_gesture_panel.xml b/LineageActions/res/xml/fp_gesture_panel.xml similarity index 95% rename from MotoActions/res/xml/fp_gesture_panel.xml rename to LineageActions/res/xml/fp_gesture_panel.xml index 2302d0d..499dd1b 100644 --- a/MotoActions/res/xml/fp_gesture_panel.xml +++ b/LineageActions/res/xml/fp_gesture_panel.xml @@ -89,6 +89,13 @@ android:title="@string/haptic_feedback" android:summary="@string/haptic_feedback_summary" /> + + + android:targetPackage="org.lineageos.settings.device" + android:targetClass="org.lineageos.settings.device.GestureSettingsActivity" /> + android:targetPackage="org.lineageos.settings.device" + android:targetClass="org.lineageos.settings.device.DozeSettingsActivity" /> + android:targetPackage="org.lineageos.settings.device" + android:targetClass="org.lineageos.settings.device.FPGestureSettingsActivity" /> + + + + diff --git a/MotoActions/res/xml/screen_off_gesture_panel.xml b/LineageActions/res/xml/screen_off_gesture_panel.xml similarity index 93% rename from MotoActions/res/xml/screen_off_gesture_panel.xml rename to LineageActions/res/xml/screen_off_gesture_panel.xml index f73d272..f4055e1 100644 --- a/MotoActions/res/xml/screen_off_gesture_panel.xml +++ b/LineageActions/res/xml/screen_off_gesture_panel.xml @@ -28,6 +28,11 @@ android:title="@string/haptic_feedback" android:summary="@string/haptic_feedback_summary" /> + + mScreenStateNotifiers = new LinkedList<>(); - private final List mUpdatedStateNotifiers = new LinkedList<>(); + private final List mScreenStateNotifiers = new LinkedList(); + private final List mUpdatedStateNotifiers = + new LinkedList(); - public MotoActionsService(Context context) { - super("MotoActionService"); + public LineageActionsService(Context context) { + super("LineageActionService"); + mContext = context; Log.d(TAG, "Starting"); - MotoActionsSettings motoActionsSettings = new MotoActionsSettings(context, this); - SensorHelper sensorHelper = new SensorHelper(context); - new ScreenReceiver(context, this); + LineageActionsSettings lineageActionsSettings = new LineageActionsSettings(context, this); + mSensorHelper = new SensorHelper(context); + mScreenReceiver = new ScreenReceiver(context, this); - DozePulseAction mDozePulseAction = new DozePulseAction(context); + mDozePulseAction = new DozePulseAction(context); mScreenStateNotifiers.add(mDozePulseAction); // Actionable sensors get screen on/off notifications - mScreenStateNotifiers.add(new GlanceSensor(motoActionsSettings, sensorHelper, mDozePulseAction)); - mScreenStateNotifiers.add(new ProximitySensor(motoActionsSettings, sensorHelper, mDozePulseAction)); + mScreenStateNotifiers.add(new ProximitySensor(lineageActionsSettings, mSensorHelper, mDozePulseAction)); + mScreenStateNotifiers.add(new StowSensor(lineageActionsSettings, mSensorHelper, mDozePulseAction)); // Other actions that are always enabled - mUpdatedStateNotifiers.add(new CameraActivationSensor(motoActionsSettings, sensorHelper)); - mUpdatedStateNotifiers.add(new ChopChopSensor(motoActionsSettings, sensorHelper)); - mUpdatedStateNotifiers.add(new ProximitySilencer(motoActionsSettings, context, sensorHelper)); - mUpdatedStateNotifiers.add(new FlipToMute(motoActionsSettings, context, sensorHelper)); - mUpdatedStateNotifiers.add(new LiftToSilence(motoActionsSettings, context, sensorHelper)); + mUpdatedStateNotifiers.add(new CameraActivationSensor(lineageActionsSettings, mSensorHelper)); + mUpdatedStateNotifiers.add(new ChopChopSensor(lineageActionsSettings, mSensorHelper)); + mUpdatedStateNotifiers.add(new ProximitySilencer(lineageActionsSettings, context, mSensorHelper)); + mUpdatedStateNotifiers.add(new FlipToMute(lineageActionsSettings, context, mSensorHelper)); + mUpdatedStateNotifiers.add(new LiftToSilence(lineageActionsSettings, context, mSensorHelper)); mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); - String tag = context.getPackageName() + ":ServiceWakeLock"; - mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, tag); + mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "LineageActionsWakeLock"); updateState(); } diff --git a/MotoActions/src/com/moto/actions/MotoActionsSettings.java b/LineageActions/src/org/lineageos/settings/device/LineageActionsSettings.java similarity index 81% rename from MotoActions/src/com/moto/actions/MotoActionsSettings.java rename to LineageActions/src/org/lineageos/settings/device/LineageActionsSettings.java index af40fba..a64cffe 100644 --- a/MotoActions/src/com/moto/actions/MotoActionsSettings.java +++ b/LineageActions/src/org/lineageos/settings/device/LineageActionsSettings.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.moto.actions; +package org.lineageos.settings.device; import android.content.ContentResolver; import android.content.Context; @@ -25,13 +25,13 @@ import android.provider.Settings; import android.util.Log; -import com.moto.actions.actions.Constants; -import com.moto.actions.actions.UpdatedStateNotifier; -import com.moto.actions.actions.CameraActivationAction; -import com.moto.actions.actions.TorchAction; +import org.lineageos.settings.device.actions.Constants; +import org.lineageos.settings.device.actions.UpdatedStateNotifier; +import org.lineageos.settings.device.actions.CameraActivationAction; +import org.lineageos.settings.device.actions.TorchAction; -public class MotoActionsSettings implements SharedPreferences.OnSharedPreferenceChangeListener { - private static final String TAG = "MotoActions"; +public class LineageActionsSettings { + private static final String TAG = "LineageActions"; private static final String GESTURE_CAMERA_ACTION_KEY = "gesture_camera_action"; private static final String GESTURE_CHOP_CHOP_KEY = "gesture_chop_chop"; @@ -52,10 +52,10 @@ public class MotoActionsSettings implements SharedPreferences.OnSharedPreference private boolean mFlipToMuteEnabled; private boolean mLiftToSilenceEnabled; - public MotoActionsSettings(Context context, UpdatedStateNotifier updatedStateNotifier) { + public LineageActionsSettings(Context context, UpdatedStateNotifier updatedStateNotifier) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); loadPreferences(sharedPrefs); - sharedPrefs.registerOnSharedPreferenceChangeListener(this); + sharedPrefs.registerOnSharedPreferenceChangeListener(mPrefListener); mContext = context; mUpdatedStateNotifier = updatedStateNotifier; } @@ -107,13 +107,15 @@ public class MotoActionsSettings implements SharedPreferences.OnSharedPreference 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, false); + mIrWakeUpEnabled = sharedPreferences.getBoolean(GESTURE_IR_WAKEUP_KEY, true); mPickUpGestureEnabled = sharedPreferences.getBoolean(GESTURE_PICK_UP_KEY, true); mIrSilencerEnabled = sharedPreferences.getBoolean(GESTURE_IR_SILENCER_KEY, false); mFlipToMuteEnabled = sharedPreferences.getBoolean(GESTURE_FLIP_TO_MUTE_KEY, false); mLiftToSilenceEnabled = sharedPreferences.getBoolean(GESTURE_LIFT_TO_SILENCE_KEY, false); } + private SharedPreferences.OnSharedPreferenceChangeListener mPrefListener = + new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { boolean updated = true; @@ -123,7 +125,7 @@ public class MotoActionsSettings implements SharedPreferences.OnSharedPreference } else if (GESTURE_CHOP_CHOP_KEY.equals(key)) { mChopChopEnabled = sharedPreferences.getBoolean(GESTURE_CHOP_CHOP_KEY, true); } else if (GESTURE_IR_WAKEUP_KEY.equals(key)) { - mIrWakeUpEnabled = sharedPreferences.getBoolean(GESTURE_IR_WAKEUP_KEY, false); + mIrWakeUpEnabled = sharedPreferences.getBoolean(GESTURE_IR_WAKEUP_KEY, true); } else if (GESTURE_PICK_UP_KEY.equals(key)) { mPickUpGestureEnabled = sharedPreferences.getBoolean(GESTURE_PICK_UP_KEY, true); } else if (GESTURE_IR_SILENCER_KEY.equals(key)) { @@ -132,8 +134,9 @@ public class MotoActionsSettings implements SharedPreferences.OnSharedPreference mFlipToMuteEnabled = sharedPreferences.getBoolean(GESTURE_FLIP_TO_MUTE_KEY, false); } else if (GESTURE_LIFT_TO_SILENCE_KEY.equals(key)) { mLiftToSilenceEnabled = sharedPreferences.getBoolean(GESTURE_LIFT_TO_SILENCE_KEY, false); - } else if (Constants.FP_HOME_KEY.equals(key) || Constants.FP_HAPTIC_KEY.equals(key) || Constants.FP_HOME_KEY_OFF.equals(key) || Constants.FP_HAPTIC_SCREENOFF_KEY.equals(key) || Constants.FP_KEYS.equals(key) || Constants.FP_KEY_DBLTAP.equals(key) || Constants.FP_KEY_HOLD.equals(key) || Constants.FP_KEY_LEFT.equals(key) || Constants.FP_KEY_RIGHT.equals(key) - || Constants.FP_KEYS_OFF.equals(key) || Constants.FP_KEY_DBLTAP_OFF.equals(key) || Constants.FP_KEY_HOLD_OFF.equals(key) || Constants.FP_KEY_LEFT_OFF.equals(key) || Constants.FP_KEY_RIGHT_OFF.equals(key)) { + } else if (Constants.FP_HOME_KEY.equals(key) || Constants.FP_HAPTIC_KEY.equals(key) || Constants.FP_HOME_KEY_OFF.equals(key) || Constants.FP_HAPTIC_SCREENOFF_KEY.equals(key) ||Constants.FP_PROXIMITY_CHECK_SCREENOFF_KEY.equals(key) || Constants.FP_KEYS.equals(key) || Constants.FP_KEY_DBLTAP.equals(key) || Constants.FP_KEY_HOLD.equals(key) || Constants.FP_KEY_LEFT.equals(key) || Constants.FP_KEY_RIGHT.equals(key) + || Constants.FP_KEYS_OFF.equals(key) || Constants.FP_KEY_DBLTAP_OFF.equals(key) || Constants.FP_KEY_HOLD_OFF.equals(key) || Constants.FP_KEY_LEFT_OFF.equals(key) || Constants.FP_KEY_RIGHT_OFF.equals(key) + || Constants.GESTURE_SWIPE_RIGHT.equals(key) || Constants.GESTURE_SWIPE_LEFT.equals(key) || Constants.GESTURE_SWIPE_DOWN.equals(key) || Constants.GESTURE_SWIPE_UP.equals(key)) { Constants.writePreference(mContext, key); updated = false; } else { @@ -144,4 +147,5 @@ public class MotoActionsSettings implements SharedPreferences.OnSharedPreference mUpdatedStateNotifier.updateState(); } } + }; } diff --git a/LineageActions/src/org/lineageos/settings/device/ScreenOffGestureSettingsActivity.java b/LineageActions/src/org/lineageos/settings/device/ScreenOffGestureSettingsActivity.java new file mode 100644 index 0000000..f2c886a --- /dev/null +++ b/LineageActions/src/org/lineageos/settings/device/ScreenOffGestureSettingsActivity.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016 The CyanogenMod 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; + +import android.os.Bundle; + +import android.preference.PreferenceActivity; + +public class ScreenOffGestureSettingsActivity extends PreferenceActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (savedInstanceState == null){ + getFragmentManager().beginTransaction() + .replace(android.R.id.content, new ScreenOffGestureSettingsFragment()).commit(); + } + } +} diff --git a/LineageActions/src/org/lineageos/settings/device/ScreenOffGestureSettingsFragment.java b/LineageActions/src/org/lineageos/settings/device/ScreenOffGestureSettingsFragment.java new file mode 100644 index 0000000..ff7db33 --- /dev/null +++ b/LineageActions/src/org/lineageos/settings/device/ScreenOffGestureSettingsFragment.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2016 The CyanogenMod 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; + +import android.os.Bundle; +import android.provider.Settings; +import android.support.v7.preference.Preference; +import android.support.v14.preference.SwitchPreference; +import android.support.v14.preference.PreferenceFragment; +import android.view.MenuItem; + +import static android.provider.Settings.Secure.DOUBLE_TAP_TO_WAKE; +import static org.lineageos.settings.device.actions.Constants.KEY_GESTURE_ENABLE_HAPTIC_FEEDBACK; +import static org.lineageos.settings.device.actions.Constants.KEY_GESTURE_ENABLE_PROXIMITY_SENSOR; + +public class ScreenOffGestureSettingsFragment extends PreferenceFragment { + + private SwitchPreference mTapToWake; + private SwitchPreference mHapticFeedback; + private SwitchPreference mProximitySensor; + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); + } + + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + addPreferencesFromResource(R.xml.screen_off_gesture_panel); + mTapToWake = (SwitchPreference) findPreference("tap_to_wake"); + mTapToWake.setChecked(Settings.Secure.getInt(getActivity().getContentResolver(), DOUBLE_TAP_TO_WAKE, 0) == 1); + mTapToWake.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object objValue) { + boolean value = (Boolean) objValue; + Settings.Secure.putInt(getActivity().getContentResolver(), DOUBLE_TAP_TO_WAKE, value ? 1 : 0); + return true; + } + }); + + mHapticFeedback = (SwitchPreference) findPreference("haptic_feedback"); + mHapticFeedback.setChecked(Settings.System.getInt(getActivity().getContentResolver(), KEY_GESTURE_ENABLE_HAPTIC_FEEDBACK, 1) == 1); + mHapticFeedback.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object objValue) { + boolean value = (Boolean) objValue; + Settings.System.putInt(getActivity().getContentResolver(), KEY_GESTURE_ENABLE_HAPTIC_FEEDBACK, value ? 1 : 0); + return true; + } + }); + + mProximitySensor = (SwitchPreference) findPreference("proximity_sensor"); + mProximitySensor.setChecked(Settings.System.getInt(getActivity().getContentResolver(), KEY_GESTURE_ENABLE_PROXIMITY_SENSOR, 1) == 1); + mProximitySensor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object objValue) { + boolean value = (Boolean) objValue; + Settings.System.putInt(getActivity().getContentResolver(), KEY_GESTURE_ENABLE_PROXIMITY_SENSOR, value ? 1 : 0); + return true; + } + }); + } + +} diff --git a/MotoActions/src/com/moto/actions/SensorAction.java b/LineageActions/src/org/lineageos/settings/device/SensorAction.java similarity index 91% rename from MotoActions/src/com/moto/actions/SensorAction.java rename to LineageActions/src/org/lineageos/settings/device/SensorAction.java index 11a5df2..4bc72c4 100644 --- a/MotoActions/src/com/moto/actions/SensorAction.java +++ b/LineageActions/src/org/lineageos/settings/device/SensorAction.java @@ -15,8 +15,8 @@ * limitations under the License. */ -package com.moto.actions; +package org.lineageos.settings.device; public interface SensorAction { - void action(); + public void action(); } diff --git a/MotoActions/src/com/moto/actions/SensorHelper.java b/LineageActions/src/org/lineageos/settings/device/SensorHelper.java similarity index 83% rename from MotoActions/src/com/moto/actions/SensorHelper.java rename to LineageActions/src/org/lineageos/settings/device/SensorHelper.java index 6312ffe..2328bdf 100644 --- a/MotoActions/src/com/moto/actions/SensorHelper.java +++ b/LineageActions/src/org/lineageos/settings/device/SensorHelper.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.moto.actions; +package org.lineageos.settings.device; import java.util.List; import java.io.FileOutputStream; @@ -26,16 +26,17 @@ import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEventListener; import android.hardware.SensorManager; +import android.hardware.TriggerEventListener; +import android.util.Log; public class SensorHelper { - private static final String TAG = "MotoActions"; + private static final String TAG = "LineageActions"; 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; private static final int SENSOR_TYPE_MMI_STOW = 65539; - private static final int SENSOR_TYPE_MMI_GLANCE = 65548; private static final int BATCH_LATENCY_IN_MS = 100; @@ -44,7 +45,7 @@ public class SensorHelper { public SensorHelper(Context context) { mContext = context; - mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); + mSensorManager = (SensorManager) mContext .getSystemService(Context.SENSOR_SERVICE); dumpSensorsList(); } @@ -80,10 +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 getProximitySensor() { return mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true); } @@ -102,4 +99,15 @@ public class SensorHelper { public void unregisterListener(SensorEventListener listener) { mSensorManager.unregisterListener(listener); } + + /* TriggerSensor */ + public void requestTriggerSensor(Sensor sensor, TriggerEventListener listener) { + if (!mSensorManager.requestTriggerSensor(listener, sensor)) { + throw new RuntimeException("Failed to requestTriggerSensor for sensor " + sensor); + } + } + + public void cancelTriggerSensor(Sensor sensor, TriggerEventListener listener) { + mSensorManager.cancelTriggerSensor(listener, sensor); + } } diff --git a/MotoActions/src/com/moto/actions/ServiceWrapper.java b/LineageActions/src/org/lineageos/settings/device/ServiceWrapper.java similarity index 87% rename from MotoActions/src/com/moto/actions/ServiceWrapper.java rename to LineageActions/src/org/lineageos/settings/device/ServiceWrapper.java index 1724f58..de3609a 100644 --- a/MotoActions/src/com/moto/actions/ServiceWrapper.java +++ b/LineageActions/src/org/lineageos/settings/device/ServiceWrapper.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.moto.actions; +package org.lineageos.settings.device; import android.content.Intent; import android.os.Binder; @@ -24,10 +24,10 @@ import android.os.IBinder; import android.util.Log; public class ServiceWrapper extends android.app.Service { - static final String TAG = "MotoActions-ServiceWrapper"; + static final String TAG = "LineageActions-ServiceWrapper"; private final IBinder mBinder = new LocalBinder(); - private MotoActionsService mMotoActionsService; + private LineageActionsService mLineageActionsService; public interface ServiceCallback { void sendResults(int resultCode, Bundle b); @@ -45,7 +45,7 @@ public class ServiceWrapper extends android.app.Service { public void onCreate() { Log.i(TAG, "onCreate"); super.onCreate(); - mMotoActionsService = new MotoActionsService(this); + mLineageActionsService = new LineageActionsService(this); } @Override diff --git a/MotoActions/src/com/moto/actions/actions/CameraActivationAction.java b/LineageActions/src/org/lineageos/settings/device/actions/CameraActivationAction.java similarity index 88% rename from MotoActions/src/com/moto/actions/actions/CameraActivationAction.java rename to LineageActions/src/org/lineageos/settings/device/actions/CameraActivationAction.java index f77e27c..3d58992 100644 --- a/MotoActions/src/com/moto/actions/actions/CameraActivationAction.java +++ b/LineageActions/src/org/lineageos/settings/device/actions/CameraActivationAction.java @@ -15,7 +15,9 @@ * limitations under the License. */ -package com.moto.actions.actions; +package org.lineageos.settings.device.actions; + +import java.util.List; import android.app.KeyguardManager; import android.content.ComponentName; @@ -26,16 +28,14 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.PowerManager; import android.os.PowerManager.WakeLock; -import android.os.VibrationEffect; import android.os.Vibrator; import android.provider.MediaStore; +import android.util.Log; -import com.moto.actions.SensorAction; - -import java.util.List; +import org.lineageos.settings.device.SensorAction; public class CameraActivationAction implements SensorAction { - private static final String TAG = "MotoActions"; + private static final String TAG = "LineageActions"; private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500; @@ -55,7 +55,7 @@ public class CameraActivationAction implements SensorAction { public void action() { vibrate(); turnScreenOn(); - if (mKeyguardManager.isKeyguardLocked()) { + if (mKeyguardManager.inKeyguardRestrictedInputMode()) { launchSecureCamera(); } else { launchCamera(); @@ -63,16 +63,13 @@ public class CameraActivationAction implements SensorAction { } private void vibrate() { - Vibrator vib = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); - if (vib == null) return; - VibrationEffect effect = VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE); - vib.vibrate(effect); + Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); + v.vibrate(500); } private void turnScreenOn() { - String tag = mContext.getPackageName() + ":CameraWakeLock"; - WakeLock wl = mPowerManager.newWakeLock( - PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, tag); + PowerManager.WakeLock wl = mPowerManager.newWakeLock( + PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG); wl.acquire(TURN_SCREEN_ON_WAKE_LOCK_MS); } diff --git a/MotoActions/src/com/moto/actions/actions/CameraActivationSensor.java b/LineageActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java similarity index 56% rename from MotoActions/src/com/moto/actions/actions/CameraActivationSensor.java rename to LineageActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java index 1c219ae..c83eb6c 100644 --- a/MotoActions/src/com/moto/actions/actions/CameraActivationSensor.java +++ b/LineageActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java @@ -15,35 +15,44 @@ * limitations under the License. */ -package com.moto.actions.actions; +package org.lineageos.settings.device.actions; + +import java.util.List; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; +import android.hardware.SensorManager; import android.util.Log; -import com.moto.actions.MotoActionsSettings; -import com.moto.actions.SensorHelper; +import org.lineageos.settings.device.LineageActionsSettings; +import org.lineageos.settings.device.SensorHelper; public class CameraActivationSensor implements SensorEventListener, UpdatedStateNotifier { - private static final String TAG = "MotoActions-CameraSensor"; + private static final String TAG = "LineageActions-CameraSensor"; - private final MotoActionsSettings mMotoActionsSettings; + private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500; + + private final LineageActionsSettings mLineageActionsSettings; + private final SensorHelper mSensorHelper; + + private final Sensor mSensor; private boolean mIsEnabled; - public CameraActivationSensor(MotoActionsSettings motoActionsSettings, SensorHelper sensorHelper) { - mMotoActionsSettings = motoActionsSettings; - Sensor sensor = sensorHelper.getCameraActivationSensor(); - sensorHelper.registerListener(sensor, this); + public CameraActivationSensor(LineageActionsSettings lineageActionsSettings, SensorHelper sensorHelper) { + mLineageActionsSettings = lineageActionsSettings; + mSensorHelper = sensorHelper; + mSensor = sensorHelper.getCameraActivationSensor(); + mSensorHelper.registerListener(mSensor, this); } @Override public synchronized void updateState() { - if (mMotoActionsSettings.isCameraGestureEnabled() && !mIsEnabled) { + if (mLineageActionsSettings.isCameraGestureEnabled() && !mIsEnabled) { Log.d(TAG, "Enabling"); mIsEnabled = true; - } else if (! mMotoActionsSettings.isCameraGestureEnabled() && mIsEnabled) { + } else if (! mLineageActionsSettings.isCameraGestureEnabled() && mIsEnabled) { Log.d(TAG, "Disabling"); mIsEnabled = false; } @@ -52,7 +61,7 @@ public class CameraActivationSensor implements SensorEventListener, UpdatedState @Override public void onSensorChanged(SensorEvent event) { Log.d(TAG, "activate camera"); - if (mIsEnabled) mMotoActionsSettings.cameraAction(); + if (mIsEnabled) mLineageActionsSettings.cameraAction(); } @Override diff --git a/MotoActions/src/com/moto/actions/actions/ChopChopSensor.java b/LineageActions/src/org/lineageos/settings/device/actions/ChopChopSensor.java similarity index 74% rename from MotoActions/src/com/moto/actions/actions/ChopChopSensor.java rename to LineageActions/src/org/lineageos/settings/device/actions/ChopChopSensor.java index fc9f12e..0ccd641 100644 --- a/MotoActions/src/com/moto/actions/actions/ChopChopSensor.java +++ b/LineageActions/src/org/lineageos/settings/device/actions/ChopChopSensor.java @@ -15,20 +15,25 @@ * limitations under the License. */ -package com.moto.actions.actions; +package org.lineageos.settings.device.actions; + +import java.util.List; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; +import android.hardware.SensorManager; import android.util.Log; -import com.moto.actions.MotoActionsSettings; -import com.moto.actions.SensorHelper; +import org.lineageos.settings.device.LineageActionsSettings; +import org.lineageos.settings.device.SensorHelper; public class ChopChopSensor implements SensorEventListener, UpdatedStateNotifier { - private static final String TAG = "MotoActions-ChopChopSensor"; + private static final String TAG = "LineageActions-ChopChopSensor"; - private final MotoActionsSettings mMotoActionsSettings; + private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500; + + private final LineageActionsSettings mLineageActionsSettings; private final SensorHelper mSensorHelper; private final Sensor mSensor; private final Sensor mProx; @@ -36,8 +41,8 @@ public class ChopChopSensor implements SensorEventListener, UpdatedStateNotifier private boolean mIsEnabled; private boolean mProxIsCovered; - public ChopChopSensor(MotoActionsSettings motoActionsSettings, SensorHelper sensorHelper) { - mMotoActionsSettings = motoActionsSettings; + public ChopChopSensor(LineageActionsSettings lineageActionsSettings, SensorHelper sensorHelper) { + mLineageActionsSettings = lineageActionsSettings; mSensorHelper = sensorHelper; mSensor = sensorHelper.getChopChopSensor(); mProx = sensorHelper.getProximitySensor(); @@ -45,12 +50,12 @@ public class ChopChopSensor implements SensorEventListener, UpdatedStateNotifier @Override public synchronized void updateState() { - if (mMotoActionsSettings.isChopChopGestureEnabled() && !mIsEnabled) { + if (mLineageActionsSettings.isChopChopGestureEnabled() && !mIsEnabled) { Log.d(TAG, "Enabling"); mSensorHelper.registerListener(mSensor, this); mSensorHelper.registerListener(mProx, mProxListener); mIsEnabled = true; - } else if (! mMotoActionsSettings.isChopChopGestureEnabled() && mIsEnabled) { + } else if (! mLineageActionsSettings.isChopChopGestureEnabled() && mIsEnabled) { Log.d(TAG, "Disabling"); mSensorHelper.unregisterListener(this); mSensorHelper.unregisterListener(mProxListener); @@ -65,7 +70,7 @@ public class ChopChopSensor implements SensorEventListener, UpdatedStateNotifier Log.d(TAG, "proximity sensor covered, ignoring chop-chop"); return; } - mMotoActionsSettings.chopChopAction(); + mLineageActionsSettings.chopChopAction(); } @Override diff --git a/MotoActions/src/com/moto/actions/actions/Constants.java b/LineageActions/src/org/lineageos/settings/device/actions/Constants.java similarity index 72% rename from MotoActions/src/com/moto/actions/actions/Constants.java rename to LineageActions/src/org/lineageos/settings/device/actions/Constants.java index 307f75d..6d6cc1b 100644 --- a/MotoActions/src/com/moto/actions/actions/Constants.java +++ b/LineageActions/src/org/lineageos/settings/device/actions/Constants.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.moto.actions.actions; +package org.lineageos.settings.device.actions; import java.util.HashMap; import java.util.Map; @@ -25,13 +25,13 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.util.Log; -import com.moto.actions.util.FileUtils; +import org.lineageos.settings.device.util.FileUtils; public class Constants { public static final boolean DEBUG = false; - private static final String TAG = "MotoActions"; + private static final String TAG = "LineageActions"; // FP gestures public static final int FP_TAP_SCANCODE = 616; @@ -105,6 +105,10 @@ public class Constants { public static final String FP_HAPTIC_SCREENOFF_NODE = "/sys/homebutton/haptic_off"; public static final String FP_HAPTIC_SCREENOFF_KEY = "fp_haptic_scr_off"; + // Proximity check node + public static final String FP_PROXIMITY_CHECK_SCREENOFF_NODE = "/sys/homebutton/proximity_check_off"; + public static final String FP_PROXIMITY_CHECK_SCREENOFF_KEY = "fp_proximity_check_scr_off"; + // List of keys public static final String FP_KEYS = "fp_keys"; public static final String FP_KEY_DBLTAP = "fp_key_dbltap"; @@ -131,8 +135,48 @@ public class Constants { public static final String FP_KEY_SCREENOFF_LEFT_NODE = "/sys/homebutton/key_screenoff_left"; public static final String FP_KEY_SCREENOFF_RIGHT_NODE = "/sys/homebutton/key_screenoff_right"; + // Screen off gestures + public static final int GESTURE_SWIPE_RIGHT_SCANCODE = 622; + public static final int GESTURE_SWIPE_LEFT_SCANCODE = 623; + public static final int GESTURE_SWIPE_DOWN_SCANCODE = 624; + public static final int GESTURE_SWIPE_UP_SCANCODE = 625; + public static final int GESTURE_DOUBLE_TAP_SCANCODE = 626; + public static final int[] sSupportedScreenOffGestures = new int[]{ + GESTURE_SWIPE_RIGHT_SCANCODE, + GESTURE_SWIPE_LEFT_SCANCODE, + GESTURE_SWIPE_DOWN_SCANCODE, + GESTURE_SWIPE_UP_SCANCODE, + GESTURE_DOUBLE_TAP_SCANCODE + }; + public static final int[] sScreenOffSupportedActions = new int[]{ + ACTION_POWER, + ACTION_PLAY_PAUSE, + ACTION_PREVIOUS_TRACK, + ACTION_NEXT_TRACK, + ACTION_FLASHLIGHT, + ACTION_CAMERA, + ACTION_BROWSER, + ACTION_DIALER, + ACTION_EMAIL, + ACTION_MESSAGES + }; + + // List of screen off gestures keys + public static final String GESTURE_SWIPE_RIGHT = "screen_off_gestures_swipe_right"; + public static final String GESTURE_SWIPE_LEFT = "screen_off_gestures_swipe_left"; + public static final String GESTURE_SWIPE_DOWN = "screen_off_gestures_swipe_down"; + public static final String GESTURE_SWIPE_UP = "screen_off_gestures_swipe_up"; + + // Screen off gestures nodes + public static final String GESTURE_SWIPE_RIGHT_NODE = "/sys/android_touch/gesture_swipe_right"; + public static final String GESTURE_SWIPE_LEFT_NODE = "/sys/android_touch/gesture_swipe_left"; + public static final String GESTURE_SWIPE_DOWN_NODE = "/sys/android_touch/gesture_swipe_down"; + public static final String GESTURE_SWIPE_UP_NODE = "/sys/android_touch/gesture_swipe_up"; + public static final String GESTURE_DOUBLE_TAP_NODE = "/sys/android_touch/doubletap2wake"; + // Screen off gestures haptic public static final String KEY_GESTURE_ENABLE_HAPTIC_FEEDBACK = "screen_off_gesture_haptic_feedback"; + public static final String KEY_GESTURE_ENABLE_PROXIMITY_SENSOR = "screen_off_gesture_proximity_sensor"; // Holds -> mapping public static final Map sBooleanNodePreferenceMap = new HashMap<>(); @@ -145,6 +189,7 @@ public class Constants { FP_HOME_KEY_OFF, FP_HAPTIC_KEY, FP_HAPTIC_SCREENOFF_KEY, + FP_PROXIMITY_CHECK_SCREENOFF_KEY, FP_KEYS, FP_KEY_DBLTAP, FP_KEY_HOLD, @@ -156,6 +201,10 @@ public class Constants { FP_KEY_RIGHT_OFF, FP_KEY_LEFT_OFF, FP_HOME_KEY_OFF, + GESTURE_SWIPE_RIGHT, + GESTURE_SWIPE_LEFT, + GESTURE_SWIPE_DOWN, + GESTURE_SWIPE_UP }; static { @@ -163,6 +212,7 @@ public class Constants { sBooleanNodePreferenceMap.put(FP_HOME_KEY_OFF, FP_HOME_OFF_NODE); sBooleanNodePreferenceMap.put(FP_HAPTIC_KEY, FP_HAPTIC_NODE); sBooleanNodePreferenceMap.put(FP_HAPTIC_SCREENOFF_KEY, FP_HAPTIC_SCREENOFF_NODE); + sBooleanNodePreferenceMap.put(FP_PROXIMITY_CHECK_SCREENOFF_KEY, FP_PROXIMITY_CHECK_SCREENOFF_NODE); sBooleanNodePreferenceMap.put(FP_KEYS, FP_KEYS_NODE); sBooleanNodePreferenceMap.put(FP_KEY_DBLTAP, FP_KEY_DBLTAP_NODE); sBooleanNodePreferenceMap.put(FP_KEY_HOLD, FP_KEY_HOLD_NODE); @@ -173,10 +223,15 @@ public class Constants { sBooleanNodePreferenceMap.put(FP_KEY_HOLD_OFF, FP_KEY_SCREENOFF_HOLD_NODE); sBooleanNodePreferenceMap.put(FP_KEY_LEFT_OFF, FP_KEY_SCREENOFF_LEFT_NODE); sBooleanNodePreferenceMap.put(FP_KEY_RIGHT_OFF, FP_KEY_SCREENOFF_RIGHT_NODE); + sBooleanNodePreferenceMap.put(GESTURE_SWIPE_RIGHT, GESTURE_SWIPE_RIGHT_NODE); + sBooleanNodePreferenceMap.put(GESTURE_SWIPE_LEFT, GESTURE_SWIPE_LEFT_NODE); + sBooleanNodePreferenceMap.put(GESTURE_SWIPE_DOWN, GESTURE_SWIPE_DOWN_NODE); + sBooleanNodePreferenceMap.put(GESTURE_SWIPE_UP, GESTURE_SWIPE_UP_NODE); sNodeDefaultMap.put(FP_HOME_KEY, false); sNodeDefaultMap.put(FP_HOME_KEY_OFF, false); sNodeDefaultMap.put(FP_HAPTIC_KEY, false); sNodeDefaultMap.put(FP_HAPTIC_SCREENOFF_KEY, false); + sNodeDefaultMap.put(FP_PROXIMITY_CHECK_SCREENOFF_KEY, true); sNodeDefaultMap.put(FP_KEYS, "0"); sNodeDefaultMap.put(FP_KEY_DBLTAP, "0"); sNodeDefaultMap.put(FP_KEY_HOLD, "0"); @@ -187,6 +242,10 @@ public class Constants { sNodeDefaultMap.put(FP_KEY_HOLD_OFF, "0"); sNodeDefaultMap.put(FP_KEY_LEFT_OFF, "0"); sNodeDefaultMap.put(FP_KEY_RIGHT_OFF, "0"); + sNodeDefaultMap.put(GESTURE_SWIPE_RIGHT, "0"); + sNodeDefaultMap.put(GESTURE_SWIPE_LEFT, "0"); + sNodeDefaultMap.put(GESTURE_SWIPE_DOWN, "0"); + sNodeDefaultMap.put(GESTURE_SWIPE_UP, "0"); } public static boolean isPreferenceEnabled(Context context, String key) { @@ -204,7 +263,7 @@ public class Constants { String value = "1"; if (!pref.equals(FP_KEYS) && !pref.equals(FP_KEY_DBLTAP) && !pref.equals(FP_KEY_HOLD) && !pref.equals(FP_KEY_LEFT) && !pref.equals(FP_KEY_RIGHT) && - !pref.equals(FP_KEYS_OFF) && !pref.equals(FP_KEY_DBLTAP_OFF) && !pref.equals(FP_KEY_HOLD_OFF) && !pref.equals(FP_KEY_LEFT_OFF) && !pref.equals(FP_KEY_RIGHT_OFF)) + !pref.equals(FP_KEYS_OFF) && !pref.equals(FP_KEY_DBLTAP_OFF) && !pref.equals(FP_KEY_HOLD_OFF) && !pref.equals(FP_KEY_LEFT_OFF) && !pref.equals(FP_KEY_RIGHT_OFF) && !pref.equals(GESTURE_SWIPE_RIGHT) && !pref.equals(GESTURE_SWIPE_LEFT) && !pref.equals(GESTURE_SWIPE_DOWN) && !pref.equals(GESTURE_SWIPE_UP)) value = isPreferenceEnabled(context, pref) ? "1" : "0"; else value = GetPreference(context, pref); diff --git a/MotoActions/src/com/moto/actions/actions/FlipToMute.java b/LineageActions/src/org/lineageos/settings/device/actions/FlipToMute.java similarity index 77% rename from MotoActions/src/com/moto/actions/actions/FlipToMute.java rename to LineageActions/src/org/lineageos/settings/device/actions/FlipToMute.java index a7c753f..7db8154 100644 --- a/MotoActions/src/com/moto/actions/actions/FlipToMute.java +++ b/LineageActions/src/org/lineageos/settings/device/actions/FlipToMute.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.moto.actions.actions; +package org.lineageos.settings.device.actions; import android.app.NotificationManager; import android.content.BroadcastReceiver; @@ -25,23 +25,20 @@ import android.content.IntentFilter; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; -import android.os.VibrationEffect; -import android.os.Vibrator; import android.util.Log; -import com.moto.actions.MotoActionsSettings; -import com.moto.actions.SensorHelper; +import org.lineageos.settings.device.LineageActionsSettings; +import org.lineageos.settings.device.SensorHelper; public class FlipToMute implements UpdatedStateNotifier { - private static final String TAG = "MotoActions-FlipToMute"; + private static final String TAG = "LineageActions-FlipToMute"; private final NotificationManager mNotificationManager; - private final MotoActionsSettings mMotoActionsSettings; + private final LineageActionsSettings mLineageActionsSettings; private final SensorHelper mSensorHelper; private final Sensor mFlatDown; private final Sensor mStow; - private boolean canVibrate = false; private boolean mIsEnabled; private boolean mIsFlatDown; private boolean mIsStowed; @@ -49,31 +46,29 @@ public class FlipToMute implements UpdatedStateNotifier { private Context mContext; private Receiver mReceiver; - public FlipToMute(MotoActionsSettings motoActionsSettings, Context context, + public FlipToMute(LineageActionsSettings lineageActionsSettings, Context context, SensorHelper sensorHelper) { - mMotoActionsSettings = motoActionsSettings; + mLineageActionsSettings = lineageActionsSettings; mContext = context; mSensorHelper = sensorHelper; mFlatDown = sensorHelper.getFlatDownSensor(); mStow = sensorHelper.getStowSensor(); mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - if (mNotificationManager != null) { mFilter = mNotificationManager.getCurrentInterruptionFilter(); - } mReceiver = new Receiver(); } @Override public void updateState() { - if (mMotoActionsSettings.isFlipToMuteEnabled() && !mIsEnabled) { + if (mLineageActionsSettings.isFlipToMuteEnabled() && !mIsEnabled) { Log.d(TAG, "Enabling"); mSensorHelper.registerListener(mFlatDown, mFlatDownListener); mSensorHelper.registerListener(mStow, mStowListener); mContext.registerReceiver(mReceiver, new IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED)); mIsEnabled = true; - } else if (!mMotoActionsSettings.isFlipToMuteEnabled() && mIsEnabled) { + } else if (!mLineageActionsSettings.isFlipToMuteEnabled() && mIsEnabled) { Log.d(TAG, "Disabling"); mSensorHelper.unregisterListener(mFlatDownListener); mSensorHelper.unregisterListener(mStowListener); @@ -111,33 +106,19 @@ public class FlipToMute implements UpdatedStateNotifier { Log.d(TAG, "event: " + mIsFlatDown + " mIsStowed=" + mIsStowed); if (mIsFlatDown && mIsStowed) { - vibrate(); - canVibrate = true; mNotificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY); Log.d(TAG, "Interrupt filter: Allow priority"); } else if (!mIsFlatDown) { - if (canVibrate) { - vibrate(); - canVibrate = false; - } mNotificationManager.setInterruptionFilter(mFilter); Log.d(TAG, "Interrupt filter: Restore"); } } - private void vibrate() { - Vibrator vib = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); - if (vib == null) return; - VibrationEffect effect = VibrationEffect.createOneShot(250, VibrationEffect.DEFAULT_AMPLITUDE); - vib.vibrate(effect); - } - public class Receiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (!mIsFlatDown && !mIsStowed) { - if (mNotificationManager == null) return; mFilter = mNotificationManager.getCurrentInterruptionFilter(); Log.d(TAG, "Interrupt filter: Backup"); } diff --git a/MotoActions/src/com/moto/actions/actions/LiftToSilence.java b/LineageActions/src/org/lineageos/settings/device/actions/LiftToSilence.java similarity index 87% rename from MotoActions/src/com/moto/actions/actions/LiftToSilence.java rename to LineageActions/src/org/lineageos/settings/device/actions/LiftToSilence.java index 6b36dc2..4fe671f 100644 --- a/MotoActions/src/com/moto/actions/actions/LiftToSilence.java +++ b/LineageActions/src/org/lineageos/settings/device/actions/LiftToSilence.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.moto.actions.actions; +package org.lineageos.settings.device.actions; import android.content.Context; import android.hardware.Sensor; @@ -26,13 +26,13 @@ import android.telecom.TelecomManager; import android.telephony.TelephonyManager; import android.util.Log; -import com.moto.actions.MotoActionsSettings; -import com.moto.actions.SensorHelper; +import org.lineageos.settings.device.LineageActionsSettings; +import org.lineageos.settings.device.SensorHelper; public class LiftToSilence extends PhoneStateListener implements SensorEventListener, UpdatedStateNotifier { - private static final String TAG = "MotoActions-LiftToSilence"; + private static final String TAG = "LineageActions-LiftToSilence"; - private final MotoActionsSettings mMotoActionsSettings; + private final LineageActionsSettings mLineageActionsSettings; private final SensorHelper mSensorHelper; private final Sensor mFlatUpSensor; private final Sensor mStowSensor; @@ -44,9 +44,9 @@ public class LiftToSilence extends PhoneStateListener implements SensorEventList private boolean mIsStowed; private boolean mLastFlatUp; - public LiftToSilence(MotoActionsSettings motoActionsSettings, Context context, + public LiftToSilence(LineageActionsSettings lineageActionsSettings, Context context, SensorHelper sensorHelper) { - mMotoActionsSettings = motoActionsSettings; + mLineageActionsSettings = lineageActionsSettings; mSensorHelper = sensorHelper; mFlatUpSensor = sensorHelper.getFlatUpSensor(); mStowSensor = sensorHelper.getStowSensor(); @@ -56,7 +56,7 @@ public class LiftToSilence extends PhoneStateListener implements SensorEventList @Override public void updateState() { - if (mMotoActionsSettings.isLiftToSilenceEnabled()) { + if (mLineageActionsSettings.isLiftToSilenceEnabled()) { mTelephonyManager.listen(this, LISTEN_CALL_STATE); } else { mTelephonyManager.listen(this, 0); diff --git a/MotoActions/src/com/moto/actions/actions/ProximitySilencer.java b/LineageActions/src/org/lineageos/settings/device/actions/ProximitySilencer.java similarity index 81% rename from MotoActions/src/com/moto/actions/actions/ProximitySilencer.java rename to LineageActions/src/org/lineageos/settings/device/actions/ProximitySilencer.java index 71c2cfa..605aaf5 100644 --- a/MotoActions/src/com/moto/actions/actions/ProximitySilencer.java +++ b/LineageActions/src/org/lineageos/settings/device/actions/ProximitySilencer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.moto.actions.actions; +package org.lineageos.settings.device.actions; import android.content.Context; import android.hardware.Sensor; @@ -26,31 +26,31 @@ import android.telecom.TelecomManager; import android.telephony.TelephonyManager; import android.util.Log; -import com.moto.actions.MotoActionsSettings; -import com.moto.actions.SensorHelper; +import org.lineageos.settings.device.LineageActionsSettings; +import org.lineageos.settings.device.SensorHelper; import static android.telephony.TelephonyManager.*; public class ProximitySilencer extends PhoneStateListener implements SensorEventListener, UpdatedStateNotifier { - private static final String TAG = "MotoActions-ProximitySilencer"; + private static final String TAG = "LineageActions-ProximitySilencer"; private static final int SILENCE_DELAY_MS = 500; private final TelecomManager mTelecomManager; private final TelephonyManager mTelephonyManager; - private final MotoActionsSettings mMotoActionsSettings; + private final LineageActionsSettings mLineageActionsSettings; private final SensorHelper mSensorHelper; private final Sensor mSensor; private boolean mIsRinging; private long mRingStartedMs; private boolean mCoveredRinging; - public ProximitySilencer(MotoActionsSettings motoActionsSettings, Context context, + public ProximitySilencer(LineageActionsSettings lineageActionsSettings, Context context, SensorHelper sensorHelper) { mTelecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); - mMotoActionsSettings = motoActionsSettings; + mLineageActionsSettings = lineageActionsSettings; mSensorHelper = sensorHelper; mSensor = sensorHelper.getProximitySensor(); mCoveredRinging = false; @@ -59,7 +59,7 @@ public class ProximitySilencer extends PhoneStateListener implements SensorEvent @Override public void updateState() { - if (mMotoActionsSettings.isIrSilencerEnabled()) { + if (mLineageActionsSettings.isIrSilencerEnabled()) { mTelephonyManager.listen(this, LISTEN_CALL_STATE); } else { mTelephonyManager.listen(this, 0); @@ -72,18 +72,22 @@ public class ProximitySilencer extends PhoneStateListener implements SensorEvent long now = System.currentTimeMillis(); if (isNear){ - mCoveredRinging = mIsRinging && (now - mRingStartedMs >= SILENCE_DELAY_MS); + if (mIsRinging && (now - mRingStartedMs >= SILENCE_DELAY_MS)){ + mCoveredRinging = true; + } else { + mCoveredRinging = false; + } return; } - if (mIsRinging) { + if (!isNear && mIsRinging) { Log.d(TAG, "event: " + event.values[0] + ", " + " covered " + Boolean.toString(mCoveredRinging)); if (mCoveredRinging) { Log.d(TAG, "Silencing ringer"); mTelecomManager.silenceRinger(); } else { Log.d(TAG, "Ignoring silence gesture: " + now + " is too close to " + - mRingStartedMs + ", delay=" + SILENCE_DELAY_MS); + mRingStartedMs + ", delay=" + SILENCE_DELAY_MS + " or covered " + Boolean.toString(mCoveredRinging)); } mCoveredRinging = false; } diff --git a/MotoActions/src/com/moto/actions/actions/TorchAction.java b/LineageActions/src/org/lineageos/settings/device/actions/TorchAction.java similarity index 82% rename from MotoActions/src/com/moto/actions/actions/TorchAction.java rename to LineageActions/src/org/lineageos/settings/device/actions/TorchAction.java index 58680ba..c31bf34 100644 --- a/MotoActions/src/com/moto/actions/actions/TorchAction.java +++ b/LineageActions/src/org/lineageos/settings/device/actions/TorchAction.java @@ -15,20 +15,21 @@ * limitations under the License. */ -package com.moto.actions.actions; +package org.lineageos.settings.device.actions; import android.content.Context; -import android.hardware.camera2.CameraAccessException; -import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CameraManager; -import android.os.VibrationEffect; +import android.hardware.camera2.CameraCharacteristics; +import android.hardware.camera2.CameraAccessException; import android.os.Vibrator; -import android.support.annotation.NonNull; +import android.util.Log; -import com.moto.actions.SensorAction; +import org.lineageos.settings.device.SensorAction; public class TorchAction implements SensorAction { - private static final String TAG = "MotoActions"; + private static final String TAG = "LineageActions"; + + private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500; private CameraManager mCameraManager; private final Vibrator mVibrator; @@ -50,20 +51,17 @@ public class TorchAction implements SensorAction { } } } catch (CameraAccessException e) { - // Noop } } @Override public void action() { - VibrationEffect vibrationEffect = VibrationEffect.createOneShot(250, VibrationEffect.DEFAULT_AMPLITUDE); - mVibrator.vibrate(vibrationEffect); + mVibrator.vibrate(250); if (mRearCameraId != null) { try { mCameraManager.setTorchMode(mRearCameraId, !mTorchEnabled); mTorchEnabled = !mTorchEnabled; } catch (CameraAccessException e) { - // Noop } } } @@ -71,14 +69,14 @@ public class TorchAction implements SensorAction { private class MyTorchCallback extends CameraManager.TorchCallback { @Override - public void onTorchModeChanged(@NonNull String cameraId, boolean enabled) { + public void onTorchModeChanged(String cameraId, boolean enabled) { if (!cameraId.equals(mRearCameraId)) return; mTorchEnabled = enabled; } @Override - public void onTorchModeUnavailable(@NonNull String cameraId) { + public void onTorchModeUnavailable(String cameraId) { if (!cameraId.equals(mRearCameraId)) return; mTorchEnabled = false; diff --git a/MotoActions/src/com/moto/actions/actions/UpdatedStateNotifier.java b/LineageActions/src/org/lineageos/settings/device/actions/UpdatedStateNotifier.java similarity index 89% rename from MotoActions/src/com/moto/actions/actions/UpdatedStateNotifier.java rename to LineageActions/src/org/lineageos/settings/device/actions/UpdatedStateNotifier.java index 3cc346e..224a57b 100644 --- a/MotoActions/src/com/moto/actions/actions/UpdatedStateNotifier.java +++ b/LineageActions/src/org/lineageos/settings/device/actions/UpdatedStateNotifier.java @@ -15,8 +15,8 @@ * limitations under the License. */ -package com.moto.actions.actions; +package org.lineageos.settings.device.actions; public interface UpdatedStateNotifier { - void updateState(); + public void updateState(); } diff --git a/MotoActions/src/com/moto/actions/doze/DozePulseAction.java b/LineageActions/src/org/lineageos/settings/device/doze/DozePulseAction.java similarity index 89% rename from MotoActions/src/com/moto/actions/doze/DozePulseAction.java rename to LineageActions/src/org/lineageos/settings/device/doze/DozePulseAction.java index 8ac4ab0..4445b28 100644 --- a/MotoActions/src/com/moto/actions/doze/DozePulseAction.java +++ b/LineageActions/src/org/lineageos/settings/device/doze/DozePulseAction.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.moto.actions.doze; +package org.lineageos.settings.device.doze; import android.content.Context; import android.content.Intent; import android.util.Log; -import com.moto.actions.SensorAction; +import org.lineageos.settings.device.SensorAction; public class DozePulseAction implements SensorAction, ScreenStateNotifier { - private static final String TAG = "MotoActions"; + private static final String TAG = "LineageActions"; private static final int DELAY_BETWEEN_DOZES_IN_MS = 1500; @@ -52,7 +52,7 @@ public class DozePulseAction implements SensorAction, ScreenStateNotifier { } } - private synchronized boolean mayDoze() { + public synchronized boolean mayDoze() { long now = System.currentTimeMillis(); if (now - mLastDoze > DELAY_BETWEEN_DOZES_IN_MS) { Log.d(TAG, "Allowing doze"); diff --git a/MotoActions/src/com/moto/actions/doze/ProximitySensor.java b/LineageActions/src/org/lineageos/settings/device/doze/ProximitySensor.java similarity index 77% rename from MotoActions/src/com/moto/actions/doze/ProximitySensor.java rename to LineageActions/src/org/lineageos/settings/device/doze/ProximitySensor.java index 6ee3cbc..dca3c41 100644 --- a/MotoActions/src/com/moto/actions/doze/ProximitySensor.java +++ b/LineageActions/src/org/lineageos/settings/device/doze/ProximitySensor.java @@ -15,21 +15,21 @@ * limitations under the License. */ -package com.moto.actions.doze; +package org.lineageos.settings.device.doze; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.util.Log; -import com.moto.actions.MotoActionsSettings; -import com.moto.actions.SensorAction; -import com.moto.actions.SensorHelper; +import org.lineageos.settings.device.LineageActionsSettings; +import org.lineageos.settings.device.SensorAction; +import org.lineageos.settings.device.SensorHelper; public class ProximitySensor implements ScreenStateNotifier, SensorEventListener { - private static final String TAG = "MotoActions-ProximitySensor"; + private static final String TAG = "LineageActions-ProximitySensor"; - private final MotoActionsSettings mMotoActionsSettings; + private final LineageActionsSettings mLineageActionsSettings; private final SensorHelper mSensorHelper; private final SensorAction mSensorAction; private final Sensor mSensor; @@ -38,9 +38,9 @@ public class ProximitySensor implements ScreenStateNotifier, SensorEventListener private boolean mSawNear = false; - public ProximitySensor(MotoActionsSettings motoActionsSettings, SensorHelper sensorHelper, + public ProximitySensor(LineageActionsSettings lineageActionsSettings, SensorHelper sensorHelper, SensorAction action) { - mMotoActionsSettings = motoActionsSettings; + mLineageActionsSettings = lineageActionsSettings; mSensorHelper = sensorHelper; mSensorAction = action; @@ -58,7 +58,7 @@ public class ProximitySensor implements ScreenStateNotifier, SensorEventListener @Override public void screenTurnedOff() { - if (mMotoActionsSettings.isIrWakeupEnabled() && !mEnabled) { + if (mLineageActionsSettings.isIrWakeupEnabled() && !mEnabled) { Log.d(TAG, "Enabling"); mSensorHelper.registerListener(mSensor, this); mEnabled = true; diff --git a/MotoActions/src/com/moto/actions/doze/ScreenReceiver.java b/LineageActions/src/org/lineageos/settings/device/doze/ScreenReceiver.java similarity index 92% rename from MotoActions/src/com/moto/actions/doze/ScreenReceiver.java rename to LineageActions/src/org/lineageos/settings/device/doze/ScreenReceiver.java index b9aa691..cec01d0 100644 --- a/MotoActions/src/com/moto/actions/doze/ScreenReceiver.java +++ b/LineageActions/src/org/lineageos/settings/device/doze/ScreenReceiver.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.moto.actions.doze; +package org.lineageos.settings.device.doze; import java.util.List; @@ -24,7 +24,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import com.moto.actions.actions.Constants; +import org.lineageos.settings.device.actions.Constants; public class ScreenReceiver extends BroadcastReceiver { private final ScreenStateNotifier mNotifier; @@ -39,8 +39,6 @@ public class ScreenReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - if (intent.getAction() == null) return; - if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { mNotifier.screenTurnedOff(); } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { diff --git a/MotoActions/src/com/moto/actions/doze/ScreenStateNotifier.java b/LineageActions/src/org/lineageos/settings/device/doze/ScreenStateNotifier.java similarity index 86% rename from MotoActions/src/com/moto/actions/doze/ScreenStateNotifier.java rename to LineageActions/src/org/lineageos/settings/device/doze/ScreenStateNotifier.java index 438fff2..7b9ab59 100644 --- a/MotoActions/src/com/moto/actions/doze/ScreenStateNotifier.java +++ b/LineageActions/src/org/lineageos/settings/device/doze/ScreenStateNotifier.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.moto.actions.doze; +package org.lineageos.settings.device.doze; public interface ScreenStateNotifier { - void screenTurnedOn(); - void screenTurnedOff(); + public void screenTurnedOn(); + public void screenTurnedOff(); } diff --git a/LineageActions/src/org/lineageos/settings/device/doze/StowSensor.java b/LineageActions/src/org/lineageos/settings/device/doze/StowSensor.java new file mode 100644 index 0000000..74c22fe --- /dev/null +++ b/LineageActions/src/org/lineageos/settings/device/doze/StowSensor.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015 The CyanogenMod Project + * 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 java.lang.System; + +import org.lineageos.settings.device.LineageActionsSettings; +import org.lineageos.settings.device.SensorAction; +import org.lineageos.settings.device.SensorHelper; + +public class StowSensor implements ScreenStateNotifier, SensorEventListener { + private static final String TAG = "LineageActions-StowSensor"; + private static final int IN_POCKET_MIN_TIME = 5000; + + private final LineageActionsSettings mLineageActionsSettings; + private final SensorHelper mSensorHelper; + private final SensorAction mSensorAction; + private final Sensor mSensor; + + private boolean mEnabled; + private boolean mLastStowed; + private long isStowedTime; + + public StowSensor(LineageActionsSettings lineageActionsSettings, SensorHelper sensorHelper, + SensorAction action) { + mLineageActionsSettings = lineageActionsSettings; + mSensorHelper = sensorHelper; + mSensorAction = action; + + mSensor = sensorHelper.getStowSensor(); + } + + @Override + public void screenTurnedOn() { + if (mEnabled) { + Log.d(TAG, "Disabling"); + mSensorHelper.unregisterListener(this); + mEnabled = false; + } + } + + @Override + public void screenTurnedOff() { + if (!mLineageActionsSettings.isIrWakeupEnabled() && + mLineageActionsSettings.isPickUpEnabled() && !mEnabled) { + Log.d(TAG, "Enabling"); + mSensorHelper.registerListener(mSensor, this); + mEnabled = true; + } + } + + @Override + public void onSensorChanged(SensorEvent event) { + boolean thisStowed = (event.values[0] != 0); + if(thisStowed){ + isStowedTime = System.currentTimeMillis(); + } else if (mLastStowed && !thisStowed) { + long inPocketTime = System.currentTimeMillis() - isStowedTime; + if(inPocketTime >= IN_POCKET_MIN_TIME){ + Log.d(TAG, "Triggered after " + inPocketTime / 1000 + " seconds"); + mSensorAction.action(); + } + } + mLastStowed = thisStowed; + Log.d(TAG, "event: " + thisStowed); + } + + @Override + public void onAccuracyChanged(Sensor sensor, int accuracy) { + } +} diff --git a/MotoActions/src/com/moto/actions/util/FileUtils.java b/LineageActions/src/org/lineageos/settings/device/util/FileUtils.java similarity index 98% rename from MotoActions/src/com/moto/actions/util/FileUtils.java rename to LineageActions/src/org/lineageos/settings/device/util/FileUtils.java index dec3446..4993c94 100644 --- a/MotoActions/src/com/moto/actions/util/FileUtils.java +++ b/LineageActions/src/org/lineageos/settings/device/util/FileUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.moto.actions.util; +package org.lineageos.settings.device.util; import android.util.Log; diff --git a/MotoActions/res/drawable/ic_settings_gestures_dashboard.xml b/MotoActions/res/drawable/ic_settings_gestures_dashboard.xml deleted file mode 100644 index 18f3b95..0000000 --- a/MotoActions/res/drawable/ic_settings_gestures_dashboard.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - diff --git a/MotoActions/res/layout/preference_category_material_settings.xml b/MotoActions/res/layout/preference_category_material_settings.xml deleted file mode 100644 index 5a1043d..0000000 --- a/MotoActions/res/layout/preference_category_material_settings.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/MotoActions/res/layout/preference_material_settings.xml b/MotoActions/res/layout/preference_material_settings.xml deleted file mode 100644 index 9682e32..0000000 --- a/MotoActions/res/layout/preference_material_settings.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/MotoActions/src/com/moto/actions/doze/GlanceSensor.java b/MotoActions/src/com/moto/actions/doze/GlanceSensor.java deleted file mode 100644 index 1b6e0db..0000000 --- a/MotoActions/src/com/moto/actions/doze/GlanceSensor.java +++ /dev/null @@ -1,76 +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 com.moto.actions.doze; - -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.util.Log; - -import com.moto.actions.MotoActionsSettings; -import com.moto.actions.SensorAction; -import com.moto.actions.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 boolean mEnabled; - - public GlanceSensor(MotoActionsSettings motoActionsSettings, SensorHelper sensorHelper, - SensorAction action) { - mMotoActionsSettings = motoActionsSettings; - mSensorHelper = sensorHelper; - mSensorAction = action; - - mSensor = sensorHelper.getGlanceSensor(); - } - - @Override - public void screenTurnedOn() { - if (mEnabled) { - Log.d(TAG, "Disabling"); - mSensorHelper.unregisterListener(mGlanceListener); - mEnabled = false; - } - } - - @Override - public void screenTurnedOff() { - if (mMotoActionsSettings.isPickUpEnabled() && !mEnabled) { - Log.d(TAG, "Enabling"); - mSensorHelper.registerListener(mSensor, mGlanceListener); - mEnabled = true; - } - } - - private SensorEventListener mGlanceListener = new SensorEventListener() { - @Override - public void onSensorChanged(SensorEvent event) { - Log.d(TAG, "triggered"); - mSensorAction.action(); - } - - @Override - public void onAccuracyChanged(Sensor mSensor, int accuracy) { - } - }; -} diff --git a/device.mk b/device.mk index d3d0d4b..49f34f7 100644 --- a/device.mk +++ b/device.mk @@ -264,9 +264,9 @@ PRODUCT_COPY_FILES += \ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_telephony.xml \ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_video.xml -# MotoActions +# LineageActions PRODUCT_PACKAGES += \ - MotoActions + LineageActions # Netutils PRODUCT_PACKAGES += \ @@ -302,7 +302,8 @@ PRODUCT_PACKAGES += \ # Overlay DEVICE_PACKAGE_OVERLAYS += \ - $(LOCAL_PATH)/overlay + $(LOCAL_PATH)/overlay \ + $(LOCAL_PATH)/overlay-lineage # Perf configs PRODUCT_COPY_FILES += \ diff --git a/overlay-lineage/frameworks/base/core/res/res/values/config.xml b/overlay-lineage/frameworks/base/core/res/res/values/config.xml new file mode 100644 index 0000000..55c25e7 --- /dev/null +++ b/overlay-lineage/frameworks/base/core/res/res/values/config.xml @@ -0,0 +1,46 @@ + + + + + + + + + + true + + + + + + + + diff --git a/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml b/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml new file mode 100644 index 0000000..7e966fb --- /dev/null +++ b/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml @@ -0,0 +1,69 @@ + + + + + + + true + 100 + true + + + 0 + + + + Standard:standard + Vibrant:dynamic + Comfort:astronomy + + + + 0 + + + false + + + + /system/priv-app/LineageActions/LineageActions.apk + + + + + org.lineageos.settings.device.KeyHandler + + + diff --git a/overlay/packages/apps/Settings/res/values/config.xml b/overlay-lineage/packages/apps/Dialer/java/com/android/dialer/callrecord/res/values/config.xml similarity index 65% rename from overlay/packages/apps/Settings/res/values/config.xml rename to overlay-lineage/packages/apps/Dialer/java/com/android/dialer/callrecord/res/values/config.xml index d3ed607..f206c16 100644 --- a/overlay/packages/apps/Settings/res/values/config.xml +++ b/overlay-lineage/packages/apps/Dialer/java/com/android/dialer/callrecord/res/values/config.xml @@ -1,5 +1,7 @@ - - - - - - 1 - + true + 4 diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index 5e6ec3e..eec6bd4 100644 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -23,50 +23,41 @@ Software implementation will be used if config_hardware_auto_brightness_available is not set --> true - - 3 - 88 - - true - - 2 - 10 + 1 + 6 + 12 + 25 50 - 90 - 100 - 150 - 200 - 300 - 400 + 80 + 120 + 175 + 250 + 350 500 - 800 + 750 1000 - 1300 + 1400 2000 - 3000 - 4000 - 8000 + 3500 + 6000 10000 + 15000 + 20000 + 30000 + 65535 - 3 - 11 - 40 - 62 - 74 - 85 - 102 - 102 - 102 - 102 - 128 + 7 + 10 + 13 + 16 + 22 + 28 + 34 + 43 + 52 + 61 + 72 + 83 + 94 + 105 + 117 + 129 + 141 153 - 170 + 166 179 - 238 - 255 - 255 - 255 - 256 + 192 + 205 + 218 @@ -241,19 +236,8 @@ 5000 - - true - - - true - - - false - - - true + + #ff0000ff true @@ -297,7 +281,7 @@ true - true + false @@ -322,8 +306,8 @@ turned off and the screen off animation has been performed. --> true - - false + + true true - - true - - - org.codeaurora.ims - - - true - true false - - - /vendor/app/MotoActions/MotoActions.apk - + + true - - com.moto.actions.KeyHandler - + + true @@ -411,33 +387,38 @@ + "/system/framework/arm64/boot-core-libart.oat" "/system/framework/arm64/boot-framework.oat" + "/system/framework/arm64/boot.oat" + "/system/framework/boot-core-libart.vdex" "/system/framework/boot-framework.vdex" + "/system/framework/boot.vdex" "/system/framework/oat/arm64/services.odex" "/system/framework/oat/arm64/services.vdex" - "/system/framework/arm64/boot.oat" - "/system/framework/boot.vdex" - "/system/framework/arm64/boot-core-libart.oat" - "/system/framework/boot-core-libart.vdex" + + true + true - - true + + true - - true - - + true - - true + + org.codeaurora.ims + + + true true + + true diff --git a/overlay/frameworks/base/core/res/res/xml/power_profile.xml b/overlay/frameworks/base/core/res/res/xml/power_profile.xml index 0080cc1..22f977a 100644 --- a/overlay/frameworks/base/core/res/res/xml/power_profile.xml +++ b/overlay/frameworks/base/core/res/res/xml/power_profile.xml @@ -1,66 +1,61 @@ 0 - 93 - 216.4 - .6 - 103.6 - 33.7 - 678.6 - 172 - 37 - 343.4 - 33.3 + 98.648 + 193.430 + 1.075 + 41.638 + 4.446 + 40.478 + 570.594 + 19.646 + 182.518 + 41.395 - 29 + 35.5 + 35 + 30 25 20 15 10 5 - 2 + 3.5 + 8.309 + 170.273 + 146.062 + 866.419 + 1.133 + 26.438 + 63.683 + 112.528 - 4 - 4 + 8 652800 1036800 1401600 1689600 - 1843200 + 1804800 1958400 2016000 - 35 - 45.4 - 60 - 77.5 - 96 - 105 - 112 + 33.802 + 46.767 + 59.310 + 78.318 + 99.180 + 112.014 + 118.914 - - 652800 - 1036800 - 1401600 - 1689600 - 1843200 - 1958400 - 2016000 - - - 35 - 45.4 - 60 - 77.5 - 96 - 105 - 112 - - 4 - 7 + 6.198 3000 + 0.585 + 65.896 + 130.159 + + 184.53 \ No newline at end of file diff --git a/overlay/packages/apps/Snap/res/values/config.xml b/overlay/packages/apps/Snap/res/values/config.xml index 9bbdac3..4ecca1c 100644 --- a/overlay/packages/apps/Snap/res/values/config.xml +++ b/overlay/packages/apps/Snap/res/values/config.xml @@ -16,6 +16,7 @@ --> + false @@ -32,4 +33,7 @@ Example: 1920x1080 --> 1280x960 + + true +