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

Commit 8a1783f1 authored by Miranda Kephart's avatar Miranda Kephart Committed by Android (Google) Code Review
Browse files

Merge changes from topic "mkephart-screenshot-constants" into main

* changes:
  Duplicate ScreenshotController under a flag
  Move code/interfaces out of ScreenshotController
parents 3332ccdd 32566b39
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.

+6 −6
Original line number Diff line number Diff line
@@ -286,7 +286,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
                    ScreenshotNotificationSmartActionsProvider.ACTION_TYPE,
                    ScreenshotNotificationSmartActionsProvider.DEFAULT_ACTION_TYPE);
            Intent intent = new Intent(context, SmartActionsReceiver.class)
                    .putExtra(ScreenshotController.EXTRA_ACTION_INTENT, action.actionIntent)
                    .putExtra(SmartActionsReceiver.EXTRA_ACTION_INTENT, action.actionIntent)
                    .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
            addIntentExtras(mScreenshotId, intent, actionType, true /* smartActionsEnabled */);
            PendingIntent broadcastIntent = PendingIntent.getBroadcast(context,
@@ -302,9 +302,9 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
    private static void addIntentExtras(String screenshotId, Intent intent, String actionType,
            boolean smartActionsEnabled) {
        intent
                .putExtra(ScreenshotController.EXTRA_ACTION_TYPE, actionType)
                .putExtra(ScreenshotController.EXTRA_ID, screenshotId)
                .putExtra(ScreenshotController.EXTRA_SMART_ACTIONS_ENABLED, smartActionsEnabled);
                .putExtra(SmartActionsReceiver.EXTRA_ACTION_TYPE, actionType)
                .putExtra(SmartActionsReceiver.EXTRA_ID, screenshotId)
                .putExtra(SmartActionsReceiver.EXTRA_SMART_ACTIONS_ENABLED, smartActionsEnabled);
    }

    /**
@@ -327,8 +327,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
        }

        Intent wrappedIntent = new Intent(mContext, SmartActionsReceiver.class)
                .putExtra(ScreenshotController.EXTRA_ACTION_INTENT, quickShare.actionIntent)
                .putExtra(ScreenshotController.EXTRA_ACTION_INTENT_FILLIN,
                .putExtra(SmartActionsReceiver.EXTRA_ACTION_INTENT, quickShare.actionIntent)
                .putExtra(SmartActionsReceiver.EXTRA_ACTION_INTENT_FILLIN,
                        createFillInIntent(uri, imageTime))
                .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        Bundle extras = quickShare.getExtras();
+12 −29
Original line number Diff line number Diff line
@@ -95,28 +95,9 @@ 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);

    public interface TransitionDestination {
        /**
         * Allows the long screenshot activity to call back with a destination location (the bounds
         * on screen of the destination for the transitioning view) and a Runnable to be run once
         * the transition animation is complete.
         */
        void setTransitionDestination(Rect transitionDestination, Runnable onTransitionEnd);
    }

    // These strings are used for communicating the action invoked to
    // ScreenshotNotificationSmartActionsProvider.
    public static final String EXTRA_ACTION_TYPE = "android:screenshot_action_type";
    public static final String EXTRA_ID = "android:screenshot_id";
    public static final String EXTRA_SMART_ACTIONS_ENABLED = "android:smart_actions_enabled";
    public static final String EXTRA_ACTION_INTENT = "android:screenshot_action_intent";
    public static final String EXTRA_ACTION_INTENT_FILLIN =
            "android:screenshot_action_intent_fillin";


    // From WizardManagerHelper.java
    private static final String SETTINGS_SECURE_USER_SETUP_COMPLETE = "user_setup_complete";

@@ -378,9 +359,7 @@ public class ScreenshotController implements ScreenshotHandler {
            if (screenshotPrivateProfileAccessibilityAnnouncementFix()) {
                mAnnouncementResolver.getScreenshotAnnouncement(
                        screenshot.getUserHandle().getIdentifier(),
                        announcement -> {
                            mViewProxy.announceForAccessibility(announcement);
                        });
                        mViewProxy::announceForAccessibility);
            } else {
                if (mUserManager.isManagedProfile(screenshot.getUserHandle().getIdentifier())) {
                    mViewProxy.announceForAccessibility(mContext.getResources().getString(
@@ -413,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);
@@ -603,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) {
@@ -854,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);
    }
}
Loading