#include "Activity.hpp"
#include "UniversalSwitchLog.hpp"
#include "ActivityFactory.hpp"
-#include "Optional.hpp"
#include <app.h>
#define CHECK_ERROR(ret) do { \
public:
constexpr static const char *activityType = DerivedType::activityType;
AppControlActivity()
- : Activity(activityType)
+ : Activity(activityType), appControlHandle(nullptr)
{}
~AppControlActivity()
{
- if (app_control) {
- auto ret = app_control_destroy(*app_control);
+ if (appControlHandle) {
+ auto ret = app_control_destroy(appControlHandle);
CHECK_ERROR(ret);
}
}
bool process() override
{
- app_control_h tmp_app_control;
- auto ret = app_control_create(&tmp_app_control);
+ auto ret = app_control_create(&appControlHandle);
RETURN_ON_ERROR(ret);
- app_control = tmp_app_control;
+ ret = app_control_set_operation(appControlHandle, APP_CONTROL_OPERATION_DEFAULT);
+ RETURN_ON_ERROR(ret);
- ret = app_control_set_operation(*app_control, APP_CONTROL_OPERATION_DEFAULT);
+ ret = app_control_set_app_id(appControlHandle, DerivedType::appToLaunch);
RETURN_ON_ERROR(ret);
- ret = app_control_set_app_id(*app_control, DerivedType::appToLaunch);
+ ret = addExtraDataToCall();
RETURN_ON_ERROR(ret);
- ret = app_control_send_launch_request(*app_control, NULL, NULL);
+ ret = app_control_send_launch_request(appControlHandle, NULL, NULL);
RETURN_ON_ERROR(ret);
return true;
}
protected:
- Optional<app_control_h> app_control;
+ virtual int addExtraDataToCall()
+ {
+ return APP_CONTROL_ERROR_NONE;
+ }
+
+ app_control_h appControlHandle;
};
class StartHomeScreenActivity : public AppControlActivity<StartHomeScreenActivity, true>
static constexpr const char *activityType = "START_TASK_MGR";
static constexpr const char *appToLaunch = "org.tizen.task-mgr";
};
+
+class StartSettingsActivity : public AppControlActivity<StartSettingsActivity, false>
+{
+public:
+ int addExtraDataToCall() override
+ {
+ return app_control_add_extra_data(appControlHandle, "SHOW_US_SETTINGS", "1");
+ }
+
+ static constexpr const char *activityType = "START_SETTINGS";
+ static constexpr const char *appToLaunch = "org.tizen.setting-accessibility";
+};