Fix findId spinning if session id is not found.
If session id is not found, the iterator is not incremented
so the end() condition is reached.
The Test:
How is this bug discovered:
Calling AMediaDrm_closeSession() after AMediaDrm_provideKeyResponse()
results in spinning.
This cl is tested on nyc-mr1-dev branch using a NativeClearKeySystemTest
that is not yet checked in. This test will be ported to master soon.
After testing in nyc-mr1-dev, the source in both branches is compared.
Test: ANDROID_BUILD_TOP= ./android-cts/tools/cts-tradefed run cts -m CtsMediaTestCases --test android.media.cts.NativeClearKeySystemTest#testClearKeyPlaybackCenc
bug: 32235473
Change-Id: I58c495d7499f70b7e85cab43911323b143a9d8fd
diff --git a/media/ndk/NdkMediaDrm.cpp b/media/ndk/NdkMediaDrm.cpp
index 8d34ab0..cdce932 100644
--- a/media/ndk/NdkMediaDrm.cpp
+++ b/media/ndk/NdkMediaDrm.cpp
@@ -222,8 +222,7 @@
static bool findId(AMediaDrm *mObj, const AMediaDrmByteArray &id, List<idvec_t>::iterator &iter) {
- iter = mObj->mIds.begin();
- while (iter != mObj->mIds.end()) {
+ for (iter = mObj->mIds.begin(); iter != mObj->mIds.end(); ++iter) {
if (iter->array() == id.ptr && iter->size() == id.length) {
return true;
}