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

Commit 2175e9c3 authored by Jeff Brown's avatar Jeff Brown
Browse files

Add support for dozing after screen off.

On some devices, we want the screen off transition to complete before
we start dozing.  Added a new config.xml attribute config_dozeAfterScreenOff
to configure this behavior.

Defer starting dreams until the display is ready.

Fixed some minor issues in the system UI doze service when setting the
display state.

Bug: 16187655
Change-Id: Ib1bc60de5457166f4b4880732db5df989dda67a4
parent 2642357b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Slog;
import android.view.ActionMode;
+4 −0
Original line number Diff line number Diff line
@@ -1281,6 +1281,10 @@
         Doze dreams will run whenever the power manager is in a dozing state. -->
    <string name="config_dozeComponent"></string>

    <!-- If true, the doze component is not started until after the screen has been
         turned off and the screen off animation has been performed. -->
    <bool name="config_dozeAfterScreenOff">false</bool>

    <!-- Power Management: Specifies whether to decouple the auto-suspend state of the
         device from the display on/off state.

+1 −0
Original line number Diff line number Diff line
@@ -1536,6 +1536,7 @@
  <java-symbol type="bool" name="config_useAttentionLight" />
  <java-symbol type="bool" name="config_animateScreenLights" />
  <java-symbol type="bool" name="config_automatic_brightness_available" />
  <java-symbol type="bool" name="config_dozeAfterScreenOff" />
  <java-symbol type="bool" name="config_enableActivityRecognitionHardwareOverlay" />
  <java-symbol type="bool" name="config_enableFusedLocationOverlay" />
  <java-symbol type="bool" name="config_enableHardwareFlpOverlay" />
+2 −28
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public class DozeService extends DreamService {
                new Intent(NOTIFICATION_PULSE_ACTION).setPackage(getPackageName()),
                PendingIntent.FLAG_UPDATE_CURRENT);
        mDisplayStateWhenOn = mDisplayStateSupported ? Display.STATE_DOZE : Display.STATE_ON;
        setDozeScreenState(mDisplayStateWhenOn);
        mDisplayOff.run();
    }

    @Override
@@ -160,16 +160,6 @@ public class DozeService extends DreamService {
        mHandler.postDelayed(mDisplayOff, millis);
    }

    public void startDozing() {
        if (DEBUG) Log.d(mTag, "startDozing mDreaming=" + mDreaming);
        if (!mDreaming) {
            Log.w(mTag, "Not dozing, no longer dreaming");
            return;
        }

        super.startDozing();
    }

    @Override
    public void onDreamingStopped() {
        if (DEBUG) Log.d(mTag, "onDreamingStopped isDozing=" + isDozing());
@@ -180,24 +170,8 @@ public class DozeService extends DreamService {
            mWakeLock.release();
        }
        listenForPulseSignals(false);
        stopDozing();
        dozingStopped();
    }

    @Override
    public void onDetachedFromWindow() {
        if (DEBUG) Log.d(mTag, "onDetachedFromWindow");
        super.onDetachedFromWindow();

        dozingStopped();
    }

    @Override
    public void onDestroy() {
        if (DEBUG) Log.d(mTag, "onDestroy");
        super.onDestroy();

        dozingStopped();
        mHandler.removeCallbacks(mDisplayOff);
    }

    private void requestDoze() {
+0 −2
Original line number Diff line number Diff line
@@ -4079,7 +4079,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        @Override
        public void requestDoze(DozeService dozeService) {
            if (dozeService == null) return;
            dozeService.stayAwake(PROCESSING_TIME);
            mHandler.obtainMessage(H.REQUEST_DOZE, dozeService).sendToTarget();
        }

@@ -4094,7 +4093,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        @Override
        public void dozingStopped(DozeService dozeService) {
            if (dozeService == null) return;
            dozeService.stayAwake(PROCESSING_TIME);
            mHandler.obtainMessage(H.DOZING_STOPPED, dozeService).sendToTarget();
        }

Loading