Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0728206a authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Ensure that dreams show while docked." into jb-mr1-dev

parents aa99257d 9fca9e96
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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) {
@@ -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();

@@ -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);
            }
+44 −34
Original line number Diff line number Diff line
@@ -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
@@ -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.