Loading packages/SystemUI/aconfig/systemui.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -605,16 +605,6 @@ flag { } } flag { name: "screenshot_private_profile_behavior_fix" namespace: "systemui" description: "Private profile support for screenshots" bug: "327613051" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "screenshot_save_image_exporter" namespace: "systemui" Loading packages/SystemUI/src/com/android/systemui/screenshot/MessageContainerController.kt +7 −33 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import android.view.ViewGroup.MarginLayoutParams import android.view.ViewTreeObserver import android.view.animation.AccelerateDecelerateInterpolator import androidx.constraintlayout.widget.Guideline import com.android.systemui.Flags.screenshotPrivateProfileBehaviorFix import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.res.R import com.android.systemui.screenshot.message.ProfileMessageController Loading Loading @@ -49,7 +48,6 @@ constructor( } fun onScreenshotTaken(screenshot: ScreenshotData) { if (screenshotPrivateProfileBehaviorFix()) { mainScope.launch { val profileData = profileMessageController.onScreenshotTaken(screenshot.userHandle) var notifiedApps: List<CharSequence> = Loading @@ -71,30 +69,6 @@ constructor( animateInMessageContainer() } } } else { val workProfileData = workProfileMessageController.onScreenshotTaken(screenshot.userHandle) var notifiedApps: List<CharSequence> = screenshotDetectionController.maybeNotifyOfScreenshot(screenshot) // If work profile first run needs to show, bias towards that, otherwise show screenshot // detection notification if needed. if (workProfileData != null) { workProfileFirstRunView.visibility = View.VISIBLE detectionNoticeView.visibility = View.GONE workProfileMessageController.populateView( workProfileFirstRunView, workProfileData, this::animateOutMessageContainer ) animateInMessageContainer() } else if (notifiedApps.isNotEmpty()) { detectionNoticeView.visibility = View.VISIBLE workProfileFirstRunView.visibility = View.GONE screenshotDetectionController.populateView(detectionNoticeView, notifiedApps) animateInMessageContainer() } } } private fun animateInMessageContainer() { Loading packages/SystemUI/src/com/android/systemui/screenshot/RequestProcessor.ktdeleted 100644 → 0 +0 −62 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.util.Log import android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE /** Implementation of [ScreenshotRequestProcessor] */ class RequestProcessor( private val capture: ImageCapture, private val policy: ScreenshotPolicy, ) : ScreenshotRequestProcessor { override suspend fun process(screenshot: ScreenshotData): ScreenshotData { var result = screenshot // Apply work profile screenshots policy: // // If the focused app belongs to a work profile, transforms a full screen // (or partial) screenshot request to a task snapshot (provided image) screenshot. // Whenever displayContentInfo is fetched, the topComponent is also populated // regardless of the managed profile status. if (screenshot.type != TAKE_SCREENSHOT_PROVIDED_IMAGE) { val info = policy.findPrimaryContent(screenshot.displayId) Log.d(TAG, "findPrimaryContent: $info") result.taskId = info.taskId result.topComponent = info.component result.userHandle = info.user if (policy.isManagedProfile(info.user.identifier)) { val image = capture.captureTask(info.taskId) ?: throw RequestProcessorException("Task snapshot returned a null Bitmap!") // Provide the task snapshot as the screenshot result.type = TAKE_SCREENSHOT_PROVIDED_IMAGE result.bitmap = image result.screenBounds = info.bounds } } return result } } private const val TAG = "RequestProcessor" packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotRequestProcessor.kt +1 −1 Original line number Diff line number Diff line Loading @@ -27,5 +27,5 @@ fun interface ScreenshotRequestProcessor { suspend fun process(original: ScreenshotData): ScreenshotData } /** Exception thrown by [RequestProcessor] if something goes wrong. */ /** Exception thrown by [ScreenshotRequestProcessor] if something goes wrong. */ class RequestProcessorException(message: String) : IllegalStateException(message) packages/SystemUI/src/com/android/systemui/screenshot/policy/ScreenshotPolicyModule.kt +10 −18 Original line number Diff line number Diff line Loading @@ -19,14 +19,11 @@ package com.android.systemui.screenshot.policy import android.content.ComponentName import android.content.Context import android.os.Process import com.android.systemui.Flags.screenshotPrivateProfileBehaviorFix import com.android.systemui.SystemUIService import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.screenshot.ImageCapture import com.android.systemui.screenshot.RequestProcessor import com.android.systemui.screenshot.ScreenshotPolicy import com.android.systemui.screenshot.ScreenshotRequestProcessor import com.android.systemui.screenshot.data.repository.DisplayContentRepository import com.android.systemui.screenshot.data.repository.DisplayContentRepositoryImpl Loading Loading @@ -68,23 +65,18 @@ interface ScreenshotPolicyModule { @Application context: Context, @Background background: CoroutineDispatcher, imageCapture: ImageCapture, policyProvider: Provider<ScreenshotPolicy>, displayContentRepoProvider: Provider<DisplayContentRepository>, displayContentRepo: DisplayContentRepository, policyListProvider: Provider<List<CapturePolicy>>, ): ScreenshotRequestProcessor { return if (screenshotPrivateProfileBehaviorFix()) { PolicyRequestProcessor( return PolicyRequestProcessor( background = background, capture = imageCapture, displayTasks = displayContentRepoProvider.get(), displayTasks = displayContentRepo, policies = policyListProvider.get(), defaultOwner = Process.myUserHandle(), defaultComponent = ComponentName(context.packageName, SystemUIService::class.java.toString()) ) } else { RequestProcessor(imageCapture, policyProvider.get()) } } } } Loading
packages/SystemUI/aconfig/systemui.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -605,16 +605,6 @@ flag { } } flag { name: "screenshot_private_profile_behavior_fix" namespace: "systemui" description: "Private profile support for screenshots" bug: "327613051" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "screenshot_save_image_exporter" namespace: "systemui" Loading
packages/SystemUI/src/com/android/systemui/screenshot/MessageContainerController.kt +7 −33 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import android.view.ViewGroup.MarginLayoutParams import android.view.ViewTreeObserver import android.view.animation.AccelerateDecelerateInterpolator import androidx.constraintlayout.widget.Guideline import com.android.systemui.Flags.screenshotPrivateProfileBehaviorFix import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.res.R import com.android.systemui.screenshot.message.ProfileMessageController Loading Loading @@ -49,7 +48,6 @@ constructor( } fun onScreenshotTaken(screenshot: ScreenshotData) { if (screenshotPrivateProfileBehaviorFix()) { mainScope.launch { val profileData = profileMessageController.onScreenshotTaken(screenshot.userHandle) var notifiedApps: List<CharSequence> = Loading @@ -71,30 +69,6 @@ constructor( animateInMessageContainer() } } } else { val workProfileData = workProfileMessageController.onScreenshotTaken(screenshot.userHandle) var notifiedApps: List<CharSequence> = screenshotDetectionController.maybeNotifyOfScreenshot(screenshot) // If work profile first run needs to show, bias towards that, otherwise show screenshot // detection notification if needed. if (workProfileData != null) { workProfileFirstRunView.visibility = View.VISIBLE detectionNoticeView.visibility = View.GONE workProfileMessageController.populateView( workProfileFirstRunView, workProfileData, this::animateOutMessageContainer ) animateInMessageContainer() } else if (notifiedApps.isNotEmpty()) { detectionNoticeView.visibility = View.VISIBLE workProfileFirstRunView.visibility = View.GONE screenshotDetectionController.populateView(detectionNoticeView, notifiedApps) animateInMessageContainer() } } } private fun animateInMessageContainer() { Loading
packages/SystemUI/src/com/android/systemui/screenshot/RequestProcessor.ktdeleted 100644 → 0 +0 −62 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.util.Log import android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE /** Implementation of [ScreenshotRequestProcessor] */ class RequestProcessor( private val capture: ImageCapture, private val policy: ScreenshotPolicy, ) : ScreenshotRequestProcessor { override suspend fun process(screenshot: ScreenshotData): ScreenshotData { var result = screenshot // Apply work profile screenshots policy: // // If the focused app belongs to a work profile, transforms a full screen // (or partial) screenshot request to a task snapshot (provided image) screenshot. // Whenever displayContentInfo is fetched, the topComponent is also populated // regardless of the managed profile status. if (screenshot.type != TAKE_SCREENSHOT_PROVIDED_IMAGE) { val info = policy.findPrimaryContent(screenshot.displayId) Log.d(TAG, "findPrimaryContent: $info") result.taskId = info.taskId result.topComponent = info.component result.userHandle = info.user if (policy.isManagedProfile(info.user.identifier)) { val image = capture.captureTask(info.taskId) ?: throw RequestProcessorException("Task snapshot returned a null Bitmap!") // Provide the task snapshot as the screenshot result.type = TAKE_SCREENSHOT_PROVIDED_IMAGE result.bitmap = image result.screenBounds = info.bounds } } return result } } private const val TAG = "RequestProcessor"
packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotRequestProcessor.kt +1 −1 Original line number Diff line number Diff line Loading @@ -27,5 +27,5 @@ fun interface ScreenshotRequestProcessor { suspend fun process(original: ScreenshotData): ScreenshotData } /** Exception thrown by [RequestProcessor] if something goes wrong. */ /** Exception thrown by [ScreenshotRequestProcessor] if something goes wrong. */ class RequestProcessorException(message: String) : IllegalStateException(message)
packages/SystemUI/src/com/android/systemui/screenshot/policy/ScreenshotPolicyModule.kt +10 −18 Original line number Diff line number Diff line Loading @@ -19,14 +19,11 @@ package com.android.systemui.screenshot.policy import android.content.ComponentName import android.content.Context import android.os.Process import com.android.systemui.Flags.screenshotPrivateProfileBehaviorFix import com.android.systemui.SystemUIService import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.screenshot.ImageCapture import com.android.systemui.screenshot.RequestProcessor import com.android.systemui.screenshot.ScreenshotPolicy import com.android.systemui.screenshot.ScreenshotRequestProcessor import com.android.systemui.screenshot.data.repository.DisplayContentRepository import com.android.systemui.screenshot.data.repository.DisplayContentRepositoryImpl Loading Loading @@ -68,23 +65,18 @@ interface ScreenshotPolicyModule { @Application context: Context, @Background background: CoroutineDispatcher, imageCapture: ImageCapture, policyProvider: Provider<ScreenshotPolicy>, displayContentRepoProvider: Provider<DisplayContentRepository>, displayContentRepo: DisplayContentRepository, policyListProvider: Provider<List<CapturePolicy>>, ): ScreenshotRequestProcessor { return if (screenshotPrivateProfileBehaviorFix()) { PolicyRequestProcessor( return PolicyRequestProcessor( background = background, capture = imageCapture, displayTasks = displayContentRepoProvider.get(), displayTasks = displayContentRepo, policies = policyListProvider.get(), defaultOwner = Process.myUserHandle(), defaultComponent = ComponentName(context.packageName, SystemUIService::class.java.toString()) ) } else { RequestProcessor(imageCapture, policyProvider.get()) } } } }