Support widget alias id 33/266633/3
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 16 Nov 2021 09:00:17 +0000 (18:00 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Wed, 17 Nov 2021 00:34:39 +0000 (00:34 +0000)
After this patch is applied, AMD supports the widget alias id feature.
If the widget application has the metadata that is widget/aliasid, AMD
sets the real widget ID and checks whether the application is running or
not.

Change-Id: Iddc846afe0b00607010a9a899c691e7409e938e9
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/amd_app_property.c
src/lib/amd_app_property.h
src/lib/amd_request.c

index 6d79c0d9fd00800a6ba25bde2fc4f98a88cbc7d6..dca5c0c44d7c9f977c5970c782930ccf5ae0016f 100644 (file)
@@ -865,6 +865,54 @@ int _app_property_set_real_appid(uid_t uid, bundle *b)
        return 0;
 }
 
+int _app_property_set_real_widget_id(uid_t uid, bundle *b)
+{
+       app_property_h app_property;
+       const char *widget_id = NULL;
+       const char *comp_type;
+       struct appinfo *ai;
+       const char *appid;
+       GList *iter;
+
+       appid = bundle_get_val(b, AUL_K_APPID);
+       if (!appid)
+               return -1;
+
+       ai = _appinfo_find(uid, appid);
+       if (!ai)
+               return -1;
+
+       comp_type = _appinfo_get_value(ai, AIT_COMPTYPE);
+       if (comp_type == NULL || strcmp(comp_type, APP_TYPE_WIDGET) != 0)
+               return -1;
+
+       app_property = _app_property_find(uid);
+       if (!app_property)
+               return -1;
+
+       iter = app_property->metadata_list;
+       while (iter) {
+               struct metadata_entity *entity = iter->data;
+               if (!strcmp(entity->appid, appid) &&
+                       !strcmp(entity->key, METADATA_WIDGET_ALIAS_ID)) {
+                       widget_id = entity->value;
+                       break;
+               }
+
+               iter = g_list_next(iter);
+       }
+
+       if (widget_id == NULL || widget_id[0] == '\0')
+               return -1;
+
+       _W("alias_id(%s), widget_id(%s)", appid, widget_id);
+       bundle_del(b, AUL_K_ORG_APPID);
+       bundle_add(b, AUL_K_ORG_APPID, appid);
+       bundle_del(b, AUL_K_APPID);
+       bundle_add(b, AUL_K_APPID, widget_id);
+       return 0;
+}
+
 static int __dispatch_app_set_alias_appid(request_h req)
 {
        int ret;
@@ -1147,6 +1195,7 @@ int _app_property_init(void)
                { METADATA_LARGEMEMORY, NULL },
                { METADATA_OOMTERMINATION, NULL },
                { METADATA_VIPAPP, NULL },
+               { METADATA_WIDGET_ALIAS_ID, NULL },
        };
        int r;
        int i;
index 97a1f6af6dd25c70b508ffaffe64a2c37e341aa3..e2c14afc3aba7aa9c480cd3b9e5c2d585fadfd52 100644 (file)
 extern "C" {
 #endif
 
+#undef METADATA_LARGEMEMORY
 #define METADATA_LARGEMEMORY "http://tizen.org/metadata/largememory"
 
+#undef METADATA_OOMTERMINATION
 #define METADATA_OOMTERMINATION "http://tizen.org/metadata/oomtermination"
 
+#undef METADATA_VIPAPP
 #define METADATA_VIPAPP "http://tizen.org/metadata/vipapp"
 
+#undef METADATA_WIDGET_ALIAS_ID
+#define METADATA_WIDGET_ALIAS_ID "http://tizen.org/metadata/widget/aliasid"
+
 typedef struct app_property_s *app_property_h;
 
 int _app_property_add_alias_info(app_property_h app_property,
@@ -91,6 +97,8 @@ int _app_property_metadata_remove_filter(const char *key, const char *value);
 
 int _app_property_set_real_appid(uid_t uid, bundle *b);
 
+int _app_property_set_real_widget_id(uid_t uid, bundle *b);
+
 #ifdef __cplusplus
 }
 #endif
index 6d93e71e2706ea786f172b44bcb1d39a110c5207..f3d145196047e1510e66acc209e3488a12b43ff9 100644 (file)
@@ -507,6 +507,7 @@ static int __check_request(request_h req)
                        req->cmd == APP_RESUME)
                bundle_del(req->kb, AUL_K_INSTANCE_ID);
 
+       _app_property_set_real_widget_id(req->t_uid, req->kb);
        _appinfo_set_effective_appid(req->t_uid, req->kb);
 
        appid = bundle_get_val(req->kb, AUL_K_APPID);