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
2b6581af
authored
Jun 03, 2021
by
olly
Committed by
bachinger
Jun 03, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix nullness checks for addition of Cursor.getString stub
PiperOrigin-RevId: 377298145
parent
b0a3bc5b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
8 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloadIndex.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadataIndex.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloadIndex.java
View file @
2b6581af
...
...
@@ -15,12 +15,15 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
offline
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
android.content.ContentValues
;
import
android.database.Cursor
;
import
android.database.SQLException
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteException
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
androidx.annotation.GuardedBy
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.VisibleForTesting
;
...
...
@@ -371,7 +374,7 @@ public final class DefaultDownloadIndex implements WritableDownloadIndex {
}
/** Infers the MIME type from a v2 table row. */
private
static
String
inferMimeType
(
String
downloadType
)
{
private
static
String
inferMimeType
(
@Nullable
String
downloadType
)
{
if
(
"dash"
.
equals
(
downloadType
))
{
return
MimeTypes
.
APPLICATION_MPD
;
}
else
if
(
"hls"
.
equals
(
downloadType
))
{
...
...
@@ -441,8 +444,8 @@ public final class DefaultDownloadIndex implements WritableDownloadIndex {
byte
[]
keySetId
=
cursor
.
getBlob
(
COLUMN_INDEX_KEY_SET_ID
);
DownloadRequest
request
=
new
DownloadRequest
.
Builder
(
/* id= */
c
ursor
.
getString
(
COLUMN_INDEX_ID
),
/* uri= */
Uri
.
parse
(
c
ursor
.
getString
(
COLUMN_INDEX_URI
)))
/* id= */
c
heckNotNull
(
cursor
.
getString
(
COLUMN_INDEX_ID
)
),
/* uri= */
Uri
.
parse
(
c
heckNotNull
(
cursor
.
getString
(
COLUMN_INDEX_URI
)
)))
.
setMimeType
(
cursor
.
getString
(
COLUMN_INDEX_MIME_TYPE
))
.
setStreamKeys
(
decodeStreamKeys
(
cursor
.
getString
(
COLUMN_INDEX_STREAM_KEYS
)))
.
setKeySetId
(
keySetId
.
length
>
0
?
keySetId
:
null
)
...
...
@@ -493,7 +496,8 @@ public final class DefaultDownloadIndex implements WritableDownloadIndex {
*/
DownloadRequest
request
=
new
DownloadRequest
.
Builder
(
/* id= */
cursor
.
getString
(
0
),
/* uri= */
Uri
.
parse
(
cursor
.
getString
(
2
)))
/* id= */
checkNotNull
(
cursor
.
getString
(
0
)),
/* uri= */
Uri
.
parse
(
checkNotNull
(
cursor
.
getString
(
2
))))
.
setMimeType
(
inferMimeType
(
cursor
.
getString
(
1
)))
.
setStreamKeys
(
decodeStreamKeys
(
cursor
.
getString
(
3
)))
.
setCustomCacheKey
(
cursor
.
getString
(
4
))
...
...
@@ -519,9 +523,9 @@ public final class DefaultDownloadIndex implements WritableDownloadIndex {
downloadProgress
);
}
private
static
List
<
StreamKey
>
decodeStreamKeys
(
String
encodedStreamKeys
)
{
private
static
List
<
StreamKey
>
decodeStreamKeys
(
@Nullable
String
encodedStreamKeys
)
{
ArrayList
<
StreamKey
>
streamKeys
=
new
ArrayList
<>();
if
(
encodedStreamKeys
.
isEmpty
(
))
{
if
(
TextUtils
.
isEmpty
(
encodedStreamKeys
))
{
return
streamKeys
;
}
String
[]
streamKeysStrings
=
Util
.
split
(
encodedStreamKeys
,
","
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadataIndex.java
View file @
2b6581af
...
...
@@ -15,6 +15,8 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
upstream
.
cache
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
android.content.ContentValues
;
import
android.database.Cursor
;
import
android.database.SQLException
;
...
...
@@ -146,7 +148,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
try
(
Cursor
cursor
=
getCursor
())
{
Map
<
String
,
CacheFileMetadata
>
fileMetadata
=
new
HashMap
<>(
cursor
.
getCount
());
while
(
cursor
.
moveToNext
())
{
String
name
=
c
ursor
.
getString
(
COLUMN_INDEX_NAME
);
String
name
=
c
heckNotNull
(
cursor
.
getString
(
COLUMN_INDEX_NAME
)
);
long
length
=
cursor
.
getLong
(
COLUMN_INDEX_LENGTH
);
long
lastTouchTimestamp
=
cursor
.
getLong
(
COLUMN_INDEX_LAST_TOUCH_TIMESTAMP
);
fileMetadata
.
put
(
name
,
new
CacheFileMetadata
(
length
,
lastTouchTimestamp
));
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java
View file @
2b6581af
...
...
@@ -832,7 +832,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
try
(
Cursor
cursor
=
getCursor
())
{
while
(
cursor
.
moveToNext
())
{
int
id
=
cursor
.
getInt
(
COLUMN_INDEX_ID
);
String
key
=
c
ursor
.
getString
(
COLUMN_INDEX_KEY
);
String
key
=
c
heckNotNull
(
cursor
.
getString
(
COLUMN_INDEX_KEY
)
);
byte
[]
metadataBytes
=
cursor
.
getBlob
(
COLUMN_INDEX_METADATA
);
ByteArrayInputStream
inputStream
=
new
ByteArrayInputStream
(
metadataBytes
);
...
...
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