hwc: Define and Use mSecureLock
Define and Use mSecureLock in composition and binder
thread. This is to ensure both variables mSecureMode
and mSecuring are updated in binder thread without
any context switch to composition thread
Change-Id: Ibd701bd3363515e2f7e8a9711bbc5b66053cfa03
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 43bebac..f90420f 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -260,6 +260,7 @@
ctx->mBlankLock.lock();
//Will be unlocked at the end of set
ctx->mExtLock.lock();
+ ctx->mSecureLock.lock();
reset(ctx, numDisplays, displays);
ctx->mOverlay->configBegin();
@@ -614,6 +615,7 @@
MDPComp::resetIdleFallBack();
ctx->mVideoTransFlag = false;
//Was locked at the beginning of prepare
+ ctx->mSecureLock.unlock();
ctx->mExtLock.unlock();
ctx->mBlankLock.unlock();
return ret;
diff --git a/libhwcomposer/hwc_qclient.cpp b/libhwcomposer/hwc_qclient.cpp
index b27a88c..c20f5c1 100644
--- a/libhwcomposer/hwc_qclient.cpp
+++ b/libhwcomposer/hwc_qclient.cpp
@@ -71,6 +71,7 @@
}
void QClient::securing(uint32_t startEnd) {
+ Locker::Autolock _sl(mHwcContext->mSecureLock);
//The only way to make this class in this process subscribe to media
//player's death.
IMediaDeathNotifier::getMediaPlayerService();
@@ -84,6 +85,7 @@
}
void QClient::unsecuring(uint32_t startEnd) {
+ Locker::Autolock _sl(mHwcContext->mSecureLock);
mHwcContext->mSecuring = startEnd;
//We're done unsecuring
if(startEnd == IQService::END)
@@ -93,6 +95,7 @@
}
void QClient::MPDeathNotifier::died() {
+ Locker::Autolock _sl(mHwcContext->mSecureLock);
ALOGD_IF(QCLIENT_DEBUG, "Media Player died");
mHwcContext->mSecuring = false;
mHwcContext->mSecureMode = false;
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 9a7ef0d..7b39ae5 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -346,6 +346,13 @@
mutable Locker mBlankLock;
//Lock to protect prepare & set when detaching external disp
mutable Locker mExtLock;
+ /*Lock to set both mSecureMode and mSecuring as part
+ of binder thread without context switch to composition
+ thread. This lock is needed only for A-family targets
+ since the state of mSecureMode and mSecuring variables
+ are not checked in B-family targets.
+ */
+ mutable Locker mSecureLock;
//Drawing round when we use GPU
bool isPaddingRound;
// External Orientation