Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f8de54e4
authored
Jan 21, 2022
by
olly
Committed by
Ian Baker
Jan 25, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Replace use of AssertionError in non-test code
PiperOrigin-RevId: 423324890
parent
bfd227d3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
29 deletions
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplBase.java
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplLegacy.java
libraries/session/src/main/java/androidx/media3/session/MediaLibrarySessionImpl.java
libraries/session/src/main/java/androidx/media3/session/MediaUtils.java
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplBase.java
View file @
f8de54e4
...
@@ -2211,8 +2211,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -2211,8 +2211,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
try
{
try
{
MediaUtils
.
getFutureResult
(
future
,
/* timeoutMs= */
3_000
);
MediaUtils
.
getFutureResult
(
future
,
/* timeoutMs= */
3_000
);
}
catch
(
ExecutionException
e
)
{
}
catch
(
ExecutionException
e
)
{
//
It never happens because future.setException will not be called anywhere
//
Never happens because future.setException will not be called.
throw
new
AssertionError
(
e
);
throw
new
IllegalStateException
(
e
);
}
catch
(
TimeoutException
e
)
{
}
catch
(
TimeoutException
e
)
{
Log
.
w
(
TAG
,
"set/clearVideoSurface takes too long on the session side."
,
e
);
Log
.
w
(
TAG
,
"set/clearVideoSurface takes too long on the session side."
,
e
);
// TODO(b/188888693): Let developers know the failure in their code.
// TODO(b/188888693): Let developers know the failure in their code.
...
@@ -2247,10 +2247,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -2247,10 +2247,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
/** Returns session interface if the controller can send the predefined command. */
/** Returns session interface if the controller can send the predefined command. */
@Nullable
@Nullable
IMediaSession
getSessionInterfaceWithSessionCommandIfAble
(
@CommandCode
int
commandCode
)
{
IMediaSession
getSessionInterfaceWithSessionCommandIfAble
(
@CommandCode
int
commandCode
)
{
if
(
commandCode
==
COMMAND_CODE_CUSTOM
)
{
checkArgument
(
commandCode
!=
COMMAND_CODE_CUSTOM
);
throw
new
AssertionError
(
"Use getSessionInterfaceWithSessionCommandIfAble(SessionCommand) for custom commands"
);
}
if
(!
sessionCommands
.
contains
(
commandCode
))
{
if
(!
sessionCommands
.
contains
(
commandCode
))
{
Log
.
w
(
TAG
,
"Controller isn't allowed to call command, commandCode="
+
commandCode
);
Log
.
w
(
TAG
,
"Controller isn't allowed to call command, commandCode="
+
commandCode
);
return
null
;
return
null
;
...
@@ -2261,10 +2258,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -2261,10 +2258,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
/** Returns session interface if the controller can send the custom command. */
/** Returns session interface if the controller can send the custom command. */
@Nullable
@Nullable
IMediaSession
getSessionInterfaceWithSessionCommandIfAble
(
SessionCommand
command
)
{
IMediaSession
getSessionInterfaceWithSessionCommandIfAble
(
SessionCommand
command
)
{
if
(
command
.
commandCode
!=
COMMAND_CODE_CUSTOM
)
{
checkArgument
(
command
.
commandCode
==
COMMAND_CODE_CUSTOM
);
throw
new
AssertionError
(
"Use getSessionInterfaceWithSessionCommandIfAble(int) for predefined commands"
);
}
if
(!
sessionCommands
.
contains
(
command
))
{
if
(!
sessionCommands
.
contains
(
command
))
{
Log
.
w
(
TAG
,
"Controller isn't allowed to call session command:"
+
command
);
Log
.
w
(
TAG
,
"Controller isn't allowed to call session command:"
+
command
);
return
null
;
return
null
;
...
...
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplLegacy.java
View file @
f8de54e4
...
@@ -280,7 +280,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -280,7 +280,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
Uri
.
parse
(
pendingSetMediaUriRequest
.
value
),
pendingSetMediaUriRequest
.
extras
);
Uri
.
parse
(
pendingSetMediaUriRequest
.
value
),
pendingSetMediaUriRequest
.
extras
);
break
;
break
;
default
:
default
:
throw
new
AssertionError
(
"Unexpected type "
+
pendingSetMediaUriRequest
.
type
);
throw
new
IllegalStateException
(
"Unexpected type "
+
pendingSetMediaUriRequest
.
type
);
}
}
pendingSetMediaUriRequest
.
result
.
set
(
new
SessionResult
(
RESULT_SUCCESS
));
pendingSetMediaUriRequest
.
result
.
set
(
new
SessionResult
(
RESULT_SUCCESS
));
pendingSetMediaUriRequest
=
null
;
pendingSetMediaUriRequest
=
null
;
...
@@ -345,7 +345,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -345,7 +345,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
Uri
.
parse
(
pendingSetMediaUriRequest
.
value
),
pendingSetMediaUriRequest
.
extras
);
Uri
.
parse
(
pendingSetMediaUriRequest
.
value
),
pendingSetMediaUriRequest
.
extras
);
break
;
break
;
default
:
default
:
throw
new
AssertionError
(
"Unexpected type "
+
pendingSetMediaUriRequest
.
type
);
throw
new
IllegalStateException
(
"Unexpected type "
+
pendingSetMediaUriRequest
.
type
);
}
}
pendingSetMediaUriRequest
.
result
.
set
(
new
SessionResult
(
RESULT_SUCCESS
));
pendingSetMediaUriRequest
.
result
.
set
(
new
SessionResult
(
RESULT_SUCCESS
));
pendingSetMediaUriRequest
=
null
;
pendingSetMediaUriRequest
=
null
;
...
...
libraries/session/src/main/java/androidx/media3/session/MediaLibrarySessionImpl.java
View file @
f8de54e4
...
@@ -292,12 +292,7 @@ import java.util.concurrent.Future;
...
@@ -292,12 +292,7 @@ import java.util.concurrent.Future;
if
(
result
.
resultCode
==
RESULT_SUCCESS
)
{
if
(
result
.
resultCode
==
RESULT_SUCCESS
)
{
List
<
MediaItem
>
items
=
checkNotNull
(
result
.
value
);
List
<
MediaItem
>
items
=
checkNotNull
(
result
.
value
);
if
(
items
.
size
()
>
pageSize
)
{
if
(
items
.
size
()
>
pageSize
)
{
throw
new
AssertionError
(
throw
new
IllegalStateException
(
"Invalid size="
+
items
.
size
()
+
", pageSize="
+
pageSize
);
"The number of items must be less than or equal to the pageSize"
+
", size="
+
items
.
size
()
+
", pageSize="
+
pageSize
);
}
}
}
}
}
}
...
...
libraries/session/src/main/java/androidx/media3/session/MediaUtils.java
View file @
f8de54e4
...
@@ -646,7 +646,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -646,7 +646,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
return
MediaDescriptionCompat
.
BT_FOLDER_TYPE_YEARS
;
return
MediaDescriptionCompat
.
BT_FOLDER_TYPE_YEARS
;
case
MediaMetadata
.
FOLDER_TYPE_NONE
:
case
MediaMetadata
.
FOLDER_TYPE_NONE
:
default
:
default
:
throw
new
AssertionError
(
"Unsupported folder type
"
+
folderType
);
throw
new
IllegalArgumentException
(
"Unrecognized FolderType:
"
+
folderType
);
}
}
}
}
...
@@ -743,15 +743,14 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -743,15 +743,14 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
case
Player
.
STATE_IDLE
:
case
Player
.
STATE_IDLE
:
return
PlaybackStateCompat
.
STATE_NONE
;
return
PlaybackStateCompat
.
STATE_NONE
;
case
Player
.
STATE_READY
:
case
Player
.
STATE_READY
:
case
Player
.
STATE_ENDED
:
return
PlaybackStateCompat
.
STATE_PAUSED
;
return
PlaybackStateCompat
.
STATE_PAUSED
;
case
Player
.
STATE_BUFFERING
:
case
Player
.
STATE_BUFFERING
:
return
playWhenReady
return
playWhenReady
?
PlaybackStateCompat
.
STATE_BUFFERING
?
PlaybackStateCompat
.
STATE_BUFFERING
:
PlaybackStateCompat
.
STATE_PAUSED
;
:
PlaybackStateCompat
.
STATE_PAUSED
;
case
Player
.
STATE_ENDED
:
return
PlaybackStateCompat
.
STATE_PAUSED
;
default
:
default
:
throw
new
AssertionError
(
"Playback state shouldn't be
"
+
playbackState
);
throw
new
IllegalArgumentException
(
"Unrecognized State:
"
+
playbackState
);
}
}
}
}
...
@@ -820,8 +819,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -820,8 +819,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
convertToCurrentPositionMs
(
playbackStateCompat
,
currentMediaMetadata
,
timeDiffMs
);
convertToCurrentPositionMs
(
playbackStateCompat
,
currentMediaMetadata
,
timeDiffMs
);
return
(
currentPosition
<
duration
)
?
Player
.
STATE_READY
:
Player
.
STATE_ENDED
;
return
(
currentPosition
<
duration
)
?
Player
.
STATE_READY
:
Player
.
STATE_ENDED
;
default
:
default
:
throw
new
AssertionError
(
throw
new
IllegalStateException
(
"
PlaybackStateCompat.State shouldn't be
"
+
playbackStateCompat
.
getState
());
"
Unrecognized PlaybackStateCompat:
"
+
playbackStateCompat
.
getState
());
}
}
}
}
...
@@ -947,8 +946,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -947,8 +946,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
case
PlaybackStateCompat
.
REPEAT_MODE_GROUP
:
case
PlaybackStateCompat
.
REPEAT_MODE_GROUP
:
return
Player
.
REPEAT_MODE_ALL
;
return
Player
.
REPEAT_MODE_ALL
;
default
:
default
:
throw
new
AssertionError
(
throw
new
IllegalArgumentException
(
"
PlaybackStateCompat repeat mode shouldn't be
"
+
playbackStateCompatRepeatMode
);
"
Unrecognized PlaybackStateCompat.RepeatMode:
"
+
playbackStateCompatRepeatMode
);
}
}
}
}
...
@@ -963,7 +962,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -963,7 +962,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
case
Player
.
REPEAT_MODE_ALL
:
case
Player
.
REPEAT_MODE_ALL
:
return
PlaybackStateCompat
.
REPEAT_MODE_ALL
;
return
PlaybackStateCompat
.
REPEAT_MODE_ALL
;
default
:
default
:
throw
new
AssertionError
(
"Player.RepeatMode shouldn't be
"
+
repeatMode
);
throw
new
IllegalArgumentException
(
"Unrecognized RepeatMode:
"
+
repeatMode
);
}
}
}
}
...
@@ -978,8 +977,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -978,8 +977,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
case
PlaybackStateCompat
.
SHUFFLE_MODE_GROUP
:
case
PlaybackStateCompat
.
SHUFFLE_MODE_GROUP
:
return
true
;
return
true
;
default
:
default
:
throw
new
AssertionError
(
throw
new
IllegalArgumentException
(
"
PlaybackStateCompat.ShuffleMode shouldn't be
"
+
playbackStateCompatShuffleMode
);
"
Unrecognized ShuffleMode:
"
+
playbackStateCompatShuffleMode
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment