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

Commit 32566b39 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Duplicate ScreenshotController under a flag

Bug: 354711957
Flag: com.android.systemui.screenshot_ui_controller_refactor
Test: manual (with flag on/off)
Change-Id: I47a1f5b5c7453e0517a7ef948024669d3c7f1995
parent 3e431136
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -600,6 +600,13 @@ flag {
    }
}

flag {
    name: "screenshot_ui_controller_refactor"
    namespace: "systemui"
    description: "Simplify and refactor ScreenshotController"
    bug: "354711957"
}

flag {
   name: "run_fingerprint_detect_on_dismissible_keyguard"
   namespace: "systemui"
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.screenshot

import android.view.Display

interface InteractiveScreenshotHandler : ScreenshotHandler {
    fun isPendingSharedTransition(): Boolean

    fun requestDismissal(event: ScreenshotEvent)

    fun removeWindow()

    fun onDestroy()

    interface Factory {
        fun create(display: Display): InteractiveScreenshotHandler
    }
}
+848 −0

File added.

Preview size limit exceeded, changes collapsed.

+11 −7
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ import javax.inject.Provider;
/**
 * Controls the state and flow for screenshots.
 */
public class ScreenshotController implements ScreenshotHandler {
public class ScreenshotController implements InteractiveScreenshotHandler {
    private static final String TAG = logTag(ScreenshotController.class);

    // From WizardManagerHelper.java
@@ -392,16 +392,19 @@ public class ScreenshotController implements ScreenshotHandler {
     * Requests the view to dismiss the current screenshot (may be ignored, if screenshot is already
     * being dismissed)
     */
    void requestDismissal(ScreenshotEvent event) {
    @Override
    public void requestDismissal(ScreenshotEvent event) {
        mViewProxy.requestDismissal(event);
    }

    boolean isPendingSharedTransition() {
    @Override
    public boolean isPendingSharedTransition() {
        return mActionExecutor.isPendingSharedTransition();
    }

    // Any cleanup needed when the service is being destroyed.
    void onDestroy() {
    @Override
    public void onDestroy() {
        if (mSaveInBgTask != null) {
            // just log success/failure for the pre-existing screenshot
            mSaveInBgTask.setActionsReadyListener(this::logSuccessOnActionsReady);
@@ -582,7 +585,8 @@ public class ScreenshotController implements ScreenshotHandler {
        layout.setClipToPadding(false);
    }

    void removeWindow() {
    @Override
    public void removeWindow() {
        final View decorView = mWindow.peekDecorView();
        if (decorView != null && decorView.isAttachedToWindow()) {
            if (DEBUG_WINDOW) {
@@ -833,12 +837,12 @@ public class ScreenshotController implements ScreenshotHandler {

    /** Injectable factory to create screenshot controller instances for a specific display. */
    @AssistedFactory
    public interface Factory {
    public interface Factory extends InteractiveScreenshotHandler.Factory {
        /**
         * Creates an instance of the controller for that specific display.
         *
         * @param display                 display to capture
         */
        ScreenshotController create(Display display);
        LegacyScreenshotController create(Display display);
    }
}
+6 −5
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ interface ScreenshotHandler {
class TakeScreenshotExecutorImpl
@Inject
constructor(
    private val screenshotControllerFactory: ScreenshotController.Factory,
    private val interactiveScreenshotHandlerFactory: InteractiveScreenshotHandler.Factory,
    displayRepository: DisplayRepository,
    @Application private val mainScope: CoroutineScope,
    private val screenshotRequestProcessor: ScreenshotRequestProcessor,
@@ -83,7 +83,7 @@ constructor(
    private val headlessScreenshotHandler: HeadlessScreenshotHandler,
) : TakeScreenshotExecutor {
    private val displays = displayRepository.displays
    private var screenshotController: ScreenshotController? = null
    private var screenshotController: InteractiveScreenshotHandler? = null
    private val notificationControllers = mutableMapOf<Int, ScreenshotNotificationsController>()

    /**
@@ -183,7 +183,7 @@ constructor(

    /** Propagates the close system dialog signal to the ScreenshotController. */
    override fun onCloseSystemDialogsReceived() {
        if (screenshotController?.isPendingSharedTransition == false) {
        if (screenshotController?.isPendingSharedTransition() == false) {
            screenshotController?.requestDismissal(SCREENSHOT_DISMISSED_OTHER)
        }
    }
@@ -218,8 +218,9 @@ constructor(
        }
    }

    private fun getScreenshotController(display: Display): ScreenshotController {
        val controller = screenshotController ?: screenshotControllerFactory.create(display)
    private fun getScreenshotController(display: Display): InteractiveScreenshotHandler {
        val controller =
            screenshotController ?: interactiveScreenshotHandlerFactory.create(display)
        screenshotController = controller
        return controller
    }
Loading