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
0444e0b3
authored
Feb 17, 2020
by
ibaker
Committed by
Ian Baker
Feb 17, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add Util.toHexString
PiperOrigin-RevId: 295539969
parent
ed210bca
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
library/common/src/test/java/com/google/android/exoplayer2/util/UtilTest.java
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
View file @
0444e0b3
...
@@ -1256,6 +1256,22 @@ public final class Util {
...
@@ -1256,6 +1256,22 @@ public final class Util {
}
}
/**
/**
* Returns a string containing a lower-case hex representation of the bytes provided.
*
* @param bytes The byte data to convert to hex.
* @return A String containing the hex representation of {@code bytes}.
*/
public
static
String
toHexString
(
byte
[]
bytes
)
{
StringBuilder
result
=
new
StringBuilder
(
bytes
.
length
*
2
);
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
result
.
append
(
Character
.
forDigit
((
bytes
[
i
]
>>
4
)
&
0xF
,
16
))
.
append
(
Character
.
forDigit
(
bytes
[
i
]
&
0xF
,
16
));
}
return
result
.
toString
();
}
/**
* Returns a string with comma delimited simple names of each object's class.
* Returns a string with comma delimited simple names of each object's class.
*
*
* @param objects The objects whose simple class names should be comma delimited and returned.
* @param objects The objects whose simple class names should be comma delimited and returned.
...
...
library/common/src/test/java/com/google/android/exoplayer2/util/UtilTest.java
View file @
0444e0b3
...
@@ -706,6 +706,13 @@ public class UtilTest {
...
@@ -706,6 +706,13 @@ public class UtilTest {
}
}
@Test
@Test
public
void
testToHexString
()
{
byte
[]
bytes
=
TestUtil
.
createByteArray
(
0x12
,
0xFC
,
0x06
);
assertThat
(
Util
.
toHexString
(
bytes
)).
isEqualTo
(
"12fc06"
);
}
@Test
public
void
testGetCodecsOfType
()
{
public
void
testGetCodecsOfType
()
{
assertThat
(
getCodecsOfType
(
null
,
C
.
TRACK_TYPE_VIDEO
)).
isNull
();
assertThat
(
getCodecsOfType
(
null
,
C
.
TRACK_TYPE_VIDEO
)).
isNull
();
assertThat
(
getCodecsOfType
(
"avc1.64001e,vp9.63.1"
,
C
.
TRACK_TYPE_AUDIO
)).
isNull
();
assertThat
(
getCodecsOfType
(
"avc1.64001e,vp9.63.1"
,
C
.
TRACK_TYPE_AUDIO
)).
isNull
();
...
...
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