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
This commit is contained in:
parent
46b4ebc7b6
commit
69093db7f5
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.session;
|
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.checkArgument;
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.media3.common.util.Assertions.checkState;
|
import static androidx.media3.common.util.Assertions.checkState;
|
||||||
@ -502,6 +503,24 @@ public class MediaSession {
|
|||||||
/* cb= */ null,
|
/* cb= */ null,
|
||||||
/* connectionHints= */ Bundle.EMPTY);
|
/* 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;
|
private final MediaSessionImpl impl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user