|
|
@ -46,7 +46,6 @@ public class SamsungDozeService extends Service { |
|
|
|
|
|
|
|
|
|
|
|
private static final String GESTURE_HAND_WAVE_KEY = "gesture_hand_wave"; |
|
|
|
private static final String GESTURE_HAND_WAVE_KEY = "gesture_hand_wave"; |
|
|
|
private static final String GESTURE_POCKET_KEY = "gesture_pocket"; |
|
|
|
private static final String GESTURE_POCKET_KEY = "gesture_pocket"; |
|
|
|
private static final String PROXIMITY_WAKE_KEY = "proximity_wake_enable"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final int POCKET_DELTA_NS = 1000 * 1000 * 1000; |
|
|
|
private static final int POCKET_DELTA_NS = 1000 * 1000 * 1000; |
|
|
|
|
|
|
|
|
|
|
@ -56,7 +55,6 @@ public class SamsungDozeService extends Service { |
|
|
|
|
|
|
|
|
|
|
|
private boolean mHandwaveGestureEnabled = false; |
|
|
|
private boolean mHandwaveGestureEnabled = false; |
|
|
|
private boolean mPocketGestureEnabled = false; |
|
|
|
private boolean mPocketGestureEnabled = false; |
|
|
|
private boolean mProximityWakeEnabled = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SamsungProximitySensor implements SensorEventListener { |
|
|
|
class SamsungProximitySensor implements SensorEventListener { |
|
|
|
private SensorManager mSensorManager; |
|
|
|
private SensorManager mSensorManager; |
|
|
@ -93,9 +91,6 @@ public class SamsungDozeService extends Service { |
|
|
|
|
|
|
|
|
|
|
|
if (mHandwaveGestureEnabled && mPocketGestureEnabled) { |
|
|
|
if (mHandwaveGestureEnabled && mPocketGestureEnabled) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} else if (mProximityWakeEnabled && (delta < POCKET_DELTA_NS)) { |
|
|
|
|
|
|
|
mPowerManager.wakeUp(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} else if (mHandwaveGestureEnabled && !mPocketGestureEnabled) { |
|
|
|
} else if (mHandwaveGestureEnabled && !mPocketGestureEnabled) { |
|
|
|
return delta < POCKET_DELTA_NS; |
|
|
|
return delta < POCKET_DELTA_NS; |
|
|
|
} else if (!mHandwaveGestureEnabled && mPocketGestureEnabled) { |
|
|
|
} else if (!mHandwaveGestureEnabled && mPocketGestureEnabled) { |
|
|
@ -105,8 +100,7 @@ public class SamsungDozeService extends Service { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void testAndEnable() { |
|
|
|
public void testAndEnable() { |
|
|
|
if ((isDozeEnabled() && (mHandwaveGestureEnabled || mPocketGestureEnabled)) || |
|
|
|
if ((isDozeEnabled() && (mHandwaveGestureEnabled || mPocketGestureEnabled)) { |
|
|
|
mProximityWakeEnabled) { |
|
|
|
|
|
|
|
mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); |
|
|
|
mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -171,7 +165,6 @@ public class SamsungDozeService extends Service { |
|
|
|
private void loadPreferences(SharedPreferences sharedPreferences) { |
|
|
|
private void loadPreferences(SharedPreferences sharedPreferences) { |
|
|
|
mHandwaveGestureEnabled = sharedPreferences.getBoolean(GESTURE_HAND_WAVE_KEY, false); |
|
|
|
mHandwaveGestureEnabled = sharedPreferences.getBoolean(GESTURE_HAND_WAVE_KEY, false); |
|
|
|
mPocketGestureEnabled = sharedPreferences.getBoolean(GESTURE_POCKET_KEY, false); |
|
|
|
mPocketGestureEnabled = sharedPreferences.getBoolean(GESTURE_POCKET_KEY, false); |
|
|
|
mProximityWakeEnabled = sharedPreferences.getBoolean(PROXIMITY_WAKE_KEY, false); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() { |
|
|
|
private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() { |
|
|
@ -193,8 +186,6 @@ public class SamsungDozeService extends Service { |
|
|
|
mHandwaveGestureEnabled = sharedPreferences.getBoolean(GESTURE_HAND_WAVE_KEY, false); |
|
|
|
mHandwaveGestureEnabled = sharedPreferences.getBoolean(GESTURE_HAND_WAVE_KEY, false); |
|
|
|
} else if (GESTURE_POCKET_KEY.equals(key)) { |
|
|
|
} else if (GESTURE_POCKET_KEY.equals(key)) { |
|
|
|
mPocketGestureEnabled = sharedPreferences.getBoolean(GESTURE_POCKET_KEY, false); |
|
|
|
mPocketGestureEnabled = sharedPreferences.getBoolean(GESTURE_POCKET_KEY, false); |
|
|
|
} else if (PROXIMITY_WAKE_KEY.equals(key)) { |
|
|
|
|
|
|
|
mProximityWakeEnabled = sharedPreferences.getBoolean(PROXIMITY_WAKE_KEY, false); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|