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

Commit d3d992b4 authored by minch's avatar minch
Browse files

Show new share screen UI on desktop

Flag: com.android.systemui.large_screen_sharing
Test: Verified that click share app/entire screen inside clank
      can trigger LargeScreenCaptureShareScreenContent
      on TangorPro with ag/34944409.
Bug: 435736499
Change-Id: I9c051b6255a08069a73604038bb8e995cf53c5b0
parent 303b139c
Loading
Loading
Loading
Loading
+46 −15
Original line number Diff line number Diff line
@@ -65,6 +65,10 @@ import com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelect
import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDevicePolicyResolver;
import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDisabledDialogDelegate;
import com.android.systemui.res.R;
import com.android.systemui.screencapture.common.shared.model.ScreenCaptureActivityIntentParameters;
import com.android.systemui.screencapture.common.shared.model.ScreenCaptureType;
import com.android.systemui.screencapture.domain.interactor.ScreenCaptureUiInteractor;
import com.android.systemui.screencapture.sharescreen.domain.interactor.ScreenCaptureShareScreenFeaturesInteractor;
import com.android.systemui.statusbar.phone.AlertDialogWithDelegate;
import com.android.systemui.statusbar.phone.SystemUIDialog;

@@ -86,6 +90,8 @@ public class MediaProjectionPermissionActivity extends Activity {
    private final ScreenCaptureDisabledDialogDelegate mScreenCaptureDisabledDialogDelegate;
    private final KeyguardManager mKeyguardManager;

    private final ScreenCaptureUiInteractor mScreenCaptureUiInteractor;

    private String mPackageName;
    private int mUid;

@@ -105,13 +111,15 @@ public class MediaProjectionPermissionActivity extends Activity {
            StatusBarManager statusBarManager,
            KeyguardManager keyguardManager,
            MediaProjectionMetricsLogger mediaProjectionMetricsLogger,
            ScreenCaptureDisabledDialogDelegate screenCaptureDisabledDialogDelegate) {
            ScreenCaptureDisabledDialogDelegate screenCaptureDisabledDialogDelegate,
            ScreenCaptureUiInteractor screenCaptureUiInteractor) {
        mFeatureFlags = featureFlags;
        mScreenCaptureDevicePolicyResolver = screenCaptureDevicePolicyResolver;
        mStatusBarManager = statusBarManager;
        mKeyguardManager = keyguardManager;
        mMediaProjectionMetricsLogger = mediaProjectionMetricsLogger;
        mScreenCaptureDisabledDialogDelegate = screenCaptureDisabledDialogDelegate;
        mScreenCaptureUiInteractor = screenCaptureUiInteractor;
    }

    @Override
@@ -195,6 +203,22 @@ public class MediaProjectionPermissionActivity extends Activity {
                MediaProjectionUtils.INSTANCE.packageHasCastingCapabilities(
                        packageManager, mPackageName);

        if (savedInstanceState == null) {
            mMediaProjectionMetricsLogger.notifyProjectionInitiated(
                    mUid,
                    hasCastingCapabilities
                            ? SessionCreationSource.CAST
                            : SessionCreationSource.APP);
        }

        final boolean showLargeScreenShareDialog =
                !hasCastingCapabilities
                && ScreenCaptureShareScreenFeaturesInteractor
                        .INSTANCE.isLargeScreenSharingEnabled();
        final Runnable screenShareDialogRunnable;
        if (showLargeScreenShareDialog) {
            screenShareDialogRunnable = this::showShareScreenUI;
        } else {
            // Using application context for the dialog, instead of the activity context, so we get
            // the correct screen width when in split screen.
            Context dialogContext = createDisplayContext(getDisplay());
@@ -204,22 +228,16 @@ public class MediaProjectionPermissionActivity extends Activity {
                    new AlertDialogWithDelegate(
                            dialogContext, R.style.Theme_SystemUI_Dialog, delegate);

        if (savedInstanceState == null) {
            mMediaProjectionMetricsLogger.notifyProjectionInitiated(
                    mUid,
                    hasCastingCapabilities
                            ? SessionCreationSource.CAST
                            : SessionCreationSource.APP);
        }

            setUpDialog(mDialog);
            screenShareDialogRunnable = mDialog::show;
        }

        boolean shouldDismissKeyguard =
                com.android.systemui.Flags.mediaProjectionDialogBehindLockscreen();
        if (shouldDismissKeyguard && mKeyguardManager.isDeviceLocked()) {
            requestDeviceUnlock();
            requestDeviceUnlock(screenShareDialogRunnable);
        } else {
            mDialog.show();
            screenShareDialogRunnable.run();
        }

        if (savedInstanceState == null) {
@@ -227,6 +245,19 @@ public class MediaProjectionPermissionActivity extends Activity {
        }
    }

    private void showShareScreenUI() {

        final ScreenCaptureActivityIntentParameters params =
                new ScreenCaptureActivityIntentParameters(
                        ScreenCaptureType.SHARE_SCREEN,
                        mReviewGrantedConsentRequired,
                        /* resultReceiver= */ null,
                        /* mediaProjection= */ null,
                        getHostUserHandle(), mUid);
        mScreenCaptureUiInteractor.show(params);
        finish();
    }

    private String extractAppName(ApplicationInfo applicationInfo, PackageManager packageManager) {
        String label = applicationInfo.loadLabel(packageManager).toString();

@@ -346,7 +377,7 @@ public class MediaProjectionPermissionActivity extends Activity {
        return false;
    }

    private void requestDeviceUnlock() {
    private void requestDeviceUnlock(Runnable onDismissSucceeded) {
        mKeyguardManager.requestDismissKeyguard(this,
                new KeyguardManager.KeyguardDismissCallback() {

@@ -366,7 +397,7 @@ public class MediaProjectionPermissionActivity extends Activity {

                    @Override
                    public void onDismissSucceeded() {
                        mDialog.show();
                        onDismissSucceeded.run();
                    }
                });
    }
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.screencapture.sharescreen.domain.interactor

import com.android.systemui.Flags
import com.android.systemui.dagger.SysUISingleton

@SysUISingleton
object ScreenCaptureShareScreenFeaturesInteractor {

    val isLargeScreenSharingEnabled: Boolean
        get() = Flags.largeScreenSharing()
}