| 233 | } |
| 234 | |
| 235 | void LoaderService::transitionAppToState(const std::shared_ptr<app::AppInstance>& app, app::State state) { |
| 236 | const app::AppManifest& app_manifest = app->getManifest(); |
| 237 | const app::State old_state = app->getState(); |
| 238 | |
| 239 | LOGGER.info( "App \"{}\" state: {} -> {}", |
| 240 | app_manifest.appId, |
| 241 | appStateToString(old_state), |
| 242 | appStateToString(state) |
| 243 | ); |
| 244 | |
| 245 | switch (state) { |
| 246 | using enum app::State; |
| 247 | case Initial: |
| 248 | check(false, LOG_MESSAGE_ILLEGAL_STATE); |
| 249 | case Created: |
| 250 | assert(app->getState() == app::State::Initial); |
| 251 | app->getApp()->onCreate(*app); |
| 252 | pubsubExternal->publish(Event::ApplicationStarted); |
| 253 | break; |
| 254 | case Showing: { |
| 255 | assert(app->getState() == app::State::Hiding || app->getState() == app::State::Created); |
| 256 | pubsubExternal->publish(Event::ApplicationShowing); |
| 257 | break; |
| 258 | } |
| 259 | case Hiding: { |
| 260 | assert(app->getState() == app::State::Showing); |
| 261 | pubsubExternal->publish(Event::ApplicationHiding); |
| 262 | break; |
| 263 | } |
| 264 | case Destroyed: |
| 265 | app->getApp()->onDestroy(*app); |
| 266 | pubsubExternal->publish(Event::ApplicationStopped); |
| 267 | break; |
| 268 | } |
| 269 | |
| 270 | app->setState(state); |
| 271 | } |
| 272 | |
| 273 | app::LaunchId LoaderService::start(const std::string& id, std::shared_ptr<const Bundle> parameters) { |
| 274 | const auto launch_id = nextLaunchId++; |