mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add methods for comparing PlaybackException data
Also replace the equals() method in MediaUtils. PiperOrigin-RevId: 378638642
This commit is contained in:
parent
b5dbadee0c
commit
805cd47682
2 changed files with 50 additions and 0 deletions
|
|
@ -344,6 +344,23 @@ public final class ExoPlaybackException extends PlaybackException {
|
||||||
return (RuntimeException) Assertions.checkNotNull(getCause());
|
return (RuntimeException) Assertions.checkNotNull(getCause());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean errorInfoEquals(@Nullable PlaybackException that) {
|
||||||
|
if (!super.errorInfoEquals(that)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// We know that is not null and is an ExoPlaybackException because of the super call returning
|
||||||
|
// true.
|
||||||
|
ExoPlaybackException other = (ExoPlaybackException) Util.castNonNull(that);
|
||||||
|
return type == other.type
|
||||||
|
&& Util.areEqual(rendererName, other.rendererName)
|
||||||
|
&& rendererIndex == other.rendererIndex
|
||||||
|
&& Util.areEqual(rendererFormat, other.rendererFormat)
|
||||||
|
&& rendererFormatSupport == other.rendererFormatSupport
|
||||||
|
&& Util.areEqual(mediaPeriodId, other.mediaPeriodId)
|
||||||
|
&& isRecoverable == other.isRecoverable;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a copy of this exception with the provided {@link MediaPeriodId}.
|
* Returns a copy of this exception with the provided {@link MediaPeriodId}.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import androidx.annotation.CallSuper;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
@ -293,6 +294,38 @@ public class PlaybackException extends Exception implements Bundleable {
|
||||||
this.timestampMs = timestampMs;
|
this.timestampMs = timestampMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the error data associated to this exception equals the error data associated to
|
||||||
|
* {@code other}.
|
||||||
|
*
|
||||||
|
* <p>Note that this method does not compare the exceptions' stacktraces.
|
||||||
|
*/
|
||||||
|
@CallSuper
|
||||||
|
public boolean errorInfoEquals(@Nullable PlaybackException other) {
|
||||||
|
if (this == other) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (other == null || getClass() != other.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable Throwable thisCause = getCause();
|
||||||
|
@Nullable Throwable thatCause = other.getCause();
|
||||||
|
if (thisCause != null && thatCause != null) {
|
||||||
|
if (!Util.areEqual(thisCause.getMessage(), thatCause.getMessage())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Util.areEqual(thisCause.getClass(), thatCause.getClass())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (thisCause != null || thatCause != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return errorCode == other.errorCode
|
||||||
|
&& Util.areEqual(getMessage(), other.getMessage())
|
||||||
|
&& timestampMs == other.timestampMs;
|
||||||
|
}
|
||||||
|
|
||||||
// Bundleable implementation.
|
// Bundleable implementation.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue