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

Commit 80887686 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Screenshot detection: MATCH_ANY_USER for resolving pacakage label" into main

parents dc381ae6 bd409916
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.screenshot

import android.content.pm.PackageManager
import android.content.pm.PackageManager.ComponentInfoFlags
import android.content.pm.PackageManager.MATCH_ANY_USER
import android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS
import android.view.Display
import android.view.IWindowManager
@@ -47,7 +48,8 @@ constructor(
        // Convert component names to app names.
        return components.map {
            packageManager
                .getActivityInfo(it, ComponentInfoFlags.of(MATCH_DISABLED_COMPONENTS.toLong()))
                .getActivityInfo(it, ComponentInfoFlags.of(
                    (MATCH_DISABLED_COMPONENTS or MATCH_ANY_USER).toLong()))
                .loadLabel(packageManager)
        }
    }
+6 −6
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.screenshot
import android.content.ComponentName
import android.content.pm.ActivityInfo
import android.content.pm.PackageManager
import android.content.pm.PackageManager.MATCH_ANY_USER
import android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS
import android.testing.AndroidTestingRunner
import android.view.Display
@@ -191,16 +192,16 @@ class ScreenshotDetectionControllerTest {
        whenever(
            packageManager.getActivityInfo(
                eq(component),
                argThat(includesFlagBits(MATCH_DISABLED_COMPONENTS))
                argThat(includesFlagBits(MATCH_DISABLED_COMPONENTS or MATCH_ANY_USER))
            )
        ).thenReturn(activityInfo);
        ).thenReturn(activityInfo)

        whenever(
            packageManager.getActivityInfo(
                eq(component),
                argThat(excludesFlagBits(MATCH_DISABLED_COMPONENTS))
            )
        ).thenThrow(PackageManager.NameNotFoundException::class.java);
        ).thenThrow(PackageManager.NameNotFoundException::class.java)

        whenever(windowManager.notifyScreenshotListeners(eq(Display.DEFAULT_DISPLAY)))
            .thenReturn(listOf(component))
@@ -212,5 +213,4 @@ class ScreenshotDetectionControllerTest {
        assertEquals(1, list.size)
        assertEquals(appName, list[0])
    }

}