mirror of
https://github.com/samsonjs/media.git
synced 2026-04-18 13:25:47 +00:00
Decomission ControllerInfoProxy in favor of ControllerInfo.
This CL makes it possible to create a media3 ControllerInfo in test code, which is needed to test several aspects of a media3-based media app. It does this by exposing a test-only static factory method. This is a hacky low-effort approach; a better solution could be to split ControllerInfo up into a public interface that was exposed to client logic, and that they could extend, and a package-private implementation with internal fields like the callback. That's a much bigger change, however.
PiperOrigin-RevId: 491978830
(cherry picked from commit 69093db7f5)
This commit is contained in:
parent
05f640ec7d
commit
93694b2283
1 changed files with 19 additions and 0 deletions
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package androidx.media3.session;
|
||||
|
||||
import static androidx.annotation.VisibleForTesting.PRIVATE;
|
||||
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||
import static androidx.media3.common.util.Assertions.checkState;
|
||||
|
|
@ -502,6 +503,24 @@ public class MediaSession {
|
|||
/* cb= */ null,
|
||||
/* connectionHints= */ Bundle.EMPTY);
|
||||
}
|
||||
|
||||
// TODO(b/259546357): Remove when ControllerInfo can be instantiated cleanly in tests.
|
||||
/** Returns a {@link ControllerInfo} suitable for use when testing client code. */
|
||||
@VisibleForTesting(otherwise = PRIVATE)
|
||||
public static ControllerInfo createTestOnlyControllerInfo(
|
||||
RemoteUserInfo remoteUserInfo,
|
||||
int libraryVersion,
|
||||
int interfaceVersion,
|
||||
boolean trusted,
|
||||
Bundle connectionHints) {
|
||||
return new MediaSession.ControllerInfo(
|
||||
remoteUserInfo,
|
||||
libraryVersion,
|
||||
interfaceVersion,
|
||||
trusted,
|
||||
/* cb= */ null,
|
||||
connectionHints);
|
||||
}
|
||||
}
|
||||
|
||||
private final MediaSessionImpl impl;
|
||||
|
|
|
|||
Loading…
Reference in a new issue