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

Commit 9bb27a05 authored by Kenneth Ford's avatar Kenneth Ford Committed by Android (Google) Code Review
Browse files

Merge "Add rear display dialog methods to CommandQueue and StatusBarService" into tm-qpr-dev

parents eb2b8f14 b8bb4dd9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -325,4 +325,7 @@ oneway interface IStatusBar

    /** Dump protos from SystemUI. The proto definition is defined there */
    void dumpProto(in String[] args, in ParcelFileDescriptor pfd);

    /** Shows rear display educational dialog */
    void showRearDisplayDialog(int currentBaseState);
}
+3 −0
Original line number Diff line number Diff line
@@ -226,4 +226,7 @@ interface IStatusBarService

    /** Unregisters a nearby media devices provider. */
    void unregisterNearbyMediaDevicesProvider(in INearbyMediaDevicesProvider provider);

    /** Shows rear display educational dialog */
    void showRearDisplayDialog(int currentBaseState);
}
+17 −0
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ public class CommandQueue extends IStatusBar.Stub implements
    private static final int MSG_REGISTER_NEARBY_MEDIA_DEVICE_PROVIDER = 66 << MSG_SHIFT;
    private static final int MSG_UNREGISTER_NEARBY_MEDIA_DEVICE_PROVIDER = 67 << MSG_SHIFT;
    private static final int MSG_TILE_SERVICE_REQUEST_LISTENING_STATE = 68 << MSG_SHIFT;
    private static final int MSG_SHOW_REAR_DISPLAY_DIALOG = 69 << MSG_SHIFT;

    public static final int FLAG_EXCLUDE_NONE = 0;
    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -474,6 +475,11 @@ public class CommandQueue extends IStatusBar.Stub implements
         */
        default void unregisterNearbyMediaDevicesProvider(
                @NonNull INearbyMediaDevicesProvider provider) {}

        /**
         * @see IStatusBar#showRearDisplayDialog
         */
        default void showRearDisplayDialog(int currentBaseState) {}
    }

    public CommandQueue(Context context) {
@@ -1228,6 +1234,13 @@ public class CommandQueue extends IStatusBar.Stub implements
                .sendToTarget();
    }

    @Override
    public void showRearDisplayDialog(int currentBaseState) {
        synchronized (mLock) {
            mHandler.obtainMessage(MSG_SHOW_REAR_DISPLAY_DIALOG, currentBaseState).sendToTarget();
        }
    }

    @Override
    public void requestAddTile(
            @NonNull ComponentName componentName,
@@ -1724,6 +1737,10 @@ public class CommandQueue extends IStatusBar.Stub implements
                        mCallbacks.get(i).requestTileServiceListeningState(component);
                    }
                    break;
                case MSG_SHOW_REAR_DISPLAY_DIALOG:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).showRearDisplayDialog((Integer) msg.obj);
                    }
            }
        }
    }
+8 −0
Original line number Diff line number Diff line
@@ -519,4 +519,12 @@ public class CommandQueueTest extends SysuiTestCase {
        waitForIdleSync();
        verify(mCallbacks).setNavigationBarLumaSamplingEnabled(eq(1), eq(true));
    }

    @Test
    public void testShowRearDisplayDialog() {
        final int currentBaseState = 1;
        mCommandQueue.showRearDisplayDialog(currentBaseState);
        waitForIdleSync();
        verify(mCallbacks).showRearDisplayDialog(eq(currentBaseState));
    }
}
+8 −14
Original line number Diff line number Diff line
@@ -17,10 +17,7 @@
package com.android.server.devicestate;

import static android.Manifest.permission.CONTROL_DEVICE_STATE;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.hardware.devicestate.DeviceStateManager.ACTION_SHOW_REAR_DISPLAY_OVERLAY;
import static android.hardware.devicestate.DeviceStateManager.EXTRA_ORIGINAL_DEVICE_BASE_STATE;
import static android.hardware.devicestate.DeviceStateManager.INVALID_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MAXIMUM_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MINIMUM_DEVICE_STATE;
@@ -36,10 +33,7 @@ import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.WindowConfiguration;
import android.content.Context;
import android.content.Intent;
import android.hardware.devicestate.DeviceStateInfo;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.devicestate.DeviceStateManagerInternal;
@@ -64,6 +58,7 @@ import com.android.internal.util.FrameworkStatsLog;
import com.android.server.DisplayThread;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.statusbar.StatusBarManagerInternal;
import com.android.server.wm.ActivityTaskManagerInternal;
import com.android.server.wm.WindowProcessController;

@@ -731,19 +726,18 @@ public final class DeviceStateManagerService extends SystemService {

    /**
     * If we get a request to enter rear display  mode, we need to display an educational
     * overlay to let the user know what will happen. This creates the pending request and then
     * launches the {@link RearDisplayEducationActivity}
     * overlay to let the user know what will happen. This calls into the
     * {@link StatusBarManagerInternal} to notify SystemUI to display the educational dialog.
     */
    @GuardedBy("mLock")
    private void showRearDisplayEducationalOverlayLocked(OverrideRequest request) {
        mRearDisplayPendingOverrideRequest = request;

        Intent intent = new Intent(ACTION_SHOW_REAR_DISPLAY_OVERLAY);
        intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(EXTRA_ORIGINAL_DEVICE_BASE_STATE, mBaseState.get().getIdentifier());
        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchWindowingMode(WindowConfiguration.WINDOWING_MODE_FULLSCREEN);
        getUiContext().startActivity(intent, options.toBundle());
        StatusBarManagerInternal statusBar =
                LocalServices.getService(StatusBarManagerInternal.class);
        if (statusBar != null) {
            statusBar.showRearDisplayDialog(mBaseState.get().getIdentifier());
        }
    }

    private void cancelStateRequestInternal(int callingPid) {
Loading