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

Commit 367f1de0 authored by Kenneth Ford's avatar Kenneth Ford
Browse files

Add rear display dialog methods to CommandQueue and StatusBarService

Creates new methods through CommandQueue and StatusBarService
to allow DeviceStateManagerService to notify SystemUI
to show the rear display education dialog

Bug: 207686851
Test: CommandQueueTest
Change-Id: I65e22a9940a866bb62b597f5cd4f6ce81d891e12
parent 0153dd58
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -324,4 +324,7 @@ oneway interface IStatusBar


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

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


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

    /** Shows rear display educational dialog */
    void showRearDisplayDialog(int currentBaseState);
}
}
+17 −0
Original line number Original line Diff line number Diff line
@@ -163,6 +163,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_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_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_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_NONE = 0;
    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -472,6 +473,11 @@ public class CommandQueue extends IStatusBar.Stub implements
         */
         */
        default void unregisterNearbyMediaDevicesProvider(
        default void unregisterNearbyMediaDevicesProvider(
                @NonNull INearbyMediaDevicesProvider provider) {}
                @NonNull INearbyMediaDevicesProvider provider) {}

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


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


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

    @Override
    @Override
    public void requestAddTile(
    public void requestAddTile(
            @NonNull ComponentName componentName,
            @NonNull ComponentName componentName,
@@ -1721,6 +1734,10 @@ public class CommandQueue extends IStatusBar.Stub implements
                        mCallbacks.get(i).requestTileServiceListeningState(component);
                        mCallbacks.get(i).requestTileServiceListeningState(component);
                    }
                    }
                    break;
                    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 Original line Diff line number Diff line
@@ -523,4 +523,12 @@ public class CommandQueueTest extends SysuiTestCase {
        waitForIdleSync();
        waitForIdleSync();
        verify(mCallbacks).setNavigationBarLumaSamplingEnabled(eq(1), eq(true));
        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 Original line Diff line number Diff line
@@ -17,10 +17,7 @@
package com.android.server.devicestate;
package com.android.server.devicestate;


import static android.Manifest.permission.CONTROL_DEVICE_STATE;
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.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.INVALID_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MAXIMUM_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MAXIMUM_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MINIMUM_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.IntRange;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.WindowConfiguration;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.hardware.devicestate.DeviceStateInfo;
import android.hardware.devicestate.DeviceStateInfo;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.devicestate.DeviceStateManagerInternal;
import android.hardware.devicestate.DeviceStateManagerInternal;
@@ -64,6 +58,7 @@ import com.android.internal.util.FrameworkStatsLog;
import com.android.server.DisplayThread;
import com.android.server.DisplayThread;
import com.android.server.LocalServices;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.SystemService;
import com.android.server.statusbar.StatusBarManagerInternal;
import com.android.server.wm.ActivityTaskManagerInternal;
import com.android.server.wm.ActivityTaskManagerInternal;
import com.android.server.wm.WindowProcessController;
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
     * 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
     * overlay to let the user know what will happen. This calls into the
     * launches the {@link RearDisplayEducationActivity}
     * {@link StatusBarManagerInternal} to notify SystemUI to display the educational dialog.
     */
     */
    @GuardedBy("mLock")
    @GuardedBy("mLock")
    private void showRearDisplayEducationalOverlayLocked(OverrideRequest request) {
    private void showRearDisplayEducationalOverlayLocked(OverrideRequest request) {
        mRearDisplayPendingOverrideRequest = request;
        mRearDisplayPendingOverrideRequest = request;


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


    private void cancelStateRequestInternal(int callingPid) {
    private void cancelStateRequestInternal(int callingPid) {
Loading