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
(cherry picked from commit 694d690bc0)
This commit is contained in:
tonihei 2023-04-03 11:45:15 +01:00 committed by Rohit Singh
parent 3480a27994
commit 654a6786a6

View file

@ -89,8 +89,8 @@ import androidx.media3.common.util.Util;
int controllerInterfaceVersion =
bundle.getInt(FIELD_CONTROLLER_INTERFACE_VERSION, /* defaultValue= */ 0);
String packageName = checkNotNull(bundle.getString(FIELD_PACKAGE_NAME));
int pid = bundle.getInt(FIELD_PID, /* defaultValue= */ 0);
checkArgument(pid != 0);
checkArgument(bundle.containsKey(FIELD_PID));
int pid = bundle.getInt(FIELD_PID);
@Nullable Bundle connectionHints = bundle.getBundle(FIELD_CONNECTION_HINTS);
return new ConnectionRequest(
libraryVersion,