Commit 694d690b by tonihei Committed by Marc Baechinger

Improve check for invalid connection request

The check currently relies on the default value of 0 returned if the
Bundle doesn't define a pid. But in some cases, like Robolectric unit tests,
0 is a possible pid. The check can be improved by directly asserting that
the value is defined.

PiperOrigin-RevId: 521414649
parent 0bfe4386
...@@ -89,8 +89,8 @@ import androidx.media3.common.util.Util; ...@@ -89,8 +89,8 @@ import androidx.media3.common.util.Util;
int controllerInterfaceVersion = int controllerInterfaceVersion =
bundle.getInt(FIELD_CONTROLLER_INTERFACE_VERSION, /* defaultValue= */ 0); bundle.getInt(FIELD_CONTROLLER_INTERFACE_VERSION, /* defaultValue= */ 0);
String packageName = checkNotNull(bundle.getString(FIELD_PACKAGE_NAME)); String packageName = checkNotNull(bundle.getString(FIELD_PACKAGE_NAME));
int pid = bundle.getInt(FIELD_PID, /* defaultValue= */ 0); checkArgument(bundle.containsKey(FIELD_PID));
checkArgument(pid != 0); int pid = bundle.getInt(FIELD_PID);
@Nullable Bundle connectionHints = bundle.getBundle(FIELD_CONNECTION_HINTS); @Nullable Bundle connectionHints = bundle.getBundle(FIELD_CONNECTION_HINTS);
return new ConnectionRequest( return new ConnectionRequest(
libraryVersion, libraryVersion,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment