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

Commit af2570af authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix concurrent display mode auto canceling"

parents ae9f6e5d fd444024
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.TaskStackListener;
import android.content.Context;
import android.hardware.devicestate.DeviceStateInfo;
@@ -1235,7 +1236,8 @@ public final class DeviceStateManagerService extends SystemService {

    private class OverrideRequestTaskStackListener extends TaskStackListener {
        @Override
        public void onTaskStackChanged() throws RemoteException {
        public void onTaskMovedToFront(ActivityManager.RunningTaskInfo taskInfo)
                throws RemoteException {
            synchronized (mLock) {
                if (!shouldCancelOverrideRequestWhenRequesterNotOnTop()) {
                    return;
+6 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertThrows;

import android.app.ActivityManager;
import android.hardware.devicestate.DeviceStateInfo;
import android.hardware.devicestate.DeviceStateRequest;
import android.hardware.devicestate.IDeviceStateManagerCallback;
@@ -541,7 +542,7 @@ public final class DeviceStateManagerServiceTest {
    }

    @Test
    public void requestState_flagCancelWhenRequesterNotOnTop_onTaskStackChanged()
    public void requestState_flagCancelWhenRequesterNotOnTop_onTaskMovedToFront()
            throws RemoteException {
        requestState_flagCancelWhenRequesterNotOnTop_common(
                // When the app is foreground, the state should not change
@@ -549,7 +550,8 @@ public final class DeviceStateManagerServiceTest {
                    int pid = Binder.getCallingPid();
                    when(mWindowProcessController.getPid()).thenReturn(pid);
                    try {
                        mService.mOverrideRequestTaskStackListener.onTaskStackChanged();
                        mService.mOverrideRequestTaskStackListener.onTaskMovedToFront(
                                new ActivityManager.RunningTaskInfo());
                    } catch (RemoteException e) {
                        throw new RuntimeException(e);
                    }
@@ -558,7 +560,8 @@ public final class DeviceStateManagerServiceTest {
                () -> {
                    when(mWindowProcessController.getPid()).thenReturn(FAKE_PROCESS_ID);
                    try {
                        mService.mOverrideRequestTaskStackListener.onTaskStackChanged();
                        mService.mOverrideRequestTaskStackListener.onTaskMovedToFront(
                                new ActivityManager.RunningTaskInfo());
                    } catch (RemoteException e) {
                        throw new RuntimeException(e);
                    }