Loading packages/SystemUI/src/com/android/systemui/doze/DozeService.java +24 −1 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class DozeService extends DreamService { private PendingIntent mNotificationPulseIntent; private int mMultipulseCount; private int mNotificationPulseInterval; private boolean mPowerSaveActive; public DozeService() { if (DEBUG) Log.d(mTag, "new DozeService()"); Loading @@ -94,6 +95,7 @@ public class DozeService extends DreamService { pw.print(" mNotificationLightOn: "); pw.println(mNotificationLightOn); pw.print(" mMultipulseCount: "); pw.println(mMultipulseCount); pw.print(" mNotificationPulseInterval: "); pw.println(mNotificationPulseInterval); pw.print(" mPowerSaveActive: "); pw.println(mPowerSaveActive); } @Override Loading Loading @@ -141,7 +143,13 @@ public class DozeService extends DreamService { @Override public void onDreamingStarted() { super.onDreamingStarted(); if (DEBUG) Log.d(mTag, "onDreamingStarted canDoze=" + canDoze()); mPowerSaveActive = mHost != null && mHost.isPowerSaveActive(); if (DEBUG) Log.d(mTag, "onDreamingStarted canDoze=" + canDoze() + " mPowerSaveActive=" + mPowerSaveActive); if (mPowerSaveActive) { finishToSavePower(); return; } mDreaming = true; listenForPulseSignals(true); requestDoze(); Loading Loading @@ -232,6 +240,11 @@ public class DozeService extends DreamService { } } private void finishToSavePower() { Log.w(mTag, "Exiting ambient mode due to low power battery saver"); finish(); } private void listenForPulseSignals(boolean listen) { if (DEBUG) Log.d(mTag, "listenForPulseSignals: " + listen); mSigMotionSensor.setListening(listen); Loading Loading @@ -329,6 +342,14 @@ public class DozeService extends DreamService { mNotificationLightOn = on; rescheduleNotificationPulse(); } @Override public void onPowerSaveChanged(boolean active) { mPowerSaveActive = active; if (mPowerSaveActive && mDreaming) { finishToSavePower(); } } }; public interface Host { Loading @@ -337,11 +358,13 @@ public class DozeService extends DreamService { void requestDoze(DozeService dozeService); void requestPulse(int pulses, boolean delayed, DozeService dozeService); void dozingStopped(DozeService dozeService); boolean isPowerSaveActive(); public interface Callback { void onNewNotifications(); void onBuzzBeepBlinked(); void onNotificationLight(boolean on); void onPowerSaveChanged(boolean active); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +14 −0 Original line number Diff line number Diff line Loading @@ -752,6 +752,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, @Override public void onPowerSaveChanged() { mHandler.post(mCheckBarModes); if (mDozeServiceHost != null) { mDozeServiceHost.firePowerSaveChanged(mBatteryController.isPowerSave()); } } @Override public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { Loading Loading @@ -3920,6 +3923,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private DozeService mCurrentDozeService; public void firePowerSaveChanged(boolean active) { for (Callback callback : mCallbacks) { callback.onPowerSaveChanged(active); } } public void fireBuzzBeepBlinked() { for (Callback callback : mCallbacks) { callback.onBuzzBeepBlinked(); Loading Loading @@ -3970,6 +3979,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mHandler.obtainMessage(H.DOZING_STOPPED, dozeService).sendToTarget(); } @Override public boolean isPowerSaveActive() { return mBatteryController != null && mBatteryController.isPowerSave(); } private void handleRequestDoze(DozeService dozeService) { mCurrentDozeService = dozeService; if (!mDozing) { Loading Loading
packages/SystemUI/src/com/android/systemui/doze/DozeService.java +24 −1 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class DozeService extends DreamService { private PendingIntent mNotificationPulseIntent; private int mMultipulseCount; private int mNotificationPulseInterval; private boolean mPowerSaveActive; public DozeService() { if (DEBUG) Log.d(mTag, "new DozeService()"); Loading @@ -94,6 +95,7 @@ public class DozeService extends DreamService { pw.print(" mNotificationLightOn: "); pw.println(mNotificationLightOn); pw.print(" mMultipulseCount: "); pw.println(mMultipulseCount); pw.print(" mNotificationPulseInterval: "); pw.println(mNotificationPulseInterval); pw.print(" mPowerSaveActive: "); pw.println(mPowerSaveActive); } @Override Loading Loading @@ -141,7 +143,13 @@ public class DozeService extends DreamService { @Override public void onDreamingStarted() { super.onDreamingStarted(); if (DEBUG) Log.d(mTag, "onDreamingStarted canDoze=" + canDoze()); mPowerSaveActive = mHost != null && mHost.isPowerSaveActive(); if (DEBUG) Log.d(mTag, "onDreamingStarted canDoze=" + canDoze() + " mPowerSaveActive=" + mPowerSaveActive); if (mPowerSaveActive) { finishToSavePower(); return; } mDreaming = true; listenForPulseSignals(true); requestDoze(); Loading Loading @@ -232,6 +240,11 @@ public class DozeService extends DreamService { } } private void finishToSavePower() { Log.w(mTag, "Exiting ambient mode due to low power battery saver"); finish(); } private void listenForPulseSignals(boolean listen) { if (DEBUG) Log.d(mTag, "listenForPulseSignals: " + listen); mSigMotionSensor.setListening(listen); Loading Loading @@ -329,6 +342,14 @@ public class DozeService extends DreamService { mNotificationLightOn = on; rescheduleNotificationPulse(); } @Override public void onPowerSaveChanged(boolean active) { mPowerSaveActive = active; if (mPowerSaveActive && mDreaming) { finishToSavePower(); } } }; public interface Host { Loading @@ -337,11 +358,13 @@ public class DozeService extends DreamService { void requestDoze(DozeService dozeService); void requestPulse(int pulses, boolean delayed, DozeService dozeService); void dozingStopped(DozeService dozeService); boolean isPowerSaveActive(); public interface Callback { void onNewNotifications(); void onBuzzBeepBlinked(); void onNotificationLight(boolean on); void onPowerSaveChanged(boolean active); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +14 −0 Original line number Diff line number Diff line Loading @@ -752,6 +752,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, @Override public void onPowerSaveChanged() { mHandler.post(mCheckBarModes); if (mDozeServiceHost != null) { mDozeServiceHost.firePowerSaveChanged(mBatteryController.isPowerSave()); } } @Override public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { Loading Loading @@ -3920,6 +3923,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private DozeService mCurrentDozeService; public void firePowerSaveChanged(boolean active) { for (Callback callback : mCallbacks) { callback.onPowerSaveChanged(active); } } public void fireBuzzBeepBlinked() { for (Callback callback : mCallbacks) { callback.onBuzzBeepBlinked(); Loading Loading @@ -3970,6 +3979,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mHandler.obtainMessage(H.DOZING_STOPPED, dozeService).sendToTarget(); } @Override public boolean isPowerSaveActive() { return mBatteryController != null && mBatteryController.isPowerSave(); } private void handleRequestDoze(DozeService dozeService) { mCurrentDozeService = dozeService; if (!mDozing) { Loading