sanders: BRINGUP A NEW LINEAGE TREE

Signed-off-by: ronaxdevil <pratabidya.007@gmail.com>
This commit is contained in:
chirayu19091997
2018-12-15 14:27:53 +00:00
committed by ronaxdevil
parent 54422cfb9b
commit 9910e9f435
68 changed files with 1035 additions and 670 deletions

View File

@@ -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

View File

@@ -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))

View File

@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.moto.actions"
package="org.lineageos.settings.device"
android:sharedUserId="android.uid.system"
>
<original-package android:name="com.cyanogenmod.settings.device" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
@@ -15,6 +14,10 @@
<protected-broadcast android:name="com.android.systemui.doze.pulse" />
<uses-sdk
android:minSdkVersion="26"
android:targetSdkVersion="26" />
<application
android:allowBackup="true"
android:label="@string/moto_actions_title"
@@ -22,8 +25,8 @@
android:persistent="true">
<provider
android:name=".MotoActionsSearchIndexablesProvider"
android:authorities="com.moto.actions"
android:name=".LineageActionsSearchIndexablesProvider"
android:authorities="org.lineageos.settings.device"
android:multiprocess="false"
android:grantUriPermissions="true"
android:permission="android.permission.READ_SEARCH_INDEXABLES"
@@ -33,7 +36,7 @@
</intent-filter>
</provider>
<receiver android:name="com.moto.actions.BootCompletedReceiver">
<receiver android:name="org.lineageos.settings.device.BootCompletedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
@@ -49,9 +52,9 @@
<activity
android:name=".DozeSettingsActivity"
android:label="@string/ambient_display_title"
android:theme="@style/MotoActions">
android:theme="@style/LineageActions">
<intent-filter>
<action android:name="com.moto.actions.DOZE_SETTINGS" />
<action android:name="org.lineageos.settings.device.DOZE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
@@ -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">
<intent-filter>
<action android:name="com.android.settings.action.IA_SETTINGS" />
</intent-filter>
@@ -69,7 +72,7 @@
android:value="com.android.settings.category.ia.homepage" />
<meta-data
android:name="com.android.settings.icon"
android:resource="@drawable/ic_settings_gestures_dashboard" />
android:resource="@drawable/ic_settings_gestures" />
<meta-data
android:name="com.android.settings.summary"
android:resource="@string/device_gestures_summary" />
@@ -78,13 +81,19 @@
<activity
android:name=".GestureSettingsActivity"
android:label="@string/device_gestures_title"
android:theme="@style/MotoActions">
android:theme="@style/LineageActions">
</activity>
<activity
android:name=".FPGestureSettingsActivity"
android:label="@string/fingerprint_gestures_title"
android:theme="@style/MotoActions">
android:theme="@style/LineageActions">
</activity>
<activity
android:name=".ScreenOffGestureSettingsActivity"
android:label="@string/screen_off_gestures_title"
android:theme="@style/LineageActions">
</activity>
</application>

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -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" />
</LinearLayout>

View File

@@ -89,4 +89,7 @@
<string name="haptic_feedback">Retorno tátil</string>
<string name="haptic_feedback_summary">Vibrar quando um gesto for detectado</string>
<!-- Proximity sensor -->
<string name="allow_proximity_sensor_title">Habilitar o sensor de proximidade</string>
<string name="allow_proximity_sensor_summary">Verificar o sensor de proximidade antes de executar a ação</string>
</resources>

View File

@@ -89,4 +89,8 @@
<string name="haptic_feedback">Haptic feedback</string>
<string name="haptic_feedback_summary">Vibrate when a touchscreen gesture is detected</string>
<!-- Proximity sensor -->
<string name="allow_proximity_sensor_title">Allow proximity sensor</string>
<string name="allow_proximity_sensor_summary">Check the proximity sensor before performing the action</string>
</resources>

View File

@@ -17,42 +17,42 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<style name="MotoActions" parent="@android:style/Theme.DeviceDefault.Settings">
<item name="dialogPreferenceStyle">@style/MotoActions.DialogPreferenceStyle</item>
<item name="preferenceCategoryStyle">@style/MotoActions.PreferenceCategoryStyle</item>
<item name="preferenceFragmentStyle">@style/MotoActions.PreferenceFragmentStyle</item>
<item name="preferenceStyle">@style/MotoActions.PreferenceStyle</item>
<item name="preferenceTheme">@style/MotoActions.PreferenceTheme</item>
<item name="switchPreferenceStyle">@style/MotoActions.SwitchPreferenceStyle</item>
<style name="LineageActions" parent="@android:style/Theme.DeviceDefault.Settings">
<item name="dialogPreferenceStyle">@style/LineageActions.DialogPreferenceStyle</item>
<item name="preferenceCategoryStyle">@style/LineageActions.PreferenceCategoryStyle</item>
<item name="preferenceFragmentStyle">@style/LineageActions.PreferenceFragmentStyle</item>
<item name="preferenceStyle">@style/LineageActions.PreferenceStyle</item>
<item name="preferenceTheme">@style/LineageActions.PreferenceTheme</item>
<item name="switchPreferenceStyle">@style/LineageActions.SwitchPreferenceStyle</item>
</style>
<style name="MotoActions.DialogPreferenceStyle" parent="@style/MotoActions.PreferenceStyle">
<style name="LineageActions.DialogPreferenceStyle" parent="@style/LineageActions.PreferenceStyle">
</style>
<style name="MotoActions.PreferenceCategoryStyle" parent="@*android:style/Preference.DeviceDefault.Category">
<style name="LineageActions.PreferenceCategoryStyle" parent="@*android:style/Preference.DeviceDefault.Category">
<item name="allowDividerAbove">true</item>
<item name="allowDividerBelow">true</item>
<item name="android:layout">@layout/preference_category_material_settings</item>
</style>
<style name="MotoActions.PreferenceFragmentStyle" parent="@*android:style/PreferenceFragment.Material">
<style name="LineageActions.PreferenceFragmentStyle" parent="@*android:style/PreferenceFragment.Material">
<item name="allowDividerAfterLastItem">false</item>
</style>
<style name="MotoActions.PreferenceStyle" parent="@*android:style/Preference.DeviceDefault">
<style name="LineageActions.PreferenceStyle" parent="@*android:style/Preference.DeviceDefault">
<item name="allowDividerAbove">false</item>
<item name="allowDividerBelow">true</item>
<item name="singleLineTitle">false</item>
<item name="android:layout">@layout/preference_material_settings</item>
</style>
<style name="MotoActions.PreferenceTheme">
<style name="LineageActions.PreferenceTheme">
</style>
<style name="MotoActions.SwitchPreferenceStyle" parent="@style/MotoActions.PreferenceStyle">
<style name="LineageActions.SwitchPreferenceStyle" parent="@style/LineageActions.PreferenceStyle">
<item name="widgetLayout">@*android:layout/preference_widget_switch</item>
</style>
<style name="MotoActions.SwitchBar" parent="@android:style/ThemeOverlay.Material.ActionBar">
<style name="LineageActions.SwitchBar" parent="@android:style/ThemeOverlay.Material.ActionBar">
</style>
</resources>

View File

@@ -25,7 +25,7 @@
<SwitchPreference
android:key="gesture_hand_wave"
android:defaultValue="false"
android:defaultValue="true"
android:title="@string/hand_wave_gesture_title"
android:summary="@string/hand_wave_gesture_summary" />

View File

@@ -89,6 +89,13 @@
android:title="@string/haptic_feedback"
android:summary="@string/haptic_feedback_summary" />
<SwitchPreference
android:key="fp_proximity_check_scr_off"
android:dependency="fp_home_scr_off"
android:defaultValue="1"
android:title="@string/allow_proximity_sensor_title"
android:summary="@string/allow_proximity_sensor_summary" />
<ListPreference
android:dependency="fp_home_scr_off"
android:title="@string/fingerprint_tap_title"

View File

@@ -24,8 +24,8 @@
android:summary="@string/device_gestures_summary"
android:icon="@drawable/ic_settings_gestures">
<intent
android:targetPackage="com.moto.actions"
android:targetClass="com.moto.actions.GestureSettingsActivity" />
android:targetPackage="org.lineageos.settings.device"
android:targetClass="org.lineageos.settings.device.GestureSettingsActivity" />
</Preference>
<Preference
@@ -34,8 +34,8 @@
android:summary="@string/ambient_display_manage_summary"
android:icon="@drawable/ic_settings_doze">
<intent
android:targetPackage="com.moto.actions"
android:targetClass="com.moto.actions.DozeSettingsActivity" />
android:targetPackage="org.lineageos.settings.device"
android:targetClass="org.lineageos.settings.device.DozeSettingsActivity" />
</Preference>
<Preference
@@ -44,8 +44,18 @@
android:summary="@string/fingerprint_gestures_manage_summary"
android:icon="@drawable/ic_settings_fingerprint">
<intent
android:targetPackage="com.moto.actions"
android:targetClass="com.moto.actions.FPGestureSettingsActivity" />
android:targetPackage="org.lineageos.settings.device"
android:targetClass="org.lineageos.settings.device.FPGestureSettingsActivity" />
</Preference>
<Preference
android:key="screen_off_gestures"
android:title="@string/screen_off_gestures_title"
android:summary="@string/screen_off_gestures_manage_summary"
android:icon="@drawable/ic_settings_screen_off_gestures">
<intent
android:targetPackage="org.lineageos.settings.device"
android:targetClass="org.lineageos.settings.device.ScreenOffGestureSettingsActivity" />
</Preference>
</PreferenceScreen>

View File

@@ -28,6 +28,11 @@
android:title="@string/haptic_feedback"
android:summary="@string/haptic_feedback_summary" />
<SwitchPreference
android:key="proximity_sensor"
android:title="@string/allow_proximity_sensor_title"
android:summary="@string/allow_proximity_sensor_summary" />
<ListPreference
android:title="@string/screen_off_gestures_swipe_left_title"
android:summary="%s"

View File

@@ -14,9 +14,10 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class ActionsPreferenceActivity extends PreferenceActivity {
@@ -24,12 +25,9 @@ public class ActionsPreferenceActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
if (savedInstanceState == null){
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new ActionsPreferenceFragment()).commit();
}
}
}

View File

@@ -15,12 +15,17 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.os.Bundle;
import android.support.v14.preference.PreferenceFragment;
public class ActionsPreferenceFragment extends PreferenceFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -27,11 +27,14 @@ import android.content.ServiceConnection;
import android.os.IBinder;
import android.util.Log;
import com.moto.actions.actions.Constants;
import com.moto.actions.ServiceWrapper.LocalBinder;
import lineageos.providers.LineageSettings;
import org.lineageos.settings.device.util.FileUtils;
import org.lineageos.settings.device.actions.Constants;
import org.lineageos.settings.device.ServiceWrapper.LocalBinder;
public class BootCompletedReceiver extends BroadcastReceiver {
static final String TAG = "MotoActions";
static final String TAG = "LineageActions";
final String NAVBAR_SHOWN = "navbar_shown";
private ServiceWrapper mServiceWrapper;
@@ -40,18 +43,26 @@ public class BootCompletedReceiver extends BroadcastReceiver {
public void onReceive(final Context context, Intent intent) {
Log.i(TAG, "Booting");
if (intent.getAction() != null && !intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
return;
}
// Restore nodes to saved preference values
for (String pref : Constants.sPrefKeys) {
Constants.writePreference(context, pref);
}
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if (!preferences.getBoolean(NAVBAR_SHOWN, false)) {
enableNavBar(true, context);
preferences.edit().putBoolean(NAVBAR_SHOWN, true).commit();
}
context.startService(new Intent(context, ServiceWrapper.class));
}
protected static void enableNavBar(boolean enable, Context context) {
// LineageSettings.Global.putInt(context.getContentResolver(),
// LineageSettings.Global.DEV_FORCE_SHOW_NAVBAR, enable ? 1 : 0);
}
private ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {

View File

@@ -14,9 +14,10 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class DozeSettingsActivity extends PreferenceActivity {
@@ -24,12 +25,9 @@ public class DozeSettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setTitle(R.string.ambient_display_title);
if (savedInstanceState == null){
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new DozeSettingsFragment()).commit();
}
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new DozeSettingsFragment()).commit();
}
}

View File

@@ -14,8 +14,9 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.app.ActionBar;
import android.os.Bundle;
import android.support.v14.preference.PreferenceFragment;
import android.provider.Settings;
@@ -40,6 +41,14 @@ public class DozeSettingsFragment extends PreferenceFragment {
private String KEY_GESTURE_HAND_WAVE = "gesture_hand_wave";
private String KEY_GESTURE_PICK_UP = "gesture_pick_up";
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ActionBar actionbar = getActivity().getActionBar();
actionbar.setDisplayHomeAsUpEnabled(true);
actionbar.setTitle(R.string.ambient_display_title);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -54,7 +63,7 @@ public class DozeSettingsFragment extends PreferenceFragment {
View switchBar = view.findViewById(R.id.switch_bar);
mAmbientDisplaySwitch = (Switch) switchBar.findViewById(android.R.id.switch_widget);
mAmbientDisplaySwitch.setChecked(MotoActionsSettings.isDozeEnabled(getActivity().getContentResolver()));
mAmbientDisplaySwitch.setChecked(LineageActionsSettings.isDozeEnabled(getActivity().getContentResolver()));
mAmbientDisplaySwitch.setOnCheckedChangeListener(mAmbientDisplayPrefListener);
switchBar.setOnClickListener(new View.OnClickListener() {
@@ -65,14 +74,14 @@ public class DozeSettingsFragment extends PreferenceFragment {
});
mSwitchBarText = switchBar.findViewById(R.id.switch_text);
mSwitchBarText.setText(MotoActionsSettings.isDozeEnabled(getActivity().getContentResolver()) ? R.string.switch_bar_on :
mSwitchBarText.setText(LineageActionsSettings.isDozeEnabled(getActivity().getContentResolver()) ? R.string.switch_bar_on :
R.string.switch_bar_off);
}
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.doze_panel);
boolean dozeEnabled = MotoActionsSettings.isDozeEnabled(getActivity().getContentResolver());
boolean dozeEnabled = LineageActionsSettings.isDozeEnabled(getActivity().getContentResolver());
mHandwavePreference = (SwitchPreference) findPreference(KEY_GESTURE_HAND_WAVE);
mPickupPreference = (SwitchPreference) findPreference(KEY_GESTURE_PICK_UP);
updatePrefs(dozeEnabled);

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.os.Bundle;
@@ -25,13 +25,9 @@ public class FPGestureSettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setTitle(R.string.fingerprint_gestures_title);
}
if (savedInstanceState == null){
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new FPGestureSettingsFragment()).commit();
}
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.app.ActionBar;
import android.os.Bundle;
@@ -33,10 +33,10 @@ import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
import com.moto.actions.actions.Constants;
import org.lineageos.settings.device.actions.Constants;
import static com.moto.actions.actions.Constants.FP_HOME_KEY;
import static com.moto.actions.actions.Constants.FP_HOME_KEY_OFF;
import static org.lineageos.settings.device.actions.Constants.FP_HOME_KEY;
import static org.lineageos.settings.device.actions.Constants.FP_HOME_KEY_OFF;
public class FPGestureSettingsFragment extends PreferenceFragment {
@@ -47,6 +47,14 @@ public class FPGestureSettingsFragment extends PreferenceFragment {
private TextView mSwitchBarText;
private Switch mFPGestureSwitch;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ActionBar actionbar = getActivity().getActionBar();
actionbar.setDisplayHomeAsUpEnabled(true);
actionbar.setTitle(R.string.fingerprint_gestures_title);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.os.Bundle;
@@ -25,12 +25,9 @@ public class GestureSettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
if (savedInstanceState == null){
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new GestureSettingsFragment()).commit();
}
}
}

View File

@@ -14,13 +14,19 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.os.Bundle;
import android.support.v14.preference.PreferenceFragment;
public class GestureSettingsFragment extends PreferenceFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.actions_panel);

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
@@ -30,6 +30,9 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
@@ -60,11 +63,13 @@ import android.view.ViewConfiguration;
import com.android.internal.os.DeviceKeyHandler;
import com.android.internal.util.ArrayUtils;
import com.moto.actions.util.FileUtils;
import org.lineageos.settings.device.util.FileUtils;
import java.util.List;
import static com.moto.actions.actions.Constants.*;
import lineageos.providers.LineageSettings;
import static org.lineageos.settings.device.actions.Constants.*;
public class KeyHandler implements DeviceKeyHandler {
@@ -84,17 +89,24 @@ public class KeyHandler implements DeviceKeyHandler {
.build();
private final Context mContext;
private final PowerManager mPowerManager;
WakeLock mProximityWakeLock;
WakeLock mGestureWakeLock;
private KeyguardManager mKeyguardManager;
private ScreenOffGesturesHandler mScreenOffGesturesHandler;
private FPScreenOffGesturesHandler mFPScreenOffGesturesHandler;
private SensorManager mSensorManager;
private CameraManager mCameraManager;
private String mRearCameraId;
private boolean mTorchEnabled;
private Sensor mProximitySensor;
private Vibrator mVibrator;
private int mProximityTimeOut;
private boolean mProximityWakeSupported;
private ISearchManager mSearchManagerService;
private Handler mHandler;
private int fpTapCounts = 0;
private boolean fpTapPending = false;
private boolean screenOffGesturePending = false;
private boolean fpGesturePending = false;
private Runnable doubleTapRunnable = new Runnable() {
public void run() {
@@ -116,6 +128,11 @@ public class KeyHandler implements DeviceKeyHandler {
resetDoubleTapOnFP();
}
};
private Runnable screenOffGestureRunnable = new Runnable() {
public void run() {
resetScreenOffGestureDelay();
}
};
private Runnable fpGestureRunnable = new Runnable() {
public void run() {
resetFPGestureDelay();
@@ -126,11 +143,25 @@ public class KeyHandler implements DeviceKeyHandler {
mContext = context;
mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mScreenOffGesturesHandler = new ScreenOffGesturesHandler();
mFPScreenOffGesturesHandler = new FPScreenOffGesturesHandler();
mGestureWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"GestureWakeLock");
final Resources resources = mContext.getResources();
mProximityTimeOut = resources.getInteger(
org.lineageos.platform.internal.R.integer.config_proximityCheckTimeout);
mProximityWakeSupported = resources.getBoolean(
org.lineageos.platform.internal.R.bool.config_proximityCheckOnWake);
if (mProximityWakeSupported) {
mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
mProximityWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"ProximityWakeLock");
}
mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if (mVibrator == null || !mVibrator.hasVibrator()) {
mVibrator = null;
@@ -396,6 +427,14 @@ public class KeyHandler implements DeviceKeyHandler {
return !FileUtils.readOneLine(getFPNodeBasedOnScreenState(FP_HAPTIC_NODE)).equals("0");
}
private boolean isProximityEnabledOnScreenOffGesturesFP() {
return !FileUtils.readOneLine(getFPNodeBasedOnScreenState(FP_PROXIMITY_CHECK_SCREENOFF_NODE)).equals("0");
}
private boolean isProximityEnabledOnScreenOffGestures() {
return Settings.System.getInt(mContext.getContentResolver(), KEY_GESTURE_ENABLE_PROXIMITY_SENSOR, 1) != 0;
}
private String getFPNodeBasedOnScreenState(String node) {
if (mPowerManager.isScreenOn()) {
return node;
@@ -430,7 +469,8 @@ public class KeyHandler implements DeviceKeyHandler {
}
boolean isFPScanCode = ArrayUtils.contains(sSupportedFPGestures, scanCode);
if (!isFPScanCode) {
boolean isScreenOffGesturesScanCode = ArrayUtils.contains(sSupportedScreenOffGestures, scanCode);
if (!isFPScanCode && !isScreenOffGesturesScanCode) {
return event;
}
@@ -468,6 +508,8 @@ public class KeyHandler implements DeviceKeyHandler {
} else {
processFPScancode(scanCode);
}
} else if (isScreenOffGesturesScanCode) {
handleScreenOffScancode(scanCode);
}
return null;
}
@@ -632,18 +674,141 @@ public class KeyHandler implements DeviceKeyHandler {
}
private void processFPScreenOffScancode(int scanCode) {
if (!mFPScreenOffGesturesHandler.hasMessages(FP_ACTION_REQUEST)) {
if (isProximityEnabledOnScreenOffGesturesFP() && !mFPScreenOffGesturesHandler.hasMessages(FP_ACTION_REQUEST)) {
Message msg = mFPScreenOffGesturesHandler.obtainMessage(FP_ACTION_REQUEST);
msg.arg1 = scanCode;
boolean defaultProximity = mContext.getResources().getBoolean(
org.lineageos.platform.internal.R.bool.config_proximityCheckOnWakeEnabledByDefault);
boolean proximityWakeCheckEnabled = LineageSettings.System.getInt(mContext.getContentResolver(),
LineageSettings.System.PROXIMITY_ON_WAKE, defaultProximity ? 1 : 0) == 1;
if (mProximityWakeSupported && proximityWakeCheckEnabled && mProximitySensor != null) {
mFPScreenOffGesturesHandler.sendMessageDelayed(msg, mProximityTimeOut);
registerFPScreenOffListener(scanCode);
} else {
mFPScreenOffGesturesHandler.sendMessage(msg);
}
}else{
processFPScancode(scanCode);
}
}
private void registerFPScreenOffListener(final int scanCode) {
mProximityWakeLock.acquire();
mSensorManager.registerListener(new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
mProximityWakeLock.release();
mSensorManager.unregisterListener(this);
if (!mFPScreenOffGesturesHandler.hasMessages(FP_ACTION_REQUEST)) {
// The sensor took to long, ignoring.
return;
}
mFPScreenOffGesturesHandler.removeMessages(FP_ACTION_REQUEST);
if (event.values[0] == mProximitySensor.getMaximumRange()) {
Message msg = mFPScreenOffGesturesHandler.obtainMessage(FP_ACTION_REQUEST);
msg.arg1 = scanCode;
mFPScreenOffGesturesHandler.sendMessage(msg);
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
}, mProximitySensor, SensorManager.SENSOR_DELAY_FASTEST);
}
private void resetScreenOffGestureDelay() {
screenOffGesturePending = false;
mHandler.removeCallbacks(screenOffGestureRunnable);
}
private void resetFPGestureDelay() {
fpGesturePending = false;
mHandler.removeCallbacks(fpGestureRunnable);
}
private void handleScreenOffScancode(int scanCode) {
if (screenOffGesturePending) {
return;
} else {
resetScreenOffGestureDelay();
screenOffGesturePending = true;
mHandler.postDelayed(screenOffGestureRunnable, 500);
}
if (isProximityEnabledOnScreenOffGestures() && !mScreenOffGesturesHandler.hasMessages(GESTURE_REQUEST)) {
Message msg = mScreenOffGesturesHandler.obtainMessage(GESTURE_REQUEST);
msg.arg1 = scanCode;
boolean defaultProximity = mContext.getResources().getBoolean(
org.lineageos.platform.internal.R.bool.config_proximityCheckOnWakeEnabledByDefault);
boolean proximityWakeCheckEnabled = LineageSettings.System.getInt(mContext.getContentResolver(),
LineageSettings.System.PROXIMITY_ON_WAKE, defaultProximity ? 1 : 0) == 1;
if (mProximityWakeSupported && proximityWakeCheckEnabled && mProximitySensor != null) {
mScreenOffGesturesHandler.sendMessageDelayed(msg, mProximityTimeOut);
registerScreenOffGesturesListener(scanCode);
} else {
mScreenOffGesturesHandler.sendMessage(msg);
}
}else{
processScreenOffScancode(scanCode);
}
}
private void processScreenOffScancode(int scanCode) {
int action = 0;
switch (scanCode) {
case GESTURE_SWIPE_RIGHT_SCANCODE:
action = str2int(FileUtils.readOneLine(GESTURE_SWIPE_RIGHT_NODE));
break;
case GESTURE_SWIPE_LEFT_SCANCODE:
action = str2int(FileUtils.readOneLine(GESTURE_SWIPE_LEFT_NODE));
break;
case GESTURE_SWIPE_DOWN_SCANCODE:
action = str2int(FileUtils.readOneLine(GESTURE_SWIPE_DOWN_NODE));
break;
case GESTURE_SWIPE_UP_SCANCODE:
action = str2int(FileUtils.readOneLine(GESTURE_SWIPE_UP_NODE));
break;
case GESTURE_DOUBLE_TAP_SCANCODE:
action = str2int(FileUtils.readOneLine(GESTURE_DOUBLE_TAP_NODE));
if (action != 0) {
action = ACTION_POWER;
}
break;
}
boolean isActionSupported = ArrayUtils.contains(sScreenOffSupportedActions, action);
if (isActionSupported) {
fireScreenOffAction(action);
}
}
private void registerScreenOffGesturesListener(final int scanCode) {
mProximityWakeLock.acquire();
mSensorManager.registerListener(new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
mProximityWakeLock.release();
mSensorManager.unregisterListener(this);
if (!mScreenOffGesturesHandler.hasMessages(GESTURE_REQUEST)) {
// The sensor took to long, ignoring.
return;
}
mScreenOffGesturesHandler.removeMessages(GESTURE_REQUEST);
if (event.values[0] == mProximitySensor.getMaximumRange()) {
Message msg = mScreenOffGesturesHandler.obtainMessage(GESTURE_REQUEST);
msg.arg1 = scanCode;
mScreenOffGesturesHandler.sendMessage(msg);
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
}, mProximitySensor, SensorManager.SENSOR_DELAY_FASTEST);
}
private void fireScreenOffAction(int action) {
boolean haptic = Settings.System.getInt(mContext.getContentResolver(), KEY_GESTURE_ENABLE_HAPTIC_FEEDBACK, 1) != 0;
if (haptic && (action == ACTION_CAMERA || action == ACTION_FLASHLIGHT)) {
@@ -731,6 +896,14 @@ public class KeyHandler implements DeviceKeyHandler {
}
}
private class ScreenOffGesturesHandler extends Handler {
@Override
public void handleMessage(Message msg) {
int scanCode = msg.arg1;
processScreenOffScancode(scanCode);
}
}
private class FPScreenOffGesturesHandler extends Handler {
@Override
public void handleMessage(Message msg) {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.database.Cursor;
import android.database.MatrixCursor;
@@ -33,8 +33,8 @@ import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
public class MotoActionsSearchIndexablesProvider extends SearchIndexablesProvider {
private static final String TAG = "MotoActionsSearchIndexablesProvider";
public class LineageActionsSearchIndexablesProvider extends SearchIndexablesProvider {
private static final String TAG = "LineageActionsSearchIndexablesProvider";
@Override
public boolean onCreate() {
@@ -56,6 +56,13 @@ public class MotoActionsSearchIndexablesProvider extends SearchIndexablesProvide
FPGestureSettingsActivity.class.getName(),
R.drawable.ic_settings_fingerprint)));
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.screen_off_gesture_panel,
ScreenOffGestureSettingsActivity.class.getName(),
R.drawable.ic_settings_screen_off_gestures)));
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.screen_off_gesture_panel_indexable,
ScreenOffGestureSettingsActivity.class.getName(),
R.drawable.ic_settings_screen_off_gestures)));
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.doze_panel,
DozeSettingsActivity.class.getName(),
R.drawable.ic_settings_doze)));
@@ -73,7 +80,7 @@ public class MotoActionsSearchIndexablesProvider extends SearchIndexablesProvide
ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = null;
ref[COLUMN_INDEX_XML_RES_ICON_RESID] = sir.iconResId;
ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = "com.android.settings.action.EXTRA_SETTINGS";
ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = "com.moto.actions";
ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = "org.lineageos.settings.device";
ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = sir.className;
return ref;
}

View File

@@ -15,66 +15,73 @@
* limitations under the License.
*/
package com.moto.actions;
package org.lineageos.settings.device;
import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.provider.Settings;
import android.util.Log;
import java.util.List;
import java.util.LinkedList;
import com.moto.actions.actions.UpdatedStateNotifier;
import com.moto.actions.actions.CameraActivationSensor;
import com.moto.actions.actions.ChopChopSensor;
import com.moto.actions.actions.FlipToMute;
import com.moto.actions.actions.LiftToSilence;
import com.moto.actions.actions.ProximitySilencer;
import org.lineageos.settings.device.actions.UpdatedStateNotifier;
import org.lineageos.settings.device.actions.CameraActivationSensor;
import org.lineageos.settings.device.actions.ChopChopSensor;
import org.lineageos.settings.device.actions.FlipToMute;
import org.lineageos.settings.device.actions.LiftToSilence;
import org.lineageos.settings.device.actions.ProximitySilencer;
import com.moto.actions.doze.DozePulseAction;
import com.moto.actions.doze.GlanceSensor;
import com.moto.actions.doze.ProximitySensor;
import com.moto.actions.doze.ScreenReceiver;
import com.moto.actions.doze.ScreenStateNotifier;
import org.lineageos.settings.device.doze.DozePulseAction;
import org.lineageos.settings.device.doze.ProximitySensor;
import org.lineageos.settings.device.doze.ScreenReceiver;
import org.lineageos.settings.device.doze.ScreenStateNotifier;
import org.lineageos.settings.device.doze.StowSensor;
public class MotoActionsService extends IntentService implements ScreenStateNotifier,
public class LineageActionsService extends IntentService implements ScreenStateNotifier,
UpdatedStateNotifier {
private static final String TAG = "MotoActions";
private static final String TAG = "LineageActions";
private final Context mContext;
private final DozePulseAction mDozePulseAction;
private final PowerManager mPowerManager;
private final PowerManager.WakeLock mWakeLock;
private final ScreenReceiver mScreenReceiver;
private final SensorHelper mSensorHelper;
private final List<ScreenStateNotifier> mScreenStateNotifiers = new LinkedList<>();
private final List<UpdatedStateNotifier> mUpdatedStateNotifiers = new LinkedList<>();
private final List<ScreenStateNotifier> mScreenStateNotifiers = new LinkedList<ScreenStateNotifier>();
private final List<UpdatedStateNotifier> mUpdatedStateNotifiers =
new LinkedList<UpdatedStateNotifier>();
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();
}

View File

@@ -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();
}
}
};
}

View File

@@ -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();
}
}
}

View File

@@ -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;
}
});
}
}

View File

@@ -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();
}

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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

View File

@@ -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 <preference_key> -> <proc_node> mapping
public static final Map<String, String> 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);

View File

@@ -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");
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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");

View File

@@ -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;

View File

@@ -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)) {

View File

@@ -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();
}

View File

@@ -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) {
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.moto.actions.util;
package org.lineageos.settings.device.util;
import android.util.Log;

View File

@@ -1,28 +0,0 @@
<?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="32.0"
android:viewportHeight="32.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M20,20.2V24H6V5.3h8.7l2.4,-4H7.6c-2.2,0 -4,1.8 -4,4v21.3c0,2.2 1.8,4 4,4h10.7c2.2,0 4,-1.8 4,-4V14.9L20,20.2zM15.6,28h-5.3v-1.3h5.3V28z"/>
<path
android:fillColor="#FFFFFFFF"
android:pathData="M28.5,7l1.1,-2.4L32,3.5l-2.4,-1.1L28.5,0l-1.1,2.4L25,3.5l2.4,1.1L28.5,7zM21,7.4l-2.2,-4.8l-2.2,4.8l-4.8,2.2l4.8,2.2l2.2,4.8l2.2,-4.8l4.8,-2.2L21,7.4zM28.5,12.2l-1.1,2.4L25,15.6l2.4,1.1l1.1,2.4l1.1,-2.4l2.4,-1.1l-2.4,-1.1L28.5,12.2z"/>
</vector>

View File

@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The Android Open Source 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.
-->
<!-- Based off frameworks/base/core/res/res/layout/preference_category_material.xml
except that this supports icon -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:paddingStart="?android:attr/listPreferredItemPaddingStart" >
<LinearLayout
android:id="@+id/icon_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start|center_vertical"
android:orientation="horizontal">
<com.android.internal.widget.PreferenceImageView
android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="?android:attr/textColorPrimary"
android:maxWidth="18dp"
android:maxHeight="18dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="56dp"
android:orientation="vertical">
<TextView
android:id="@android:id/title"
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Material.Body2"
android:textColor="?android:attr/colorAccent"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"/>
<TextView
android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="end"
android:singleLine="true" />
</LinearLayout>
</FrameLayout>

View File

@@ -1,86 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 The Android Open Source 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.
-->
<!-- Based off frameworks/base/core/res/res/layout/preference_material.xml
except that this has the negative margin on the image removed. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/selectableItemBackground"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/icon_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="56dp"
android:gravity="start|center_vertical"
android:orientation="horizontal"
android:paddingEnd="12dp"
android:paddingTop="4dp"
android:paddingBottom="4dp">
<com.android.internal.widget.PreferenceImageView
android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="48dp"
android:maxHeight="48dp"/>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<TextView
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="24dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceListItem"
android:ellipsize="marquee"/>
<TextView
android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="24dp"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="10"/>
</RelativeLayout>
<!-- Preference should place its actual preference widget here. -->
<LinearLayout
android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="end|center_vertical"
android:paddingStart="16dp"
android:orientation="vertical"/>
</LinearLayout>

View File

@@ -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) {
}
};
}

View File

@@ -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 += \

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 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.
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Hardware keys present on the device, stored as a bit field.
This integer should equal the sum of the corresponding value for each
of the following keys present:
1 - Home
2 - Back
4 - Menu
8 - Assistant (search)
16 - App switch
32 - Camera
64 - Volume rocker
For example, a device with Home, Back and Menu keys would set this
config to 7. -->
<!--<integer name="config_deviceHardwareKeys">64</integer>-->
<!-- Is the notification LED intrusive? Used to decide if there should be a disable option -->
<bool name="config_intrusiveNotificationLed">true</bool>
<!-- Is the battery LED intrusive? Used to decide if there should be a disable option -->
<!-- <bool name="config_intrusiveBatteryLed">true</bool> -->
<!-- Support in Surfaceflinger for blur layers.
NOTE: This requires additional hardware-specific code. -->
<!--<bool name="config_uiBlurEnabled">true</bool>-->
</resources>

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 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.
-->
<resources>
<!-- Default value for proximity check on screen wake
NOTE ! - Enable for devices that have a fast response proximity sensor (ideally < 300ms)-->
<bool name="config_proximityCheckOnWake">true</bool>
<integer name="config_proximityCheckTimeout">100</integer>
<bool name="config_proximityCheckOnWakeEnabledByDefault">true</bool>
<!-- All the capabilities of the LEDs on this device, stored as a bit field.
This integer should equal the sum of the corresponding value for each
of the following capabilities present:
LIGHTS_RGB_NOTIFICATION_LED = 1
LIGHTS_RGB_BATTERY_LED = 2
LIGHTS_MULTIPLE_NOTIFICATION_LED = 4
LIGHTS_PULSATING_LED = 8
LIGHTS_SEGMENTED_BATTERY_LED = 16
LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS = 32
For example, a device support pulsating, RGB notification and
battery LEDs would set this config to 11. -->
<integer name="config_deviceLightCapabilities">0</integer>
<!-- Display mode remapping table.
If the mode names returned by the backend do not match
the predefined and translated strings in the Settings
app, they can be remapped here. The format is
"oldname:newname", one per entry. -->
<string-array name="config_displayModeMappings" translatable="false">
<item>Standard:standard</item>
<item>Vibrant:dynamic</item>
<item>Comfort:astronomy</item>
</string-array>
<!-- Turn on LiveDisplay auto mode by default -->
<integer name="config_defaultLiveDisplayMode">0</integer>
<!-- Should we filter any display modes which are unampped? -->
<bool name="config_filterDisplayModes">false</bool>
<!-- Paths to the libraries that contain device specific key handlers -->
<string-array name="config_deviceKeyHandlerLibs" translatable="false">
<item>/system/priv-app/LineageActions/LineageActions.apk</item>
</string-array>
<!-- Names of the key handler classes -->
<string-array name="config_deviceKeyHandlerClasses" translatable="false">
<item>org.lineageos.settings.device.KeyHandler</item>
</string-array>
</resources>

View File

@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The CyanogenMod Project
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2016 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.
@@ -13,15 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- Defines the location of the fingerprint sensor on the device
0 = back
1 = front
2 = left side
3 = right side
-->
<integer name="config_fingerprintSensorLocation">1</integer>
<bool name="call_recording_enabled">true</bool>
<integer name="call_recording_audio_source">4</integer>
</resources>

View File

@@ -23,50 +23,41 @@
Software implementation will be used if config_hardware_auto_brightness_available is not set -->
<bool name="config_automatic_brightness_available">true</bool>
<!-- Minimum screen brightness setting allowed by the power manager.
The user is forbidden from setting the brightness below this level. -->
<integer name="config_screenBrightnessSettingMinimum">3</integer>
<!-- Default screen brightness setting.
Must be in the range specified by minimum and maximum. -->
<integer name="config_screenBrightnessSettingDefault">88</integer>
<!-- Indicate whether to allow the device to suspend when the screen is off
due to the proximity sensor. This resource should only be set to true
if the sensor HAL correctly handles the proximity sensor as a wake-up source.
Otherwise, the device may fail to wake out of suspend reliably.
The default is false. -->
<bool name="config_suspendWhenScreenOffDueToProximity">true</bool>
<!-- Array of light sensor LUX values to define our levels for auto backlight brightness support.
The N entries of this array define N 1 zones as follows:
Zone 0: 0 <= LUX < array[0]
Zone 1: array[0] <= LUX < array[1]
...
Zone N: array[N - 1] <= LUX < array[N]
Zone N + 1 array[N] <= LUX < infinity
Must be overridden in platform specific overlays -->
<integer-array name="config_autoBrightnessLevels">
<item>2</item>
<item>10</item>
<item>1</item>
<item>6</item>
<item>12</item>
<item>25</item>
<item>50</item>
<item>90</item>
<item>100</item>
<item>150</item>
<item>200</item>
<item>300</item>
<item>400</item>
<item>80</item>
<item>120</item>
<item>175</item>
<item>250</item>
<item>350</item>
<item>500</item>
<item>800</item>
<item>750</item>
<item>1000</item>
<item>1300</item>
<item>1400</item>
<item>2000</item>
<item>3000</item>
<item>4000</item>
<item>8000</item>
<item>3500</item>
<item>6000</item>
<item>10000</item>
<item>15000</item>
<item>20000</item>
<item>30000</item>
<item>65535</item>
</integer-array>
<!-- Array of output values for LCD backlight corresponding to the LUX values
@@ -75,25 +66,29 @@
This must be overridden in platform specific overlays -->
<integer-array name="config_autoBrightnessLcdBacklightValues">
<item>3</item>
<item>11</item>
<item>40</item>
<item>62</item>
<item>74</item>
<item>85</item>
<item>102</item>
<item>102</item>
<item>102</item>
<item>102</item>
<item>128</item>
<item>7</item>
<item>10</item>
<item>13</item>
<item>16</item>
<item>22</item>
<item>28</item>
<item>34</item>
<item>43</item>
<item>52</item>
<item>61</item>
<item>72</item>
<item>83</item>
<item>94</item>
<item>105</item>
<item>117</item>
<item>129</item>
<item>141</item>
<item>153</item>
<item>170</item>
<item>166</item>
<item>179</item>
<item>238</item>
<item>255</item>
<item>255</item>
<item>255</item>
<item>256</item>
<item>192</item>
<item>205</item>
<item>218</item>
</integer-array>
<!-- Vibrator pattern for feedback about a long screen/key press -->
@@ -241,19 +236,8 @@
<!-- Default LED off time for notification LED in milliseconds. -->
<integer name="config_defaultNotificationLedOff">5000</integer>
<!-- Is the battery LED intrusive? Used to decide if there should be a disable option -->
<bool name="config_intrusiveBatteryLed">true</bool>
<!-- Is the notification LED intrusive? Used to decide if there should be a disable option -->
<bool name="config_intrusiveNotificationLed">true</bool>
<!-- Does the battery LED support multiple colors?
Used to decide if the user can change the colors -->
<bool name="config_multiColorBatteryLed">false</bool>
<!-- Do the battery/notification LEDs support pulsing?
Used to decide if we show pulse settings -->
<bool name="config_ledCanPulse">true</bool>
<!-- Default color for notification LED is white. -->
<color name="config_defaultNotificationColor">#ff0000ff</color>
<!-- If this is true, the screen will come on when you unplug usb/power/whatever. -->
<bool name="config_unplugTurnsOnScreen">true</bool>
@@ -297,7 +281,7 @@
<bool name="config_enableMultiUserUI">true</bool>
<!-- Indicate whether the SD card is accessible without removing the battery. -->
<bool name="config_batterySdCardAccessibility">true</bool>
<bool name="config_batterySdCardAccessibility">false</bool>
<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
autodetected from the Configuration. -->
@@ -322,8 +306,8 @@
turned off and the screen off animation has been performed. -->
<bool name="config_dozeAfterScreenOffByDefault">true</bool>
<!-- Disable AOD by default -->
<bool name="config_dozeAlwaysOnEnabled">false</bool>
<!-- Enable doze powersaving -->
<bool name="config_enableAutoPowerModes">true</bool>
<!-- Power Management: Specifies whether to decouple the interactive state of the
device from the display on/off state.
@@ -362,29 +346,21 @@
provisioning, availability etc -->
<bool name="config_carrier_wfc_ims_available">true</bool>
<!-- Flag specifying whether VT is available on device -->
<bool name="config_device_vt_available">true</bool>
<!-- ImsService package name to bind to by default, if config_dynamic_bind_ims is true -->
<string name="config_ims_package">org.codeaurora.ims</string>
<!-- Flag specifying whether or not IMS will use the ImsResolver dynamically -->
<bool name="config_dynamic_bind_ims">true</bool>
<!-- Boolean indicating if current platform supports BLE peripheral mode -->
<bool name="config_bluetooth_le_peripheral_mode_supported">true</bool>
<!-- Whether device supports double tap to wake -->
<bool name="config_supportDoubleTapWake">false</bool>
<!-- Paths to the libraries that contain device specific key handlers -->
<string-array name="config_deviceKeyHandlerLibs" translatable="false">
<item>/vendor/app/MotoActions/MotoActions.apk</item>
</string-array>
<!-- Indicate whether to allow the device to suspend when the screen is off
due to the proximity sensor. This resource should only be set to true
if the sensor HAL correctly handles the proximity sensor as a wake-up source.
Otherwise, the device may fail to wake out of suspend reliably.
The default is false. -->
<bool name="config_suspendWhenScreenOffDueToProximity">true</bool>
<string-array name="config_deviceKeyHandlerClasses" translatable="false">
<item>com.moto.actions.KeyHandler</item>
</string-array>
<!-- Is the notification LED intrusive? Used to decide if there should be a disable option -->
<bool name="config_intrusiveNotificationLed">true</bool>
<!-- Default value for proximity check on screen wake
NOTE ! - Enable for devices that have a fast response proximity sensor (ideally < 300ms)-->
@@ -411,33 +387,38 @@
<!-- Default files to pin via Pinner Service -->
<string-array translatable="false" name="config_defaultPinnerServiceFiles">
<item>"/system/framework/arm64/boot-core-libart.oat"</item>
<item>"/system/framework/arm64/boot-framework.oat"</item>
<item>"/system/framework/arm64/boot.oat"</item>
<item>"/system/framework/boot-core-libart.vdex"</item>
<item>"/system/framework/boot-framework.vdex"</item>
<item>"/system/framework/boot.vdex"</item>
<item>"/system/framework/oat/arm64/services.odex"</item>
<item>"/system/framework/oat/arm64/services.vdex"</item>
<item>"/system/framework/arm64/boot.oat"</item>
<item>"/system/framework/boot.vdex"</item>
<item>"/system/framework/arm64/boot-core-libart.oat"</item>
<item>"/system/framework/boot-core-libart.vdex"</item>
</string-array>
<!-- Should the pinner service pin the Camera application? -->
<bool name="config_pinnerCameraApp">true</bool>
<!-- Boolean indicating whether the HWC setColorTransform function can be performed efficiently
in hardware. -->
<bool name="config_setColorTransformAccelerated">true</bool>
<!-- enable doze powersaving mode -->
<bool name="config_enableAutoPowerModes">true</bool>
<!-- If this is true, device supports Sustained Performance Mode. -->
<bool name="config_sustainedPerformanceModeSupported">true</bool>
<!-- Whether the always on display mode is available. -->
<bool name="config_dozeAlwaysOnDisplayAvailable">true</bool>
<!-- Whether the display blanks itself when transitioning from a doze to a non-doze state -->
<!-- Whether the display blanks itself when transition from a doze to a non-doze state -->
<bool name="config_displayBlanksAfterDoze">true</bool>
<!-- Whether device has turbo power charging support -->
<bool name="config_hasTurboPowerCharger">true</bool>
<!-- ImsService package name to bind to by default, if config_dynamic_bind_ims is true -->
<string name="config_ims_package">org.codeaurora.ims</string>
<!-- Flag specifying whether or not IMS will use the ImsResolver dynamically -->
<bool name="config_dynamic_bind_ims">true</bool>
<!-- Whether or not swipe up gesture's opt-in setting is available on this device -->
<bool name="config_swipe_up_gesture_setting_available">true</bool>
<!-- Flag indicating whether we should enable smart battery. -->
<bool name="config_smart_battery_available">true</bool>
</resources>

View File

@@ -1,66 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<device name="Android">
<item name="none">0</item>
<item name="screen.on">93</item>
<item name="screen.full">216.4</item>
<item name="wifi.on">.6</item>
<item name="wifi.active">103.6</item>
<item name="wifi.scan">33.7</item>
<item name="camera.avg">678.6</item>
<item name="camera.flashlight">172</item>
<item name="gps.on">37</item>
<item name="radio.active">343.4</item>
<item name="radio.scanning">33.3</item>
<item name="screen.on">98.648</item>
<item name="screen.full">193.430</item>
<item name="wifi.on">1.075</item>
<item name="wifi.active">41.638</item>
<item name="wifi.scan">4.446</item>
<item name="camera.flashlight">40.478</item>
<item name="camera.avg">570.594</item>
<item name="gps.on">19.646</item>
<item name="radio.active">182.518</item>
<item name="radio.scanning">41.395</item>
<array name="radio.on">
<value>29</value>
<value>35.5</value>
<value>35</value>
<value>30</value>
<value>25</value>
<value>20</value>
<value>15</value>
<value>10</value>
<value>5</value>
<value>2</value>
<value>3.5</value>
</array>
<item name="modem.controller.idle">8.309</item>
<item name="modem.controller.rx">170.273</item>
<item name="modem.controller.tx">146.062</item>
<item name="modem.controller.voltage">866.419</item>
<item name="bluetooth.controller.idle">1.133</item>
<item name="bluetooth.controller.rx">26.438</item>
<item name="bluetooth.controller.tx">63.683</item>
<item name="bluetooth.controller.voltage">112.528</item>
<array name="cpu.clusters.cores">
<value>4</value>
<value>4</value>
<value>8</value>
</array>
<array name="cpu.speeds.cluster0">
<value>652800</value>
<value>1036800</value>
<value>1401600</value>
<value>1689600</value>
<value>1843200</value>
<value>1804800</value>
<value>1958400</value>
<value>2016000</value>
</array>
<array name="cpu.active.cluster0">
<value>35</value>
<value>45.4</value>
<value>60</value>
<value>77.5</value>
<value>96</value>
<value>105</value>
<value>112</value>
<value>33.802</value>
<value>46.767</value>
<value>59.310</value>
<value>78.318</value>
<value>99.180</value>
<value>112.014</value>
<value>118.914</value>
</array>
<array name="cpu.speeds.cluster1">
<value>652800</value>
<value>1036800</value>
<value>1401600</value>
<value>1689600</value>
<value>1843200</value>
<value>1958400</value>
<value>2016000</value>
</array>
<array name="cpu.active.cluster1">
<value>35</value>
<value>45.4</value>
<value>60</value>
<value>77.5</value>
<value>96</value>
<value>105</value>
<value>112</value>
</array>
<item name="cpu.idle">4</item>
<item name="cpu.awake">7</item>
<item name="cpu.idle">6.198</item>
<item name="battery.capacity">3000</item>
<item name="wifi.controller.idle">0.585</item>
<item name="wifi.controller.rx">65.896</item>
<item name="wifi.controller.tx">130.159</item>
<array name="wifi.controller.tx_levels" />
<item name="wifi.controller.voltage">184.53</item>
</device>

View File

@@ -16,6 +16,7 @@
-->
<resources>
<!-- Opens back camera using openLegacy() -->
<bool name="back_camera_open_legacy">false</bool>
@@ -32,4 +33,7 @@
Example: 1920x1080 -->
<string name="preview_size_for_photo">1280x960</string>
<!-- Enable support for camera api v2 -->
<bool name="support_camera_api_v2">true</bool>
</resources>