transcoding: add thermal status listener
Register thermal status listener with thermal manager, and
pause/resume transcoding activity when thermal status goes
above certain threshold (currently set at CRITICAL).
Add unit tests with mock thermal policy. Also add unit test
that exercise the actual transcoding service, but use adb
shell cmd to fake thermal status change.
bug: 169452730
test: unit testing added in the CL; manual testing using
"adb shell cmd thermalservice override-status #" and observe
thermal throttling logs from transcoding service.
Change-Id: I7d28ed3069bdd73e8984ad138e2edba9c9a2360a
diff --git a/media/libmediatranscoding/TranscodingUidPolicy.cpp b/media/libmediatranscoding/TranscodingUidPolicy.cpp
index b0fa545..11c8ab3 100644
--- a/media/libmediatranscoding/TranscodingUidPolicy.cpp
+++ b/media/libmediatranscoding/TranscodingUidPolicy.cpp
@@ -32,9 +32,7 @@
constexpr static int32_t IMPORTANCE_UNKNOWN = INT32_MAX;
TranscodingUidPolicy::TranscodingUidPolicy()
- : mUidObserver(nullptr),
- mRegistered(false),
- mTopUidState(IMPORTANCE_UNKNOWN) {
+ : mUidObserver(nullptr), mRegistered(false), mTopUidState(IMPORTANCE_UNKNOWN) {
registerSelf();
}
@@ -129,8 +127,7 @@
bool TranscodingUidPolicy::isUidOnTop(uid_t uid) {
Mutex::Autolock _l(mUidLock);
- return mTopUidState != IMPORTANCE_UNKNOWN &&
- mTopUidState == getProcState_l(uid);
+ return mTopUidState != IMPORTANCE_UNKNOWN && mTopUidState == getProcState_l(uid);
}
std::unordered_set<uid_t> TranscodingUidPolicy::getTopUids() const {
@@ -155,12 +152,10 @@
// Top set changed if 1) the uid is in the current top uid set, or 2) the
// new procState is at least the same priority as the current top uid state.
bool isUidCurrentTop =
- mTopUidState != IMPORTANCE_UNKNOWN &&
- mStateUidMap[mTopUidState].count(uid) > 0;
+ mTopUidState != IMPORTANCE_UNKNOWN && mStateUidMap[mTopUidState].count(uid) > 0;
bool isNewStateHigherThanTop =
procState != IMPORTANCE_UNKNOWN &&
- (procState <= mTopUidState ||
- mTopUidState == IMPORTANCE_UNKNOWN);
+ (procState <= mTopUidState || mTopUidState == IMPORTANCE_UNKNOWN);
topUidSetChanged = (isUidCurrentTop || isNewStateHigherThanTop);
// Move uid to the new procState.
@@ -192,8 +187,7 @@
// Find the lowest uid state (ignoring PROCESS_STATE_UNKNOWN) with some monitored uids.
for (auto stateIt = mStateUidMap.begin(); stateIt != mStateUidMap.end(); stateIt++) {
- if (stateIt->first != IMPORTANCE_UNKNOWN &&
- !stateIt->second.empty()) {
+ if (stateIt->first != IMPORTANCE_UNKNOWN && !stateIt->second.empty()) {
mTopUidState = stateIt->first;
break;
}