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

Commit 4759b06c authored by Lucas Silva's avatar Lucas Silva Committed by Automerger Merge Worker
Browse files

Merge changes Ifece2dc6,Id0c37612 into tm-qpr-dev am: 3dad16a6 am: 973b3adc

parents f28e836e 973b3adc
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.service.dreams;

import android.content.ComponentName;

/**
 * Dream manager local system service interface.
@@ -59,19 +58,4 @@ public abstract class DreamManagerInternal {
     * @param isScreenOn True if the screen is currently on.
     */
    public abstract boolean canStartDreaming(boolean isScreenOn);

    /**
     * Called by the ActivityTaskManagerService to verify that the startDreamActivity
     * request comes from the current active dream component.
     *
     * This function and its call path should not acquire the DreamManagerService lock
     * to avoid deadlock with the ActivityTaskManager lock.
     *
     * TODO: Make this interaction push-based - the DreamManager should inform the
     * ActivityTaskManager whenever the active dream component changes.
     *
     * @param doze If true returns the current active doze component. Otherwise, returns the
     *             active dream component.
     */
    public abstract ComponentName getActiveDreamComponent(boolean doze);
}
+12 −12
Original line number Diff line number Diff line
@@ -1357,6 +1357,12 @@
      "group": "WM_DEBUG_ANIM",
      "at": "com\/android\/server\/wm\/WindowState.java"
    },
    "-787664727": {
      "message": "Cannot launch dream activity due to invalid state. dream component: %s packageName: %s",
      "level": "ERROR",
      "group": "WM_DEBUG_DREAM",
      "at": "com\/android\/server\/wm\/ActivityTaskManagerService.java"
    },
    "-784959154": {
      "message": "Attempted to add private presentation window to a non-private display.  Aborting.",
      "level": "WARN",
@@ -2893,6 +2899,12 @@
      "group": "WM_DEBUG_BOOT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "601283564": {
      "message": "Dream packageName does not match active dream. Package %s does not match %s",
      "level": "ERROR",
      "group": "WM_DEBUG_DREAM",
      "at": "com\/android\/server\/wm\/ActivityTaskManagerService.java"
    },
    "608694300": {
      "message": "  NEW SURFACE SESSION %s",
      "level": "INFO",
@@ -3133,12 +3145,6 @@
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/WindowStateAnimator.java"
    },
    "829869827": {
      "message": "Cannot launch dream activity due to invalid state. dreaming: %b packageName: %s",
      "level": "ERROR",
      "group": "WM_DEBUG_DREAM",
      "at": "com\/android\/server\/wm\/ActivityTaskManagerService.java"
    },
    "835814848": {
      "message": "%s",
      "level": "INFO",
@@ -4159,12 +4165,6 @@
      "group": "WM_DEBUG_WINDOW_ORGANIZER",
      "at": "com\/android\/server\/wm\/TaskOrganizerController.java"
    },
    "1918771553": {
      "message": "Dream packageName does not match active dream. Package %s does not match %s or %s",
      "level": "ERROR",
      "group": "WM_DEBUG_DREAM",
      "at": "com\/android\/server\/wm\/ActivityTaskManagerService.java"
    },
    "1921821199": {
      "message": "Preserving %s until the new one is added",
      "level": "VERBOSE",
+2 −11
Original line number Diff line number Diff line
@@ -491,10 +491,6 @@ public final class DreamManagerService extends SystemService {
        }
    }

    private ComponentName getActiveDreamComponentInternal(boolean doze) {
        return chooseDreamForUser(doze, ActivityManager.getCurrentUser());
    }

    /**
     * If doze is true, returns the doze component for the user.
     * Otherwise, returns the system dream component, if present.
@@ -647,7 +643,7 @@ public final class DreamManagerService extends SystemService {
                .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, DREAM_WAKE_LOCK_TAG);
        final Binder dreamToken = mCurrentDream.token;
        mHandler.post(wakeLock.wrap(() -> {
            mAtmInternal.notifyDreamStateChanged(true);
            mAtmInternal.notifyActiveDreamChanged(name);
            mController.startDream(dreamToken, name, isPreviewMode, canDoze, userId, wakeLock,
                    mDreamOverlayServiceName, reason);
        }));
@@ -672,7 +668,7 @@ public final class DreamManagerService extends SystemService {

    @GuardedBy("mLock")
    private void cleanupDreamLocked() {
        mHandler.post(() -> mAtmInternal.notifyDreamStateChanged(false /*dreaming*/));
        mHandler.post(() -> mAtmInternal.notifyActiveDreamChanged(null));

        if (mCurrentDream == null) {
            return;
@@ -1012,11 +1008,6 @@ public final class DreamManagerService extends SystemService {
            return canStartDreamingInternal(isScreenOn);
        }

        @Override
        public ComponentName getActiveDreamComponent(boolean doze) {
            return getActiveDreamComponentInternal(doze);
        }

        @Override
        public void requestDream() {
            requestDreamInternal();
+3 −1
Original line number Diff line number Diff line
@@ -287,8 +287,10 @@ public abstract class ActivityTaskManagerInternal {

    /**
     * Called when the device changes its dreaming state.
     *
     * @param activeDreamComponent The currently active dream. If null, the device is not dreaming.
     */
    public abstract void notifyDreamStateChanged(boolean dreaming);
    public abstract void notifyActiveDreamChanged(@Nullable ComponentName activeDreamComponent);

    /**
     * Set a uid that is allowed to bypass stopped app switches, launching an app
+13 −23
Original line number Diff line number Diff line
@@ -209,7 +209,6 @@ import android.os.UserManager;
import android.os.WorkSource;
import android.provider.Settings;
import android.service.dreams.DreamActivity;
import android.service.dreams.DreamManagerInternal;
import android.service.voice.IVoiceInteractionSession;
import android.service.voice.VoiceInteractionManagerInternal;
import android.sysprop.DisplayProperties;
@@ -669,11 +668,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    private volatile boolean mSleeping;

    /**
     * The mDreaming state is set by the {@link DreamManagerService} when it receives a request to
     * start/stop the dream. It is set to true shortly  before the {@link DreamService} is started.
     * It is set to false after the {@link DreamService} is stopped.
     * The mActiveDreamComponent state is set by the {@link DreamManagerService} when it receives a
     * request to start/stop the dream. It is set to the active dream shortly before the
     * {@link DreamService} is started. It is set to null after the {@link DreamService} is stopped.
     */
    private volatile boolean mDreaming;
    @Nullable
    private volatile ComponentName mActiveDreamComponent;

    /**
     * The process state used for processes that are running the top activities.
@@ -1439,31 +1439,21 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    }

    boolean isDreaming() {
        return mDreaming;
        return mActiveDreamComponent != null;
    }

    boolean canLaunchDreamActivity(String packageName) {
        if (!mDreaming || packageName == null) {
        if (mActiveDreamComponent == null || packageName == null) {
            ProtoLog.e(WM_DEBUG_DREAM, "Cannot launch dream activity due to invalid state. "
                    + "dreaming: %b packageName: %s", mDreaming, packageName);
                    + "dream component: %s packageName: %s", mActiveDreamComponent, packageName);
            return false;
        }
        final DreamManagerInternal dreamManager =
                LocalServices.getService(DreamManagerInternal.class);
        // Verify that the package is the current active dream or doze component. The
        // getActiveDreamComponent() call path does not acquire the DreamManager lock and thus
        // is safe to use.
        final ComponentName activeDream = dreamManager.getActiveDreamComponent(false /* doze */);
        if (activeDream != null && packageName.equals(activeDream.getPackageName())) {
            return true;
        }
        final ComponentName activeDoze = dreamManager.getActiveDreamComponent(true /* doze */);
        if (activeDoze != null && packageName.equals(activeDoze.getPackageName())) {
        if (packageName.equals(mActiveDreamComponent.getPackageName())) {
            return true;
        }
        ProtoLog.e(WM_DEBUG_DREAM,
                "Dream packageName does not match active dream. Package %s does not match %s or %s",
                packageName, String.valueOf(activeDream), String.valueOf(activeDoze));
                "Dream packageName does not match active dream. Package %s does not match %s",
                packageName, String.valueOf(mActiveDreamComponent));
        return false;
    }

@@ -5680,9 +5670,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }

        @Override
        public void notifyDreamStateChanged(boolean dreaming) {
        public void notifyActiveDreamChanged(@Nullable ComponentName dreamComponent) {
            synchronized (mGlobalLock) {
                mDreaming = dreaming;
                mActiveDreamComponent = dreamComponent;
            }
        }