aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvm03 <vasy@vasy.ru>2017-02-14 19:02:05 +0300
committervm03 <vasy@vasy.ru>2017-02-14 19:02:05 +0300
commit8857ff1fc4f4bbce10e1d0198fb33faa7464224c (patch)
tree6de80c30386c687f8284d3bf8c5c6e66da204b08
parent40d784fd8a762f1377d180a51332be63c72c5d2f (diff)
cmactions: kang CMActions from motorola
Change-Id: Ibbb47bb4b77ff8c0bc93f0659cf8fb2fbefc1270
-rw-r--r--CMActions/Android.mk41
-rw-r--r--CMActions/AndroidManifest.xml43
-rw-r--r--CMActions/proguard.flags9
-rw-r--r--CMActions/res/drawable/ic_settings_gestures.xml32
-rw-r--r--CMActions/res/values/styles.xml21
-rw-r--r--CMActions/res/xml/gesture_panel.xml40
-rw-r--r--CMActions/src/com/cyanogenmod/cmactions/BootCompletedReceiver.java35
-rw-r--r--CMActions/src/com/cyanogenmod/cmactions/CMActionsService.java205
-rw-r--r--CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceActivity.java32
-rw-r--r--CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceFragment.java75
-rw-r--r--lineage.dependencies4
11 files changed, 537 insertions, 0 deletions
diff --git a/CMActions/Android.mk b/CMActions/Android.mk
new file mode 100644
index 0000000..00cb9da
--- /dev/null
+++ b/CMActions/Android.mk
@@ -0,0 +1,41 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CMActions
+LOCAL_CERTIFICATE := platform
+LOCAL_PRIVILEGED_MODULE := true
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-v14-preference \
+ android-support-v7-appcompat \
+ android-support-v7-preference \
+ android-support-v7-recyclerview \
+ org.cyanogenmod.platform.internal
+
+LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+
+LOCAL_RESOURCE_DIR := \
+ $(LOCAL_PATH)/res \
+ $(LOCAL_PATH)/../../../../packages/resources/devicesettings/res \
+ frameworks/support/v14/preference/res \
+ frameworks/support/v7/appcompat/res \
+ frameworks/support/v7/preference/res \
+ frameworks/support/v7/recyclerview/res
+
+LOCAL_AAPT_FLAGS := --auto-add-overlay \
+ --extra-packages android.support.v14.preference:android.support.v7.appcompat:android.support.v7.preference:android.support.v7.recyclerview
+
+ifneq ($(INCREMENTAL_BUILDS),)
+ LOCAL_PROGUARD_ENABLED := disabled
+ LOCAL_JACK_ENABLED := incremental
+endif
+
+include frameworks/base/packages/SettingsLib/common.mk
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/CMActions/AndroidManifest.xml b/CMActions/AndroidManifest.xml
new file mode 100644
index 0000000..16df21a
--- /dev/null
+++ b/CMActions/AndroidManifest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.cyanogenmod.cmactions"
+ android:sharedUserId="android.uid.system">
+
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+
+ <protected-broadcast android:name="com.android.systemui.doze.pulse" />
+
+ <application
+ android:label="@string/device_settings_app_name"
+ android:persistent="true">
+
+ <receiver android:name="com.cyanogenmod.cmactions.BootCompletedReceiver">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </receiver>
+
+ <service android:name="com.cyanogenmod.cmactions.CMActionsService"
+ android:permission="CMActionsService">
+ </service>
+
+ <activity
+ android:name=".GesturePreferenceActivity"
+ android:label="@string/screen_gestures_panel_title"
+ android:theme="@style/CMActions">
+ <intent-filter>
+ <action android:name="com.android.settings.action.EXTRA_SETTINGS" />
+ </intent-filter>
+ <meta-data
+ android:name="com.android.settings.category"
+ android:value="com.android.settings.category.device" />
+ <meta-data
+ android:name="com.android.settings.icon"
+ android:resource="@drawable/ic_settings_gestures" />
+ </activity>
+
+ </application>
+</manifest>
diff --git a/CMActions/proguard.flags b/CMActions/proguard.flags
new file mode 100644
index 0000000..b23afd2
--- /dev/null
+++ b/CMActions/proguard.flags
@@ -0,0 +1,9 @@
+-keep class com.cyanogenmod.CMActions.* {
+ *;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keep class ** extends android.support.v14.preference.PreferenceFragment
diff --git a/CMActions/res/drawable/ic_settings_gestures.xml b/CMActions/res/drawable/ic_settings_gestures.xml
new file mode 100644
index 0000000..95cdede
--- /dev/null
+++ b/CMActions/res/drawable/ic_settings_gestures.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2015 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M4.7,6.9c0.7-0.7,1.4-1.4,1.7-1.2c0.5,0.2,0,1-0.3,1.5c-0.2,0.4-2.8,3.9-2.8,6.3c0,1.3,0.5,2.3,1.3,3
+c0.7,0.6,1.7,0.7,2.6,0.5c1.1-0.3,1.9-1.4,3-2.8c1.2-1.5,2.8-3.4,4-3.4c1.6,0,1.6,1,1.7,1.8c-3.7,0.6-5.3,3.7-5.3,5.4
+s1.4,3.1,3.2,3.1c1.6,0,4.3-1.3,4.6-6.1H21v-2.5h-2.4c-0.1-1.7-1.1-4.2-4-4.2c-2.2,0-4.1,1.9-4.9,2.8c-0.6,0.7-2,2.5-2.3,2.7
+c-0.2,0.3-0.7,0.8-1.1,0.8c-0.4,0-0.7-0.8-0.4-1.9c0.3-1.1,1.4-2.9,1.8-3.5C8.5,8,9.1,7.2,9.1,5.9C9.1,3.7,7.4,3,6.6,3
+C5.3,3,4.1,4,3.9,4.3C3.5,4.6,3.2,4.9,3,5.2L4.7,6.9z
+M13.9,18.6c-0.3,0-0.7-0.3-0.7-0.7c0-0.6,0.7-2.2,2.8-2.8
+C15.8,17.8,14.6,18.6,13.9,18.6z" />
+</vector>
diff --git a/CMActions/res/values/styles.xml b/CMActions/res/values/styles.xml
new file mode 100644
index 0000000..c497d8e
--- /dev/null
+++ b/CMActions/res/values/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <style name="CMActions" parent="@android:style/Theme.Material.Settings">
+ <item name="preferenceTheme">@android:style/Theme.Material.Settings</item>
+ </style>
+</resources>
diff --git a/CMActions/res/xml/gesture_panel.xml b/CMActions/res/xml/gesture_panel.xml
new file mode 100644
index 0000000..c75c224
--- /dev/null
+++ b/CMActions/res/xml/gesture_panel.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <PreferenceCategory
+ android:key="ambient_display_key"
+ android:title="@string/ambient_display_title" >
+
+ <SwitchPreference
+ android:key="ambient_display_enable"
+ android:defaultValue="true"
+ android:title="@string/ambient_display_enable_title"
+ android:summary="@string/ambient_display_enable_summary" />
+
+ <SwitchPreference
+ android:key="gesture_hand_wave"
+ android:defaultValue="false"
+ android:title="@string/hand_wave_gesture_title"
+ android:summary="@string/hand_wave_gesture_summary" />
+
+ <SwitchPreference
+ android:key="gesture_pocket"
+ android:defaultValue="false"
+ android:title="@string/pocket_gesture_title"
+ android:summary="@string/pocket_gesture_summary" />
+
+ </PreferenceCategory>
+
+</PreferenceScreen>
diff --git a/CMActions/src/com/cyanogenmod/cmactions/BootCompletedReceiver.java b/CMActions/src/com/cyanogenmod/cmactions/BootCompletedReceiver.java
new file mode 100644
index 0000000..e179053
--- /dev/null
+++ b/CMActions/src/com/cyanogenmod/cmactions/BootCompletedReceiver.java
@@ -0,0 +1,35 @@
+/*
+ * 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 com.cyanogenmod.cmactions;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class BootCompletedReceiver extends BroadcastReceiver {
+
+ private static final boolean DEBUG = false;
+ private static final String TAG = "CMActions";
+
+ @Override
+ public void onReceive(final Context context, Intent intent) {
+ if (DEBUG) Log.d(TAG, "Starting service");
+ context.startService(new Intent(context, CMActionsService.class));
+ }
+
+}
diff --git a/CMActions/src/com/cyanogenmod/cmactions/CMActionsService.java b/CMActions/src/com/cyanogenmod/cmactions/CMActionsService.java
new file mode 100644
index 0000000..9eb1efa
--- /dev/null
+++ b/CMActions/src/com/cyanogenmod/cmactions/CMActionsService.java
@@ -0,0 +1,205 @@
+/*
+ * 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 com.cyanogenmod.cmactions;
+
+import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.os.IBinder;
+import android.os.PowerManager;
+import android.os.UserHandle;
+import android.preference.PreferenceManager;
+import android.provider.Settings;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CMActionsService extends Service {
+ private static final String TAG = "CMActionsService";
+ private static final boolean DEBUG = false;
+
+ private static final String GESTURE_HAND_WAVE_KEY = "gesture_hand_wave";
+ private static final String GESTURE_POCKET_KEY = "gesture_pocket";
+
+ private static final String DOZE_INTENT = "com.android.systemui.doze.pulse";
+
+ private static final int POCKET_DELTA_NS = 1000 * 1000 * 1000;
+
+ private Context mContext;
+ private MotoProximitySensor mSensor;
+ private PowerManager mPowerManager;
+ private PowerManager.WakeLock mWakeLock;
+
+ private boolean mHandwaveGestureEnabled = false;
+ private boolean mPocketGestureEnabled = false;
+
+ class MotoProximitySensor implements SensorEventListener {
+ private SensorManager mSensorManager;
+ private Sensor mSensor;
+
+ private boolean mSawNear = false;
+ private long mInPocketTime = 0;
+
+ public MotoProximitySensor(Context context) {
+ mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
+ mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
+ }
+
+ @Override
+ public void onSensorChanged(SensorEvent event) {
+ boolean isNear = event.values[0] < mSensor.getMaximumRange();
+ if (mSawNear && !isNear) {
+ if (shouldPulse(event.timestamp)) {
+ launchDozePulse();
+ }
+ } else {
+ mInPocketTime = event.timestamp;
+ }
+ mSawNear = isNear;
+ }
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+ /* Empty */
+ }
+
+ private boolean shouldPulse(long timestamp) {
+ long delta = timestamp - mInPocketTime;
+
+ if (mHandwaveGestureEnabled && mPocketGestureEnabled) {
+ return true;
+ } else if (mHandwaveGestureEnabled && !mPocketGestureEnabled) {
+ return delta < POCKET_DELTA_NS;
+ } else if (!mHandwaveGestureEnabled && mPocketGestureEnabled) {
+ return delta >= POCKET_DELTA_NS;
+ }
+ return false;
+ }
+
+ public void enable() {
+ mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
+ }
+
+ public void disable() {
+ mSensorManager.unregisterListener(this, mSensor);
+ }
+ }
+
+ @Override
+ public void onCreate() {
+ if (DEBUG) Log.d(TAG, "CMActionsService Started");
+ mContext = this;
+ mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
+ mSensor = new MotoProximitySensor(mContext);
+ mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "CMActionsWakeLock");
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
+ loadPreferences(sharedPrefs);
+ sharedPrefs.registerOnSharedPreferenceChangeListener(mPrefListener);
+ if (!isInteractive() && areGesturesEnabled()) {
+ mSensor.enable();
+ }
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ if (DEBUG) Log.d(TAG, "Starting service");
+ IntentFilter screenStateFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
+ screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
+ mContext.registerReceiver(mScreenStateReceiver, screenStateFilter);
+ return START_STICKY;
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ private void launchDozePulse() {
+ mContext.sendBroadcastAsUser(new Intent(DOZE_INTENT), UserHandle.ALL);
+ }
+
+ private boolean isInteractive() {
+ return mPowerManager.isInteractive();
+ }
+
+ private boolean areGesturesEnabled() {
+ return (mHandwaveGestureEnabled || mPocketGestureEnabled) &&
+ Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.DOZE_ENABLED, 1) != 0;
+ }
+
+ private void onDisplayOn() {
+ if (DEBUG) Log.d(TAG, "Display on");
+ mSensor.disable();
+ if (areGesturesEnabled() && !mWakeLock.isHeld()) {
+ if (DEBUG) Log.d(TAG, "Acquiring wakelock");
+ mWakeLock.acquire();
+ }
+ }
+
+ private void onDisplayOff() {
+ if (DEBUG) Log.d(TAG, "Display off");
+ if (areGesturesEnabled()) {
+ mSensor.enable();
+ }
+ if (mWakeLock.isHeld()) {
+ if (DEBUG) Log.d(TAG, "Releasing wakelock");
+ mWakeLock.release();
+ }
+ }
+
+ private void loadPreferences(SharedPreferences sharedPreferences) {
+ mHandwaveGestureEnabled = sharedPreferences.getBoolean(GESTURE_HAND_WAVE_KEY, false);
+ mPocketGestureEnabled = sharedPreferences.getBoolean(GESTURE_POCKET_KEY, false);
+ }
+
+ private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
+ onDisplayOff();
+ } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
+ onDisplayOn();
+ }
+ }
+ };
+
+ private SharedPreferences.OnSharedPreferenceChangeListener mPrefListener =
+ new SharedPreferences.OnSharedPreferenceChangeListener() {
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if (GESTURE_HAND_WAVE_KEY.equals(key)) {
+ mHandwaveGestureEnabled = sharedPreferences.getBoolean(GESTURE_HAND_WAVE_KEY, false);
+ } else if (GESTURE_POCKET_KEY.equals(key)) {
+ mPocketGestureEnabled = sharedPreferences.getBoolean(GESTURE_POCKET_KEY, false);
+ }
+
+ if (areGesturesEnabled() && !mWakeLock.isHeld()) {
+ if (DEBUG) Log.d(TAG, "Acquiring wakelock");
+ mWakeLock.acquire();
+ }
+ }
+ };
+}
diff --git a/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceActivity.java b/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceActivity.java
new file mode 100644
index 0000000..837fe80
--- /dev/null
+++ b/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceActivity.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 com.cyanogenmod.cmactions;
+
+import android.os.Bundle;
+
+import com.android.settingslib.drawer.SettingsDrawerActivity;
+
+public class GesturePreferenceActivity extends SettingsDrawerActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getFragmentManager().beginTransaction()
+ .replace(R.id.content_frame, new GesturePreferenceFragment()).commit();
+ }
+
+}
diff --git a/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceFragment.java b/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceFragment.java
new file mode 100644
index 0000000..73ce0a5
--- /dev/null
+++ b/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceFragment.java
@@ -0,0 +1,75 @@
+/*
+ * 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 com.cyanogenmod.cmactions;
+
+import android.os.Bundle;
+import android.support.v14.preference.PreferenceFragment;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+import android.provider.Settings;
+
+public class GesturePreferenceFragment extends PreferenceFragment {
+
+ private static final String KEY_AMBIENT_DISPLAY_ENABLE = "ambient_display_enable";
+ private static final String KEY_GESTURE_POCKET = "gesture_pocket";
+ private static final String KEY_GESTURE_HAND_WAVE = "gesture_hand_wave";
+
+ private SwitchPreference mAmbientDisplayPreference;
+ private SwitchPreference mPocketPreference;
+ private SwitchPreference mHandwavePreference;
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ addPreferencesFromResource(R.xml.gesture_panel);
+ boolean dozeEnabled = isDozeEnabled();
+ mAmbientDisplayPreference =
+ (SwitchPreference) findPreference(KEY_AMBIENT_DISPLAY_ENABLE);
+ // Read from DOZE_ENABLED secure setting
+ mAmbientDisplayPreference.setChecked(dozeEnabled);
+ mAmbientDisplayPreference.setOnPreferenceChangeListener(mAmbientDisplayPrefListener);
+ mPocketPreference =
+ (SwitchPreference) findPreference(KEY_GESTURE_POCKET);
+ mPocketPreference.setEnabled(dozeEnabled);
+ mHandwavePreference =
+ (SwitchPreference) findPreference(KEY_GESTURE_HAND_WAVE);
+ mHandwavePreference.setEnabled(dozeEnabled);
+ }
+
+ private boolean enableDoze(boolean enable) {
+ return Settings.Secure.putInt(getActivity().getContentResolver(),
+ Settings.Secure.DOZE_ENABLED, enable ? 1 : 0);
+ }
+
+ private boolean isDozeEnabled() {
+ return Settings.Secure.getInt(getActivity().getContentResolver(),
+ Settings.Secure.DOZE_ENABLED, 1) != 0;
+ }
+
+ private Preference.OnPreferenceChangeListener mAmbientDisplayPrefListener =
+ new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ boolean enable = (boolean) newValue;
+ boolean ret = enableDoze(enable);
+ if (ret) {
+ mPocketPreference.setEnabled(enable);
+ mHandwavePreference.setEnabled(enable);
+ }
+ return ret;
+ }
+ };
+}
diff --git a/lineage.dependencies b/lineage.dependencies
index 946d96a..ba0d547 100644
--- a/lineage.dependencies
+++ b/lineage.dependencies
@@ -10,5 +10,9 @@
{
"repository": "android_external_sony_boringssl-compat",
"target_path": "external/sony/boringssl-compat"
+ },
+ {
+ "repository": "android_packages_resources_devicesettings",
+ "target_path": "packages/resources/devicesettings"
}
]