Start app and get runnables list by homescreen 15/20215/2
authorwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
Wed, 20 Feb 2019 05:42:43 +0000 (13:42 +0800)
committerwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
Tue, 26 Feb 2019 06:06:18 +0000 (14:06 +0800)
1.add getRunnables interface.
2.add Event_AppListChanged event.
3.delete area defination in libhomescreen.hpp

Bug-AGL: SPEC-2188

Change-Id: I8344067ecadc09e917610eb0a6e191924106f012
Signed-off-by: wang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
include/libhomescreen.hpp
src/libhomescreen.cpp

index 0fed49f..e51e01c 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ * Copyright (c) 2018,2019 TOYOTA MOTOR CORPORATION
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,6 +41,7 @@ public:
        using handler_func = std::function<void(json_object*)>;
 
        enum EventType {
+               Event_Min,
                Event_ShowWindow = 1,
                Event_TapShortcut = 1,
                Event_OnScreenMessage,
@@ -47,19 +49,11 @@ public:
                Event_HideWindow,
                Event_ReplyShowWindow,
                Event_ShowNotification,
-               Event_ShowInformation
+               Event_ShowInformation,
+               Event_AppListChanged,
+               Event_Max
        };
 
-       /* Key for json obejct */
-       const char *_keyParameter = "parameter";
-       const char *_keyArea = "area";
-
-       /* display area */
-       const char *_areaNormal = "normal";
-       const char *_areaFullScreen = "fullscreen";
-       const char *_areaSplitMain = "split.main";
-       const char *_areaSplitSub = "split.sub";
-
        static const std::vector<std::string> api_list;
        static const std::vector<std::string> event_list;
 
@@ -87,6 +81,7 @@ public:
        int replyShowWindow(const char* application_id, json_object* json);
        int showNotification(json_object* json);
        int showInformation(json_object* json);
+       int getRunnables(void);
 
 
 private:
index 121def7..ad18ca4 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ * Copyright (c) 2018,2019 TOYOTA MOTOR CORPORATION
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,7 +48,8 @@ const std::vector<std::string> LibHomeScreen::api_list {
        std::string("hideWindow"),
        std::string("replyShowWindow"),
        std::string("showNotification"),
-       std::string("showInformation")
+       std::string("showInformation"),
+       std::string("getRunnables")
 };
 
 const std::vector<std::string> LibHomeScreen::event_list {
@@ -59,6 +61,7 @@ const std::vector<std::string> LibHomeScreen::event_list {
        std::string("replyShowWindow"),
        std::string("showNotification"),
        std::string("showInformation"),
+       std::string("application-list-changed"),
        std::string("none")
 };
 
@@ -303,7 +306,7 @@ int LibHomeScreen::onScreenReply(const char* reply_message)
  */
 void LibHomeScreen::set_event_handler(enum EventType et, handler_func f)
 {
-       if (et >= 1 && et <= 7) {
+       if (et > Event_Min && et < Event_Max) {
                switch (et) {
                        case Event_ShowWindow:
                                this->subscribe(LibHomeScreen::event_list[0]);
@@ -326,6 +329,9 @@ void LibHomeScreen::set_event_handler(enum EventType et, handler_func f)
                        case Event_ShowInformation:
                                this->subscribe(LibHomeScreen::event_list[6]);
                                break;
+                       case Event_AppListChanged:
+                               this->subscribe(LibHomeScreen::event_list[7]);
+                               break;
                }
 
                this->handlers[et] = std::move(f);
@@ -597,6 +603,23 @@ int LibHomeScreen::showInformation(json_object* json)
        return this->call("showInformation", json);
 }
 
+/**
+ * get runnables list
+ *
+ * Call HomeScreen Service's getRunnables verb to get runnalbes list.
+ *
+ * #### Parameters
+ * - Nothing
+ *
+ * #### Return
+ * - Returns 0 on success or -1 in case of error.
+ *
+ */
+int LibHomeScreen::getRunnables(void)
+{
+       return this->call("getRunnables", nullptr);
+}
+
 
 /************* Callback Function *************/
 
@@ -692,6 +715,12 @@ void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_m
                        i->second(json_data);
                }
        }
+       else if (strcasecmp(event_type, LibHomeScreen::event_list[7].c_str()) == 0) {
+               auto i = this->handlers.find(Event_AppListChanged);
+               if ( i != this->handlers.end() ) {
+                       i->second(json_data);
+               }
+       }
 }
 
 /**