Add to check group mode from rua 28/243528/8
authorChanggyu Choi <changyu.choi@samsung.com>
Tue, 8 Sep 2020 02:13:36 +0000 (11:13 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 8 Sep 2020 05:11:07 +0000 (14:11 +0900)
Change-Id: I69dcaa6c0ac23b0d006ae50a34a9f27a7494fdd0
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
inc/amd.h
inc/amd_api_launch_mode.h [new file with mode: 0644]
inc/amd_launch_mode.h [new file with mode: 0644]
modules/rua/src/amd_rua_launch_context.c
src/core/amd_launch_mode.c [new file with mode: 0644]
src/lib/amd_api_launch_mode.c [new file with mode: 0644]

index a6fb2f642a0ac31c894dc01d31582b3b5fb3b545..538df04bde1c474f549e290054c28b3a00498218 100644 (file)
--- a/inc/amd.h
+++ b/inc/amd.h
@@ -38,3 +38,4 @@
 #include <amd_api_compinfo.h>
 #include <amd_api_comp_status.h>
 #include <amd_api_logger.h>
+#include <amd_api_launch_mode.h>
diff --git a/inc/amd_api_launch_mode.h b/inc/amd_api_launch_mode.h
new file mode 100644 (file)
index 0000000..aece88d
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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
+
+#include <stdbool.h>
+#include <sys/types.h>
+
+#include <bundle_internal.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool amd_launch_mode_is_group_mode(bundle *kb, uid_t uid);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/inc/amd_launch_mode.h b/inc/amd_launch_mode.h
new file mode 100644 (file)
index 0000000..6f76313
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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
+
+#include <stdbool.h>
+#include <sys/types.h>
+
+#include <bundle_internal.h>
+
+bool _launch_mode_is_group_mode(bundle *kb, uid_t uid);
\ No newline at end of file
index 749b760acadf41fa2c656750fedd2d860b9c0a79..c945a569e9c8360c25c7aea08085d8b5e52947a9 100644 (file)
@@ -41,6 +41,7 @@
 #define QUERY_KEY_ICON          "icon="
 #define QUERY_KEY_NAME          "name="
 #define AUL_SVC_K_URI           "__APP_SVC_URI__"
+#define APP_SVC_K_LAUNCH_MODE   "__APP_SVC_LAUNCH_MODE__"
 
 struct rua_launch_context_s {
        char *id;
@@ -233,6 +234,18 @@ int _rua_launch_context_set(bundle *kb)
 static int __on_launch_app_start_start(const char *msg, int arg1, int arg2,
                void *arg3, bundle *data)
 {
+       amd_request_h req = (amd_request_h)arg3;
+       bundle *kb = data;
+       const char *launch_mode;
+       uid_t uid;
+
+       launch_mode = bundle_get_val(kb, APP_SVC_K_LAUNCH_MODE);
+       if (launch_mode && strcmp(launch_mode, "single")) {
+               uid = amd_request_get_target_uid(req);
+               if (!amd_launch_mode_is_group_mode(kb, uid))
+                       bundle_del(kb, AUL_K_INSTANCE_ID);
+       }
+
        _rua_launch_context_free();
        _rua_launch_context_set(data);
 
diff --git a/src/core/amd_launch_mode.c b/src/core/amd_launch_mode.c
new file mode 100644 (file)
index 0000000..fff7b87
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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 <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <aul.h>
+#include <system_info.h>
+#include <aul_comp_types.h>
+
+#include <amd.h>
+
+#define APP_SVC_K_LAUNCH_MODE   "__APP_SVC_LAUNCH_MODE__"
+
+bool _launch_mode_is_group_mode(bundle *kb, uid_t uid)
+{
+       const char *str;
+       const char *mode = NULL;
+       const char *appid;
+       const char *comp_type;
+       const char *comp_id;
+       const char *type;
+       amd_appinfo_h ai;
+       amd_compinfo_h ci;
+
+       if (!kb)
+               return false;
+
+       appid = bundle_get_val(kb, AUL_K_APPID);
+       if (!appid)
+               return false;
+
+       ai = amd_appinfo_find(uid, appid);
+       if (!ai)
+               return false;
+
+       comp_type = amd_appinfo_get_value(ai, AMD_AIT_COMPTYPE);
+       if (comp_type && !strcmp(comp_type, APP_TYPE_UI)) {
+               mode = amd_appinfo_get_value(ai, AMD_AIT_LAUNCH_MODE);
+       } else if (comp_type && !strcmp(comp_type, APP_TYPE_COMPONENT_BASED)) {
+               comp_id = bundle_get_val(kb, AUL_K_COMPONENT_ID);
+               if (!comp_id)
+                       return false;
+
+               ci = amd_compinfo_find(uid, comp_id);
+               if (!ci)
+                       return false;
+
+               type = amd_compinfo_get_value(ci, AMD_COMPINFO_TYPE_TYPE);
+               if (!type || strcmp(type, "frame") != 0)
+                       return false;
+
+               mode = amd_compinfo_get_value(ci,
+                               AMD_COMPINFO_TYPE_LAUNCH_MODE);
+       }
+
+       if (mode && !strcmp(mode, "caller")) {
+               str = bundle_get_val(kb, APP_SVC_K_LAUNCH_MODE);
+               if (str && !strcmp(str, "group"))
+                       return true;
+       } else if (mode && !strcmp(mode, "group")) {
+               return true;
+       }
+
+       return false;
+}
\ No newline at end of file
diff --git a/src/lib/amd_api_launch_mode.c b/src/lib/amd_api_launch_mode.c
new file mode 100644 (file)
index 0000000..dd1f609
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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 "amd_api.h"
+#include "amd_api_launch_mode.h"
+#include "amd_launch_mode.h"
+
+EXPORT_API bool amd_launch_mode_is_group_mode(bundle *kb, uid_t uid)
+{
+       return _launch_mode_is_group_mode(kb, uid);
+}
\ No newline at end of file