[Bug] SCS segfaulted when launching without any containers provided in config.
[Cause] Some functions assumed that certain config fields should never be empty
[Solution] Additional checks to avoid segfault.
[Verification] Build, install, run tests, launch SCS without any predefined containers.
Try to switch between containers when less than two containers are present.
Change-Id: I58a69d55807f686fb168057dfb1b447707351a46
}
// check if default container exists, throw ContainerOperationException if not found
}
// check if default container exists, throw ContainerOperationException if not found
- if (mContainers.find(mConfig.defaultId) == mContainers.end()) {
+ if (!mConfig.defaultId.empty() && mContainers.find(mConfig.defaultId) == mContainers.end()) {
LOGE("Provided default container ID " << mConfig.defaultId << " is invalid.");
throw ContainerOperationException("Provided default container ID " + mConfig.defaultId +
" is invalid.");
LOGE("Provided default container ID " << mConfig.defaultId << " is invalid.");
throw ContainerOperationException("Provided default container ID " + mConfig.defaultId +
" is invalid.");
return c1.second->getPrivilege() < c2.second->getPrivilege();
});
return c1.second->getPrivilege() < c2.second->getPrivilege();
});
- mConfig.foregroundId = foregroundIterator->second->getId();
- LOGI(mConfig.foregroundId << ": no foreground container configured, setting one with highest priority");
- foregroundIterator->second->goForeground();
+ if (foregroundIterator != mContainers.end()) {
+ mConfig.foregroundId = foregroundIterator->second->getId();
+ LOGI(mConfig.foregroundId << ": no foreground container configured, setting one with highest priority");
+ foregroundIterator->second->goForeground();
+ }
LOGI("switchingSequenceMonitorNotify() called");
auto nextContainerId = getNextToForegroundContainerId();
LOGI("switchingSequenceMonitorNotify() called");
auto nextContainerId = getNextToForegroundContainerId();
- focus(nextContainerId);
+
+ if (!nextContainerId.empty()) {
+ focus(nextContainerId);
+ }