Loading services/java/com/android/server/UiModeManagerService.java +16 −3 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.os.Handler; import android.os.PowerManager; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.service.dreams.DreamService; Loading Loading @@ -90,6 +91,8 @@ class UiModeManagerService extends IUiModeManager.Stub { private NotificationManager mNotificationManager; private StatusBarManager mStatusBarManager; private final PowerManager mPowerManager; private final PowerManager.WakeLock mWakeLock; static Intent buildHomeIntent(String category) { Loading Loading @@ -163,8 +166,8 @@ class UiModeManagerService extends IUiModeManager.Stub { mContext.registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); mConfiguration.setToDefaults(); Loading Loading @@ -502,7 +505,17 @@ class UiModeManagerService extends IUiModeManager.Stub { try { IDreamManager dreamManagerService = IDreamManager.Stub.asInterface( ServiceManager.getService(DreamService.DREAM_SERVICE)); if (dreamManagerService != null && !dreamManagerService.isDreaming()) { // Wake up. // The power manager will wake up the system when it starts receiving power // but there is a race between that happening and the UI mode manager // starting a dream. We want the system to already be awake // by the time this happens. Otherwise the dream may not start. mPowerManager.wakeUp(SystemClock.uptimeMillis()); // Dream. dreamManagerService.dream(); } } catch (RemoteException ex) { Slog.e(TAG, "Could not start dream when docked.", ex); } Loading services/java/com/android/server/power/PowerManagerService.java +44 −34 Original line number Diff line number Diff line Loading @@ -1078,7 +1078,11 @@ public final class PowerManagerService extends IPowerManager.Stub } private boolean shouldWakeUpWhenPluggedOrUnpluggedLocked(boolean wasPowered, int oldPlugType) { if (mWakeUpWhenPluggedOrUnpluggedConfig) { // Don't wake when powered unless configured to do so. if (!mWakeUpWhenPluggedOrUnpluggedConfig) { return false; } // FIXME: Need more accurate detection of wireless chargers. // // We are unable to accurately detect whether the device is resting on the Loading Loading @@ -1110,11 +1114,17 @@ public final class PowerManagerService extends IPowerManager.Stub WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT) { return false; } return true; } // If already dreaming and becoming powered, then don't wake. if (mIsPowered && (mWakefulness == WAKEFULNESS_NAPPING || mWakefulness == WAKEFULNESS_DREAMING)) { return false; } // Otherwise wake up! return true; } /** * Updates the value of mStayOn. * Sets DIRTY_STAY_ON if a change occurred. Loading Loading
services/java/com/android/server/UiModeManagerService.java +16 −3 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.os.Handler; import android.os.PowerManager; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.service.dreams.DreamService; Loading Loading @@ -90,6 +91,8 @@ class UiModeManagerService extends IUiModeManager.Stub { private NotificationManager mNotificationManager; private StatusBarManager mStatusBarManager; private final PowerManager mPowerManager; private final PowerManager.WakeLock mWakeLock; static Intent buildHomeIntent(String category) { Loading Loading @@ -163,8 +166,8 @@ class UiModeManagerService extends IUiModeManager.Stub { mContext.registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); mConfiguration.setToDefaults(); Loading Loading @@ -502,7 +505,17 @@ class UiModeManagerService extends IUiModeManager.Stub { try { IDreamManager dreamManagerService = IDreamManager.Stub.asInterface( ServiceManager.getService(DreamService.DREAM_SERVICE)); if (dreamManagerService != null && !dreamManagerService.isDreaming()) { // Wake up. // The power manager will wake up the system when it starts receiving power // but there is a race between that happening and the UI mode manager // starting a dream. We want the system to already be awake // by the time this happens. Otherwise the dream may not start. mPowerManager.wakeUp(SystemClock.uptimeMillis()); // Dream. dreamManagerService.dream(); } } catch (RemoteException ex) { Slog.e(TAG, "Could not start dream when docked.", ex); } Loading
services/java/com/android/server/power/PowerManagerService.java +44 −34 Original line number Diff line number Diff line Loading @@ -1078,7 +1078,11 @@ public final class PowerManagerService extends IPowerManager.Stub } private boolean shouldWakeUpWhenPluggedOrUnpluggedLocked(boolean wasPowered, int oldPlugType) { if (mWakeUpWhenPluggedOrUnpluggedConfig) { // Don't wake when powered unless configured to do so. if (!mWakeUpWhenPluggedOrUnpluggedConfig) { return false; } // FIXME: Need more accurate detection of wireless chargers. // // We are unable to accurately detect whether the device is resting on the Loading Loading @@ -1110,11 +1114,17 @@ public final class PowerManagerService extends IPowerManager.Stub WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT) { return false; } return true; } // If already dreaming and becoming powered, then don't wake. if (mIsPowered && (mWakefulness == WAKEFULNESS_NAPPING || mWakefulness == WAKEFULNESS_DREAMING)) { return false; } // Otherwise wake up! return true; } /** * Updates the value of mStayOn. * Sets DIRTY_STAY_ON if a change occurred. Loading