Add AUL_SVC_RET_ETIMEOUT error
[platform/core/appfw/aul-1.git] / src / aul_svc.cc
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <bundle.h>
18 #include <bundle_cpp.h>
19 #include <bundle_internal.h>
20 #include <dlfcn.h>
21 #include <glib.h>
22 #include <iniparser.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <sys/stat.h>
27 #include <sys/types.h>
28
29 #include <atomic>
30 #include <memory>
31 #include <string>
32 #include <vector>
33
34 #include "aul/app_control/resolve_info.hh"
35 #include "include/aul.h"
36 #include "include/aul_app_group.h"
37 #include "include/aul_error.h"
38 #include "include/aul_sock.h"
39 #include "include/aul_svc.h"
40 #include "include/aul_svc_internal.h"
41 #include "src/aul_api.h"
42 #include "src/aul_svc_priv_key.h"
43 #include "src/aul_util.h"
44 #include "src/launch.h"
45
46 #undef MAX_MIME_STR_SIZE
47 #define MAX_MIME_STR_SIZE 256
48
49 #undef MAX_SCHEME_STR_SIZE
50 #define MAX_SCHEME_STR_SIZE 256
51
52 #undef MAX_HOST_STR_SIZE
53 #define MAX_HOST_STR_SIZE 256
54
55 #undef DEPRECATION_WARNING
56 #define DEPRECATION_WARNING() do {                                             \
57     dlog_print(DLOG_WARN, LOG_TAG,                                             \
58         "DEPRECATION WARNING: %s() is deprecated and "                         \
59         "will be removed from next release.", __FUNCTION__);                   \
60 } while (0)
61
62 namespace {
63
64 constexpr const char kPathAmdReady[] = "/run/.amd_ready";
65 constexpr const char kPathLibAulServer[] = LIBDIR "/libaul-server.so.0";
66 constexpr const char kAulServiceForeachUsrAliasInfo[] =
67     "aul_service_foreach_usr_alias_info";
68
69 class CbInfo {
70  public:
71   CbInfo(int request_code, aul_svc_res_fn res_fn,
72       aul_svc_err_cb err_cb, void* user_data)
73       : request_code_(request_code),
74         res_fn_(res_fn),
75         err_cb_(err_cb),
76         user_data_(user_data) {
77   }
78
79   int request_code_;
80   aul_svc_res_fn res_fn_;
81   aul_svc_err_cb err_cb_;
82   void* user_data_;
83 };
84
85 class AliasInfo {
86  public:
87   explicit AliasInfo(std::string alias_appid)
88       : alias_appid_(std::move(alias_appid)) {
89   }
90
91   std::string alias_appid_;
92   std::string appid_;
93 };
94
95 int SetBundle(bundle* b, const char* key, const char* value) {
96   if (bundle_get_type(b, key) != BUNDLE_TYPE_NONE) {
97     if (bundle_del(b, key) != BUNDLE_ERROR_NONE)
98       return AUL_SVC_RET_ERROR;
99   }
100
101   if (value == nullptr)
102     return AUL_SVC_RET_EINVAL;
103
104   if (bundle_add(b, key, value) != BUNDLE_ERROR_NONE)
105     return AUL_SVC_RET_ERROR;
106
107   SECURE_LOGD("key(%s), value(%s)", key, value);
108   return AUL_SVC_RET_OK;
109 }
110
111 int SetBundleArray(bundle* b, const char* key, const char** value,
112     int len) {
113   int is_array = aul_svc_data_is_array(b, key);
114   if (is_array) {
115     if (bundle_del(b, key) != BUNDLE_ERROR_NONE)
116       return AUL_SVC_RET_ERROR;
117   }
118
119   if (value == nullptr)
120     return AUL_SVC_RET_EINVAL;
121
122   if (bundle_add_str_array(b, key, value, len) != BUNDLE_ERROR_NONE)
123     return AUL_SVC_RET_ERROR;
124
125   SECURE_LOGD("key(%s), length(%d)", key, len);
126   return AUL_SVC_RET_OK;
127 }
128
129 std::string GetAliasAppId(const char* appid) {
130   dictionary* dic = iniparser_load("/usr/share/appsvc/alias.ini");
131   if (dic == nullptr)
132     return {};
133
134   auto dic_ptr = std::unique_ptr<dictionary, decltype(iniparser_freedict)*>(
135       dic, iniparser_freedict);
136
137   std::string key = std::string("Alias:") + appid;
138   const char* value = iniparser_getstring(dic, key.c_str(), nullptr);
139   SECURE_LOGD("appid(%s), alias_id(%s)", appid, value);
140   if (value == nullptr)
141     return {};
142
143   return std::string(value);
144 }
145
146 bool IsSpecialApp(const char* appid) {
147   if (!strcmp(appid, APP_SELECTOR) || !strcmp(appid, SHARE_PANEL))
148     return true;
149
150   return false;
151 }
152
153 bool IsSpecialOperation(const char* operation) {
154   if (operation == nullptr)
155     return false;
156
157   int ret = strcmp(operation,
158       "http://tizen.org/appcontrol/operation/guide_privacy_setting");
159   if (ret == 0)
160     return true;
161
162   return false;
163 }
164
165 std::string GetAppId(bundle* request) {
166   const char* appid = aul_svc_get_pkgname(request);
167   if (appid == nullptr) {
168     if (aul_svc_get_operation(request) == nullptr) {
169       _E("Invalid request");
170       return {};
171     }
172
173     appid = "@UNKNOWN";
174   }
175
176   int ret = bundle_get_type(request, AUL_SVC_K_SELECTOR_EXTRA_LIST);
177   if (ret != BUNDLE_TYPE_NONE) {
178     if (appid == nullptr || !strcmp(appid, "@UNKNOWN"))
179       appid = APP_SELECTOR;
180   }
181
182   ret = bundle_get_type(request, AUL_K_FORCE_LAUNCH_APP_SELECTOR);
183   if (ret != BUNDLE_TYPE_NONE)
184     appid = APP_SELECTOR;
185
186   return std::string(appid);
187 }
188
189 void SetLaunchData(bundle* request, const std::string& appid) {
190   const char* operation = aul_svc_get_operation(request);
191   if (operation == nullptr)
192     aul_svc_set_operation(request, AUL_SVC_OPERATION_DEFAULT);
193
194   if (IsSpecialApp(appid.c_str()) || IsSpecialOperation(operation)) {
195     SetBundle(request, AUL_SVC_K_CAN_BE_LEADER, "true");
196     SetBundle(request, AUL_SVC_K_REROUTE, "true");
197     SetBundle(request, AUL_SVC_K_RECYCLE, "true");
198   }
199
200   const char* launch_mode = aul_svc_get_launch_mode(request);
201   if (launch_mode && !strcmp(launch_mode, "group")) {
202     int ret = bundle_get_type(request, AUL_K_INSTANCE_ID);
203     if (ret == BUNDLE_TYPE_NONE)
204       aul_set_instance_info(appid.c_str(), request);
205   }
206 }
207
208 int AulErrorConvert(int res) {
209   switch (res) {
210   case AUL_R_EILLACC:
211     return AUL_SVC_RET_EILLACC;
212   case AUL_R_EINVAL:
213     return AUL_SVC_RET_EINVAL;
214   case AUL_R_ETERMINATING:
215     return AUL_SVC_RET_ETERMINATING;
216   case AUL_R_EREJECTED:
217     return AUL_SVC_RET_EREJECTED;
218   case AUL_R_ENOAPP:
219     return AUL_SVC_RET_ENOMATCH;
220   case AUL_R_ECANCELED:
221     return AUL_SVC_RET_ECANCELED;
222   case AUL_R_ETIMEOUT:
223     return AUL_SVC_RET_ETIMEOUT;
224   default:
225     return AUL_SVC_RET_ELAUNCH;
226   }
227 }
228
229 void LaunchWithResultCb(bundle* b, int is_cancel, void* data) {
230   int res;
231   if (is_cancel) {
232     res = AUL_SVC_RES_CANCEL;
233   } else {
234     const char* val = bundle_get_val(b, AUL_SVC_K_RES_VAL);
235     res = (val == nullptr) ? AUL_SVC_RES_NOT_OK : atoi(val);
236   }
237
238   bundle_del(b, AUL_SVC_K_RES_VAL);
239   auto* cb_info = static_cast<CbInfo*>(data);
240   if (cb_info == nullptr) {
241     _E("Invalid parameter");
242     return;
243   }
244
245   if (cb_info->res_fn_) {
246     cb_info->res_fn_(b, cb_info->request_code_,
247         static_cast<aul_svc_result_val>(res), cb_info->user_data_);
248     cb_info->res_fn_ = nullptr;
249   }
250
251   if (cb_info->err_cb_ != nullptr)
252     return;
253
254   delete cb_info;
255 }
256
257 void ErrorCb(int error, void* data) {
258   if (error < 0)
259     error = AulErrorConvert(error);
260
261   auto* cb_info = static_cast<CbInfo*>(data);
262   if (cb_info == nullptr) {
263     _E("Invalid parameter");
264     return;
265   }
266
267   if (cb_info->err_cb_) {
268     cb_info->err_cb_(cb_info->request_code_, error, cb_info->user_data_);
269     cb_info->err_cb_ = nullptr;
270   }
271
272   if (cb_info->res_fn_)
273     return;
274
275   delete cb_info;
276 }
277
278 using SendLaunchRequestCb =
279     int (*)(const std::string&, bundle*, uid_t, CbInfo*);
280 using SendLaunchRequestSyncCb =
281     int (*)(const std::string&, bundle*, uid_t, bundle**);
282
283 template <typename T, typename A>
284 int SendLaunchRequest(T cb, bundle* request, uid_t uid, A arg) {
285   if (request == nullptr) {
286     _E("Invalid parameter");
287     return AUL_SVC_RET_EINVAL;
288   }
289
290   std::string appid = GetAppId(request);
291   if (appid.empty()) {
292     _E("GetAppId() is failed");
293     return AUL_SVC_RET_EINVAL;
294   }
295
296   SetLaunchData(request, appid);
297   return cb(appid, request, uid, arg);
298 }
299
300 int SendAndReceive(int cmd, uid_t uid, bundle* request, bundle** response) {
301   int fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, cmd, request,
302       AUL_SOCK_ASYNC);
303   if (fd < 0)
304     return AUL_SVC_RET_ERROR;
305
306   app_pkt_t* pkt = nullptr;
307   int ret = aul_sock_recv_reply_pkt(fd, &pkt);
308   if (ret < 0) {
309     _E("Failed to receive reply packet. error(%d)", ret);
310     return AUL_SVC_RET_ERROR;
311   }
312
313   auto ptr = std::unique_ptr<app_pkt_t, decltype(std::free)*>(pkt, std::free);
314   if (pkt->cmd != APP_GET_INFO_OK && pkt->cmd != cmd) {
315     if (pkt->cmd == APP_GET_INFO_ERROR)
316       return AUL_SVC_RET_ERROR;
317
318     return AulErrorConvert(aul_error_convert(pkt->cmd));
319   }
320
321   bundle* b = nullptr;
322   if (pkt->opt & AUL_SOCK_BUNDLE) {
323     b = bundle_decode(pkt->data, pkt->len);
324     if (b == nullptr) {
325       _E("bundle_decode() is failed");
326       return AUL_SVC_RET_ENOMEM;
327     }
328   } else {
329     _E("Invalid packet");
330     return AUL_SVC_RET_ERROR;
331   }
332
333   *response = b;
334   return AUL_SVC_RET_OK;
335 }
336
337 std::atomic<bool> amd_ready { false };
338 bool IsAmdReady() {
339   if (amd_ready)
340     return amd_ready;
341
342   if (access(kPathAmdReady, F_OK) == 0) {
343     amd_ready.exchange(true);
344     return amd_ready;
345   }
346
347   return false;
348 }
349
350 using AulServiceAliasInfoCb =
351     bool (*)(const char*, const char*, void*);
352 using AulServiceForeachUsrAliasInfoFunc =
353     int (*)(AulServiceAliasInfoCb, uid_t, void*);
354
355 int GetAppIdByAliasAppIdFromDB(const char* alias_appid, char** app_id,
356     uid_t uid) {
357   void* handle = dlopen(kPathLibAulServer, RTLD_LAZY | RTLD_GLOBAL);
358   if (handle == nullptr) {
359     _E("dlopen() is failed. path(%s), error(%s)", kPathLibAulServer, dlerror());
360     return AUL_SVC_RET_ERROR;
361   }
362
363   auto dl_closer = [](void* ptr) {
364     dlclose(ptr);
365   };
366
367   std::unique_ptr<void, decltype(dl_closer)> handle_auto(handle, dl_closer);
368   auto* func = reinterpret_cast<AulServiceForeachUsrAliasInfoFunc>(
369       dlsym(handle, kAulServiceForeachUsrAliasInfo));
370   if (func == nullptr) {
371     _E("dlsym() is failed. error(%s)", dlerror());
372     return AUL_SVC_RET_ERROR;
373   }
374
375   AliasInfo info(alias_appid);
376   int ret = func(
377       [](const char* alias_appid, const char* appid, void* user_data) -> bool {
378         auto* info = static_cast<AliasInfo*>(user_data);
379         if (info->alias_appid_ == alias_appid) {
380           info->appid_ = appid;
381           return false;
382         }
383
384         return true;
385       }, uid, &info);
386   if (ret != 0) {
387     _E("%s() is failed. error(%d)", kAulServiceForeachUsrAliasInfo, ret);
388     return AUL_SVC_RET_ERROR;
389   }
390
391   if (info.appid_.empty())
392     return AUL_SVC_RET_ERROR;
393
394   *app_id = strdup(info.appid_.c_str());
395   if (*app_id == nullptr) {
396     _E("strdup() is failed");
397     return AUL_SVC_RET_ENOMEM;
398   }
399
400   return AUL_SVC_RET_OK;
401 }
402
403 }  // namespace
404
405 extern "C" API int aul_svc_set_operation(bundle* b, const char* operation) {
406   if (b == nullptr) {
407     _E("Invalid parameter");
408     return AUL_SVC_RET_EINVAL;
409   }
410
411   return ::SetBundle(b, AUL_SVC_K_OPERATION, operation);
412 }
413
414 extern "C" API int aul_svc_set_uri(bundle* b, const char* uri) {
415   if (b == nullptr) {
416     _E("Invalid parameter");
417     return AUL_SVC_RET_EINVAL;
418   }
419
420   return ::SetBundle(b, AUL_SVC_K_URI, uri);
421 }
422
423 extern "C" API int aul_svc_set_mime(bundle* b, const char* mime) {
424   if (b == nullptr) {
425     _E("Invalid parameter");
426     return AUL_SVC_RET_EINVAL;
427   }
428
429   return ::SetBundle(b, AUL_SVC_K_MIME, mime);
430 }
431
432 extern "C" API int aul_svc_add_data(bundle* b, const char* key,
433     const char* value) {
434   if (b == nullptr || key == nullptr)
435     return AUL_SVC_RET_EINVAL;
436
437   return ::SetBundle(b, key, value);
438 }
439
440 extern "C" API int aul_svc_add_data_array(bundle* b, const char* key,
441     const char** value, int len) {
442   if (b == nullptr || key == nullptr)
443     return AUL_SVC_RET_EINVAL;
444
445   return ::SetBundleArray(b, key, value, len);
446 }
447
448 extern "C" API int aul_svc_set_pkgname(bundle* b, const char* pkg_name) {
449   if (b == nullptr) {
450     _E("Invalid parameter");
451     return AUL_SVC_RET_EINVAL;
452   }
453
454   return ::SetBundle(b, AUL_SVC_K_PKG_NAME, pkg_name);
455 }
456
457 extern "C" API int aul_svc_set_appid(bundle* b, const char* appid) {
458   if (b == nullptr || appid == nullptr) {
459     _E("Invalid parameter");
460     return AUL_SVC_RET_EINVAL;
461   }
462
463   std::string alias_id = ::GetAliasAppId(appid);
464   if (!alias_id.empty())
465     appid = alias_id.c_str();
466
467   return ::SetBundle(b, AUL_SVC_K_PKG_NAME, appid);
468 }
469
470 extern "C" API int aul_svc_set_category(bundle* b, const char* category) {
471   if (b == nullptr) {
472     _E("Invalid parameter");
473     return AUL_SVC_RET_EINVAL;
474   }
475
476   return ::SetBundle(b, AUL_SVC_K_CATEGORY, category);
477 }
478
479 extern "C" API int aul_svc_set_launch_mode(bundle* b, const char* mode) {
480   if (b == nullptr) {
481     _E("Invalid parameter");
482     return AUL_SVC_RET_EINVAL;
483   }
484
485   return ::SetBundle(b, AUL_SVC_K_LAUNCH_MODE, mode);
486 }
487
488 extern "C" API int aul_svc_resolve(bundle* b, uid_t uid, char*** appid_array,
489     unsigned int* len) {
490   return aul_svc_get_appid_array(b, uid, appid_array, len);
491 }
492
493 extern "C" API int aul_svc_run_service(bundle* b, int request_code,
494     aul_svc_res_fn cbfunc, void* data) {
495   return aul_svc_run_service_for_uid(b, request_code, cbfunc, data, getuid());
496 }
497
498 extern "C" API int aul_svc_run_service_for_uid(bundle* b, int request_code,
499   aul_svc_res_fn cbfunc, void* data, uid_t uid) {
500   CbInfo* cb_info = nullptr;
501   if (cbfunc) {
502     cb_info = new (std::nothrow) CbInfo(request_code, cbfunc, nullptr, data);
503     if (cb_info == nullptr)
504       LOGE("Out of memory");
505   }
506
507   std::tuple<aul_svc_res_fn, void*> param { cbfunc, data };
508   int ret = ::SendLaunchRequest<::SendLaunchRequestCb, ::CbInfo*>(
509       [](const std::string& appid, bundle* request, uid_t uid,
510           CbInfo* cb_info) -> int {
511         int ret;
512         if (cb_info) {
513           ret = aul_launch_app_with_result_for_uid(appid.c_str(), request,
514               LaunchWithResultCb, cb_info, uid);
515          } else {
516           ret = aul_launch_app_for_uid(appid.c_str(), request, uid);
517         }
518
519         return ret;
520       }, b, uid, cb_info);
521   if (ret < 0) {
522     if (cb_info)
523       delete cb_info;
524
525     ret = AulErrorConvert(ret);
526   }
527
528   return ret;
529 }
530
531 extern "C" API int aul_svc_get_list(bundle* b, aul_svc_info_iter_fn iter_fn,
532     void* data) {
533   return aul_svc_get_list_for_uid(b, iter_fn, data, getuid());
534 }
535
536 extern "C" API int aul_svc_get_list_for_uid(bundle* b,
537     aul_svc_info_iter_fn iter_fn, void* data, uid_t uid) {
538   if (b == nullptr || iter_fn == nullptr) {
539     _E("Invalid parameter");
540     return AUL_SVC_RET_EINVAL;
541   }
542
543   char** appid_array = nullptr;
544   unsigned int len = 0;
545   int ret = aul_svc_get_appid_array(b, uid, &appid_array, &len);
546   if (ret != AUL_SVC_RET_OK)
547     return ret;
548
549   if (len == 0) {
550     _E("Failed to find associated application");
551     aul_svc_free_appid_array(appid_array, len);
552     return AUL_SVC_RET_ENOMATCH;
553   }
554
555   for (unsigned int i = 0; i < len; ++i) {
556     SECURE_LOGD("APPID: %s", appid_array[i]);
557     if (iter_fn(appid_array[i], data) != 0)
558       break;
559   }
560
561   aul_svc_free_appid_array(appid_array, len);
562   return AUL_SVC_RET_OK;
563 }
564
565 extern "C" API int aul_svc_get_all_defapps(aul_svc_info_iter_fn iter_fn,
566     void* data) {
567   return aul_svc_get_all_defapps_for_uid(iter_fn, data, getuid());
568 }
569
570 extern "C" API int aul_svc_get_all_defapps_for_uid(aul_svc_info_iter_fn iter_fn,
571     void* data, uid_t uid) {
572   if (iter_fn == nullptr) {
573     _E("Invalid parameter");
574     return AUL_SVC_RET_EINVAL;
575   }
576
577   bundle* response;
578   tizen_base::Bundle request;
579   int ret = ::SendAndReceive(APP_GET_APP_CONTROL_DEFAULT_APPS, uid,
580       request.GetHandle(), &response);
581   if (ret != AUL_SVC_RET_OK)
582     return ret;
583
584   tizen_base::Bundle res(response, false, true);
585   auto appid_array = res.GetStringArray(AUL_K_APPID_LIST);
586   for (auto& appid : appid_array) {
587     if (iter_fn(appid.c_str(), data) != 0)
588       break;
589   }
590
591   return AUL_SVC_RET_OK;
592 }
593
594 extern "C" API const char* aul_svc_get_operation(bundle* b) {
595   return bundle_get_val(b, AUL_SVC_K_OPERATION);
596 }
597
598 extern "C" API const char* aul_svc_get_uri(bundle* b) {
599   return bundle_get_val(b, AUL_SVC_K_URI);
600 }
601
602 extern "C" API const char* aul_svc_get_mime(bundle* b) {
603   return bundle_get_val(b, AUL_SVC_K_MIME);
604 }
605
606 extern "C" API const char* aul_svc_get_data(bundle* b, const char* key) {
607   return bundle_get_val(b, key);
608 }
609
610 extern "C" API const char** aul_svc_get_data_array(bundle* b, const char* key,
611     int* len) {
612   return bundle_get_str_array(b, key, len);
613 }
614
615 extern "C" API const char* aul_svc_get_pkgname(bundle* b) {
616   return bundle_get_val(b, AUL_SVC_K_PKG_NAME);
617 }
618
619 extern "C" API const char* aul_svc_get_appid(bundle* b) {
620   return bundle_get_val(b, AUL_SVC_K_PKG_NAME);
621 }
622
623 extern "C" API const char* aul_svc_get_category(bundle* b) {
624   return bundle_get_val(b, AUL_SVC_K_CATEGORY);
625 }
626
627 extern "C" API const char* aul_svc_get_launch_mode(bundle* b) {
628   return bundle_get_val(b, AUL_SVC_K_LAUNCH_MODE);
629 }
630
631 extern "C" API int aul_svc_create_result_bundle(bundle* inb, bundle** outb) {
632   if (inb == nullptr || outb == nullptr) {
633     _E("Invalid parameter");
634     return AUL_SVC_RET_EINVAL;
635   }
636
637   int ret = aul_create_result_bundle(inb, outb);
638   if (ret != AUL_R_OK)
639     return AulErrorConvert(ret);
640
641   return AUL_SVC_RET_OK;
642 }
643
644 extern "C" API int aul_svc_send_result(bundle* b, aul_svc_result_val result) {
645   if (b == nullptr) {
646     _E("Invalid parameter");
647     return AUL_SVC_RET_EINVAL;
648   }
649
650   int ret = ::SetBundle(b, AUL_SVC_K_RES_VAL, std::to_string(result).c_str());
651   if (ret < 0)
652     return AUL_SVC_RET_ERROR;
653
654   if (result == AUL_SVC_RES_CANCEL)
655     ret = aul_send_result(b, 1);
656   else
657     ret = aul_send_result(b, 0);
658
659   bundle_del(b, AUL_SVC_K_RES_VAL);
660   return ret;
661 }
662
663 extern "C" API int aul_svc_data_is_array(bundle* b, const char* key) {
664   int type = bundle_get_type(b, key);
665   if (type <= 0)
666     return 0;
667
668   if (type & BUNDLE_TYPE_ARRAY)
669     return 1;
670
671   return 0;
672 }
673
674 extern "C" API int aul_svc_allow_transient_app(bundle* b, int wid) {
675   if (b == nullptr) {
676     _E("Invalid parameter");
677     return AUL_SVC_RET_EINVAL;
678   }
679
680   return ::SetBundle(b, AUL_SVC_K_WIN_ID, std::to_string(wid).c_str());
681 }
682
683 extern "C" API int aul_svc_request_transient_app(bundle* b, int callee_wid,
684     aul_svc_host_res_fn cbfunc, void* data) {
685   return 0;
686 }
687
688 extern "C" API int aul_svc_subapp_terminate_request_pid(int pid) {
689   int cpid = getpid();
690   int lcnt;
691   int* lpids = nullptr;
692   aul_app_group_get_leader_pids(&lcnt, &lpids);
693   for (int i = 0; i < lcnt; ++i) {
694     if (lpids[i] == cpid) {
695       int cnt;
696       int* pids = nullptr;
697       aul_app_group_get_group_pids(cpid, &cnt, &pids);
698       if (cnt == 0) {
699         free(lpids);
700         if (pids)
701           free(pids);
702
703         return aul_subapp_terminate_request_pid(pid);
704       }
705
706       if (pids != nullptr)
707         free(pids);
708       break;
709     }
710   }
711
712   if (lpids != nullptr)
713     free(lpids);
714
715   return aul_app_group_clear_top();
716 }
717
718 extern "C" API int aul_send_service_result(bundle* b) {
719   return aul_send_result(b, 0);
720 }
721
722 extern "C" API int aul_svc_subscribe_launch_result(bundle* b,
723     const char* result) {
724   if (b == nullptr) {
725     _E("Invalid parameter");
726     return AUL_SVC_RET_EINVAL;
727   }
728
729   return ::SetBundle(b, result, "1");
730 }
731
732 extern "C" API int aul_svc_set_loader_id(bundle* b, int loader_id) {
733   if (b == nullptr || loader_id <= 0) {
734     _E("Invalid parameter");
735     return AUL_SVC_RET_EINVAL;
736   }
737
738   return ::SetBundle(b, AUL_K_LOADER_ID, std::to_string(loader_id).c_str());
739 }
740
741 extern "C" API int aul_svc_set_loader_name(bundle* b, const char* loader_name) {
742   if (b == nullptr || loader_name == nullptr) {
743     _E("Invalid parameter");
744     return AUL_SVC_RET_EINVAL;
745   }
746
747   return ::SetBundle(b, AUL_K_LOADER_NAME, loader_name);
748 }
749
750 extern "C" API int aul_svc_set_background_launch(bundle* b, int enabled) {
751   if (b == nullptr) {
752     _E("Invalid parameter");
753     return AUL_SVC_RET_EINVAL;
754   }
755
756   return ::SetBundle(b, AUL_SVC_K_BG_LAUNCH, enabled ? "enable" : nullptr);
757 }
758
759 extern "C" API int aul_svc_get_appid_by_alias_appid(const char* alias_appid,
760     char** appid) {
761   return aul_svc_get_appid_by_alias_appid_for_uid(alias_appid, appid, getuid());
762 }
763
764 extern "C" API int aul_svc_get_appid_by_alias_appid_for_uid(
765     const char* alias_appid, char** appid, uid_t uid) {
766   if (alias_appid == nullptr || appid == nullptr) {
767     _E("Invalid parameter");
768     return AUL_SVC_RET_EINVAL;
769   }
770
771   if (!IsAmdReady())
772     return GetAppIdByAliasAppIdFromDB(alias_appid, appid, uid);
773
774   bundle* response;
775   tizen_base::Bundle request;
776   request.Add(AUL_K_ALIAS_APPID, alias_appid);
777   int ret = ::SendAndReceive(APP_GET_APPID_BY_ALIAS_APPID, uid,
778       request.GetHandle(), &response);
779   if (ret != AUL_SVC_RET_OK)
780     return ret;
781
782   tizen_base::Bundle res(response, false, true);
783   auto val = res.GetString(AUL_K_APPID);
784   if (val.empty())
785     return AUL_SVC_RET_ERROR;
786
787   *appid = strdup(val.c_str());
788   if (*appid == nullptr) {
789     _E("Out of memory");
790     return AUL_SVC_RET_ENOMEM;
791   }
792
793   return AUL_SVC_RET_OK;
794 }
795
796 extern "C" API const char *aul_svc_get_instance_id(bundle* b) {
797   return bundle_get_val(b, AUL_K_INSTANCE_ID);
798 }
799
800 extern "C" API int aul_svc_set_instance_id(bundle* b, const char* instance_id) {
801   if (b == nullptr) {
802     _E("Invalid parameter");
803     return AUL_SVC_RET_EINVAL;
804   }
805
806   return ::SetBundle(b, AUL_K_INSTANCE_ID, instance_id);
807 }
808
809 extern "C" API int aul_svc_run_service_async(bundle* b, int request_code,
810     aul_svc_res_fn cbfunc, void* data) {
811   return aul_svc_run_service_async_for_uid(b, request_code, cbfunc, data,
812       getuid());
813 }
814
815 extern "C" API int aul_svc_run_service_async_for_uid(bundle* b,
816     int request_code, aul_svc_res_fn cbfunc, void* data, uid_t uid) {
817   CbInfo* cb_info = nullptr;
818   if (cbfunc)
819     cb_info = new (std::nothrow) CbInfo(request_code, cbfunc, nullptr, data);
820
821   int ret = ::SendLaunchRequest<::SendLaunchRequestCb, ::CbInfo*>(
822       [](const std::string& appid, bundle* request, uid_t uid,
823           CbInfo* info) -> int {
824         if (info) {
825           return aul_launch_app_with_result_async_for_uid(appid.c_str(),
826               request, LaunchWithResultCb, info, uid);
827         }
828
829         return aul_launch_app_async_for_uid(appid.c_str(), request, uid);
830       }, b, uid, cb_info);
831   if (ret < 0) {
832     if (cb_info)
833       delete cb_info;
834
835     ret = AulErrorConvert(ret);
836   }
837
838   return ret;
839 }
840
841 extern "C" API int aul_svc_send_launch_request(bundle* b, int request_code,
842     aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb, void* user_data) {
843   return aul_svc_send_launch_request_for_uid(b, request_code,
844       cbfunc, err_cb, user_data, getuid());
845 }
846
847 extern "C" API int aul_svc_send_launch_request_for_uid(bundle* b,
848     int request_code, aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
849     void* user_data, uid_t uid) {
850   if (b == nullptr || err_cb == nullptr) {
851     _E("Invalid parameter");
852     return AUL_SVC_RET_EINVAL;
853   }
854
855   CbInfo* cb_info = new (std::nothrow) CbInfo(request_code, cbfunc, err_cb,
856       user_data);
857   if (cb_info == nullptr)
858     _E("Out of memory");
859
860   int ret = ::SendLaunchRequest<::SendLaunchRequestCb, ::CbInfo*>(
861       [](const std::string& appid, bundle* request, uid_t uid,
862         CbInfo* info) -> int {
863         return aul_send_launch_request_for_uid(appid.c_str(), request, uid,
864             info->res_fn_ ? ::LaunchWithResultCb : nullptr, ::ErrorCb, info);
865       }, b, uid, cb_info);
866   if (ret < 0) {
867     delete cb_info;
868     ret = ::AulErrorConvert(ret);
869   }
870
871   return ret;
872 }
873
874 extern "C" API int aul_svc_send_launch_request_sync_for_uid(bundle* b,
875     int request_code, bundle** res_b, aul_svc_result_val* res, uid_t uid) {
876   if (b == nullptr || res_b == nullptr || res == nullptr) {
877     _E("Invalid parameter");
878     return AUL_SVC_RET_EINVAL;
879   }
880
881   int ret = ::SendLaunchRequest<::SendLaunchRequestSyncCb, bundle**>(
882       [](const std::string& appid, bundle* request, uid_t uid,
883           bundle** response) -> int {
884         return aul_send_launch_request_sync_for_uid(appid.c_str(), request,
885             uid, response);
886       }, b, uid, res_b);
887   if (ret > 0) {
888     auto* val = bundle_get_val(*res_b, AUL_SVC_K_RES_VAL);
889     *res = static_cast<aul_svc_result_val>(
890         (val == nullptr) ? AUL_SVC_RES_NOT_OK : atoi(val));
891   } else {
892     ret = ::AulErrorConvert(ret);
893     *res = AUL_SVC_RES_CANCEL;
894   }
895
896   return ret;
897 }
898
899 extern "C" API int aul_svc_info_create(bundle* b, aul_svc_info_h* h) {
900   if (b == nullptr || h == nullptr) {
901     _E("Invalid parameter");
902     return AUL_SVC_RET_EINVAL;
903   }
904
905   aul::ResolveInfo* resolve_info = nullptr;
906   try {
907     tizen_base::Bundle kb(b, false, false);
908     resolve_info = aul::ResolveInfo::Manager::Create(kb);
909   } catch (aul::Exception& e) {
910     return AUL_SVC_RET_ERROR;
911   }
912
913   *h = static_cast<aul_svc_info_h>(resolve_info);
914   return AUL_SVC_RET_OK;
915 }
916
917 extern "C" API int aul_svc_info_get_operation(aul_svc_info_h h,
918     char** operation) {
919   if (h == nullptr || operation == nullptr) {
920     _E("Invalid parameter");
921     return AUL_SVC_RET_EINVAL;
922   }
923
924   auto* info = static_cast<aul::ResolveInfo*>(h);
925   auto& value = info->GetOperation();
926   *operation = strdup(value.empty() ? "NULL" : value.c_str());
927   if (*operation == nullptr) {
928     _E("Failed to duplicate operation");
929     return AUL_SVC_RET_ERROR;
930   }
931
932   return AUL_SVC_RET_OK;
933 }
934
935 extern "C" API int aul_svc_info_get_uri(aul_svc_info_h h, char** uri) {
936   if (h == nullptr || uri == nullptr) {
937     _E("Invalid parameter");
938     return AUL_SVC_RET_EINVAL;
939   }
940
941   auto* info = static_cast<aul::ResolveInfo*>(h);
942   auto& value = info->GetUri();
943   *uri = strdup(value.empty() ? "NULL" : value.c_str());
944   if (*uri == nullptr) {
945     _E("Failed to duplicate URI");
946     return AUL_SVC_RET_ERROR;
947   }
948
949   return AUL_SVC_RET_OK;
950 }
951
952 extern "C" API int aul_svc_info_get_uri_scheme(aul_svc_info_h h,
953     char** uri_scheme) {
954   if (h == nullptr || uri_scheme == nullptr) {
955     _E("Invalid parameter");
956     return AUL_SVC_RET_EINVAL;
957   }
958
959   auto* info = static_cast<aul::ResolveInfo*>(h);
960   auto& value = info->GetScheme();
961   *uri_scheme = strdup(value.empty() ? "NULL" : value.c_str());
962   if (*uri_scheme == nullptr) {
963     _E("Failed to duplicate URI scheme");
964     return AUL_SVC_RET_ERROR;
965   }
966
967   return AUL_SVC_RET_OK;
968 }
969
970 extern "C" API int aul_svc_info_get_uri_host(aul_svc_info_h h,
971     char** uri_host) {
972   if (h == nullptr || uri_host == nullptr) {
973     _E("Invalid parameter");
974     return AUL_SVC_RET_EINVAL;
975   }
976
977   auto* info = static_cast<aul::ResolveInfo*>(h);
978   auto& value = info->GetHost();
979   *uri_host = strdup(value.empty() ? "NULL" : value.c_str());
980   if (*uri_host == nullptr) {
981     _E("Failed to duplicate URI host");
982     return AUL_SVC_RET_ERROR;
983   }
984
985   return AUL_SVC_RET_OK;
986 }
987
988 extern "C" API int aul_svc_info_get_mime(aul_svc_info_h h, char** mime) {
989   if (h == nullptr || mime == nullptr) {
990     _E("Invalid parameter");
991     return AUL_SVC_RET_EINVAL;
992   }
993
994   auto* info = static_cast<aul::ResolveInfo*>(h);
995   auto& value = info->GetMime();
996   *mime = strdup(value.empty() ? "NULL" : value.c_str());
997   if (*mime == nullptr) {
998     _E("Failed to duplicate MIME-Type");
999     return AUL_SVC_RET_ERROR;
1000   }
1001
1002   return AUL_SVC_RET_OK;
1003 }
1004
1005 extern "C" API int aul_svc_info_get_mime_type(aul_svc_info_h h,
1006     char** mime_type) {
1007   if (h == nullptr || mime_type == nullptr) {
1008     _E("Invalid parameter");
1009     return AUL_SVC_RET_EINVAL;
1010   }
1011
1012   auto* info = static_cast<aul::ResolveInfo*>(h);
1013   auto& value = info->GetMType();
1014   *mime_type = strdup(value.empty() ? "NULL" : value.c_str());
1015   if (*mime_type == nullptr) {
1016     _E("Failed to duplicate the type of MIME-Type");
1017     return AUL_SVC_RET_ERROR;
1018   }
1019
1020   return AUL_SVC_RET_OK;
1021 }
1022
1023 extern "C" API int aul_svc_info_get_mime_subtype(aul_svc_info_h h,
1024     char** mime_subtype) {
1025   if (h == nullptr || mime_subtype == nullptr) {
1026     _E("Invalid parameter");
1027     return AUL_SVC_RET_EINVAL;
1028   }
1029
1030   auto* info = static_cast<aul::ResolveInfo*>(h);
1031   auto& value = info->GetSType();
1032   *mime_subtype = strdup(value.empty() ? "NULL" : value.c_str());
1033   if (*mime_subtype == nullptr) {
1034     _E("Failed to duplicate the subtype of MIME-Type");
1035     return AUL_SVC_RET_ERROR;
1036   }
1037
1038   return AUL_SVC_RET_OK;
1039 }
1040
1041 extern "C" API int aul_svc_info_destroy(aul_svc_info_h h) {
1042   if (h == nullptr) {
1043     _E("Invalid parameter");
1044     return AUL_SVC_RET_EINVAL;
1045   }
1046
1047   auto* info = static_cast<aul::ResolveInfo*>(h);
1048   delete info;
1049   return AUL_SVC_RET_OK;
1050 }
1051
1052 extern "C" API int aul_svc_set_caller_instance_id(bundle* b,
1053     const char* instance_id) {
1054   if (b == nullptr) {
1055     _E("Invalid parameter");
1056     return AUL_SVC_RET_EINVAL;
1057   }
1058
1059   return ::SetBundle(b, AUL_K_CALLER_INSTANCE_ID, instance_id);
1060 }
1061
1062 extern "C" API int aul_svc_set_comp_id(bundle* b, const char* comp_id) {
1063   if (b == nullptr) {
1064     _E("Invalid parameter");
1065     return AUL_SVC_RET_EINVAL;
1066   }
1067
1068   return ::SetBundle(b, AUL_K_COMPONENT_ID, comp_id);
1069 }
1070
1071 extern "C" API const char *aul_svc_get_comp_id(bundle* b) {
1072   return bundle_get_val(b, AUL_K_COMPONENT_ID);
1073 }
1074
1075 extern "C" API int aul_svc_subapp_terminate_request(bundle* b, int pid) {
1076   if (b == nullptr || pid < 0) {
1077     _E("Invalid parameter");
1078     return AUL_SVC_RET_EINVAL;
1079   }
1080
1081   const char* inst_id = bundle_get_val(b, AUL_K_INSTANCE_ID);
1082   if (inst_id == nullptr) {
1083     _E("Invalid parameter");
1084     return AUL_SVC_RET_EINVAL;
1085   }
1086
1087   char buf[512] = { 0, };
1088   const char* caller_inst_id = bundle_get_val(b, AUL_K_CALLER_INSTANCE_ID);
1089   if (caller_inst_id == nullptr) {
1090     int ret = aul_app_get_instance_id_bypid(getpid(), buf, sizeof(buf));
1091     if (ret != AUL_R_OK) {
1092       _E("aul_app_get_instance_id_bypid() is failed. error(%d)", ret);
1093       return AUL_SVC_RET_ERROR;
1094     }
1095
1096     caller_inst_id = buf;
1097   }
1098
1099   int cnt = 0;
1100   aul_app_group_foreach_group_info(caller_inst_id,
1101       [](aul_app_group_info_h info, void* data) {
1102       int* count = static_cast<int*>(data);
1103       (*count)++;
1104       }, static_cast<void*>(&cnt));
1105   if (cnt == 0)
1106     return aul_subapp_terminate_request(inst_id, pid);
1107
1108   return aul_app_group_clear_top();
1109 }
1110
1111 extern "C" API int aul_svc_send_resume_request(bundle* b, int request_code,
1112     aul_svc_err_cb err_cb, void *user_data) {
1113   return aul_svc_send_resume_request_for_uid(b, request_code, err_cb, user_data,
1114       getuid());
1115 }
1116
1117 extern "C" API int aul_svc_send_resume_request_for_uid(bundle* b,
1118     int request_code, aul_svc_err_cb err_cb, void* user_data, uid_t uid) {
1119   if (b == nullptr || err_cb == nullptr) {
1120     _E("Invalid parameter");
1121     return AUL_SVC_RET_EINVAL;
1122   }
1123
1124   auto* cb_info = new (std::nothrow) CbInfo(request_code, nullptr, err_cb,
1125       user_data);
1126   if (cb_info == nullptr)
1127     _E("Out of memory");
1128
1129   int ret = ::SendLaunchRequest<::SendLaunchRequestCb, ::CbInfo*>(
1130       [](const std::string& appid, bundle* request, uid_t uid,
1131           CbInfo* info) -> int {
1132         return aul_send_resume_request_for_uid(appid.c_str(), request, uid,
1133             ErrorCb, info);
1134       }, b, uid, cb_info);
1135   if (ret < 0) {
1136     delete cb_info;
1137     ret = ::AulErrorConvert(ret);
1138   }
1139
1140   return ret;
1141 }
1142
1143 extern "C" API int aul_svc_get_appid_array(bundle* b, uid_t uid,
1144     char*** appid_array, unsigned int* len) {
1145   if (b == nullptr || appid_array == nullptr || len == nullptr) {
1146     _E("Invalid parameter");
1147     return AUL_SVC_RET_EINVAL;
1148   }
1149
1150   bundle_del(b, AUL_K_APPID);
1151   bundle_add(b, AUL_K_APPID, "@UNKNOWN");
1152
1153   bundle* response;
1154   int ret = ::SendAndReceive(APP_GET_APPID_LIST, uid, b, &response);
1155   if (ret != AUL_SVC_RET_OK)
1156     return ret;
1157
1158   tizen_base::Bundle res(response, false, true);
1159   auto str = res.GetString(AUL_SVC_K_URI_R_INFO);
1160   if (!str.empty())
1161     ::SetBundle(b, AUL_SVC_K_URI_R_INFO, str.c_str());
1162
1163   auto str_arr = res.GetStringArray(AUL_K_APPID_LIST);
1164   if (str_arr.empty()) {
1165     _E("Failed to get appid list");
1166     return AUL_SVC_RET_ERROR;
1167   }
1168
1169   *appid_array = reinterpret_cast<char**>(
1170       calloc(str_arr.size(), sizeof(char*)));
1171   if (*appid_array == nullptr) {
1172     _E("Out of memory");
1173     return AUL_SVC_RET_ENOMEM;
1174   }
1175
1176   *len = str_arr.size();
1177
1178   int i = 0;
1179   for (auto& appid : str_arr)
1180     (*appid_array)[i++] = strdup(appid.c_str());
1181
1182   return AUL_SVC_RET_OK;
1183 }
1184
1185 extern "C" API void aul_svc_free_appid_array(char** appid_array,
1186     unsigned int len) {
1187   if (appid_array == nullptr)
1188     return;
1189
1190   for (unsigned int i = 0; i < len; ++i)
1191     free(appid_array[i]);
1192
1193   free(appid_array);
1194 }
1195
1196 extern "C" API int aul_svc_set_defapp(const char* op, const char* mime_type,
1197     const char* uri, const char* defapp) {
1198   DEPRECATION_WARNING();
1199   return AUL_SVC_RET_OK;
1200 }
1201
1202 extern "C" API int aul_svc_set_defapp_for_uid(const char* op,
1203     const char* mime_type, const char* uri, const char* defapp, uid_t uid) {
1204   DEPRECATION_WARNING();
1205   return AUL_SVC_RET_OK;
1206 }
1207
1208 extern "C" API int aul_svc_unset_defapp(const char* defapp) {
1209   DEPRECATION_WARNING();
1210   return AUL_SVC_RET_OK;
1211 }
1212
1213 extern "C" API int aul_svc_unset_defapp_for_uid(const char* defapp, uid_t uid) {
1214   DEPRECATION_WARNING();
1215   return AUL_SVC_RET_OK;
1216 }
1217
1218 extern "C" API int aul_svc_unset_all_defapps(void) {
1219   DEPRECATION_WARNING();
1220   return AUL_SVC_RET_OK;
1221 }
1222
1223 extern "C" API int aul_svc_unset_all_defapps_for_uid(uid_t uid) {
1224   DEPRECATION_WARNING();
1225   return AUL_SVC_RET_OK;
1226 }
1227
1228 extern "C" API int aul_svc_is_defapp(const char* pkg_name) {
1229   DEPRECATION_WARNING();
1230   return AUL_SVC_RET_OK;
1231 }
1232
1233 extern "C" API int aul_svc_is_defapp_for_uid(const char* pkg_name, uid_t uid) {
1234   DEPRECATION_WARNING();
1235   return AUL_SVC_RET_OK;
1236 }
1237
1238 extern "C" API int aul_svc_set_alias_appid(const char* alias_appid,
1239     const char* appid) {
1240   DEPRECATION_WARNING();
1241   return AUL_SVC_RET_OK;
1242 }
1243
1244 extern "C" API int aul_svc_set_alias_appid_for_uid(const char* alias_appid,
1245     const char* appid, uid_t uid) {
1246   DEPRECATION_WARNING();
1247   return AUL_SVC_RET_OK;
1248 }
1249
1250 extern "C" API int aul_svc_unset_alias_appid(const char* alias_appid) {
1251   DEPRECATION_WARNING();
1252   return AUL_SVC_RET_OK;
1253 }
1254
1255 extern "C" API int aul_svc_unset_alias_appid_for_uid(const char* alias_appid,
1256     uid_t uid) {
1257   DEPRECATION_WARNING();
1258   return AUL_SVC_RET_OK;
1259 }
1260
1261 extern "C" API int aul_svc_foreach_alias_info(
1262     void (*callback)(const char *, const char *, void *),
1263     void* user_data) {
1264   DEPRECATION_WARNING();
1265   return AUL_SVC_RET_OK;
1266 }
1267
1268 extern "C" API int aul_svc_foreach_alias_info_for_uid(
1269     void (*callback)(const char *, const char *, void *),
1270     uid_t uid, void* user_data) {
1271   DEPRECATION_WARNING();
1272   return AUL_SVC_RET_OK;
1273 }
1274
1275 extern "C" API int aul_svc_enable_alias_info(const char* appid) {
1276   DEPRECATION_WARNING();
1277   return AUL_SVC_RET_OK;
1278 }
1279
1280 extern "C" API int aul_svc_enable_alias_info_for_uid(const char* appid,
1281     uid_t uid) {
1282   DEPRECATION_WARNING();
1283   return AUL_SVC_RET_OK;
1284 }
1285
1286 extern "C" API int aul_svc_disable_alias_info(const char* appid) {
1287   DEPRECATION_WARNING();
1288   return AUL_SVC_RET_OK;
1289 }
1290
1291 extern "C" API int aul_svc_disable_alias_info_for_uid(const char* appid,
1292     uid_t uid) {
1293   DEPRECATION_WARNING();
1294   return AUL_SVC_RET_OK;
1295 }
1296
1297 extern "C" API int aul_svc_foreach_alias_info_by_appid(
1298     int (*callback)(const char *, const char *, void *),
1299     const char* appid, void* user_data) {
1300   DEPRECATION_WARNING();
1301   return AUL_SVC_RET_OK;
1302 }
1303
1304 extern "C" API int aul_svc_foreach_alias_info_by_appid_for_uid(
1305     int (*callback)(const char *, const char *, void *),
1306     const char* appid, uid_t uid, void* user_data) {
1307   DEPRECATION_WARNING();
1308   return AUL_SVC_RET_OK;
1309 }
1310
1311 extern "C" API int aul_svc_foreach_allowed_info(
1312     int (*callback)(const char *, const char *, void *),
1313     void* user_data) {
1314   DEPRECATION_WARNING();
1315   return AUL_SVC_RET_OK;
1316 }
1317
1318 extern "C" API int aul_svc_foreach_allowed_info_for_uid(
1319     int (*callback)(const char *, const char *, void *),
1320     uid_t uid, void* user_data) {
1321   DEPRECATION_WARNING();
1322   return AUL_SVC_RET_OK;
1323 }
1324
1325 extern "C" API int aul_svc_foreach_allowed_info_by_appid(
1326     int (*callback)(const char *, const char *, void *),
1327     const char* appid, void* user_data) {
1328   DEPRECATION_WARNING();
1329   return AUL_SVC_RET_OK;
1330 }
1331
1332 extern "C" API int aul_svc_foreach_allowed_info_by_appid_for_uid(
1333     int (*callback)(const char *, const char *, void *),
1334     const char* appid, uid_t uid, void* user_data) {
1335   DEPRECATION_WARNING();
1336   return AUL_SVC_RET_OK;
1337 }