summaryrefslogtreecommitdiffstats
path: root/src/hs-appinfo.h
diff options
context:
space:
mode:
authorwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2019-02-20 13:52:59 +0800
committerwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2019-03-25 19:42:35 +0800
commit211769e800f3a57de55b3774de82af55d2a0160a (patch)
tree07325ab1aeacb9a0c349e1927812e8080ff8744c /src/hs-appinfo.h
parent25299ef60fa4df5f590ff364cff004e90376a4bf (diff)
Start app and get runnables list by homescreen
1.start application in showWindow. 2.add "getRunnables" verb. 3.handle "application-list-changed" event from afm-main and add "application-list-changed" event. Bug-AGL: SPEC-2188 Change-Id: I619b97424d20af373a945ff502a8133339916923 Signed-off-by: wang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
Diffstat (limited to 'src/hs-appinfo.h')
-rw-r--r--src/hs-appinfo.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/hs-appinfo.h b/src/hs-appinfo.h
new file mode 100644
index 0000000..7747f52
--- /dev/null
+++ b/src/hs-appinfo.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HOMESCREEN_APPINFO_H
+#define HOMESCREEN_APPINFO_H
+
+#include <string>
+#include <mutex>
+#include <memory>
+#include <vector>
+#include <functional>
+#include <unordered_map>
+#include "hs-helper.h"
+#include "hs-proxy.h"
+
+
+struct AppDetail {
+ std::string name;
+ std::string id;
+ std::string detail; // detail json_object string
+ bool periphery;
+
+ std::string getProperty(std::string key) const;
+};
+
+class HS_AppInfo {
+public:
+ HS_AppInfo() = default;
+ ~HS_AppInfo();
+ HS_AppInfo(HS_AppInfo const &) = delete;
+ HS_AppInfo &operator=(HS_AppInfo const &) = delete;
+ HS_AppInfo(HS_AppInfo &&) = delete;
+ HS_AppInfo &operator=(HS_AppInfo &&) = delete;
+
+ static HS_AppInfo* instance(void);
+ int init(afb_api_t api);
+ void onEvent(afb_api_t api, const char *event, struct json_object *object);
+
+ void getRunnables(struct json_object **object);
+ std::string getAppProperty(const std::string appid, std::string key) const;
+ std::string checkAppId(const std::string &appid);
+
+private:
+ void updateAppDetailList(afb_api_t api, struct json_object *object);
+ void createAppDetailList(struct json_object *object);
+ std::string parseAppDetail(struct json_object *object, AppDetail &info) const;
+ void addAppDetail(struct json_object *object);
+ void removeAppDetail(std::string appid);
+ struct json_object* retrieveRunnables(struct json_object *obj_runnables, std::string id);
+ void pushAppListChangedEvent(const char *oper, struct json_object *object);
+ std::string id2appid(const std::string &id) const;
+ bool isPeripheryApp(const char *appid) const;
+
+ // applications can't display on launcher
+ const std::vector<const char*> periphery_app_list {
+ "launcher",
+ "homescreen",
+ "onscreenapp",
+ "restriction"
+ };
+
+ typedef void (HS_AppInfo::*func_handler)(afb_api_t, struct json_object*);
+ const std::unordered_map<std::string, func_handler> concerned_event_list {
+ {"afm-main/application-list-changed", &HS_AppInfo::updateAppDetailList}
+ };
+
+private:
+ static HS_AppInfo* me;
+ HS_AfmMainProxy* afmmain = nullptr;
+ std::unordered_map<std::string, std::string> appid2name;
+ std::unordered_map<std::string, std::string> name2appid;
+ std::unordered_map<std::string, AppDetail> app_detail_list;
+ std::mutex mtx;
+};
+
+#endif // HOMESCREEN_APPINFO_H \ No newline at end of file