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

Commit 202dca0f authored by Sindhu B's avatar Sindhu B Committed by Android (Google) Code Review
Browse files

Merge "Fix: DreamServiceWrapper causing significant jank at wakeup and sleep" into main

parents 56b9b7a3 127740da
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.service.dreams;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.service.dreams.Flags.dreamHandlesConfirmKeys;
import static android.service.dreams.Flags.dreamHandlesBeingObscured;
import static android.service.dreams.Flags.startAndStopDozingInBackground;

import android.annotation.FlaggedApi;
import android.annotation.IdRes;
@@ -923,9 +924,16 @@ public class DreamService extends Service implements Window.Callback {

        if (mDozing) {
            try {
                if (startAndStopDozingInBackground()) {
                    mDreamManager.startDozingOneway(
                        mDreamToken, mDozeScreenState, mDozeScreenStateReason,
                        mDozeScreenBrightness);
                } else {
                    mDreamManager.startDozing(
                            mDreamToken, mDozeScreenState, mDozeScreenStateReason,
                            mDozeScreenBrightness);
                }

            } catch (RemoteException ex) {
                // system server died
            }
@@ -1250,7 +1258,11 @@ public class DreamService extends Service implements Window.Callback {
        try {
            // finishSelf will unbind the dream controller from the dream service. This will
            // trigger DreamService.this.onDestroy and DreamService.this will die.
            if (startAndStopDozingInBackground()) {
                mDreamManager.finishSelfOneway(mDreamToken, true /*immediate*/);
            } else {
                mDreamManager.finishSelf(mDreamToken, true /*immediate*/);
            }
        } catch (RemoteException ex) {
            // system server died
        }
+2 −0
Original line number Diff line number Diff line
@@ -50,4 +50,6 @@ interface IDreamManager {
    void startDreamActivity(in Intent intent);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)")
    oneway void setDreamIsObscured(in boolean isObscured);
    oneway void startDozingOneway(in IBinder token, int screenState, int reason, int screenBrightness);
    oneway void finishSelfOneway(in IBinder token, boolean immediate);
}
+10 −0
Original line number Diff line number Diff line
@@ -47,3 +47,13 @@ flag {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
    name: "start_and_stop_dozing_in_background"
    namespace: "systemui"
    description: "Move the start-dozing and stop-dozing operation to the background"
    bug: "330287187"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+32 −0
Original line number Diff line number Diff line
@@ -1078,6 +1078,21 @@ public final class DreamManagerService extends SystemService {
            }
        }

        @Override // Binder call
        public void finishSelfOneway(IBinder token, boolean immediate) {
            // Requires no permission, called by Dream from an arbitrary process.
            if (token == null) {
                throw new IllegalArgumentException("token must not be null");
            }

            final long ident = Binder.clearCallingIdentity();
            try {
                finishSelfInternal(token, immediate);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }

        @Override // Binder call
        public void startDozing(
                IBinder token, int screenState, @Display.StateReason int reason,
@@ -1095,6 +1110,23 @@ public final class DreamManagerService extends SystemService {
            }
        }

        @Override // Binder call
        public void startDozingOneway(
                IBinder token, int screenState, @Display.StateReason int reason,
                int screenBrightness) {
            // Requires no permission, called by Dream from an arbitrary process.
            if (token == null) {
                throw new IllegalArgumentException("token must not be null");
            }

            final long ident = Binder.clearCallingIdentity();
            try {
                startDozingInternal(token, screenState, reason, screenBrightness);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }

        @Override // Binder call
        public void stopDozing(IBinder token) {
            // Requires no permission, called by Dream from an arbitrary process.