--- /dev/null
+#include "Activity.hpp"
+#include "UniversalSwitchLog.hpp"
+#include "ActivityFactory.hpp"
+#include "Optional.hpp"
+#include <app.h>
+
+#define CHECK_ERROR(ret) do { \
+ if (ret != APP_CONTROL_ERROR_NONE) { \
+ DEBUG("app_control failed. err = %d", ret); \
+ } \
+ } while (false)
+
+#define RETURN_ON_ERROR(ret) do { \
+ if (ret != APP_CONTROL_ERROR_NONE) { \
+ CHECK_ERROR(ret); \
+ return true; \
+ } \
+ } while (false)
+
+namespace
+{
+ enum AppToLaunch {
+ HOME_SCREEN,
+ LOCK_SCREEN,
+ TASK_MGR
+ };
+
+ static constexpr const char *ACTIVITY_TYPE[] = {"START_HOME_SCREEN", "START_LOCK_SCREEN", "START_TASK_MGR"};
+ static constexpr const char *LAUNCH_TYPE[] = {"org.tizen.homescreen-efl", "org.tizen.lockscreen", "org.tizen.task-mgr"};
+}
+
+template <AppToLaunch appToLaunch, bool bindable>
+class AppControlActivity : public Activity, private RegisterActivity<AppControlActivity<appToLaunch, bindable>, bindable>
+{
+public:
+ constexpr static const char *activityType = ACTIVITY_TYPE[appToLaunch];
+ AppControlActivity()
+ : Activity(activityType)
+ {}
+
+ ~AppControlActivity()
+ {
+ if (app_control) {
+ auto ret = app_control_destroy(*app_control);
+ CHECK_ERROR(ret);
+ }
+ }
+
+ bool process() override
+ {
+ app_control_h tmp_app_control;
+ auto ret = app_control_create(&tmp_app_control);
+ RETURN_ON_ERROR(ret);
+
+ app_control = tmp_app_control;
+
+ ret = app_control_set_operation(*app_control, APP_CONTROL_OPERATION_DEFAULT);
+ RETURN_ON_ERROR(ret);
+
+ ret = app_control_set_app_id(*app_control, LAUNCH_TYPE[appToLaunch]);
+ RETURN_ON_ERROR(ret);
+
+ ret = app_control_send_launch_request(*app_control, NULL, NULL);
+ RETURN_ON_ERROR(ret);
+
+ return true;
+ }
+protected:
+ Optional<app_control_h> app_control;
+};
+
+class StartHomeScreenActivity : public AppControlActivity<HOME_SCREEN, true> {};
+class StartLockScreenActivity : public AppControlActivity<LOCK_SCREEN, false> {};
+class StartTaskManagerActivity : public AppControlActivity<TASK_MGR, true> {};
+
+#undef RETURN_ON_ERROR
+#undef CHECK_ERROR
\ No newline at end of file
auto homeScreen = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_HOME_SCREEN"},
defaultImg,
- std::string {},
+ "START_HOME_SCREEN",
VconfKeyType::NONE,
std::vector<std::string> {},
std::string {},
auto recentApps = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_RECENT_APPS"},
defaultImg,
- std::string {},
+ "START_TASK_MGR",
VconfKeyType::NONE,
std::vector<std::string> {},
std::string {},
std::vector<std::string> {VCONF_KEY_SOUND_ENABLED, VCONF_KEY_VIBRATION_ENABLED});
auto lock = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_LOCK"},
- defaultImg);
+ defaultImg,
+ "START_LOCK_SCREEN");
auto captureScreenshot = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_CAPTURE_SCREENSHOT"},
defaultImg);