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
d088be7a
authored
Mar 14, 2019
by
eguven
Committed by
Oliver Woodman
Mar 15, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove DownloadState.stopFlags
PiperOrigin-RevId: 238442845
parent
f566c948
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
107 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloadIndex.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadManager.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadState.java
library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloadIndexTest.java
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateBuilder.java
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateTest.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloadIndex.java
View file @
d088be7a
...
...
@@ -53,7 +53,6 @@ public final class DefaultDownloadIndex implements DownloadIndex {
private
static
final
String
COLUMN_DOWNLOADED_BYTES
=
"downloaded_bytes"
;
private
static
final
String
COLUMN_TOTAL_BYTES
=
"total_bytes"
;
private
static
final
String
COLUMN_FAILURE_REASON
=
"failure_reason"
;
private
static
final
String
COLUMN_STOP_FLAGS
=
"stop_flags"
;
private
static
final
String
COLUMN_NOT_MET_REQUIREMENTS
=
"not_met_requirements"
;
private
static
final
String
COLUMN_MANUAL_STOP_REASON
=
"manual_stop_reason"
;
private
static
final
String
COLUMN_START_TIME_MS
=
"start_time_ms"
;
...
...
@@ -61,6 +60,10 @@ public final class DefaultDownloadIndex implements DownloadIndex {
private
static
final
String
COLUMN_STREAM_KEYS
=
"stream_keys"
;
private
static
final
String
COLUMN_CUSTOM_METADATA
=
"custom_metadata"
;
@SuppressWarnings
(
"DeprecatedIsStillUsed"
)
@Deprecated
private
static
final
String
COLUMN_STOP_FLAGS
=
"stop_flags"
;
private
static
final
int
COLUMN_INDEX_ID
=
0
;
private
static
final
int
COLUMN_INDEX_TYPE
=
1
;
private
static
final
int
COLUMN_INDEX_URI
=
2
;
...
...
@@ -70,13 +73,12 @@ public final class DefaultDownloadIndex implements DownloadIndex {
private
static
final
int
COLUMN_INDEX_DOWNLOADED_BYTES
=
6
;
private
static
final
int
COLUMN_INDEX_TOTAL_BYTES
=
7
;
private
static
final
int
COLUMN_INDEX_FAILURE_REASON
=
8
;
private
static
final
int
COLUMN_INDEX_STOP_FLAGS
=
9
;
private
static
final
int
COLUMN_INDEX_NOT_MET_REQUIREMENTS
=
10
;
private
static
final
int
COLUMN_INDEX_MANUAL_STOP_REASON
=
11
;
private
static
final
int
COLUMN_INDEX_START_TIME_MS
=
12
;
private
static
final
int
COLUMN_INDEX_UPDATE_TIME_MS
=
13
;
private
static
final
int
COLUMN_INDEX_STREAM_KEYS
=
14
;
private
static
final
int
COLUMN_INDEX_CUSTOM_METADATA
=
15
;
private
static
final
int
COLUMN_INDEX_NOT_MET_REQUIREMENTS
=
9
;
private
static
final
int
COLUMN_INDEX_MANUAL_STOP_REASON
=
10
;
private
static
final
int
COLUMN_INDEX_START_TIME_MS
=
11
;
private
static
final
int
COLUMN_INDEX_UPDATE_TIME_MS
=
12
;
private
static
final
int
COLUMN_INDEX_STREAM_KEYS
=
13
;
private
static
final
int
COLUMN_INDEX_CUSTOM_METADATA
=
14
;
private
static
final
String
WHERE_ID_EQUALS
=
COLUMN_ID
+
" = ?"
;
...
...
@@ -91,7 +93,6 @@ public final class DefaultDownloadIndex implements DownloadIndex {
COLUMN_DOWNLOADED_BYTES
,
COLUMN_TOTAL_BYTES
,
COLUMN_FAILURE_REASON
,
COLUMN_STOP_FLAGS
,
COLUMN_NOT_MET_REQUIREMENTS
,
COLUMN_MANUAL_STOP_REASON
,
COLUMN_START_TIME_MS
,
...
...
@@ -210,7 +211,7 @@ public final class DefaultDownloadIndex implements DownloadIndex {
values
.
put
(
COLUMN_DOWNLOADED_BYTES
,
downloadState
.
downloadedBytes
);
values
.
put
(
COLUMN_TOTAL_BYTES
,
downloadState
.
totalBytes
);
values
.
put
(
COLUMN_FAILURE_REASON
,
downloadState
.
failureReason
);
values
.
put
(
COLUMN_STOP_FLAGS
,
downloadState
.
stopFlags
);
values
.
put
(
COLUMN_STOP_FLAGS
,
/*stopFlags*/
0
);
values
.
put
(
COLUMN_NOT_MET_REQUIREMENTS
,
downloadState
.
notMetRequirements
);
values
.
put
(
COLUMN_MANUAL_STOP_REASON
,
downloadState
.
manualStopReason
);
values
.
put
(
COLUMN_START_TIME_MS
,
downloadState
.
startTimeMs
);
...
...
@@ -288,7 +289,6 @@ public final class DefaultDownloadIndex implements DownloadIndex {
cursor
.
getLong
(
COLUMN_INDEX_DOWNLOADED_BYTES
),
cursor
.
getLong
(
COLUMN_INDEX_TOTAL_BYTES
),
cursor
.
getInt
(
COLUMN_INDEX_FAILURE_REASON
),
cursor
.
getInt
(
COLUMN_INDEX_STOP_FLAGS
),
cursor
.
getInt
(
COLUMN_INDEX_NOT_MET_REQUIREMENTS
),
cursor
.
getInt
(
COLUMN_INDEX_MANUAL_STOP_REASON
),
cursor
.
getLong
(
COLUMN_INDEX_START_TIME_MS
),
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadManager.java
View file @
d088be7a
This diff is collapsed.
Click to expand it.
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadState.java
View file @
d088be7a
...
...
@@ -76,20 +76,10 @@ public final class DownloadState {
/** The download is failed because of unknown reason. */
public
static
final
int
FAILURE_REASON_UNKNOWN
=
1
;
/**
* Download stop flags. Possible flag values are {@link #STOP_FLAG_MANUAL} and {@link
* #STOP_FLAG_REQUIREMENTS_NOT_MET}.
*/
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
(
flag
=
true
,
value
=
{
STOP_FLAG_MANUAL
,
STOP_FLAG_REQUIREMENTS_NOT_MET
})
public
@interface
StopFlags
{}
/** Download is stopped by the application. */
public
static
final
int
STOP_FLAG_MANUAL
=
1
;
/** Download is stopped as the requirements are not met. */
public
static
final
int
STOP_FLAG_REQUIREMENTS_NOT_MET
=
1
<<
1
;
/** The download isn't manually stopped. */
public
static
final
int
MANUAL_STOP_REASON_NONE
=
0
;
/** The download is manually stopped but a reason isn't specified. */
public
static
final
int
MANUAL_STOP_REASON_UNDEFINED
=
Integer
.
MAX_VALUE
;
/** Returns the state string for the given state value. */
public
static
String
getStateString
(
@State
int
state
)
{
...
...
@@ -156,11 +146,9 @@ public final class DownloadState {
* #FAILURE_REASON_NONE}.
*/
@FailureReason
public
final
int
failureReason
;
/** Download stop flags. These flags stop downloading any content. */
@StopFlags
public
final
int
stopFlags
;
/** Not met requirements to download. */
@Requirements
.
RequirementFlags
public
final
int
notMetRequirements
;
/**
If {@link #STOP_FLAG_MANUAL} is set then this field holds t
he manual stop reason. */
/**
T
he manual stop reason. */
public
final
int
manualStopReason
;
/**
...
...
@@ -183,7 +171,6 @@ public final class DownloadState {
/* downloadedBytes= */
0
,
/* totalBytes= */
C
.
LENGTH_UNSET
,
FAILURE_REASON_NONE
,
/* stopFlags= */
0
,
/* notMetRequirements= */
0
,
/* manualStopReason= */
0
,
/* startTimeMs= */
currentTimeMs
,
...
...
@@ -202,7 +189,6 @@ public final class DownloadState {
long
downloadedBytes
,
long
totalBytes
,
@FailureReason
int
failureReason
,
@StopFlags
int
stopFlags
,
@RequirementFlags
int
notMetRequirements
,
int
manualStopReason
,
long
startTimeMs
,
...
...
@@ -210,10 +196,9 @@ public final class DownloadState {
StreamKey
[]
streamKeys
,
byte
[]
customMetadata
)
{
Assertions
.
checkState
((
failureReason
==
FAILURE_REASON_NONE
)
==
(
state
!=
STATE_FAILED
));
Assertions
.
checkState
(
stopFlags
==
0
||
(
state
!=
STATE_DOWNLOADING
&&
state
!=
STATE_QUEUED
));
Assertions
.
checkState
(
((
stopFlags
&
STOP_FLAG_REQUIREMENTS_NOT_MET
)
==
0
)
==
(
notMetRequirements
==
0
));
Assertions
.
checkState
(((
stopFlags
&
STOP_FLAG_MANUAL
)
!=
0
)
||
(
manualStopReason
==
0
));
if
(
manualStopReason
!=
0
||
notMetRequirements
!=
0
)
{
Assertions
.
checkState
(
state
!=
STATE_DOWNLOADING
&&
state
!=
STATE_QUEUED
);
}
this
.
id
=
id
;
this
.
type
=
type
;
this
.
uri
=
uri
;
...
...
@@ -223,7 +208,6 @@ public final class DownloadState {
this
.
downloadedBytes
=
downloadedBytes
;
this
.
totalBytes
=
totalBytes
;
this
.
failureReason
=
failureReason
;
this
.
stopFlags
=
stopFlags
;
this
.
notMetRequirements
=
notMetRequirements
;
this
.
manualStopReason
=
manualStopReason
;
this
.
startTimeMs
=
startTimeMs
;
...
...
@@ -247,12 +231,12 @@ public final class DownloadState {
type
,
action
.
uri
,
action
.
customCacheKey
,
getNextState
(
state
,
stopFlags
!=
0
,
action
.
isRemoveAction
),
getNextState
(
state
,
manualStopReason
!=
0
||
notMetRequirements
!=
0
,
action
.
isRemoveAction
),
/* downloadPercentage= */
C
.
PERCENTAGE_UNSET
,
downloadedBytes
,
/* totalBytes= */
C
.
LENGTH_UNSET
,
FAILURE_REASON_NONE
,
stopFlags
,
notMetRequirements
,
manualStopReason
,
startTimeMs
,
...
...
@@ -261,14 +245,14 @@ public final class DownloadState {
action
.
data
);
}
private
static
int
getNextState
(
int
currentState
,
boolean
stopFlagsSet
,
boolean
remove
)
{
private
static
int
getNextState
(
int
currentState
,
boolean
isStopped
,
boolean
remove
)
{
int
nextState
;
if
(
remove
)
{
nextState
=
STATE_REMOVING
;
}
else
{
if
(
currentState
==
STATE_REMOVING
||
currentState
==
STATE_RESTARTING
)
{
nextState
=
STATE_RESTARTING
;
}
else
if
(
stopFlagsSet
)
{
}
else
if
(
isStopped
)
{
nextState
=
STATE_STOPPED
;
}
else
{
nextState
=
STATE_QUEUED
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloadIndexTest.java
View file @
d088be7a
...
...
@@ -81,8 +81,6 @@ public class DefaultDownloadIndexTest {
.
setDownloadedBytes
(
200
)
.
setTotalBytes
(
400
)
.
setFailureReason
(
DownloadState
.
FAILURE_REASON_UNKNOWN
)
.
setStopFlags
(
DownloadState
.
STOP_FLAG_REQUIREMENTS_NOT_MET
|
DownloadState
.
STOP_FLAG_MANUAL
)
.
setNotMetRequirements
(
0x87654321
)
.
setManualStopReason
(
0x12345678
)
.
setStartTimeMs
(
10
)
...
...
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateBuilder.java
View file @
d088be7a
...
...
@@ -36,7 +36,6 @@ class DownloadStateBuilder {
private
long
downloadedBytes
;
private
long
totalBytes
;
private
int
failureReason
;
private
int
stopFlags
;
private
int
notMetRequirements
;
private
int
manualStopReason
;
private
long
startTimeMs
;
...
...
@@ -74,7 +73,6 @@ class DownloadStateBuilder {
this
.
downloadedBytes
=
(
long
)
0
;
this
.
totalBytes
=
(
long
)
C
.
LENGTH_UNSET
;
this
.
failureReason
=
DownloadState
.
FAILURE_REASON_NONE
;
this
.
stopFlags
=
0
;
this
.
startTimeMs
=
(
long
)
0
;
this
.
updateTimeMs
=
(
long
)
0
;
this
.
streamKeys
=
streamKeys
;
...
...
@@ -131,11 +129,6 @@ class DownloadStateBuilder {
return
this
;
}
public
DownloadStateBuilder
setStopFlags
(
int
stopFlags
)
{
this
.
stopFlags
=
stopFlags
;
return
this
;
}
public
DownloadStateBuilder
setNotMetRequirements
(
int
notMetRequirements
)
{
this
.
notMetRequirements
=
notMetRequirements
;
return
this
;
...
...
@@ -177,7 +170,6 @@ class DownloadStateBuilder {
downloadedBytes
,
totalBytes
,
failureReason
,
stopFlags
,
notMetRequirements
,
manualStopReason
,
startTimeMs
,
...
...
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateTest.java
View file @
d088be7a
...
...
@@ -171,7 +171,7 @@ public class DownloadStateTest {
DownloadStateBuilder
downloadStateBuilder
=
new
DownloadStateBuilder
(
downloadAction
)
.
setState
(
DownloadState
.
STATE_STOPPED
)
.
set
StopFlags
(
DownloadState
.
STOP_FLAG_MANUAL
);
.
set
ManualStopReason
(
DownloadState
.
MANUAL_STOP_REASON_UNDEFINED
);
DownloadState
downloadState
=
downloadStateBuilder
.
build
();
DownloadState
mergedDownloadState
=
downloadState
.
mergeAction
(
downloadAction
);
...
...
@@ -185,7 +185,7 @@ public class DownloadStateTest {
DownloadStateBuilder
downloadStateBuilder
=
new
DownloadStateBuilder
(
downloadAction
)
.
setState
(
DownloadState
.
STATE_STOPPED
)
.
set
StopFlags
(
DownloadState
.
STOP_FLAG_MANUAL
);
.
set
ManualStopReason
(
DownloadState
.
MANUAL_STOP_REASON_UNDEFINED
);
DownloadState
downloadState
=
downloadStateBuilder
.
build
();
DownloadState
mergedDownloadState
=
downloadState
.
mergeAction
(
downloadAction
);
...
...
@@ -196,12 +196,28 @@ public class DownloadStateTest {
}
@Test
public
void
mergeAction_
stopFlag
SetButNotInStoppedState_stateBecomesStopped
()
{
public
void
mergeAction_
manualStopReason
SetButNotInStoppedState_stateBecomesStopped
()
{
DownloadAction
downloadAction
=
createDownloadAction
();
DownloadStateBuilder
downloadStateBuilder
=
new
DownloadStateBuilder
(
downloadAction
)
.
setState
(
DownloadState
.
STATE_COMPLETED
)
.
setStopFlags
(
DownloadState
.
STOP_FLAG_MANUAL
);
.
setManualStopReason
(
DownloadState
.
MANUAL_STOP_REASON_UNDEFINED
);
DownloadState
downloadState
=
downloadStateBuilder
.
build
();
DownloadState
mergedDownloadState
=
downloadState
.
mergeAction
(
downloadAction
);
DownloadState
expectedDownloadState
=
downloadStateBuilder
.
setState
(
DownloadState
.
STATE_STOPPED
).
build
();
assertEqual
(
mergedDownloadState
,
expectedDownloadState
);
}
@Test
public
void
mergeAction_notMetRequirementsSetButNotInStoppedState_stateBecomesStopped
()
{
DownloadAction
downloadAction
=
createDownloadAction
();
DownloadStateBuilder
downloadStateBuilder
=
new
DownloadStateBuilder
(
downloadAction
)
.
setState
(
DownloadState
.
STATE_COMPLETED
)
.
setNotMetRequirements
(
0x12345678
);
DownloadState
downloadState
=
downloadStateBuilder
.
build
();
DownloadState
mergedDownloadState
=
downloadState
.
mergeAction
(
downloadAction
);
...
...
@@ -325,7 +341,7 @@ public class DownloadStateTest {
if
(
downloadState
.
failureReason
!=
that
.
failureReason
)
{
return
false
;
}
if
(
downloadState
.
stopFlags
!=
that
.
stopFlags
)
{
if
(
downloadState
.
manualStopReason
!=
that
.
manualStopReason
)
{
return
false
;
}
if
(
downloadState
.
notMetRequirements
!=
that
.
notMetRequirements
)
{
...
...
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