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
bbcd1126
authored
Jul 14, 2019
by
tonihei
Committed by
Oliver Woodman
Jul 14, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove DownloadService from nullness blacklist.
PiperOrigin-RevId: 258038961
parent
3fe0b1a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadService.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadService.java
View file @
bbcd1126
...
...
@@ -175,7 +175,7 @@ public abstract class DownloadService extends Service {
@Nullable
private
final
String
channelId
;
@StringRes
private
final
int
channelNameResourceId
;
private
DownloadManager
downloadManager
;
@Nullable
private
DownloadManager
downloadManager
;
private
int
lastStartId
;
private
boolean
startedInForeground
;
private
boolean
taskRemoved
;
...
...
@@ -575,6 +575,7 @@ public abstract class DownloadService extends Service {
if
(
intentAction
==
null
)
{
intentAction
=
ACTION_INIT
;
}
DownloadManager
downloadManager
=
Assertions
.
checkNotNull
(
this
.
downloadManager
);
switch
(
intentAction
)
{
case
ACTION_INIT:
case
ACTION_RESTART:
...
...
@@ -640,8 +641,9 @@ public abstract class DownloadService extends Service {
@Override
public
void
onDestroy
()
{
isDestroyed
=
true
;
DownloadManagerHelper
downloadManagerHelper
=
downloadManagerListeners
.
get
(
getClass
());
boolean
unschedule
=
!
downloadManager
.
isWaitingForRequirements
();
DownloadManagerHelper
downloadManagerHelper
=
Assertions
.
checkNotNull
(
downloadManagerListeners
.
get
(
getClass
()));
boolean
unschedule
=
!
downloadManagerHelper
.
downloadManager
.
isWaitingForRequirements
();
downloadManagerHelper
.
detachService
(
this
,
unschedule
);
if
(
foregroundNotificationUpdater
!=
null
)
{
foregroundNotificationUpdater
.
stopPeriodicUpdates
();
...
...
@@ -775,7 +777,6 @@ public abstract class DownloadService extends Service {
private
final
int
notificationId
;
private
final
long
updateInterval
;
private
final
Handler
handler
;
private
final
Runnable
updateRunnable
;
private
boolean
periodicUpdatesStarted
;
private
boolean
notificationDisplayed
;
...
...
@@ -784,7 +785,6 @@ public abstract class DownloadService extends Service {
this
.
notificationId
=
notificationId
;
this
.
updateInterval
=
updateInterval
;
this
.
handler
=
new
Handler
(
Looper
.
getMainLooper
());
this
.
updateRunnable
=
this
::
update
;
}
public
void
startPeriodicUpdates
()
{
...
...
@@ -794,7 +794,7 @@ public abstract class DownloadService extends Service {
public
void
stopPeriodicUpdates
()
{
periodicUpdatesStarted
=
false
;
handler
.
removeCallbacks
(
updateRunnable
);
handler
.
removeCallbacks
AndMessages
(
null
);
}
public
void
showNotificationIfNotAlready
()
{
...
...
@@ -810,12 +810,12 @@ public abstract class DownloadService extends Service {
}
private
void
update
()
{
List
<
Download
>
downloads
=
downloadManager
.
getCurrentDownloads
();
List
<
Download
>
downloads
=
Assertions
.
checkNotNull
(
downloadManager
)
.
getCurrentDownloads
();
startForeground
(
notificationId
,
getForegroundNotification
(
downloads
));
notificationDisplayed
=
true
;
if
(
periodicUpdatesStarted
)
{
handler
.
removeCallbacks
(
updateRunnable
);
handler
.
postDelayed
(
updateRunnabl
e
,
updateInterval
);
handler
.
removeCallbacks
AndMessages
(
null
);
handler
.
postDelayed
(
this
::
updat
e
,
updateInterval
);
}
}
}
...
...
@@ -840,7 +840,8 @@ public abstract class DownloadService extends Service {
downloadManager
.
addListener
(
this
);
if
(
scheduler
!=
null
)
{
Requirements
requirements
=
downloadManager
.
getRequirements
();
setSchedulerEnabled
(
/* enabled= */
!
requirements
.
checkRequirements
(
context
),
requirements
);
setSchedulerEnabled
(
scheduler
,
/* enabled= */
!
requirements
.
checkRequirements
(
context
),
requirements
);
}
}
...
...
@@ -894,11 +895,12 @@ public abstract class DownloadService extends Service {
}
}
if
(
scheduler
!=
null
)
{
setSchedulerEnabled
(
/* enabled= */
!
requirementsMet
,
requirements
);
setSchedulerEnabled
(
scheduler
,
/* enabled= */
!
requirementsMet
,
requirements
);
}
}
private
void
setSchedulerEnabled
(
boolean
enabled
,
Requirements
requirements
)
{
private
void
setSchedulerEnabled
(
Scheduler
scheduler
,
boolean
enabled
,
Requirements
requirements
)
{
if
(!
enabled
)
{
scheduler
.
cancel
();
}
else
{
...
...
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