mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add nanoTime method to Clock to support overriding System.nanoTime()
PiperOrigin-RevId: 545237925 (cherry picked from commit de4575da28ee98a46e284cc8c7f11d34da1df29e)
This commit is contained in:
parent
26ee4c35f3
commit
cb7b3862c4
@ -10,6 +10,9 @@
|
|||||||
Previously indent and tab offset were included when limiting the cue
|
Previously indent and tab offset were included when limiting the cue
|
||||||
length to 32 characters (which was technically correct by the spec)
|
length to 32 characters (which was technically correct by the spec)
|
||||||
([#11019](https://github.com/google/ExoPlayer/issues/11019)).
|
([#11019](https://github.com/google/ExoPlayer/issues/11019)).
|
||||||
|
* Test Utilities:
|
||||||
|
* Add a `nanoTime()` method to `Clock` to provide override support of
|
||||||
|
`System.nanoTime()`
|
||||||
## 1.1
|
## 1.1
|
||||||
|
|
||||||
### 1.1.0 (2023-07-05)
|
### 1.1.0 (2023-07-05)
|
||||||
|
@ -46,6 +46,9 @@ public interface Clock {
|
|||||||
*/
|
*/
|
||||||
long uptimeMillis();
|
long uptimeMillis();
|
||||||
|
|
||||||
|
/** See {@link java.lang.System#nanoTime()} */
|
||||||
|
long nanoTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link HandlerWrapper} using a specified looper and a specified callback for handling
|
* Creates a {@link HandlerWrapper} using a specified looper and a specified callback for handling
|
||||||
* messages.
|
* messages.
|
||||||
|
@ -44,6 +44,11 @@ public class SystemClock implements Clock {
|
|||||||
return android.os.SystemClock.uptimeMillis();
|
return android.os.SystemClock.uptimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long nanoTime() {
|
||||||
|
return System.nanoTime();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerWrapper createHandler(Looper looper, @Nullable Callback callback) {
|
public HandlerWrapper createHandler(Looper looper, @Nullable Callback callback) {
|
||||||
return new SystemHandlerWrapper(new Handler(looper, callback));
|
return new SystemHandlerWrapper(new Handler(looper, callback));
|
||||||
|
@ -147,6 +147,12 @@ public class FakeClock implements Clock {
|
|||||||
return timeSinceBootMs;
|
return timeSinceBootMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized long nanoTime() {
|
||||||
|
// Milliseconds to nanoseconds
|
||||||
|
return timeSinceBootMs * 1000000L;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long uptimeMillis() {
|
public long uptimeMillis() {
|
||||||
return elapsedRealtime();
|
return elapsedRealtime();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user