MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / onStopAllAppMessage

Method onStopAllAppMessage

Tactility/Source/service/loader/Loader.cpp:182–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182void LoaderService::onStopAllAppMessage(const std::string& id) {
183 auto lock = mutex.asScopedLock();
184 if (!lock.lock(LOADER_TIMEOUT)) {
185 LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
186 return;
187 }
188
189 if (!isRunning(id)) {
190 LOGGER.error("Stop all: {} not running", id);
191 return;
192 }
193
194 int app_to_stop_index = findAppInStack(id);
195 if (app_to_stop_index < 0) {
196 LOGGER.error("Stop all: {} not found in stack", id);
197 return;
198 }
199
200
201 // Find an app to resume, if any
202 std::shared_ptr<app::AppInstance> instance_to_resume;
203 if (app_to_stop_index > 0) {
204 instance_to_resume = appStack[app_to_stop_index - 1];
205 assert(instance_to_resume);
206 }
207
208 // Stop all apps and find the LaunchId of the last-closed app, so we can call onResult() if needed
209 app::LaunchId last_launch_id = 0;
210 for (int i = appStack.size() - 1; i >= app_to_stop_index; i--) {
211 auto app_to_stop = appStack[i];
212 // Hide the app first in case it's still being shown
213 if (app_to_stop->getState() == app::State::Showing) {
214 transitionAppToState(app_to_stop, app::State::Hiding);
215 }
216 transitionAppToState(app_to_stop, app::State::Destroyed);
217 last_launch_id = app_to_stop->getLaunchId();
218
219 appStack.pop_back();
220 }
221
222 if (instance_to_resume != nullptr) {
223 LOGGER.info("Resuming {}", instance_to_resume->getManifest().appId);
224 transitionAppToState(instance_to_resume, app::State::Showing);
225
226 instance_to_resume->getApp()->onResult(
227 *instance_to_resume,
228 last_launch_id,
229 app::Result::Cancelled,
230 nullptr
231 );
232 }
233}
234
235void LoaderService::transitionAppToState(const std::shared_ptr<app::AppInstance>& app, app::State state) {
236 const app::AppManifest& app_manifest = app->getManifest();

Callers

nothing calls this directly

Calls 9

isRunningFunction · 0.85
asScopedLockMethod · 0.80
errorMethod · 0.80
getLaunchIdMethod · 0.80
infoMethod · 0.80
getAppMethod · 0.80
lockMethod · 0.45
getStateMethod · 0.45
onResultMethod · 0.45

Tested by

no test coverage detected