Fix FlagSet.equals on API levels below 24

#minor-release

PiperOrigin-RevId: 395004645
This commit is contained in:
gyumin 2021-09-06 01:37:11 +01:00 committed by Ian Baker
parent 9991f14643
commit 00dda049ea
2 changed files with 25 additions and 2 deletions

View file

@ -13,6 +13,7 @@
`ForwardingPlayer`.
* Remove `ExoPlayerLibraryInfo.GL_ASSERTIONS_ENABLED`. Use
`GlUtil.glAssertionsEnabled` instead.
* Fix `FlagSet#equals` on API levels below 24.
* Extractors:
* Support TS packets without PTS flag
([#9294](https://github.com/google/ExoPlayer/issues/9294)).

View file

@ -211,11 +211,33 @@ public final class FlagSet {
return false;
}
FlagSet that = (FlagSet) o;
return flags.equals(that.flags);
if (Util.SDK_INT < 24) {
// SparseBooleanArray.equals() is not implemented on API levels below 24.
if (size() != that.size()) {
return false;
}
for (int i = 0; i < size(); i++) {
if (get(i) != that.get(i)) {
return false;
}
}
return true;
} else {
return flags.equals(that.flags);
}
}
@Override
public int hashCode() {
return flags.hashCode();
if (Util.SDK_INT < 24) {
// SparseBooleanArray.hashCode() is not implemented on API levels below 24.
int hashCode = size();
for (int i = 0; i < size(); i++) {
hashCode = 31 * hashCode + get(i);
}
return hashCode;
} else {
return flags.hashCode();
}
}
}