Skip to content

Commit 654a678

Browse files
toniheirohitjoins
authored andcommitted
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 694d690)
1 parent 3480a27 commit 654a678

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libraries/session/src/main/java/androidx/media3/session/ConnectionRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public Bundle toBundle() {
8989
int controllerInterfaceVersion =
9090
bundle.getInt(FIELD_CONTROLLER_INTERFACE_VERSION, /* defaultValue= */ 0);
9191
String packageName = checkNotNull(bundle.getString(FIELD_PACKAGE_NAME));
92-
int pid = bundle.getInt(FIELD_PID, /* defaultValue= */ 0);
93-
checkArgument(pid != 0);
92+
checkArgument(bundle.containsKey(FIELD_PID));
93+
int pid = bundle.getInt(FIELD_PID);
9494
@Nullable Bundle connectionHints = bundle.getBundle(FIELD_CONNECTION_HINTS);
9595
return new ConnectionRequest(
9696
libraryVersion,

0 commit comments

Comments
 (0)