diff options
author | John Spurlock <jspurlock@google.com> | 2014-06-28 11:27:17 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2014-06-28 11:31:44 -0400 |
commit | 6612727c18fe6e7b6edf811f3a1a871a710c0ebe (patch) | |
tree | 18f40ccb733346346e0a0da83c8c45a04a11ce40 /packages/SystemUI/src/com/android/systemui/doze | |
parent | f41fc9664febbdbf138e8540fd7a8281f1278eb1 (diff) | |
download | frameworks_base-6612727c18fe6e7b6edf811f3a1a871a710c0ebe.zip frameworks_base-6612727c18fe6e7b6edf811f3a1a871a710c0ebe.tar.gz frameworks_base-6612727c18fe6e7b6edf811f3a1a871a710c0ebe.tar.bz2 |
Doze: allow devices to opt-out of sigmotion trigger.
For devices with unreliable significant motion sensors, allow
the tease signal to be disabled via device config.
Also add doze state to dream service dumpsys.
Bug:15863249
Change-Id: I23eeec09c69cc3bd43b187e49555391ac0a99d9f
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/doze')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/doze/DozeService.java | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java index cc0d4a7..269b4ed 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java @@ -25,13 +25,18 @@ import android.hardware.SensorManager; import android.hardware.TriggerEvent; import android.hardware.TriggerEventListener; import android.os.PowerManager; +import android.os.SystemProperties; import android.os.Vibrator; import android.service.dreams.DozeHardware; import android.service.dreams.DreamService; import android.util.Log; +import com.android.systemui.R; import com.android.systemui.SystemUIApplication; +import java.io.FileDescriptor; +import java.io.PrintWriter; + public class DozeService extends DreamService { private static final boolean DEBUG = false; @@ -48,6 +53,8 @@ public class DozeService extends DreamService { private PowerManager.WakeLock mWakeLock; private boolean mDreaming; private boolean mTeaseReceiverRegistered; + private boolean mSigMotionConfigured; + private boolean mSigMotionEnabled; public DozeService() { if (DEBUG) Log.d(mTag, "new DozeService()"); @@ -55,6 +62,17 @@ public class DozeService extends DreamService { } @Override + protected void dumpOnHandler(FileDescriptor fd, PrintWriter pw, String[] args) { + super.dumpOnHandler(fd, pw, args); + pw.print(" mDreaming: "); pw.println(mDreaming); + pw.print(" mDozeHardware: "); pw.println(mDozeHardware); + pw.print(" mTeaseReceiverRegistered: "); pw.println(mTeaseReceiverRegistered); + pw.print(" mSigMotionSensor: "); pw.println(mSigMotionSensor); + pw.print(" mSigMotionConfigured: "); pw.println(mSigMotionConfigured); + pw.print(" mSigMotionEnabled: "); pw.println(mSigMotionEnabled); + } + + @Override public void onCreate() { if (DEBUG) Log.d(mTag, "onCreate"); super.onCreate(); @@ -70,6 +88,8 @@ public class DozeService extends DreamService { mSigMotionSensor = mSensors.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION); mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mTag); + mSigMotionConfigured = SystemProperties.getBoolean("doze.tease.sigmotion", + mContext.getResources().getBoolean(R.bool.doze_tease_on_significant_motion)); } @Override @@ -156,27 +176,39 @@ public class DozeService extends DreamService { private void listenForTeaseSignals(boolean listen) { if (DEBUG) Log.d(mTag, "listenForTeaseSignals: " + listen); - if (mHost == null) return; listenForSignificantMotion(listen); + listenForBroadcast(listen); + listenForNotifications(listen); + } + + private void listenForSignificantMotion(boolean listen) { + if (!mSigMotionConfigured || mSigMotionSensor == null) return; + if (listen) { + mSigMotionEnabled = + mSensors.requestTriggerSensor(mSigMotionListener, mSigMotionSensor); + } else if (mSigMotionEnabled) { + mSensors.cancelTriggerSensor(mSigMotionListener, mSigMotionSensor); + } + } + + private void listenForBroadcast(boolean listen) { if (listen) { mContext.registerReceiver(mTeaseReceiver, new IntentFilter(TEASE_ACTION)); mTeaseReceiverRegistered = true; - mHost.addCallback(mHostCallback); } else { if (mTeaseReceiverRegistered) { mContext.unregisterReceiver(mTeaseReceiver); } mTeaseReceiverRegistered = false; - mHost.removeCallback(mHostCallback); } } - private void listenForSignificantMotion(boolean listen) { - if (mSigMotionSensor == null) return; + private void listenForNotifications(boolean listen) { + if (mHost == null) return; if (listen) { - mSensors.requestTriggerSensor(mSigMotionListener, mSigMotionSensor); + mHost.addCallback(mHostCallback); } else { - mSensors.cancelTriggerSensor(mSigMotionListener, mSigMotionSensor); + mHost.removeCallback(mHostCallback); } } |