AddStep(&TaskConfiguration::ParseXMLConfigStep);
AddStep(&TaskConfiguration::TizenIdStep);
+ AddStep(&TaskConfiguration::CheckAppRunningStateStep);
AddStep(&TaskConfiguration::ApplicationTypeStep);
AddStep(&TaskConfiguration::ResourceEncryptionStep);
AddStep(&TaskConfiguration::InstallationFSLocationStep);
_D("Tizen Pkg Id : %ls", (m_context.widgetConfig.tzPkgid).c_str());
}
+void TaskConfiguration::CheckAppRunningStateStep()
+{
+ bool isRunning = false;
+ int ret =
+ app_manager_is_running(DPL::ToUTF8String(m_context.widgetConfig.tzAppid).c_str(),
+ &isRunning);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ _E("Fail to get running state");
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
+ }
+
+ if (true == isRunning) {
+ // get app_context for running application
+ // app_context must be released with app_context_destroy
+ app_context_h appCtx = NULL;
+ ret =
+ app_manager_get_app_context(
+ DPL::ToUTF8String(m_context.widgetConfig.tzAppid).c_str(),
+ &appCtx);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ _E("Fail to get app_context");
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
+ }
+
+ // terminate app_context_h
+ ret = app_manager_terminate_app(appCtx);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ _E("Fail to terminate running application");
+ app_context_destroy(appCtx);
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
+ } 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(m_context.widgetConfig.tzAppid).c_str(),
+ &isStillRunning);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ _E("Fail to get running state");
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
+ }
+ if (!isStillRunning) {
+ break;
+ }
+ }
+ if (isStillRunning) {
+ _E("Fail to terminate running application");
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
+ }
+ _D("terminate application");
+ }
+ }
+}
+
void TaskConfiguration::ConfigureWidgetLocationStep()
{
m_context.locations =
void TaskConfiguration::CheckRDSSupportStep()
{
- //update needs RDS support to go ahead
+ //update needs RDS support to go ahead if REINSTALL command is given
if(m_context.isUpdateMode)
{
- if (!checkSupportRDSUpdate(m_widgetConfig)) {
+ if (!checkSupportRDSUpdateIfReinstall(m_widgetConfig)) {
ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate,
"RDS update failed");
}
_D("incoming version = '%ls", update.incomingVersion->Raw().c_str());
_D("Tizen AppID = %ls", update.tzAppId.c_str());
- // TODO: step Check running state
- bool isRunning = false;
- int ret =
- app_manager_is_running(DPL::ToUTF8String(update.tzAppId).c_str(),
- &isRunning);
- if (APP_MANAGER_ERROR_NONE != ret) {
- _E("Fail to get running state");
- ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
- "widget is running");
- }
-
- if (true == isRunning) {
- // get app_context for running application
- // app_context must be released with app_context_destroy
- app_context_h appCtx = NULL;
- ret =
- app_manager_get_app_context(
- DPL::ToUTF8String(update.tzAppId).c_str(),
- &appCtx);
- if (APP_MANAGER_ERROR_NONE != ret) {
- _E("Fail to get app_context");
- ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
- "widget is running");
- }
-
- // terminate app_context_h
- ret = app_manager_terminate_app(appCtx);
- if (APP_MANAGER_ERROR_NONE != ret) {
- _E("Fail to terminate running application");
- app_context_destroy(appCtx);
- ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
- "widget is running");
- } 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) {
- _E("Fail to get running state");
- ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
- "widget is running");
- }
- if (!isStillRunning) {
- break;
- }
- }
- if (isStillRunning) {
- _E("Fail to terminate running application");
- ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
- "widget is running");
- }
- _D("terminate application");
- }
- }
- //...
-
m_context.widgetConfig.tzAppid = update.tzAppId;
if (!!update.existingVersion ||
}
}
-bool TaskConfiguration::checkSupportRDSUpdate(const WrtDB::ConfigParserData
+bool TaskConfiguration::checkSupportRDSUpdateIfReinstall(const WrtDB::ConfigParserData
&configInfo)
{
if (m_context.mode.command ==