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()
#minor-release PiperOrigin-RevId: 545237925
This commit is contained in:
parent
a783d704b2
commit
de4575da28
@ -102,6 +102,8 @@
|
||||
* Make `TestExoPlayerBuilder` and `FakeClock` compatible with Espresso UI
|
||||
tests and Compose UI tests. This fixes a bug where playback advances
|
||||
non-deterministically during Espresso or Compose view interactions.
|
||||
* Add a `nanoTime()` method to `Clock` to provide override support of
|
||||
`System.nanoTime()`
|
||||
* Remove deprecated symbols:
|
||||
* Remove
|
||||
`TransformationRequest.Builder.setEnableRequestSdrToneMapping(boolean)`
|
||||
|
@ -46,6 +46,9 @@ public interface Clock {
|
||||
*/
|
||||
long uptimeMillis();
|
||||
|
||||
/** See {@link java.lang.System#nanoTime()} */
|
||||
long nanoTime();
|
||||
|
||||
/**
|
||||
* Creates a {@link HandlerWrapper} using a specified looper and a specified callback for handling
|
||||
* messages.
|
||||
|
@ -44,6 +44,11 @@ public class SystemClock implements Clock {
|
||||
return android.os.SystemClock.uptimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nanoTime() {
|
||||
return System.nanoTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerWrapper createHandler(Looper looper, @Nullable Callback callback) {
|
||||
return new SystemHandlerWrapper(new Handler(looper, callback));
|
||||
|
@ -159,6 +159,12 @@ public class FakeClock implements Clock {
|
||||
return timeSinceBootMs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized long nanoTime() {
|
||||
// Milliseconds to nanoseconds
|
||||
return timeSinceBootMs * 1000000L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long uptimeMillis() {
|
||||
return elapsedRealtime();
|
||||
|
Loading…
x
Reference in New Issue
Block a user