diff options
author | John Spurlock <jspurlock@google.com> | 2014-09-25 20:34:31 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2014-09-25 22:08:18 -0400 |
commit | 870f153583d069fb2dea6b36c71173d60b6e59a1 (patch) | |
tree | 00c72b2da48bd538f453c45c92c5f54d31da8189 /packages/SystemUI | |
parent | 471157821f7b0933c55081ef4625c78f8e798de7 (diff) | |
download | frameworks_base-870f153583d069fb2dea6b36c71173d60b6e59a1.zip frameworks_base-870f153583d069fb2dea6b36c71173d60b6e59a1.tar.gz frameworks_base-870f153583d069fb2dea6b36c71173d60b6e59a1.tar.bz2 |
Avoid dozing in car mode.
Ensure we do not begin dozing in car mode, and end dozing when
entering car mode.
Bug:17658724
Change-Id: I572b0d6163d2ece3b93d86981fd6cad832f96b99
Diffstat (limited to 'packages/SystemUI')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/doze/DozeService.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java index 6cc890b..3afdc3d 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java @@ -18,10 +18,12 @@ package com.android.systemui.doze; import android.app.AlarmManager; import android.app.PendingIntent; +import android.app.UiModeManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Configuration; import android.hardware.Sensor; import android.hardware.SensorManager; import android.hardware.TriggerEvent; @@ -61,12 +63,14 @@ public class DozeService extends DreamService { private PowerManager mPowerManager; private PowerManager.WakeLock mWakeLock; private AlarmManager mAlarmManager; + private UiModeManager mUiModeManager; private boolean mDreaming; private boolean mPulsing; private boolean mBroadcastReceiverRegistered; private boolean mDisplayStateSupported; private boolean mNotificationLightOn; private boolean mPowerSaveActive; + private boolean mCarMode; private long mNotificationPulseTime; private int mScheduleResetsRemaining; @@ -88,6 +92,7 @@ public class DozeService extends DreamService { pw.print(" mDisplayStateSupported: "); pw.println(mDisplayStateSupported); pw.print(" mNotificationLightOn: "); pw.println(mNotificationLightOn); pw.print(" mPowerSaveActive: "); pw.println(mPowerSaveActive); + pw.print(" mCarMode: "); pw.println(mCarMode); pw.print(" mNotificationPulseTime: "); pw.println(mNotificationPulseTime); pw.print(" mScheduleResetsRemaining: "); pw.println(mScheduleResetsRemaining); mDozeParameters.dump(pw); @@ -116,6 +121,7 @@ public class DozeService extends DreamService { mWakeLock.setReferenceCounted(true); mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); mDisplayStateSupported = mDozeParameters.getDisplayStateSupported(); + mUiModeManager = (UiModeManager) mContext.getSystemService(Context.UI_MODE_SERVICE); turnDisplayOff(); } @@ -135,12 +141,17 @@ public class DozeService extends DreamService { } mPowerSaveActive = mHost.isPowerSaveActive(); + mCarMode = mUiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR; if (DEBUG) Log.d(mTag, "onDreamingStarted canDoze=" + canDoze() + " mPowerSaveActive=" - + mPowerSaveActive); + + mPowerSaveActive + " mCarMode=" + mCarMode); if (mPowerSaveActive) { finishToSavePower(); return; } + if (mCarMode) { + finishForCarMode(); + return; + } mDreaming = true; listenForPulseSignals(true); @@ -221,6 +232,11 @@ public class DozeService extends DreamService { finish(); } + private void finishForCarMode() { + Log.w(mTag, "Exiting ambient mode, not allowed in car mode"); + finish(); + } + private void listenForPulseSignals(boolean listen) { if (DEBUG) Log.d(mTag, "listenForPulseSignals: " + listen); mSigMotionSensor.setListening(listen); @@ -233,6 +249,7 @@ public class DozeService extends DreamService { if (listen) { final IntentFilter filter = new IntentFilter(PULSE_ACTION); filter.addAction(NOTIFICATION_PULSE_ACTION); + filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); mContext.registerReceiver(mBroadcastReceiver, filter); mBroadcastReceiverRegistered = true; } else { @@ -341,6 +358,12 @@ public class DozeService extends DreamService { requestPulse(); rescheduleNotificationPulse(mNotificationLightOn); } + if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) { + mCarMode = true; + if (mCarMode && mDreaming) { + finishForCarMode(); + } + } } }; |