Ensure waitForIdle() waits until pending messages are handled.

Fixes: 151960323
Test: atest --test-mapping apex/blobstore
Change-Id: If5156ac22e0a5644bc6d931bed8521824095aa2b
This commit is contained in:
Sudheer Shanka
2020-03-19 11:56:50 -07:00
parent db74198593
commit fb11dc74c8

View File

@@ -1330,8 +1330,15 @@ public class BlobStoreManagerService extends SystemService {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP,
"Caller is not allowed to call this; caller=" + Binder.getCallingUid());
mHandler.post(PooledLambda.obtainRunnable(remoteCallback::sendResult, null)
.recycleOnUse());
// We post messages back and forth between mHandler thread and mBackgroundHandler
// thread while committing a blob. We need to replicate the same pattern here to
// ensure pending messages have been handled.
mHandler.post(() -> {
mBackgroundHandler.post(() -> {
mHandler.post(PooledLambda.obtainRunnable(remoteCallback::sendResult, null)
.recycleOnUse());
});
});
}
@Override