From: GiWoong Kim Date: Wed, 16 Dec 2015 05:21:17 +0000 (+0900) Subject: UI: supports reboot from context menu X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~40^2~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a2532f5f2a923e2d2671623b31ed08ecbcb8e61;p=sdk%2Femulator%2Fqemu.git UI: supports reboot from context menu When a malfunction of emulator occurs, such as no response from the guest OS, what a developer can do is selecting "force close" and restarting from emulator manager. In order to avoid the inconvenience of doing it, reboot menu is added. It is working directly to hardware after requesting sync() to guest OS ---------------- | Context menu | ---------------- | reboot | ---------------- ---------- | | emuld | ------------------------ ---------- | 1. send sync message | -------------> | sync() | | 2. start a timer | ---------- ------------------------ | The timer expires after 1s ------------------------------- | qemu_system_reset_request() | ------------------------------- Change-Id: I3c3c31c2cc19065f53b620d83c79e68e0183db53 Signed-off-by: Jinhyung Choi Signed-off-by: GiWoong Kim (cherry picked from commit 2ef8395c5aaa8076a300d1be0974060b1a7ff9b2) --- diff --git a/tizen/src/ecs/ecs.h b/tizen/src/ecs/ecs.h index d9d055d88c..db41eea415 100644 --- a/tizen/src/ecs/ecs.h +++ b/tizen/src/ecs/ecs.h @@ -62,6 +62,7 @@ #define MSG_TYPE_GUESTIP "guest_ip" #define MSG_TYPE_HDS "hds" #define MSG_TYPE_PACKAGE "package" +#define MSG_TYPE_SYSTEM "system" #define MSG_GROUP_STATUS 15 #define MSG_GROUP_HDS 100 @@ -188,7 +189,12 @@ bool ntf_to_monitor(const char* data, const int len); bool send_msg_to_guest(const char* cmd, int group, int action, char* data, int data_len); -void send_shutdown_request(void); +enum ecs_system_action { + ECS_SYSTEM_ACTION_FORCE_CLOSE, + ECS_SYSTEM_ACTION_REBOOT +}; + +void send_shutdown_request(int action); void make_send_device_ntf (char* cmd, int group, int action, char* data); diff --git a/tizen/src/ecs/ecs_msg.c b/tizen/src/ecs/ecs_msg.c index f54b4500b2..b8fb4281c6 100644 --- a/tizen/src/ecs/ecs_msg.c +++ b/tizen/src/ecs/ecs_msg.c @@ -193,9 +193,9 @@ bool send_msg_to_guest(const char* cmd, int group, int action, char* data, int d return true; } -void send_shutdown_request(void) +void send_shutdown_request(int action) { - int ret = send_msg_to_guest("system", 0, 0, NULL, 0); + int ret = send_msg_to_guest(MSG_TYPE_SYSTEM, 0, action, NULL, 0); if (!ret) { LOG_SEVERE("fail to send evdi shutdown system call to emuld.\n"); } diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 5274944e68..6d29799f95 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -125,7 +125,7 @@ static Notifier emulator_exit = { .notify = emulator_notify_exit }; static void* run_timed_shutdown_thread(void* args) { - send_shutdown_request(); + send_shutdown_request(ECS_SYSTEM_ACTION_FORCE_CLOSE); const int sleep_interval_time = 1000; /* milli-seconds */ const int timeout_for_shutdown = (uintptr_t)args; diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index e0cdfbb9cb..4c939fc666 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -40,6 +40,9 @@ extern "C" { // FIXME: To avoid very complex header inclusion chains void qemu_system_graceful_shutdown_request(unsigned int sec); +void qemu_system_reset_request(void); +#define MENU_ACTION_REBOOT 1 +void send_shutdown_request(int action); #include "util/device_hotplug.h" #include "util/ui_operations.h" @@ -79,6 +82,9 @@ ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent) /* for close */ longPressTimer = new QTimer(this); + /* for system reset */ + rebootTimer = new QTimer(this); + createItems(this, this->parent->getUiInfo()->getMenuList()); installEventFilter(this); @@ -142,6 +148,10 @@ void ContextMenu::createItems(QMenu *menu, QList &list) /* About menu */ createAboutItem(menu, item); break; + case MenuItemType::systemResetItem: + /* System Reset menu */ + createSystemResetItem(menu, item); + break; case MenuItemType::forceCloseItem: /* Force Close menu */ createForceCloseItem(menu, item); @@ -520,6 +530,23 @@ void ContextMenu::createAboutItem(QMenu *menu, MenuItem *item) item->setAction(actionAbout); } +void ContextMenu::createSystemResetItem(QMenu *menu, MenuItem *item) +{ + if (menu == NULL || item == NULL) { + return; + } + + QString menuName = item->getName(); + actionSystemReset = addGeneralAction( + menu, QIcon(QPixmap(":/icons/system_reset.png")), + menuName.isEmpty() ? MENU_FORCECLOSE_ITEM_TEXT : menuName, + item->getShortcuts().isEmpty()? NULL : + new QShortcut(item->getShortcuts().begin().value(), parent), + SLOT(slotSystemReset())); + + item->setAction(actionSystemReset); +} + void ContextMenu::createForceCloseItem(QMenu *menu, MenuItem *item) { if (menu == NULL || item == NULL) { @@ -1011,6 +1038,27 @@ void ContextMenu::slotAbout() #endif } +void ContextMenu::slotDeviceReset() +{ + qDebug("System reset request."); + qemu_system_reset_request(); + qDebug("Done for system reset request."); +} + +void ContextMenu::slotSystemReset() +{ + qDebug("Reboot."); + + send_shutdown_request(MENU_ACTION_REBOOT); + + qDebug("Sent sync message to emuld."); + + rebootTimer->setInterval(HARDWARE_REBOOT_INTERVAL); + rebootTimer->setSingleShot(true); + connect(rebootTimer, SIGNAL(timeout()), this, SLOT(slotDeviceReset())); + rebootTimer->start(); +} + void ContextMenu::slotForceClose() { qDebug("force close"); @@ -1084,4 +1132,6 @@ ContextMenu::~ContextMenu() delete shellOpener; longPressTimer->stop(); + + rebootTimer->stop(); } diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index 63dc565140..942a077b67 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -49,6 +49,7 @@ extern "C" { } #define CLOSE_POWER_KEY_INTERVAL 1200 /* milli-seconds */ +#define HARDWARE_REBOOT_INTERVAL 1000 /* milli-seconds */ class ContextMenu : public QMenu { @@ -96,6 +97,9 @@ public slots: void slotHostKeyboard(bool on); void slotAbout(); + void slotSystemReset(); + void slotDeviceReset(); + void slotForceClose(); void slotClose(); void slotPwkeyRelease(); @@ -116,6 +120,7 @@ protected: void createControlPanelItem(QMenu *menu, MenuItem *item); void createScreenShotItem(QMenu *menu, MenuItem *item); void createAboutItem(QMenu *menu, MenuItem *item); + void createSystemResetItem(QMenu *menu, MenuItem *item); void createForceCloseItem(QMenu *menu, MenuItem *item); void createCloseItem(QMenu *menu, MenuItem *item); bool eventFilter(QObject *obj, QEvent *event); @@ -146,6 +151,7 @@ private: QAction *actionControlPanel; QAction *actionScreenShot; QAction *actionAbout; + QAction *actionSystemReset; QAction *actionForceClose; QAction *actionClose; @@ -155,5 +161,6 @@ private: ShellOpener *shellOpener; QTimer *longPressTimer; + QTimer *rebootTimer; }; #endif // CONTEXTMENU_H diff --git a/tizen/src/ui/menu/menuitem.h b/tizen/src/ui/menu/menuitem.h index d271700c3b..0658bea279 100644 --- a/tizen/src/ui/menu/menuitem.h +++ b/tizen/src/ui/menu/menuitem.h @@ -50,6 +50,7 @@ namespace MenuItemType controlPanelItem, screenShotItem, aboutItem, + systemResetItem, forceCloseItem, closeItem, }; diff --git a/tizen/src/ui/resource/icons/system_reset.png b/tizen/src/ui/resource/icons/system_reset.png new file mode 100644 index 0000000000..bb4e7c203d Binary files /dev/null and b/tizen/src/ui/resource/icons/system_reset.png differ diff --git a/tizen/src/ui/resource/resource.qrc b/tizen/src/ui/resource/resource.qrc index ae4cf03bce..1cf0b31789 100644 --- a/tizen/src/ui/resource/resource.qrc +++ b/tizen/src/ui/resource/resource.qrc @@ -38,6 +38,7 @@ icons/about.png icons/advanced.png icons/close.png + icons/system_reset.png icons/force_close.png icons/rotate.png icons/scale.png diff --git a/tizen/src/ui/xmllayoutkeyword.h b/tizen/src/ui/xmllayoutkeyword.h index 996ed5ed32..f8d2e10713 100644 --- a/tizen/src/ui/xmllayoutkeyword.h +++ b/tizen/src/ui/xmllayoutkeyword.h @@ -79,6 +79,7 @@ #define ECP_MENU_KEYWORD "controlPanelItem" #define SCREENSHOT_MENU_KEYWORD "screenShotItem" #define ABOUT_MENU_KEYWORD "aboutItem" +#define SYSTEM_RESET_MENU_KEYWORD "rebootItem" #define FORCECLOSE_MENU_KEYWORD "forceCloseItem" #define CLOSE_MENU_KEYWORD "closeItem" diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp index 2b016ecacb..483afbbcd6 100644 --- a/tizen/src/ui/xmllayoutparser.cpp +++ b/tizen/src/ui/xmllayoutparser.cpp @@ -502,6 +502,8 @@ int XmlLayoutParser::parseMenuList( item = parseGeneralMenuItem(xml, MenuItemType::screenShotItem); } else if (xml.name() == ABOUT_MENU_KEYWORD) { item = parseGeneralMenuItem(xml, MenuItemType::aboutItem); + } else if (xml.name() == SYSTEM_RESET_MENU_KEYWORD) { + item = parseGeneralMenuItem(xml, MenuItemType::systemResetItem); } else if (xml.name() == FORCECLOSE_MENU_KEYWORD) { item = parseGeneralMenuItem(xml, MenuItemType::forceCloseItem); } else if (xml.name() == CLOSE_MENU_KEYWORD) {