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

Commit e1f6b0a2 authored by Andrew Xu's avatar Andrew Xu Committed by Android (Google) Code Review
Browse files

Merge "Send close system dialogs for current user" into main

parents 5d403197 db6a4dd3
Loading
Loading
Loading
Loading
+17 −1
Original line number Original line Diff line number Diff line
@@ -117,6 +117,7 @@ import android.app.ActivityOptions;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager.RootTaskInfo;
import android.app.ActivityTaskManager.RootTaskInfo;
import android.app.AppOpsManager;
import android.app.AppOpsManager;
import android.app.BroadcastOptions;
import android.app.IActivityManager;
import android.app.IActivityManager;
import android.app.IUiModeManager;
import android.app.IUiModeManager;
import android.app.NotificationManager;
import android.app.NotificationManager;
@@ -3612,7 +3613,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                break;
                break;
            case KeyGestureEvent.KEY_GESTURE_TYPE_CLOSE_ALL_DIALOGS:
            case KeyGestureEvent.KEY_GESTURE_TYPE_CLOSE_ALL_DIALOGS:
                if (complete) {
                if (complete) {
                    mContext.closeSystemDialogs();
                    closeSystemDialogsAsUser(UserHandle.CURRENT_OR_SELF);
                }
                }
                break;
                break;
            case KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_TALKBACK:
            case KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_TALKBACK:
@@ -4067,6 +4068,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
        }
    }
    }


    @SuppressLint("MissingPermission")
    private void closeSystemDialogsAsUser(UserHandle handle) {
        final Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
                .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        final Bundle options = BroadcastOptions.makeBasic()
                .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
                .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
                .toBundle();
        mContext.sendBroadcastAsUser(
                intent,
                handle,
                null /* receiverPermission */,
                options);
    }

    private void preloadRecentApps() {
    private void preloadRecentApps() {
        mPreloadedRecentApps = true;
        mPreloadedRecentApps = true;
        StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
        StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
+7 −1
Original line number Original line Diff line number Diff line
@@ -742,7 +742,13 @@ class TestPhoneWindowManager {
    }
    }


    void assertCloseAllDialogs() {
    void assertCloseAllDialogs() {
        verify(mContext).closeSystemDialogs();
        ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
        verify(mContext).sendBroadcastAsUser(intentCaptor.capture(), any(), any(), any());
        Assert.assertEquals(
                Intent.ACTION_CLOSE_SYSTEM_DIALOGS,
                intentCaptor.getValue().getAction());
        // Reset verifier for next call.
        Mockito.clearInvocations(mContext);
    }
    }


    void assertDreamRequest() {
    void assertDreamRequest() {