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
f74d2294
authored
May 22, 2019
by
olly
Committed by
Toni
May 23, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove media-session extension nullness blacklist
PiperOrigin-RevId: 249431620
parent
10ee7d8e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
32 deletions
extensions/mediasession/build.gradle
extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/MediaSessionConnector.java
extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/RepeatModeActionProvider.java
library/core/build.gradle
extensions/mediasession/build.gradle
View file @
f74d2294
...
...
@@ -33,6 +33,7 @@ android {
dependencies
{
implementation
project
(
modulePrefix
+
'library-core'
)
api
'androidx.media:media:1.0.1'
compileOnly
'org.checkerframework:checker-qual:'
+
checkerframeworkVersion
}
ext
{
...
...
extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/MediaSessionConnector.java
View file @
f74d2294
...
...
@@ -52,6 +52,7 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.checkerframework.checker.nullness.qual.EnsuresNonNullIf
;
/**
* Connects a {@link MediaSessionCompat} to a {@link Player}.
...
...
@@ -359,7 +360,7 @@ public final class MediaSessionConnector {
* @param extras Optional extras sent by a media controller.
*/
void
onCustomAction
(
Player
player
,
ControlDispatcher
controlDispatcher
,
String
action
,
Bundle
extras
);
Player
player
,
ControlDispatcher
controlDispatcher
,
String
action
,
@Nullable
Bundle
extras
);
/**
* Returns a {@link PlaybackStateCompat.CustomAction} which will be published to the media
...
...
@@ -676,6 +677,7 @@ public final class MediaSessionConnector {
*/
public
final
void
invalidateMediaSessionPlaybackState
()
{
PlaybackStateCompat
.
Builder
builder
=
new
PlaybackStateCompat
.
Builder
();
Player
player
=
this
.
player
;
if
(
player
==
null
)
{
builder
.
setActions
(
buildPrepareActions
()).
setState
(
PlaybackStateCompat
.
STATE_NONE
,
0
,
0
,
0
);
mediaSession
.
setPlaybackState
(
builder
.
build
());
...
...
@@ -749,8 +751,8 @@ public final class MediaSessionConnector {
*
* @param commandReceiver The command receiver to register.
*/
public
void
registerCustomCommandReceiver
(
CommandReceiver
commandReceiver
)
{
if
(!
customCommandReceivers
.
contains
(
commandReceiver
))
{
public
void
registerCustomCommandReceiver
(
@Nullable
CommandReceiver
commandReceiver
)
{
if
(
commandReceiver
!=
null
&&
!
customCommandReceivers
.
contains
(
commandReceiver
))
{
customCommandReceivers
.
add
(
commandReceiver
);
}
}
...
...
@@ -760,18 +762,22 @@ public final class MediaSessionConnector {
*
* @param commandReceiver The command receiver to unregister.
*/
public
void
unregisterCustomCommandReceiver
(
CommandReceiver
commandReceiver
)
{
customCommandReceivers
.
remove
(
commandReceiver
);
public
void
unregisterCustomCommandReceiver
(
@Nullable
CommandReceiver
commandReceiver
)
{
if
(
commandReceiver
!=
null
)
{
customCommandReceivers
.
remove
(
commandReceiver
);
}
}
private
void
registerCommandReceiver
(
CommandReceiver
commandReceiver
)
{
if
(!
commandReceivers
.
contains
(
commandReceiver
))
{
private
void
registerCommandReceiver
(
@Nullable
CommandReceiver
commandReceiver
)
{
if
(
commandReceiver
!=
null
&&
!
commandReceivers
.
contains
(
commandReceiver
))
{
commandReceivers
.
add
(
commandReceiver
);
}
}
private
void
unregisterCommandReceiver
(
CommandReceiver
commandReceiver
)
{
commandReceivers
.
remove
(
commandReceiver
);
private
void
unregisterCommandReceiver
(
@Nullable
CommandReceiver
commandReceiver
)
{
if
(
commandReceiver
!=
null
)
{
commandReceivers
.
remove
(
commandReceiver
);
}
}
private
long
buildPrepareActions
()
{
...
...
@@ -829,29 +835,43 @@ public final class MediaSessionConnector {
}
}
@EnsuresNonNullIf
(
result
=
true
,
expression
=
"player"
)
private
boolean
canDispatchPlaybackAction
(
long
action
)
{
return
player
!=
null
&&
(
enabledPlaybackActions
&
action
)
!=
0
;
}
@EnsuresNonNullIf
(
result
=
true
,
expression
=
"playbackPreparer"
)
private
boolean
canDispatchToPlaybackPreparer
(
long
action
)
{
return
playbackPreparer
!=
null
&&
(
playbackPreparer
.
getSupportedPrepareActions
()
&
action
)
!=
0
;
}
@EnsuresNonNullIf
(
result
=
true
,
expression
=
{
"player"
,
"queueNavigator"
})
private
boolean
canDispatchToQueueNavigator
(
long
action
)
{
return
player
!=
null
&&
queueNavigator
!=
null
&&
(
queueNavigator
.
getSupportedQueueNavigatorActions
(
player
)
&
action
)
!=
0
;
}
@EnsuresNonNullIf
(
result
=
true
,
expression
=
{
"player"
,
"ratingCallback"
})
private
boolean
canDispatchSetRating
()
{
return
player
!=
null
&&
ratingCallback
!=
null
;
}
@EnsuresNonNullIf
(
result
=
true
,
expression
=
{
"player"
,
"queueEditor"
})
private
boolean
canDispatchQueueEdit
()
{
return
player
!=
null
&&
queueEditor
!=
null
;
}
@EnsuresNonNullIf
(
result
=
true
,
expression
=
{
"player"
,
"mediaButtonEventHandler"
})
private
boolean
canDispatchMediaButtonEvent
()
{
return
player
!=
null
&&
mediaButtonEventHandler
!=
null
;
}
...
...
@@ -941,38 +961,40 @@ public final class MediaSessionConnector {
}
}
}
if
(
description
.
getTitle
()
!=
null
)
{
String
title
=
String
.
valueOf
(
description
.
getTitle
());
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_TITLE
,
title
);
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_DISPLAY_TITLE
,
title
);
CharSequence
title
=
description
.
getTitle
();
if
(
title
!=
null
)
{
String
titleString
=
String
.
valueOf
(
title
);
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_TITLE
,
titleString
);
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_DISPLAY_TITLE
,
titleString
);
}
if
(
description
.
getSubtitle
()
!=
null
)
{
CharSequence
subtitle
=
description
.
getSubtitle
();
if
(
subtitle
!=
null
)
{
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_DISPLAY_SUBTITLE
,
String
.
valueOf
(
description
.
getSubtitle
()));
MediaMetadataCompat
.
METADATA_KEY_DISPLAY_SUBTITLE
,
String
.
valueOf
(
subtitle
));
}
if
(
description
.
getDescription
()
!=
null
)
{
CharSequence
displayDescription
=
description
.
getDescription
();
if
(
displayDescription
!=
null
)
{
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_DISPLAY_DESCRIPTION
,
String
.
valueOf
(
d
escription
.
getDescription
()
));
String
.
valueOf
(
d
isplayDescription
));
}
if
(
description
.
getIconBitmap
()
!=
null
)
{
builder
.
putBitmap
(
MediaMetadataCompat
.
METADATA_KEY_DISPLAY_ICON
,
description
.
getIconBitmap
()
);
Bitmap
iconBitmap
=
description
.
getIconBitmap
();
if
(
iconBitmap
!=
null
)
{
builder
.
putBitmap
(
MediaMetadataCompat
.
METADATA_KEY_DISPLAY_ICON
,
iconBitmap
);
}
if
(
description
.
getIconUri
()
!=
null
)
{
Uri
iconUri
=
description
.
getIconUri
();
if
(
iconUri
!=
null
)
{
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_DISPLAY_ICON_URI
,
String
.
valueOf
(
description
.
getIconUri
()));
MediaMetadataCompat
.
METADATA_KEY_DISPLAY_ICON_URI
,
String
.
valueOf
(
iconUri
));
}
if
(
description
.
getMediaId
()
!=
null
)
{
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_MEDIA_ID
,
description
.
getMediaId
()
);
String
mediaId
=
description
.
getMediaId
();
if
(
mediaId
!=
null
)
{
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_MEDIA_ID
,
mediaId
);
}
if
(
description
.
getMediaUri
()
!=
null
)
{
Uri
mediaUri
=
description
.
getMediaUri
();
if
(
mediaUri
!=
null
)
{
builder
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_MEDIA_URI
,
String
.
valueOf
(
description
.
getMediaUri
()));
MediaMetadataCompat
.
METADATA_KEY_MEDIA_URI
,
String
.
valueOf
(
mediaUri
));
}
break
;
}
...
...
@@ -993,6 +1015,7 @@ public final class MediaSessionConnector {
@Override
public
void
onTimelineChanged
(
Timeline
timeline
,
@Nullable
Object
manifest
,
@Player
.
TimelineChangeReason
int
reason
)
{
Player
player
=
Assertions
.
checkNotNull
(
MediaSessionConnector
.
this
.
player
);
int
windowCount
=
player
.
getCurrentTimeline
().
getWindowCount
();
int
windowIndex
=
player
.
getCurrentWindowIndex
();
if
(
queueNavigator
!=
null
)
{
...
...
@@ -1035,6 +1058,7 @@ public final class MediaSessionConnector {
@Override
public
void
onPositionDiscontinuity
(
@Player
.
DiscontinuityReason
int
reason
)
{
Player
player
=
Assertions
.
checkNotNull
(
MediaSessionConnector
.
this
.
player
);
if
(
currentWindowIndex
!=
player
.
getCurrentWindowIndex
())
{
if
(
queueNavigator
!=
null
)
{
queueNavigator
.
onCurrentWindowIndexChanged
(
player
);
...
...
extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/RepeatModeActionProvider.java
View file @
f74d2294
...
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.ext.mediasession;
import
android.content.Context
;
import
android.os.Bundle
;
import
androidx.annotation.Nullable
;
import
android.support.v4.media.session.PlaybackStateCompat
;
import
com.google.android.exoplayer2.ControlDispatcher
;
import
com.google.android.exoplayer2.Player
;
...
...
@@ -65,7 +66,7 @@ public final class RepeatModeActionProvider implements MediaSessionConnector.Cus
@Override
public
void
onCustomAction
(
Player
player
,
ControlDispatcher
controlDispatcher
,
String
action
,
Bundle
extras
)
{
Player
player
,
ControlDispatcher
controlDispatcher
,
String
action
,
@Nullable
Bundle
extras
)
{
int
mode
=
player
.
getRepeatMode
();
int
proposedMode
=
RepeatModeUtil
.
getNextRepeatMode
(
mode
,
repeatToggleModes
);
if
(
mode
!=
proposedMode
)
{
...
...
library/core/build.gradle
View file @
f74d2294
...
...
@@ -60,7 +60,6 @@ android {
dependencies
{
implementation
'androidx.annotation:annotation:1.0.2'
compileOnly
'org.checkerframework:checker-qual:'
+
checkerframeworkVersion
compileOnly
'org.checkerframework:checker-compat-qual:'
+
checkerframeworkVersion
androidTestImplementation
'androidx.test:runner:'
+
androidXTestVersion
androidTestImplementation
'androidx.test.ext:junit:'
+
androidXTestVersion
androidTestImplementation
'com.google.truth:truth:'
+
truthVersion
...
...
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