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

Commit cda995f6 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/28256067',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/28256067', 'googleplex-android-review.googlesource.com/28359703', 'googleplex-android-review.googlesource.com/28364794'] into 24Q3-release.

Change-Id: I8cf10009a67de919e3f0d5139ff5f9b9cba56c19
parents 90ccb6f1 87b2b90d
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ class DreamOverlayAnimationsControllerTest : SysuiTestCase() {
        verify(mockAnimator, atLeastOnce()).addListener(captor.capture())

        captor.allValues.forEach { it.onAnimationEnd(mockAnimator) }
        verify(stateController).setExitAnimationsRunning(false)
        verify(stateController, times(2)).setExitAnimationsRunning(false)
    }

    @Test
@@ -154,4 +154,10 @@ class DreamOverlayAnimationsControllerTest : SysuiTestCase() {
            }
        )
    }

    @Test
    fun testCancelAnimations_clearsExitAnimationsRunning() {
        controller.cancelAnimations()
        verify(stateController).setExitAnimationsRunning(false)
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -256,6 +256,7 @@ constructor(
                it.cancel()
                null
            }
        mOverlayStateController.setExitAnimationsRunning(false)
    }

    private fun blurAnimator(
+6 −3
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ class PolicyRequestProcessor(
                        original,
                        updates.component,
                        updates.owner,
                        type.displayId
                        type.displayId,
                    )
            }
        return updated
@@ -120,6 +120,7 @@ class PolicyRequestProcessor(
        return replaceWithScreenshot(
            original = original,
            componentName = topMainRootTask?.topActivity ?: defaultComponent,
            taskId = topMainRootTask?.taskId,
            owner = defaultOwner,
            displayId = original.displayId
        )
@@ -144,11 +145,12 @@ class PolicyRequestProcessor(
        )
    }

    suspend fun replaceWithScreenshot(
    private suspend fun replaceWithScreenshot(
        original: ScreenshotData,
        componentName: ComponentName?,
        owner: UserHandle?,
        displayId: Int,
        taskId: Int? = null,
    ): ScreenshotData {
        Log.i(TAG, "Capturing screenshot: $componentName / $owner")
        val screenshot = captureDisplay(displayId)
@@ -157,7 +159,8 @@ class PolicyRequestProcessor(
            bitmap = screenshot,
            userHandle = owner,
            topComponent = componentName,
            screenBounds = Rect(0, 0, screenshot?.width ?: 0, screenshot?.height ?: 0)
            screenBounds = Rect(0, 0, screenshot?.width ?: 0, screenshot?.height ?: 0),
            taskId = taskId ?: -1,
        )
    }

+28 −14
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.UserHandle
import android.view.Display.DEFAULT_DISPLAY
import android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_CHORD
import android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.systemui.screenshot.ImageCapture
import com.android.systemui.screenshot.ScreenshotData
import com.android.systemui.screenshot.data.model.DisplayContentScenarios.ActivityNames.FILES
@@ -37,8 +38,10 @@ import org.junit.Test

class PolicyRequestProcessorTest {

    val imageCapture = object : ImageCapture {
    val imageCapture =
        object : ImageCapture {
            override fun captureDisplay(displayId: Int, crop: Rect?) = null

            override suspend fun captureTask(taskId: Int) = null
        }

@@ -46,11 +49,12 @@ class PolicyRequestProcessorTest {
    @Test
    fun testProcess_defaultOwner_whenNoPolicyApplied() {
        val fullScreenWork = DisplayContentRepository {
            singleFullScreen(TaskSpec(taskId = 1001, name = FILES, userId = WORK))
            singleFullScreen(TaskSpec(taskId = TASK_ID, name = FILES, userId = WORK))
        }

        val request =
            ScreenshotData(TAKE_SCREENSHOT_FULLSCREEN,
            ScreenshotData(
                TAKE_SCREENSHOT_FULLSCREEN,
                SCREENSHOT_KEY_CHORD,
                null,
                topComponent = null,
@@ -58,24 +62,34 @@ class PolicyRequestProcessorTest {
                taskId = -1,
                insets = Insets.NONE,
                bitmap = null,
                displayId = DEFAULT_DISPLAY)
                displayId = DEFAULT_DISPLAY
            )

        /* Create a policy request processor with no capture policies */
        val requestProcessor =
            PolicyRequestProcessor(Dispatchers.Unconfined,
            PolicyRequestProcessor(
                Dispatchers.Unconfined,
                imageCapture,
                policies = emptyList(),
                defaultOwner = UserHandle.of(PERSONAL),
                defaultComponent = ComponentName("default", "Component"),
                displayTasks = fullScreenWork)
                displayTasks = fullScreenWork
            )

        val result = runBlocking { requestProcessor.process(request) }

        assertWithMessage(
            "With no policy, the screenshot should be assigned to the default user"
        ).that(result.userHandle).isEqualTo(UserHandle.of(PERSONAL))
        assertWithMessage("With no policy, the screenshot should be assigned to the default user")
            .that(result.userHandle)
            .isEqualTo(UserHandle.of(PERSONAL))

        assertWithMessage("The topComponent of the screenshot").that(result.topComponent)
        assertWithMessage("The topComponent of the screenshot")
            .that(result.topComponent)
            .isEqualTo(ComponentName.unflattenFromString(FILES))

        assertWithMessage("Task ID").that(result.taskId).isEqualTo(TASK_ID)
    }

    companion object {
        const val TASK_ID = 1001
    }
}
 No newline at end of file
+1 −2
Original line number Diff line number Diff line
@@ -47,9 +47,8 @@ inline fun AtomicFile.readWithReserveCopy(block: (FileInputStream) -> Unit) {
/** Write to actual file and reserve file. */
@Throws(IOException::class)
inline fun AtomicFile.writeWithReserveCopy(block: (FileOutputStream) -> Unit) {
    val reserveFile = File(baseFile.parentFile, baseFile.name + ".reservecopy")
    reserveFile.delete()
    writeInlined(block)
    val reserveFile = File(baseFile.parentFile, baseFile.name + ".reservecopy")
    try {
        FileInputStream(baseFile).use { inputStream ->
            FileOutputStream(reserveFile).use { outputStream ->