UI: supports reboot from context menu
authorGiWoong Kim <giwoong.kim@samsung.com>
Wed, 16 Dec 2015 05:21:17 +0000 (14:21 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Fri, 18 Dec 2015 07:08:16 +0000 (16:08 +0900)
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 <jinh0.choi@samsung.com>
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
(cherry picked from commit 2ef8395c5aaa8076a300d1be0974060b1a7ff9b2)

tizen/src/ecs/ecs.h
tizen/src/ecs/ecs_msg.c
tizen/src/emulator.c
tizen/src/ui/menu/contextmenu.cpp
tizen/src/ui/menu/contextmenu.h
tizen/src/ui/menu/menuitem.h
tizen/src/ui/resource/icons/system_reset.png [new file with mode: 0644]
tizen/src/ui/resource/resource.qrc
tizen/src/ui/xmllayoutkeyword.h
tizen/src/ui/xmllayoutparser.cpp

index d9d055d88cab141e1a5e33a45802fc507551a6de..db41eea4158c6120cfb3728b232bfb672ff0be23 100644 (file)
@@ -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);
 
index f54b4500b295147c645140d6dce5a796e10101f1..b8fb4281c675c3313eae0014b78a86923aadd9e3 100644 (file)
@@ -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");
     }
index 5274944e68aa6b1edd5b212e2fe49074d17b22e9..6d29799f9583a5649f78eb8f83ff82e196bf2d3d 100644 (file)
@@ -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;
index e0cdfbb9cb7684162a4bcf78ec50f0fe8b614ac0..4c939fc66675026ba9638ad803d914e51cc2fd01 100644 (file)
@@ -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<MenuItem *> &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();
 }
index 63dc565140ef2aaa0a3e76fc3a5c68b8978b1629..942a077b6760184a82196b2fda0ce6811ed24773 100644 (file)
@@ -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
index d271700c3b73a36291926a3a4dc3f984df1e0ea2..0658bea27974728d0429087cfc20ec877fe428b0 100644 (file)
@@ -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 (file)
index 0000000..bb4e7c2
Binary files /dev/null and b/tizen/src/ui/resource/icons/system_reset.png differ
index ae4cf03bce28d1c58b91201c480ab679d0ffd7a4..1cf0b3178982309163a6042fd1eefbb5054880cf 100644 (file)
@@ -38,6 +38,7 @@
         <file>icons/about.png</file>
         <file>icons/advanced.png</file>
         <file>icons/close.png</file>
+        <file>icons/system_reset.png</file>
         <file>icons/force_close.png</file>
         <file>icons/rotate.png</file>
         <file>icons/scale.png</file>
index 996ed5ed325f726d967f08985779fa193ee1022d..f8d2e1071353cfe2969c48e5d1db92b95fb374f3 100644 (file)
@@ -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"
 
index 2b016ecacb6fcd9023a42eaeb392396254b41730..483afbbcd642557cded44b0b78a25bd1c99b53bc 100644 (file)
@@ -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) {