- m_installerContext.widgetConfig.tzAppid = tzAppid;
- OptionalWidgetVersion existingVersion;
- existingVersion = update.existingWidgetInfo.existingVersion;
- OptionalWidgetVersion incomingVersion = update.incomingVersion;
-
- updateTypeCheckBit = CalcWidgetUpdatePolicy(existingVersion,
- incomingVersion);
- // Calc proceed flag
- if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 ||
- m_jobStruct.updateMode ==
- WidgetUpdateMode::PolicyDirectoryForceInstall)
- {
- LogInfo("Whether widget policy allow proceed ok");
- return ConfigureResult::Updated;
+ // terminate app_context_h
+ ret = app_manager_terminate_app(appCtx);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ LogError("Fail to terminate running application");
+ app_context_destroy(appCtx);
+ return ConfigureResult::Failed_WidgetRunning;
+ } else {
+ app_context_destroy(appCtx);
+ // app_manager_terminate_app isn't sync API
+ // wait until application isn't running (50ms * 100)
+ bool isStillRunning = true;
+ int checkingloop = 100;
+ struct timespec duration = { 0, 50 * 1000 * 1000 };
+ while (--checkingloop >= 0) {
+ nanosleep(&duration, NULL);
+ int ret =
+ app_manager_is_running(
+ DPL::ToUTF8String(update.tzAppId).c_str(),
+ &isStillRunning);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ LogError("Fail to get running state");
+ return ConfigureResult::Failed_WidgetRunning;
+ }
+ if (!isStillRunning) {
+ break;
+ }
+ }
+ if (isStillRunning) {
+ LogError("Fail to terminate running application");
+ return ConfigureResult::Failed_WidgetRunning;
+ }
+ LogInfo("terminate application");