Add direct launch option using metadata 97/244197/10
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 16 Sep 2020 01:58:38 +0000 (10:58 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Wed, 16 Sep 2020 06:07:49 +0000 (15:07 +0900)
If you want to send the launch request without using loader,
please add metadata in the tizen-manifest.xml as below:
+---------------------------------------------------------------------+
|<metadata key="http://tizen.org/metadata/direct-launch" value="yes"/>|
+---------------------------------------------------------------------+

Change-Id: I29225be7404d395130c5791e618ea0fd085a96a8
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
inc/amd_direct_launch.h [new file with mode: 0644]
src/core/amd_direct_launch.c [new file with mode: 0644]
src/core/amd_main.c

diff --git a/inc/amd_direct_launch.h b/inc/amd_direct_launch.h
new file mode 100644 (file)
index 0000000..83833e1
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#pragma once
+
+int _direct_launch_init(void);
+void _direct_launch_fini(void);
\ No newline at end of file
diff --git a/src/core/amd_direct_launch.c b/src/core/amd_direct_launch.c
new file mode 100644 (file)
index 0000000..45d0cf7
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <aul_key.h>
+#include <aul_svc.h>
+#include <bundle_internal.h>
+
+#include "amd_appinfo.h"
+#include "amd_app_property.h"
+#include "amd_direct_launch.h"
+#include "amd_noti.h"
+#include "amd_util.h"
+
+#define KEY_DIRECT_LAUNCH "http://tizen.org/metadata/direct-launch"
+
+static int __on_check_direct_launch(const char *msg, int arg1, int arg2,
+               void *arg3, bundle *b)
+{
+       const struct appinfo *ai = (const struct appinfo *)arg3;
+       uid_t target_uid = (uid_t)arg2;
+       app_property_h app_property;
+       const char *appid;
+       const char *loader_id;
+
+       loader_id = bundle_get_val(b, AUL_K_LOADER_ID);
+       if (loader_id)
+               return NOTI_CONTINUE;
+
+       appid = _appinfo_get_value(ai, AIT_NAME);
+       app_property = _app_property_find(target_uid);
+       if (_app_property_metadata_match(app_property, appid,
+                       KEY_DIRECT_LAUNCH, "yes"))
+               aul_svc_set_loader_id(b, PAD_LOADER_ID_DIRECT);
+
+       return NOTI_CONTINUE;
+}
+
+int _direct_launch_init(void)
+{
+       int r;
+
+       _D("direct launch init");
+       r = _app_property_metadata_add_filter(KEY_DIRECT_LAUNCH, "yes");
+       if (r < 0) {
+               _E("Failed to add metadata filter");
+               return -1;
+       }
+
+       _noti_listen(AMD_NOTI_MSG_LAUNCH_PREPARE_END,
+                       __on_check_direct_launch);
+       return 0;
+}
+
+void _direct_launch_fini(void)
+{
+       _D("direct launch fini");
+       _app_property_metadata_remove_filter(KEY_DIRECT_LAUNCH, "yes");
+}
+
+
index bd57014ac9c5e88b285ac73e0edaf8e52b7954ce..acaa52550b9ff6a0426cff65e64d36f9a6eda67c 100644 (file)
@@ -41,6 +41,7 @@
 #include "amd_compinfo.h"
 #include "amd_config.h"
 #include "amd_cynara.h"
+#include "amd_direct_launch.h"
 #include "amd_inotify.h"
 #include "amd_launch.h"
 #include "amd_launcher_service.h"
@@ -330,6 +331,7 @@ static int __init(void)
        _request_init();
        _noti_init();
        _compinfo_init();
+       _direct_launch_init();
        if (_appinfo_init()) {
                _E("_appinfo_init failed");
                return -1;
@@ -411,6 +413,7 @@ static void __finish(void)
        __ignore_app_dead_signal();
 
        _appinfo_fini();
+       _direct_launch_fini();
        _compinfo_fini();
        _noti_fini();
        _unix_signal_fini();