summaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
author Vadim Caen <caen@google.com> 2025-02-26 16:49:12 +0100
committer Vadim Caen <caen@google.com> 2025-03-21 16:13:33 +0100
commit73b1415205ea371cc943528e12b5ba3ce3573e14 (patch)
tree35acdc992ad1ccd92db2faed5eb960bf9a93c40e /media
parent34f9f07edf00f62d54803c60a5c30af678e33195 (diff)
Builder pattern for MediaProjectionConfig
Introduce a builder pattern for MediaProjectionConfig, allowing more flexibility for the type of configuration need by the requesting application, in preparation for the content sharing option in a follow-up CL. Also adding some documentation fix and moving readding the CTS in presubmit. Test: atest CtsMediaProjectionTestCases:MediaProjectionConfigTest Flag: com.android.media.projection.flags.app_content_sharing Bug: 398757866 Change-Id: I0e048c47605fe06bf49e032f387d4009750e5f02
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/projection/MediaProjectionConfig.java346
-rw-r--r--media/java/android/media/projection/MediaProjectionManager.java10
-rw-r--r--media/java/android/media/projection/TEST_MAPPING2
-rw-r--r--media/tests/projection/Android.bp1
-rw-r--r--media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java32
5 files changed, 361 insertions, 30 deletions
diff --git a/media/java/android/media/projection/MediaProjectionConfig.java b/media/java/android/media/projection/MediaProjectionConfig.java
index 598b534e81ca..1b63c795bf90 100644
--- a/media/java/android/media/projection/MediaProjectionConfig.java
+++ b/media/java/android/media/projection/MediaProjectionConfig.java
@@ -20,23 +20,49 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static java.lang.annotation.RetentionPolicy.SOURCE;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.os.Parcelable;
-import com.android.internal.util.AnnotationValidations;
+import com.android.media.projection.flags.Flags;
import java.lang.annotation.Retention;
+import java.util.Arrays;
+import java.util.Objects;
/**
* Configure the {@link MediaProjection} session requested from
* {@link MediaProjectionManager#createScreenCaptureIntent(MediaProjectionConfig)}.
+ * <p>
+ * This configuration should be used to provide the user with options for choosing the content to
+ * be shared with the requesting application.
*/
public final class MediaProjectionConfig implements Parcelable {
/**
+ * Bitmask for setting whether this configuration is for projecting the whole display.
+ */
+ @FlaggedApi(Flags.FLAG_APP_CONTENT_SHARING)
+ public static final int PROJECTION_SOURCE_DISPLAY = 1 << 1;
+
+ /**
+ * Bitmask for setting whether this configuration is for projecting the a custom region display.
+ *
+ * @hide
+ */
+ public static final int PROJECTION_SOURCE_DISPLAY_REGION = 1 << 2;
+
+ /**
+ * Bitmask for setting whether this configuration is for projecting the a single application.
+ */
+ @FlaggedApi(Flags.FLAG_APP_CONTENT_SHARING)
+ public static final int PROJECTION_SOURCE_APP = 1 << 3;
+
+ /**
* The user, rather than the host app, determines which region of the display to capture.
*
* @hide
@@ -44,39 +70,108 @@ public final class MediaProjectionConfig implements Parcelable {
public static final int CAPTURE_REGION_USER_CHOICE = 0;
/**
+ * @hide
+ */
+ public static final int DEFAULT_PROJECTION_SOURCES =
+ PROJECTION_SOURCE_DISPLAY | PROJECTION_SOURCE_APP;
+
+ /**
* The host app specifies a particular display to capture.
*
* @hide
*/
public static final int CAPTURE_REGION_FIXED_DISPLAY = 1;
+ private static final int[] PROJECTION_SOURCES =
+ new int[]{PROJECTION_SOURCE_DISPLAY, PROJECTION_SOURCE_DISPLAY_REGION,
+ PROJECTION_SOURCE_APP};
+
+ private static final String[] PROJECTION_SOURCES_STRING =
+ new String[]{"PROJECTION_SOURCE_DISPLAY", "PROJECTION_SOURCE_DISPLAY_REGION",
+ "PROJECTION_SOURCE_APP"};
+
+ private static final int VALID_PROJECTION_SOURCES = createValidSourcesMask();
+
+ private final int mInitialSelection;
+
/** @hide */
@IntDef(prefix = "CAPTURE_REGION_", value = {CAPTURE_REGION_USER_CHOICE,
CAPTURE_REGION_FIXED_DISPLAY})
@Retention(SOURCE)
+ @Deprecated // Remove when FLAG_APP_CONTENT_SHARING is removed
public @interface CaptureRegion {
}
+ /** @hide */
+ @IntDef(flag = true, prefix = "PROJECTION_SOURCE_", value = {PROJECTION_SOURCE_DISPLAY,
+ PROJECTION_SOURCE_DISPLAY_REGION, PROJECTION_SOURCE_APP})
+ @Retention(SOURCE)
+ public @interface MediaProjectionSource {
+ }
+
/**
- * The particular display to capture. Only used when {@link #getRegionToCapture()} is
- * {@link #CAPTURE_REGION_FIXED_DISPLAY}; ignored otherwise.
+ * The particular display to capture. Only used when {@link #PROJECTION_SOURCE_DISPLAY} is set,
+ * ignored otherwise.
* <p>
* Only supports values of {@link android.view.Display#DEFAULT_DISPLAY}.
*/
@IntRange(from = DEFAULT_DISPLAY, to = DEFAULT_DISPLAY)
- private int mDisplayToCapture;
+ private final int mDisplayToCapture;
/**
* The region to capture. Defaults to the user's choice.
*/
@CaptureRegion
+ @Deprecated // Remove when FLAG_APP_CONTENT_SHARING is removed
private int mRegionToCapture;
/**
+ * The region to capture. Defaults to the user's choice.
+ */
+ @MediaProjectionSource
+ private final int mProjectionSources;
+
+ /**
+ * @see #getRequesterHint()
+ */
+ @Nullable
+ private final String mRequesterHint;
+
+ /**
* Customized instance, with region set to the provided value.
+ * @deprecated To be removed FLAG_APP_CONTENT_SHARING is removed
*/
+ @Deprecated // Remove when FLAG_APP_CONTENT_SHARING is removed
private MediaProjectionConfig(@CaptureRegion int captureRegion) {
+ if (Flags.appContentSharing()) {
+ throw new UnsupportedOperationException(
+ "Flag FLAG_APP_CONTENT_SHARING enabled. This method must not be called.");
+ }
mRegionToCapture = captureRegion;
+ mDisplayToCapture = DEFAULT_DISPLAY;
+
+ mRequesterHint = null;
+ mInitialSelection = -1;
+ mProjectionSources = -1;
+ }
+
+ /**
+ * Customized instance, with region set to the provided value.
+ */
+ private MediaProjectionConfig(@MediaProjectionSource int projectionSource,
+ @Nullable String requesterHint, int displayId, int initialSelection) {
+ if (!Flags.appContentSharing()) {
+ throw new UnsupportedOperationException(
+ "Flag FLAG_APP_CONTENT_SHARING disabled. This method must not be called");
+ }
+ if (projectionSource == 0) {
+ mProjectionSources = DEFAULT_PROJECTION_SOURCES;
+ } else {
+ mProjectionSources = projectionSource;
+ }
+ mRequesterHint = requesterHint;
+ mDisplayToCapture = displayId;
+ mInitialSelection = initialSelection;
}
/**
@@ -84,16 +179,17 @@ public final class MediaProjectionConfig implements Parcelable {
*/
@NonNull
public static MediaProjectionConfig createConfigForDefaultDisplay() {
- MediaProjectionConfig config = new MediaProjectionConfig(CAPTURE_REGION_FIXED_DISPLAY);
- config.mDisplayToCapture = DEFAULT_DISPLAY;
- return config;
+ if (Flags.appContentSharing()) {
+ return new Builder().setSourceEnabled(PROJECTION_SOURCE_DISPLAY, true).build();
+ } else {
+ return new MediaProjectionConfig(CAPTURE_REGION_FIXED_DISPLAY);
+ }
}
/**
* Returns an instance which allows the user to decide which region is captured. The consent
* dialog presents the user with all possible options. If the user selects display capture,
* then only the {@link android.view.Display#DEFAULT_DISPLAY} is supported.
- *
* <p>
* When passed in to
* {@link MediaProjectionManager#createScreenCaptureIntent(MediaProjectionConfig)}, the consent
@@ -103,13 +199,18 @@ public final class MediaProjectionConfig implements Parcelable {
*/
@NonNull
public static MediaProjectionConfig createConfigForUserChoice() {
- return new MediaProjectionConfig(CAPTURE_REGION_USER_CHOICE);
+ if (Flags.appContentSharing()) {
+ return new MediaProjectionConfig.Builder().build();
+ } else {
+ return new MediaProjectionConfig(CAPTURE_REGION_USER_CHOICE);
+ }
}
/**
* Returns string representation of the captured region.
*/
@NonNull
+ @Deprecated // Remove when FLAG_APP_CONTENT_SHARING is removed
private static String captureRegionToString(int value) {
return switch (value) {
case CAPTURE_REGION_USER_CHOICE -> "CAPTURE_REGION_USERS_CHOICE";
@@ -118,16 +219,42 @@ public final class MediaProjectionConfig implements Parcelable {
};
}
+ /**
+ * Returns string representation of the captured region.
+ */
+ @NonNull
+ private static String projectionSourceToString(int value) {
+ StringBuilder stringBuilder = new StringBuilder();
+ for (int i = 0; i < PROJECTION_SOURCES.length; i++) {
+ if ((value & PROJECTION_SOURCES[i]) > 0) {
+ stringBuilder.append(PROJECTION_SOURCES_STRING[i]);
+ stringBuilder.append(" ");
+ value &= ~PROJECTION_SOURCES[i];
+ }
+ }
+ if (value > 0) {
+ stringBuilder.append("Unknown projection sources: ");
+ stringBuilder.append(Integer.toHexString(value));
+ }
+ return stringBuilder.toString();
+ }
+
@Override
public String toString() {
- return "MediaProjectionConfig { " + "displayToCapture = " + mDisplayToCapture + ", "
- + "regionToCapture = " + captureRegionToString(mRegionToCapture) + " }";
+ if (Flags.appContentSharing()) {
+ return ("MediaProjectionConfig{mInitialSelection=%d, mDisplayToCapture=%d, "
+ + "mProjectionSource=%s, mRequesterHint='%s'}").formatted(mInitialSelection,
+ mDisplayToCapture, projectionSourceToString(mProjectionSources),
+ mRequesterHint);
+ } else {
+ return "MediaProjectionConfig { " + "displayToCapture = " + mDisplayToCapture + ", "
+ + "regionToCapture = " + captureRegionToString(mRegionToCapture) + " }";
+ }
}
-
/**
- * The particular display to capture. Only used when {@link #getRegionToCapture()} is
- * {@link #CAPTURE_REGION_FIXED_DISPLAY}; ignored otherwise.
+ * The particular display to capture. Only used when {@link #PROJECTION_SOURCE_DISPLAY} is
+ * set; ignored otherwise.
* <p>
* Only supports values of {@link android.view.Display#DEFAULT_DISPLAY}.
*
@@ -146,27 +273,57 @@ public final class MediaProjectionConfig implements Parcelable {
return mRegionToCapture;
}
+ /**
+ * A bitmask representing of requested projection sources.
+ * <p>
+ * The system supports different kind of media projection session. Although the user is
+ * picking the target content, the requesting application can configure the choices displayed
+ * to the user.
+ */
+ @FlaggedApi(Flags.FLAG_APP_CONTENT_SHARING)
+ public @MediaProjectionSource int getProjectionSources() {
+ return mProjectionSources;
+ }
+
@Override
public boolean equals(@Nullable Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MediaProjectionConfig that = (MediaProjectionConfig) o;
- return mDisplayToCapture == that.mDisplayToCapture
- && mRegionToCapture == that.mRegionToCapture;
+ if (Flags.appContentSharing()) {
+ return mDisplayToCapture == that.mDisplayToCapture
+ && mProjectionSources == that.mProjectionSources
+ && mInitialSelection == that.mInitialSelection
+ && Objects.equals(mRequesterHint, that.mRequesterHint);
+ } else {
+ return mDisplayToCapture == that.mDisplayToCapture
+ && mRegionToCapture == that.mRegionToCapture;
+ }
}
@Override
public int hashCode() {
int _hash = 1;
- _hash = 31 * _hash + mDisplayToCapture;
- _hash = 31 * _hash + mRegionToCapture;
+ if (Flags.appContentSharing()) {
+ return Objects.hash(mDisplayToCapture, mProjectionSources, mInitialSelection,
+ mRequesterHint);
+ } else {
+ _hash = 31 * _hash + mDisplayToCapture;
+ _hash = 31 * _hash + mRegionToCapture;
+ }
return _hash;
}
@Override
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
dest.writeInt(mDisplayToCapture);
- dest.writeInt(mRegionToCapture);
+ if (Flags.appContentSharing()) {
+ dest.writeInt(mProjectionSources);
+ dest.writeString(mRequesterHint);
+ dest.writeInt(mInitialSelection);
+ } else {
+ dest.writeInt(mRegionToCapture);
+ }
}
@Override
@@ -176,12 +333,17 @@ public final class MediaProjectionConfig implements Parcelable {
/** @hide */
/* package-private */ MediaProjectionConfig(@NonNull android.os.Parcel in) {
- int displayToCapture = in.readInt();
- int regionToCapture = in.readInt();
-
- mDisplayToCapture = displayToCapture;
- mRegionToCapture = regionToCapture;
- AnnotationValidations.validate(CaptureRegion.class, null, mRegionToCapture);
+ mDisplayToCapture = in.readInt();
+ if (Flags.appContentSharing()) {
+ mProjectionSources = in.readInt();
+ mRequesterHint = in.readString();
+ mInitialSelection = in.readInt();
+ } else {
+ mRegionToCapture = in.readInt();
+ mProjectionSources = -1;
+ mRequesterHint = null;
+ mInitialSelection = -1;
+ }
}
public static final @NonNull Parcelable.Creator<MediaProjectionConfig> CREATOR =
@@ -196,4 +358,138 @@ public final class MediaProjectionConfig implements Parcelable {
return new MediaProjectionConfig(in);
}
};
+
+ /**
+ * Returns true if the provided source should be enabled.
+ *
+ * @param projectionSource projection source integer to check for. The parameter can also be a
+ * bitmask of multiple sources.
+ */
+ @FlaggedApi(Flags.FLAG_APP_CONTENT_SHARING)
+ public boolean isSourceEnabled(@MediaProjectionSource int projectionSource) {
+ return (mProjectionSources & projectionSource) > 0;
+ }
+
+ /**
+ * Returns a bit mask of one, and only one, of the projection type flag.
+ */
+ @FlaggedApi(Flags.FLAG_APP_CONTENT_SHARING)
+ @MediaProjectionSource
+ public int getInitiallySelectedSource() {
+ return mInitialSelection;
+ }
+
+ /**
+ * A hint set by the requesting app indicating who the requester of this {@link MediaProjection}
+ * session is.
+ * <p>
+ * The UI component prompting the user for the permission to start the session can use
+ * this hint to provide more information about the origin of the request (e.g. a browser
+ * tab title, a meeting id if sharing to a video conferencing app, a player name if
+ * sharing the screen within a game).
+ *
+ * @return the hint to be displayed if set, null otherwise.
+ */
+ @FlaggedApi(Flags.FLAG_APP_CONTENT_SHARING)
+ @Nullable
+ public CharSequence getRequesterHint() {
+ return mRequesterHint;
+ }
+
+ private static int createValidSourcesMask() {
+ int validSources = 0;
+ for (int projectionSource : PROJECTION_SOURCES) {
+ validSources |= projectionSource;
+ }
+ return validSources;
+ }
+
+ @FlaggedApi(Flags.FLAG_APP_CONTENT_SHARING)
+ public static final class Builder {
+ private int mOptions = 0;
+ private String mRequesterHint = null;
+
+ @MediaProjectionSource
+ private int mInitialSelection;
+
+ public Builder() {
+ if (!Flags.appContentSharing()) {
+ throw new UnsupportedOperationException("Flag FLAG_APP_CONTENT_SHARING disabled");
+ }
+ }
+
+ /**
+ * Indicates which projection source the UI component should display to the user
+ * first. Calling this method without enabling the respective choice will have no effect.
+ *
+ * @return instance of this {@link Builder}.
+ * @see #setSourceEnabled(int, boolean)
+ */
+ @NonNull
+ public Builder setInitiallySelectedSource(@MediaProjectionSource int projectionSource) {
+ for (int source : PROJECTION_SOURCES) {
+ if (projectionSource == source) {
+ mInitialSelection = projectionSource;
+ return this;
+ }
+ }
+ throw new IllegalArgumentException(
+ ("projectionSource is no a valid projection source. projectionSource must be "
+ + "one of %s but was %s")
+ .formatted(Arrays.toString(PROJECTION_SOURCES_STRING),
+ projectionSourceToString(projectionSource)));
+ }
+
+ /**
+ * Let the requesting app indicate who the requester of this {@link MediaProjection}
+ * session is..
+ * <p>
+ * The UI component prompting the user for the permission to start the session can use
+ * this hint to provide more information about the origin of the request (e.g. a browser
+ * tab title, a meeting id if sharing to a video conferencing app, a player name if
+ * sharing the screen within a game).
+ * <p>
+ * Note that setting this won't hide or change the name of the application
+ * requesting the session.
+ *
+ * @return instance of this {@link Builder}.
+ */
+ @NonNull
+ public Builder setRequesterHint(@Nullable String requesterHint) {
+ mRequesterHint = requesterHint;
+ return this;
+ }
+
+ /**
+ * Set whether the UI component requesting the user permission to share their screen
+ * should display an option to share the specified source
+ *
+ * @param source the projection source to enable or disable
+ * @param enabled true to enable the source, false otherwise
+ * @return this instance for chaining.
+ * @throws IllegalArgumentException if the source is not one of the valid sources.
+ */
+ @NonNull
+ @SuppressLint("MissingGetterMatchingBuilder") // isSourceEnabled is defined
+ public Builder setSourceEnabled(@MediaProjectionSource int source, boolean enabled) {
+ if ((source & VALID_PROJECTION_SOURCES) == 0) {
+ throw new IllegalArgumentException(
+ ("source is no a valid projection source. source must be "
+ + "any of %s but was %s")
+ .formatted(Arrays.toString(PROJECTION_SOURCES_STRING),
+ projectionSourceToString(source)));
+ }
+ mOptions = enabled ? mOptions | source : mOptions & ~source;
+ return this;
+ }
+
+ /**
+ * Builds a new immutable instance of {@link MediaProjectionConfig}
+ */
+ @NonNull
+ public MediaProjectionConfig build() {
+ return new MediaProjectionConfig(mOptions, mRequesterHint, DEFAULT_DISPLAY,
+ mInitialSelection);
+ }
+ }
}
diff --git a/media/java/android/media/projection/MediaProjectionManager.java b/media/java/android/media/projection/MediaProjectionManager.java
index 9036bf385d96..4a5392d3c0c3 100644
--- a/media/java/android/media/projection/MediaProjectionManager.java
+++ b/media/java/android/media/projection/MediaProjectionManager.java
@@ -29,6 +29,7 @@ import android.compat.annotation.Overridable;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.hardware.display.VirtualDisplay;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
@@ -78,9 +79,12 @@ public final class MediaProjectionManager {
private static final String TAG = "MediaProjectionManager";
/**
- * This change id ensures that users are presented with a choice of capturing a single app
- * or the entire screen when initiating a MediaProjection session, overriding the usage of
- * MediaProjectionConfig#createConfigForDefaultDisplay.
+ * If enabled, this change id ensures that users are presented with a choice of capturing a
+ * single app and the entire screen when initiating a MediaProjection session, overriding the
+ * usage of MediaProjectionConfig#createConfigForDefaultDisplay.
+ * <p>
+ *
+ * <a href=" https://developer.android.com/guide/practices/device-compatibility-mode#override_disable_media_projection_single_app_option">More info</a>
*
* @hide
*/
diff --git a/media/java/android/media/projection/TEST_MAPPING b/media/java/android/media/projection/TEST_MAPPING
index ea62287b7411..62e776b822d2 100644
--- a/media/java/android/media/projection/TEST_MAPPING
+++ b/media/java/android/media/projection/TEST_MAPPING
@@ -4,4 +4,4 @@
"path": "frameworks/base/services/core/java/com/android/server/media/projection"
}
]
-} \ No newline at end of file
+}
diff --git a/media/tests/projection/Android.bp b/media/tests/projection/Android.bp
index 48621e4e2094..37726898824b 100644
--- a/media/tests/projection/Android.bp
+++ b/media/tests/projection/Android.bp
@@ -26,6 +26,7 @@ android_test {
"androidx.test.runner",
"androidx.test.rules",
"androidx.test.ext.junit",
+ "flag-junit",
"frameworks-base-testutils",
"mockito-target-extended-minus-junit4",
"platform-test-annotations",
diff --git a/media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java b/media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java
index 2820606958b7..bc0eae1a3ec7 100644
--- a/media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java
+++ b/media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java
@@ -18,22 +18,31 @@ package android.media.projection;
import static android.media.projection.MediaProjectionConfig.CAPTURE_REGION_FIXED_DISPLAY;
import static android.media.projection.MediaProjectionConfig.CAPTURE_REGION_USER_CHOICE;
+import static android.media.projection.MediaProjectionConfig.PROJECTION_SOURCE_DISPLAY;
+import static android.media.projection.MediaProjectionConfig.DEFAULT_PROJECTION_SOURCES;
import static android.view.Display.DEFAULT_DISPLAY;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
import android.platform.test.annotations.Presubmit;
+import android.platform.test.annotations.RequiresFlagsDisabled;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
+import com.android.media.projection.flags.Flags;
+
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests for the {@link MediaProjectionConfig} class.
- *
+ * <p>
* Build/Install/Run:
* atest MediaProjectionTests:MediaProjectionConfigTest
*/
@@ -41,6 +50,11 @@ import org.junit.runner.RunWith;
@Presubmit
@RunWith(AndroidJUnit4.class)
public class MediaProjectionConfigTest {
+
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule =
+ DeviceFlagsValueProvider.createCheckFlagsRule();
+
private static final MediaProjectionConfig DISPLAY_CONFIG =
MediaProjectionConfig.createConfigForDefaultDisplay();
private static final MediaProjectionConfig USERS_CHOICE_CONFIG =
@@ -57,17 +71,33 @@ public class MediaProjectionConfigTest {
}
@Test
+ @RequiresFlagsDisabled(Flags.FLAG_APP_CONTENT_SHARING)
public void testCreateDisplayConfig() {
assertThat(DISPLAY_CONFIG.getRegionToCapture()).isEqualTo(CAPTURE_REGION_FIXED_DISPLAY);
assertThat(DISPLAY_CONFIG.getDisplayToCapture()).isEqualTo(DEFAULT_DISPLAY);
}
@Test
+ @RequiresFlagsDisabled(Flags.FLAG_APP_CONTENT_SHARING)
public void testCreateUsersChoiceConfig() {
assertThat(USERS_CHOICE_CONFIG.getRegionToCapture()).isEqualTo(CAPTURE_REGION_USER_CHOICE);
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_APP_CONTENT_SHARING)
+ public void testDefaultProjectionSources() {
+ assertThat(USERS_CHOICE_CONFIG.getProjectionSources())
+ .isEqualTo(DEFAULT_PROJECTION_SOURCES);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_APP_CONTENT_SHARING)
+ public void testCreateDisplayConfigProjectionSource() {
+ assertThat(DISPLAY_CONFIG.getProjectionSources()).isEqualTo(PROJECTION_SOURCE_DISPLAY);
+ assertThat(DISPLAY_CONFIG.getDisplayToCapture()).isEqualTo(DEFAULT_DISPLAY);
+ }
+
+ @Test
public void testEquals() {
assertThat(MediaProjectionConfig.createConfigForUserChoice()).isEqualTo(
USERS_CHOICE_CONFIG);