Fix coding style
[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[] = "/usr/lib/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   default:
223     return AUL_SVC_RET_ELAUNCH;
224   }
225 }
226
227 void LaunchWithResultCb(bundle* b, int is_cancel, void* data) {
228   int res;
229   if (is_cancel) {
230     res = AUL_SVC_RES_CANCEL;
231   } else {
232     const char* val = bundle_get_val(b, AUL_SVC_K_RES_VAL);
233     res = (val == nullptr) ? AUL_SVC_RES_NOT_OK : atoi(val);
234   }
235
236   bundle_del(b, AUL_SVC_K_RES_VAL);
237   auto* cb_info = static_cast<CbInfo*>(data);
238   if (cb_info == nullptr) {
239     _E("Invalid parameter");
240     return;
241   }
242
243   if (cb_info->res_fn_) {
244     cb_info->res_fn_(b, cb_info->request_code_,
245         static_cast<aul_svc_result_val>(res), cb_info->user_data_);
246     cb_info->res_fn_ = nullptr;
247   }
248
249   if (cb_info->err_cb_ != nullptr)
250     return;
251
252   delete cb_info;
253 }
254
255 void ErrorCb(int error, void* data) {
256   if (error < 0)
257     error = AulErrorConvert(error);
258
259   auto* cb_info = static_cast<CbInfo*>(data);
260   if (cb_info == nullptr) {
261     _E("Invalid parameter");
262     return;
263   }
264
265   if (cb_info->err_cb_) {
266     cb_info->err_cb_(cb_info->request_code_, error, cb_info->user_data_);
267     cb_info->err_cb_ = nullptr;
268   }
269
270   if (cb_info->res_fn_)
271     return;
272
273   delete cb_info;
274 }
275
276 using SendLaunchRequestCb =
277     int (*)(const std::string&, bundle*, uid_t, CbInfo*);
278 using SendLaunchRequestSyncCb =
279     int (*)(const std::string&, bundle*, uid_t, bundle**);
280
281 template <typename T, typename A>
282 int SendLaunchRequest(T cb, bundle* request, uid_t uid, A arg) {
283   if (request == nullptr) {
284     _E("Invalid parameter");
285     return AUL_SVC_RET_EINVAL;
286   }
287
288   std::string appid = GetAppId(request);
289   if (appid.empty()) {
290     _E("GetAppId() is failed");
291     return AUL_SVC_RET_EINVAL;
292   }
293
294   SetLaunchData(request, appid);
295   return cb(appid, request, uid, arg);
296 }
297
298 int SendAndReceive(int cmd, uid_t uid, bundle* request, bundle** response) {
299   int fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, cmd, request,
300       AUL_SOCK_ASYNC);
301   if (fd < 0)
302     return AUL_SVC_RET_ERROR;
303
304   app_pkt_t* pkt = nullptr;
305   int ret = aul_sock_recv_reply_pkt(fd, &pkt);
306   if (ret < 0) {
307     _E("Failed to receive reply packet. error(%d)", ret);
308     return AUL_SVC_RET_ERROR;
309   }
310
311   auto ptr = std::unique_ptr<app_pkt_t, decltype(std::free)*>(pkt, std::free);
312   if (pkt->cmd != APP_GET_INFO_OK && pkt->cmd != cmd) {
313     if (pkt->cmd == APP_GET_INFO_ERROR)
314       return AUL_SVC_RET_ERROR;
315
316     return AulErrorConvert(aul_error_convert(pkt->cmd));
317   }
318
319   bundle* b = nullptr;
320   if (pkt->opt & AUL_SOCK_BUNDLE) {
321     b = bundle_decode(pkt->data, pkt->len);
322     if (b == nullptr) {
323       _E("bundle_decode() is failed");
324       return AUL_SVC_RET_ENOMEM;
325     }
326   } else {
327     _E("Invalid packet");
328     return AUL_SVC_RET_ERROR;
329   }
330
331   *response = b;
332   return AUL_SVC_RET_OK;
333 }
334
335 std::atomic<bool> amd_ready { false };
336 bool IsAmdReady() {
337   if (amd_ready)
338     return amd_ready;
339
340   if (access(kPathAmdReady, F_OK) == 0) {
341     amd_ready.exchange(true);
342     return amd_ready;
343   }
344
345   return false;
346 }
347
348 using AulServiceAliasInfoCb =
349     bool (*)(const char*, const char*, void*);
350 using AulServiceForeachUsrAliasInfoFunc =
351     int (*)(AulServiceAliasInfoCb, uid_t, void*);
352
353 int GetAppIdByAliasAppIdFromDB(const char* alias_appid, char** app_id,
354     uid_t uid) {
355   void* handle = dlopen(kPathLibAulServer, RTLD_LAZY | RTLD_GLOBAL);
356   if (handle == nullptr) {
357     _E("dlopen() is failed. path(%s), error(%s)", kPathLibAulServer, dlerror());
358     return AUL_SVC_RET_ERROR;
359   }
360
361   auto dl_closer = [](void* ptr) {
362     dlclose(ptr);
363   };
364
365   std::unique_ptr<void, decltype(dl_closer)> handle_auto(handle, dl_closer);
366   auto* func = reinterpret_cast<AulServiceForeachUsrAliasInfoFunc>(
367       dlsym(handle, kAulServiceForeachUsrAliasInfo));
368   if (func == nullptr) {
369     _E("dlsym() is failed. error(%s)", dlerror());
370     return AUL_SVC_RET_ERROR;
371   }
372
373   AliasInfo info(alias_appid);
374   int ret = func(
375       [](const char* alias_appid, const char* appid, void* user_data) -> bool {
376         auto* info = static_cast<AliasInfo*>(user_data);
377         if (info->alias_appid_ == alias_appid) {
378           info->appid_ = appid;
379           return false;
380         }
381
382         return true;
383       }, uid, &info);
384   if (ret != 0) {
385     _E("%s() is failed. error(%d)", kAulServiceForeachUsrAliasInfo, ret);
386     return AUL_SVC_RET_ERROR;
387   }
388
389   if (info.appid_.empty())
390     return AUL_SVC_RET_ERROR;
391
392   *app_id = strdup(info.appid_.c_str());
393   if (*app_id == nullptr) {
394     _E("strdup() is failed");
395     return AUL_SVC_RET_ENOMEM;
396   }
397
398   return AUL_SVC_RET_OK;
399 }
400
401 }  // namespace
402
403 extern "C" API int aul_svc_set_operation(bundle* b, const char* operation) {
404   if (b == nullptr) {
405     _E("Invalid parameter");
406     return AUL_SVC_RET_EINVAL;
407   }
408
409   return ::SetBundle(b, AUL_SVC_K_OPERATION, operation);
410 }
411
412 extern "C" API int aul_svc_set_uri(bundle* b, const char* uri) {
413   if (b == nullptr) {
414     _E("Invalid parameter");
415     return AUL_SVC_RET_EINVAL;
416   }
417
418   return ::SetBundle(b, AUL_SVC_K_URI, uri);
419 }
420
421 extern "C" API int aul_svc_set_mime(bundle* b, const char* mime) {
422   if (b == nullptr) {
423     _E("Invalid parameter");
424     return AUL_SVC_RET_EINVAL;
425   }
426
427   return ::SetBundle(b, AUL_SVC_K_MIME, mime);
428 }
429
430 extern "C" API int aul_svc_add_data(bundle* b, const char* key,
431     const char* value) {
432   if (b == nullptr || key == nullptr)
433     return AUL_SVC_RET_EINVAL;
434
435   return ::SetBundle(b, key, value);
436 }
437
438 extern "C" API int aul_svc_add_data_array(bundle* b, const char* key,
439     const char** value, int len) {
440   if (b == nullptr || key == nullptr)
441     return AUL_SVC_RET_EINVAL;
442
443   return ::SetBundleArray(b, key, value, len);
444 }
445
446 extern "C" API int aul_svc_set_pkgname(bundle* b, const char* pkg_name) {
447   if (b == nullptr) {
448     _E("Invalid parameter");
449     return AUL_SVC_RET_EINVAL;
450   }
451
452   return ::SetBundle(b, AUL_SVC_K_PKG_NAME, pkg_name);
453 }
454
455 extern "C" API int aul_svc_set_appid(bundle* b, const char* appid) {
456   if (b == nullptr || appid == nullptr) {
457     _E("Invalid parameter");
458     return AUL_SVC_RET_EINVAL;
459   }
460
461   std::string alias_id = ::GetAliasAppId(appid);
462   if (!alias_id.empty())
463     appid = alias_id.c_str();
464
465   return ::SetBundle(b, AUL_SVC_K_PKG_NAME, appid);
466 }
467
468 extern "C" API int aul_svc_set_category(bundle* b, const char* category) {
469   if (b == nullptr) {
470     _E("Invalid parameter");
471     return AUL_SVC_RET_EINVAL;
472   }
473
474   return ::SetBundle(b, AUL_SVC_K_CATEGORY, category);
475 }
476
477 extern "C" API int aul_svc_set_launch_mode(bundle* b, const char* mode) {
478   if (b == nullptr) {
479     _E("Invalid parameter");
480     return AUL_SVC_RET_EINVAL;
481   }
482
483   return ::SetBundle(b, AUL_SVC_K_LAUNCH_MODE, mode);
484 }
485
486 extern "C" API int aul_svc_resolve(bundle* b, uid_t uid, char*** appid_array,
487     unsigned int* len) {
488   return aul_svc_get_appid_array(b, uid, appid_array, len);
489 }
490
491 extern "C" API int aul_svc_run_service(bundle* b, int request_code,
492     aul_svc_res_fn cbfunc, void* data) {
493   return aul_svc_run_service_for_uid(b, request_code, cbfunc, data, getuid());
494 }
495
496 extern "C" API int aul_svc_run_service_for_uid(bundle* b, int request_code,
497   aul_svc_res_fn cbfunc, void* data, uid_t uid) {
498   CbInfo* cb_info = nullptr;
499   if (cbfunc) {
500     cb_info = new (std::nothrow) CbInfo(request_code, cbfunc, nullptr, data);
501     if (cb_info == nullptr)
502       LOGE("Out of memory");
503   }
504
505   std::tuple<aul_svc_res_fn, void*> param { cbfunc, data };
506   int ret = ::SendLaunchRequest<::SendLaunchRequestCb, ::CbInfo*>(
507       [](const std::string& appid, bundle* request, uid_t uid,
508           CbInfo* cb_info) -> int {
509         int ret;
510         if (cb_info) {
511           ret = aul_launch_app_with_result_for_uid(appid.c_str(), request,
512               LaunchWithResultCb, cb_info, uid);
513          } else {
514           ret = aul_launch_app_for_uid(appid.c_str(), request, uid);
515         }
516
517         return ret;
518       }, b, uid, cb_info);
519   if (ret < 0) {
520     if (cb_info)
521       delete cb_info;
522
523     ret = AulErrorConvert(ret);
524   }
525
526   return ret;
527 }
528
529 extern "C" API int aul_svc_get_list(bundle* b, aul_svc_info_iter_fn iter_fn,
530     void* data) {
531   return aul_svc_get_list_for_uid(b, iter_fn, data, getuid());
532 }
533
534 extern "C" API int aul_svc_get_list_for_uid(bundle* b,
535     aul_svc_info_iter_fn iter_fn, void* data, uid_t uid) {
536   if (b == nullptr || iter_fn == nullptr) {
537     _E("Invalid parameter");
538     return AUL_SVC_RET_EINVAL;
539   }
540
541   char** appid_array = nullptr;
542   unsigned int len = 0;
543   int ret = aul_svc_get_appid_array(b, uid, &appid_array, &len);
544   if (ret != AUL_SVC_RET_OK)
545     return ret;
546
547   if (len == 0) {
548     _E("Failed to find associated application");
549     aul_svc_free_appid_array(appid_array, len);
550     return AUL_SVC_RET_ENOMATCH;
551   }
552
553   for (unsigned int i = 0; i < len; ++i) {
554     SECURE_LOGD("APPID: %s", appid_array[i]);
555     if (iter_fn(appid_array[i], data) != 0)
556       break;
557   }
558
559   aul_svc_free_appid_array(appid_array, len);
560   return AUL_SVC_RET_OK;
561 }
562
563 extern "C" API int aul_svc_get_all_defapps(aul_svc_info_iter_fn iter_fn,
564     void* data) {
565   return aul_svc_get_all_defapps_for_uid(iter_fn, data, getuid());
566 }
567
568 extern "C" API int aul_svc_get_all_defapps_for_uid(aul_svc_info_iter_fn iter_fn,
569     void* data, uid_t uid) {
570   if (iter_fn == nullptr) {
571     _E("Invalid parameter");
572     return AUL_SVC_RET_EINVAL;
573   }
574
575   bundle* response;
576   tizen_base::Bundle request;
577   int ret = ::SendAndReceive(APP_GET_APP_CONTROL_DEFAULT_APPS, uid,
578       request.GetHandle(), &response);
579   if (ret != AUL_SVC_RET_OK)
580     return ret;
581
582   tizen_base::Bundle res(response, false, true);
583   auto appid_array = res.GetStringArray(AUL_K_APPID_LIST);
584   for (auto& appid : appid_array) {
585     if (iter_fn(appid.c_str(), data) != 0)
586       break;
587   }
588
589   return AUL_SVC_RET_OK;
590 }
591
592 extern "C" API const char* aul_svc_get_operation(bundle* b) {
593   return bundle_get_val(b, AUL_SVC_K_OPERATION);
594 }
595
596 extern "C" API const char* aul_svc_get_uri(bundle* b) {
597   return bundle_get_val(b, AUL_SVC_K_URI);
598 }
599
600 extern "C" API const char* aul_svc_get_mime(bundle* b) {
601   return bundle_get_val(b, AUL_SVC_K_MIME);
602 }
603
604 extern "C" API const char* aul_svc_get_data(bundle* b, const char* key) {
605   return bundle_get_val(b, key);
606 }
607
608 extern "C" API const char** aul_svc_get_data_array(bundle* b, const char* key,
609     int* len) {
610   return bundle_get_str_array(b, key, len);
611 }
612
613 extern "C" API const char* aul_svc_get_pkgname(bundle* b) {
614   return bundle_get_val(b, AUL_SVC_K_PKG_NAME);
615 }
616
617 extern "C" API const char* aul_svc_get_appid(bundle* b) {
618   return bundle_get_val(b, AUL_SVC_K_PKG_NAME);
619 }
620
621 extern "C" API const char* aul_svc_get_category(bundle* b) {
622   return bundle_get_val(b, AUL_SVC_K_CATEGORY);
623 }
624
625 extern "C" API const char* aul_svc_get_launch_mode(bundle* b) {
626   return bundle_get_val(b, AUL_SVC_K_LAUNCH_MODE);
627 }
628
629 extern "C" API int aul_svc_create_result_bundle(bundle* inb, bundle** outb) {
630   if (inb == nullptr || outb == nullptr) {
631     _E("Invalid parameter");
632     return AUL_SVC_RET_EINVAL;
633   }
634
635   int ret = aul_create_result_bundle(inb, outb);
636   if (ret != AUL_R_OK)
637     return AulErrorConvert(ret);
638
639   return AUL_SVC_RET_OK;
640 }
641
642 extern "C" API int aul_svc_send_result(bundle* b, aul_svc_result_val result) {
643   if (b == nullptr) {
644     _E("Invalid parameter");
645     return AUL_SVC_RET_EINVAL;
646   }
647
648   int ret = ::SetBundle(b, AUL_SVC_K_RES_VAL, std::to_string(result).c_str());
649   if (ret < 0)
650     return AUL_SVC_RET_ERROR;
651
652   if (result == AUL_SVC_RES_CANCEL)
653     ret = aul_send_result(b, 1);
654   else
655     ret = aul_send_result(b, 0);
656
657   bundle_del(b, AUL_SVC_K_RES_VAL);
658   return ret;
659 }
660
661 extern "C" API int aul_svc_data_is_array(bundle* b, const char* key) {
662   int type = bundle_get_type(b, key);
663   if (type <= 0)
664     return 0;
665
666   if (type & BUNDLE_TYPE_ARRAY)
667     return 1;
668
669   return 0;
670 }
671
672 extern "C" API int aul_svc_allow_transient_app(bundle* b, int wid) {
673   if (b == nullptr) {
674     _E("Invalid parameter");
675     return AUL_SVC_RET_EINVAL;
676   }
677
678   return ::SetBundle(b, AUL_SVC_K_WIN_ID, std::to_string(wid).c_str());
679 }
680
681 extern "C" API int aul_svc_request_transient_app(bundle* b, int callee_wid,
682     aul_svc_host_res_fn cbfunc, void* data) {
683   return 0;
684 }
685
686 extern "C" API int aul_svc_subapp_terminate_request_pid(int pid) {
687   int cpid = getpid();
688   int lcnt;
689   int* lpids = nullptr;
690   aul_app_group_get_leader_pids(&lcnt, &lpids);
691   for (int i = 0; i < lcnt; ++i) {
692     if (lpids[i] == cpid) {
693       int cnt;
694       int* pids = nullptr;
695       aul_app_group_get_group_pids(cpid, &cnt, &pids);
696       if (cnt == 0) {
697         free(lpids);
698         if (pids)
699           free(pids);
700
701         return aul_subapp_terminate_request_pid(pid);
702       }
703
704       if (pids != nullptr)
705         free(pids);
706       break;
707     }
708   }
709
710   if (lpids != nullptr)
711     free(lpids);
712
713   return aul_app_group_clear_top();
714 }
715
716 extern "C" API int aul_send_service_result(bundle* b) {
717   return aul_send_result(b, 0);
718 }
719
720 extern "C" API int aul_svc_subscribe_launch_result(bundle* b,
721     const char* result) {
722   if (b == nullptr) {
723     _E("Invalid parameter");
724     return AUL_SVC_RET_EINVAL;
725   }
726
727   return ::SetBundle(b, result, "1");
728 }
729
730 extern "C" API int aul_svc_set_loader_id(bundle* b, int loader_id) {
731   if (b == nullptr || loader_id <= 0) {
732     _E("Invalid parameter");
733     return AUL_SVC_RET_EINVAL;
734   }
735
736   return ::SetBundle(b, AUL_K_LOADER_ID, std::to_string(loader_id).c_str());
737 }
738
739 extern "C" API int aul_svc_set_loader_name(bundle* b, const char* loader_name) {
740   if (b == nullptr || loader_name == nullptr) {
741     _E("Invalid parameter");
742     return AUL_SVC_RET_EINVAL;
743   }
744
745   return ::SetBundle(b, AUL_K_LOADER_NAME, loader_name);
746 }
747
748 extern "C" API int aul_svc_set_background_launch(bundle* b, int enabled) {
749   if (b == nullptr) {
750     _E("Invalid parameter");
751     return AUL_SVC_RET_EINVAL;
752   }
753
754   return ::SetBundle(b, AUL_SVC_K_BG_LAUNCH, enabled ? "enable" : nullptr);
755 }
756
757 extern "C" API int aul_svc_get_appid_by_alias_appid(const char* alias_appid,
758     char** appid) {
759   return aul_svc_get_appid_by_alias_appid_for_uid(alias_appid, appid, getuid());
760 }
761
762 extern "C" API int aul_svc_get_appid_by_alias_appid_for_uid(
763     const char* alias_appid, char** appid, uid_t uid) {
764   if (alias_appid == nullptr || appid == nullptr) {
765     _E("Invalid parameter");
766     return AUL_SVC_RET_EINVAL;
767   }
768
769   if (!IsAmdReady())
770     return GetAppIdByAliasAppIdFromDB(alias_appid, appid, uid);
771
772   bundle* response;
773   tizen_base::Bundle request;
774   request.Add(AUL_K_ALIAS_APPID, alias_appid);
775   int ret = ::SendAndReceive(APP_GET_APPID_BY_ALIAS_APPID, uid,
776       request.GetHandle(), &response);
777   if (ret != AUL_SVC_RET_OK)
778     return ret;
779
780   tizen_base::Bundle res(response, false, true);
781   auto val = res.GetString(AUL_K_APPID);
782   if (val.empty())
783     return AUL_SVC_RET_ERROR;
784
785   *appid = strdup(val.c_str());
786   if (*appid == nullptr) {
787     _E("Out of memory");
788     return AUL_SVC_RET_ENOMEM;
789   }
790
791   return AUL_SVC_RET_OK;
792 }
793
794 extern "C" API const char *aul_svc_get_instance_id(bundle* b) {
795   return bundle_get_val(b, AUL_K_INSTANCE_ID);
796 }
797
798 extern "C" API int aul_svc_set_instance_id(bundle* b, const char* instance_id) {
799   if (b == nullptr) {
800     _E("Invalid parameter");
801     return AUL_SVC_RET_EINVAL;
802   }
803
804   return ::SetBundle(b, AUL_K_INSTANCE_ID, instance_id);
805 }
806
807 extern "C" API int aul_svc_run_service_async(bundle* b, int request_code,
808     aul_svc_res_fn cbfunc, void* data) {
809   return aul_svc_run_service_async_for_uid(b, request_code, cbfunc, data,
810       getuid());
811 }
812
813 extern "C" API int aul_svc_run_service_async_for_uid(bundle* b,
814     int request_code, aul_svc_res_fn cbfunc, void* data, uid_t uid) {
815   CbInfo* cb_info = nullptr;
816   if (cbfunc)
817     cb_info = new (std::nothrow) CbInfo(request_code, cbfunc, nullptr, data);
818
819   int ret = ::SendLaunchRequest<::SendLaunchRequestCb, ::CbInfo*>(
820       [](const std::string& appid, bundle* request, uid_t uid,
821           CbInfo* info) -> int {
822         if (info) {
823           return aul_launch_app_with_result_async_for_uid(appid.c_str(),
824               request, LaunchWithResultCb, info, uid);
825         }
826
827         return aul_launch_app_async_for_uid(appid.c_str(), request, uid);
828       }, b, uid, cb_info);
829   if (ret < 0) {
830     if (cb_info)
831       delete cb_info;
832
833     ret = AulErrorConvert(ret);
834   }
835
836   return ret;
837 }
838
839 extern "C" API int aul_svc_send_launch_request(bundle* b, int request_code,
840     aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb, void* user_data) {
841   return aul_svc_send_launch_request_for_uid(b, request_code,
842       cbfunc, err_cb, user_data, getuid());
843 }
844
845 extern "C" API int aul_svc_send_launch_request_for_uid(bundle* b,
846     int request_code, aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
847     void* user_data, uid_t uid) {
848   if (b == nullptr || err_cb == nullptr) {
849     _E("Invalid parameter");
850     return AUL_SVC_RET_EINVAL;
851   }
852
853   CbInfo* cb_info = new (std::nothrow) CbInfo(request_code, cbfunc, err_cb,
854       user_data);
855   if (cb_info == nullptr)
856     _E("Out of memory");
857
858   int ret = ::SendLaunchRequest<::SendLaunchRequestCb, ::CbInfo*>(
859       [](const std::string& appid, bundle* request, uid_t uid,
860         CbInfo* info) -> int {
861         return aul_send_launch_request_for_uid(appid.c_str(), request, uid,
862             info->res_fn_ ? ::LaunchWithResultCb : nullptr, ::ErrorCb, info);
863       }, b, uid, cb_info);
864   if (ret < 0) {
865     delete cb_info;
866     ret = ::AulErrorConvert(ret);
867   }
868
869   return ret;
870 }
871
872 extern "C" API int aul_svc_send_launch_request_sync_for_uid(bundle* b,
873     int request_code, bundle** res_b, aul_svc_result_val* res, uid_t uid) {
874   if (b == nullptr || res_b == nullptr || res == nullptr) {
875     _E("Invalid parameter");
876     return AUL_SVC_RET_EINVAL;
877   }
878
879   int ret = ::SendLaunchRequest<::SendLaunchRequestSyncCb, bundle**>(
880       [](const std::string& appid, bundle* request, uid_t uid,
881           bundle** response) -> int {
882         return aul_send_launch_request_sync_for_uid(appid.c_str(), request,
883             uid, response);
884       }, b, uid, res_b);
885   if (ret > 0) {
886     auto* val = bundle_get_val(*res_b, AUL_SVC_K_RES_VAL);
887     *res = static_cast<aul_svc_result_val>(
888         (val == nullptr) ? AUL_SVC_RES_NOT_OK : atoi(val));
889   } else {
890     ret = ::AulErrorConvert(ret);
891     *res = AUL_SVC_RES_CANCEL;
892   }
893
894   return ret;
895 }
896
897 extern "C" API int aul_svc_info_create(bundle* b, aul_svc_info_h* h) {
898   if (b == nullptr || h == nullptr) {
899     _E("Invalid parameter");
900     return AUL_SVC_RET_EINVAL;
901   }
902
903   aul::ResolveInfo* resolve_info = nullptr;
904   try {
905     tizen_base::Bundle kb(b, false, false);
906     resolve_info = aul::ResolveInfo::Manager::Create(kb);
907   } catch (aul::Exception& e) {
908     return AUL_SVC_RET_ERROR;
909   }
910
911   *h = static_cast<aul_svc_info_h>(resolve_info);
912   return AUL_SVC_RET_OK;
913 }
914
915 extern "C" API int aul_svc_info_get_operation(aul_svc_info_h h,
916     char** operation) {
917   if (h == nullptr || operation == nullptr) {
918     _E("Invalid parameter");
919     return AUL_SVC_RET_EINVAL;
920   }
921
922   auto* info = static_cast<aul::ResolveInfo*>(h);
923   auto& value = info->GetOperation();
924   *operation = strdup(value.empty() ? "NULL" : value.c_str());
925   if (*operation == nullptr) {
926     _E("Failed to duplicate operation");
927     return AUL_SVC_RET_ERROR;
928   }
929
930   return AUL_SVC_RET_OK;
931 }
932
933 extern "C" API int aul_svc_info_get_uri(aul_svc_info_h h, char** uri) {
934   if (h == nullptr || uri == nullptr) {
935     _E("Invalid parameter");
936     return AUL_SVC_RET_EINVAL;
937   }
938
939   auto* info = static_cast<aul::ResolveInfo*>(h);
940   auto& value = info->GetUri();
941   *uri = strdup(value.empty() ? "NULL" : value.c_str());
942   if (*uri == nullptr) {
943     _E("Failed to duplicate URI");
944     return AUL_SVC_RET_ERROR;
945   }
946
947   return AUL_SVC_RET_OK;
948 }
949
950 extern "C" API int aul_svc_info_get_uri_scheme(aul_svc_info_h h,
951     char** uri_scheme) {
952   if (h == nullptr || uri_scheme == nullptr) {
953     _E("Invalid parameter");
954     return AUL_SVC_RET_EINVAL;
955   }
956
957   auto* info = static_cast<aul::ResolveInfo*>(h);
958   auto& value = info->GetScheme();
959   *uri_scheme = strdup(value.empty() ? "NULL" : value.c_str());
960   if (*uri_scheme == nullptr) {
961     _E("Failed to duplicate URI scheme");
962     return AUL_SVC_RET_ERROR;
963   }
964
965   return AUL_SVC_RET_OK;
966 }
967
968 extern "C" API int aul_svc_info_get_uri_host(aul_svc_info_h h,
969     char** uri_host) {
970   if (h == nullptr || uri_host == nullptr) {
971     _E("Invalid parameter");
972     return AUL_SVC_RET_EINVAL;
973   }
974
975   auto* info = static_cast<aul::ResolveInfo*>(h);
976   auto& value = info->GetHost();
977   *uri_host = strdup(value.empty() ? "NULL" : value.c_str());
978   if (*uri_host == nullptr) {
979     _E("Failed to duplicate URI host");
980     return AUL_SVC_RET_ERROR;
981   }
982
983   return AUL_SVC_RET_OK;
984 }
985
986 extern "C" API int aul_svc_info_get_mime(aul_svc_info_h h, char** mime) {
987   if (h == nullptr || mime == nullptr) {
988     _E("Invalid parameter");
989     return AUL_SVC_RET_EINVAL;
990   }
991
992   auto* info = static_cast<aul::ResolveInfo*>(h);
993   auto& value = info->GetMime();
994   *mime = strdup(value.empty() ? "NULL" : value.c_str());
995   if (*mime == nullptr) {
996     _E("Failed to duplicate MIME-Type");
997     return AUL_SVC_RET_ERROR;
998   }
999
1000   return AUL_SVC_RET_OK;
1001 }
1002
1003 extern "C" API int aul_svc_info_get_mime_type(aul_svc_info_h h,
1004     char** mime_type) {
1005   if (h == nullptr || mime_type == nullptr) {
1006     _E("Invalid parameter");
1007     return AUL_SVC_RET_EINVAL;
1008   }
1009
1010   auto* info = static_cast<aul::ResolveInfo*>(h);
1011   auto& value = info->GetMType();
1012   *mime_type = strdup(value.empty() ? "NULL" : value.c_str());
1013   if (*mime_type == nullptr) {
1014     _E("Failed to duplicate the type of MIME-Type");
1015     return AUL_SVC_RET_ERROR;
1016   }
1017
1018   return AUL_SVC_RET_OK;
1019 }
1020
1021 extern "C" API int aul_svc_info_get_mime_subtype(aul_svc_info_h h,
1022     char** mime_subtype) {
1023   if (h == nullptr || mime_subtype == nullptr) {
1024     _E("Invalid parameter");
1025     return AUL_SVC_RET_EINVAL;
1026   }
1027
1028   auto* info = static_cast<aul::ResolveInfo*>(h);
1029   auto& value = info->GetSType();
1030   *mime_subtype = strdup(value.empty() ? "NULL" : value.c_str());
1031   if (*mime_subtype == nullptr) {
1032     _E("Failed to duplicate the subtype of MIME-Type");
1033     return AUL_SVC_RET_ERROR;
1034   }
1035
1036   return AUL_SVC_RET_OK;
1037 }
1038
1039 extern "C" API int aul_svc_info_destroy(aul_svc_info_h h) {
1040   if (h == nullptr) {
1041     _E("Invalid parameter");
1042     return AUL_SVC_RET_EINVAL;
1043   }
1044
1045   auto* info = static_cast<aul::ResolveInfo*>(h);
1046   delete info;
1047   return AUL_SVC_RET_OK;
1048 }
1049
1050 extern "C" API int aul_svc_set_caller_instance_id(bundle* b,
1051     const char* instance_id) {
1052   if (b == nullptr) {
1053     _E("Invalid parameter");
1054     return AUL_SVC_RET_EINVAL;
1055   }
1056
1057   return ::SetBundle(b, AUL_K_CALLER_INSTANCE_ID, instance_id);
1058 }
1059
1060 extern "C" API int aul_svc_set_comp_id(bundle* b, const char* comp_id) {
1061   if (b == nullptr) {
1062     _E("Invalid parameter");
1063     return AUL_SVC_RET_EINVAL;
1064   }
1065
1066   return ::SetBundle(b, AUL_K_COMPONENT_ID, comp_id);
1067 }
1068
1069 extern "C" API const char *aul_svc_get_comp_id(bundle* b) {
1070   return bundle_get_val(b, AUL_K_COMPONENT_ID);
1071 }
1072
1073 extern "C" API int aul_svc_subapp_terminate_request(bundle* b, int pid) {
1074   if (b == nullptr || pid < 0) {
1075     _E("Invalid parameter");
1076     return AUL_SVC_RET_EINVAL;
1077   }
1078
1079   const char* inst_id = bundle_get_val(b, AUL_K_INSTANCE_ID);
1080   if (inst_id == nullptr) {
1081     _E("Invalid parameter");
1082     return AUL_SVC_RET_EINVAL;
1083   }
1084
1085   char buf[512] = { 0, };
1086   const char* caller_inst_id = bundle_get_val(b, AUL_K_CALLER_INSTANCE_ID);
1087   if (caller_inst_id == nullptr) {
1088     int ret = aul_app_get_instance_id_bypid(getpid(), buf, sizeof(buf));
1089     if (ret != AUL_R_OK) {
1090       _E("aul_app_get_instance_id_bypid() is failed. error(%d)", ret);
1091       return AUL_SVC_RET_ERROR;
1092     }
1093
1094     caller_inst_id = buf;
1095   }
1096
1097   int cnt = 0;
1098   aul_app_group_foreach_group_info(caller_inst_id,
1099       [](aul_app_group_info_h info, void* data) {
1100       int* count = static_cast<int*>(data);
1101       (*count)++;
1102       }, static_cast<void*>(&cnt));
1103   if (cnt == 0)
1104     return aul_subapp_terminate_request(inst_id, pid);
1105
1106   return aul_app_group_clear_top();
1107 }
1108
1109 extern "C" API int aul_svc_send_resume_request(bundle* b, int request_code,
1110     aul_svc_err_cb err_cb, void *user_data) {
1111   return aul_svc_send_resume_request_for_uid(b, request_code, err_cb, user_data,
1112       getuid());
1113 }
1114
1115 extern "C" API int aul_svc_send_resume_request_for_uid(bundle* b,
1116     int request_code, aul_svc_err_cb err_cb, void* user_data, uid_t uid) {
1117   if (b == nullptr || err_cb == nullptr) {
1118     _E("Invalid parameter");
1119     return AUL_SVC_RET_EINVAL;
1120   }
1121
1122   auto* cb_info = new (std::nothrow) CbInfo(request_code, nullptr, err_cb,
1123       user_data);
1124   if (cb_info == nullptr)
1125     _E("Out of memory");
1126
1127   int ret = ::SendLaunchRequest<::SendLaunchRequestCb, ::CbInfo*>(
1128       [](const std::string& appid, bundle* request, uid_t uid,
1129           CbInfo* info) -> int {
1130         return aul_send_resume_request_for_uid(appid.c_str(), request, uid,
1131             ErrorCb, info);
1132       }, b, uid, cb_info);
1133   if (ret < 0) {
1134     delete cb_info;
1135     ret = ::AulErrorConvert(ret);
1136   }
1137
1138   return ret;
1139 }
1140
1141 extern "C" API int aul_svc_get_appid_array(bundle* b, uid_t uid,
1142     char*** appid_array, unsigned int* len) {
1143   if (b == nullptr || appid_array == nullptr || len == nullptr) {
1144     _E("Invalid parameter");
1145     return AUL_SVC_RET_EINVAL;
1146   }
1147
1148   bundle_del(b, AUL_K_APPID);
1149   bundle_add(b, AUL_K_APPID, "@UNKNOWN");
1150
1151   bundle* response;
1152   int ret = ::SendAndReceive(APP_GET_APPID_LIST, uid, b, &response);
1153   if (ret != AUL_SVC_RET_OK)
1154     return ret;
1155
1156   tizen_base::Bundle res(response, false, true);
1157   auto str = res.GetString(AUL_SVC_K_URI_R_INFO);
1158   if (!str.empty())
1159     ::SetBundle(b, AUL_SVC_K_URI_R_INFO, str.c_str());
1160
1161   auto str_arr = res.GetStringArray(AUL_K_APPID_LIST);
1162   if (str_arr.empty()) {
1163     _E("Failed to get appid list");
1164     return AUL_SVC_RET_ERROR;
1165   }
1166
1167   *appid_array = reinterpret_cast<char**>(
1168       calloc(str_arr.size(), sizeof(char*)));
1169   if (*appid_array == nullptr) {
1170     _E("Out of memory");
1171     return AUL_SVC_RET_ENOMEM;
1172   }
1173
1174   *len = str_arr.size();
1175
1176   int i = 0;
1177   for (auto& appid : str_arr)
1178     (*appid_array)[i++] = strdup(appid.c_str());
1179
1180   return AUL_SVC_RET_OK;
1181 }
1182
1183 extern "C" API void aul_svc_free_appid_array(char** appid_array,
1184     unsigned int len) {
1185   if (appid_array == nullptr)
1186     return;
1187
1188   for (unsigned int i = 0; i < len; ++i)
1189     free(appid_array[i]);
1190
1191   free(appid_array);
1192 }
1193
1194 extern "C" API int aul_svc_set_defapp(const char* op, const char* mime_type,
1195     const char* uri, const char* defapp) {
1196   DEPRECATION_WARNING();
1197   return AUL_SVC_RET_OK;
1198 }
1199
1200 extern "C" API int aul_svc_set_defapp_for_uid(const char* op,
1201     const char* mime_type, const char* uri, const char* defapp, uid_t uid) {
1202   DEPRECATION_WARNING();
1203   return AUL_SVC_RET_OK;
1204 }
1205
1206 extern "C" API int aul_svc_unset_defapp(const char* defapp) {
1207   DEPRECATION_WARNING();
1208   return AUL_SVC_RET_OK;
1209 }
1210
1211 extern "C" API int aul_svc_unset_defapp_for_uid(const char* defapp, uid_t uid) {
1212   DEPRECATION_WARNING();
1213   return AUL_SVC_RET_OK;
1214 }
1215
1216 extern "C" API int aul_svc_unset_all_defapps(void) {
1217   DEPRECATION_WARNING();
1218   return AUL_SVC_RET_OK;
1219 }
1220
1221 extern "C" API int aul_svc_unset_all_defapps_for_uid(uid_t uid) {
1222   DEPRECATION_WARNING();
1223   return AUL_SVC_RET_OK;
1224 }
1225
1226 extern "C" API int aul_svc_is_defapp(const char* pkg_name) {
1227   DEPRECATION_WARNING();
1228   return AUL_SVC_RET_OK;
1229 }
1230
1231 extern "C" API int aul_svc_is_defapp_for_uid(const char* pkg_name, uid_t uid) {
1232   DEPRECATION_WARNING();
1233   return AUL_SVC_RET_OK;
1234 }
1235
1236 extern "C" API int aul_svc_set_alias_appid(const char* alias_appid,
1237     const char* appid) {
1238   DEPRECATION_WARNING();
1239   return AUL_SVC_RET_OK;
1240 }
1241
1242 extern "C" API int aul_svc_set_alias_appid_for_uid(const char* alias_appid,
1243     const char* appid, uid_t uid) {
1244   DEPRECATION_WARNING();
1245   return AUL_SVC_RET_OK;
1246 }
1247
1248 extern "C" API int aul_svc_unset_alias_appid(const char* alias_appid) {
1249   DEPRECATION_WARNING();
1250   return AUL_SVC_RET_OK;
1251 }
1252
1253 extern "C" API int aul_svc_unset_alias_appid_for_uid(const char* alias_appid,
1254     uid_t uid) {
1255   DEPRECATION_WARNING();
1256   return AUL_SVC_RET_OK;
1257 }
1258
1259 extern "C" API int aul_svc_foreach_alias_info(
1260     void (*callback)(const char *, const char *, void *),
1261     void* user_data) {
1262   DEPRECATION_WARNING();
1263   return AUL_SVC_RET_OK;
1264 }
1265
1266 extern "C" API int aul_svc_foreach_alias_info_for_uid(
1267     void (*callback)(const char *, const char *, void *),
1268     uid_t uid, void* user_data) {
1269   DEPRECATION_WARNING();
1270   return AUL_SVC_RET_OK;
1271 }
1272
1273 extern "C" API int aul_svc_enable_alias_info(const char* appid) {
1274   DEPRECATION_WARNING();
1275   return AUL_SVC_RET_OK;
1276 }
1277
1278 extern "C" API int aul_svc_enable_alias_info_for_uid(const char* appid,
1279     uid_t uid) {
1280   DEPRECATION_WARNING();
1281   return AUL_SVC_RET_OK;
1282 }
1283
1284 extern "C" API int aul_svc_disable_alias_info(const char* appid) {
1285   DEPRECATION_WARNING();
1286   return AUL_SVC_RET_OK;
1287 }
1288
1289 extern "C" API int aul_svc_disable_alias_info_for_uid(const char* appid,
1290     uid_t uid) {
1291   DEPRECATION_WARNING();
1292   return AUL_SVC_RET_OK;
1293 }
1294
1295 extern "C" API int aul_svc_foreach_alias_info_by_appid(
1296     int (*callback)(const char *, const char *, void *),
1297     const char* appid, void* user_data) {
1298   DEPRECATION_WARNING();
1299   return AUL_SVC_RET_OK;
1300 }
1301
1302 extern "C" API int aul_svc_foreach_alias_info_by_appid_for_uid(
1303     int (*callback)(const char *, const char *, void *),
1304     const char* appid, uid_t uid, void* user_data) {
1305   DEPRECATION_WARNING();
1306   return AUL_SVC_RET_OK;
1307 }
1308
1309 extern "C" API int aul_svc_foreach_allowed_info(
1310     int (*callback)(const char *, const char *, void *),
1311     void* user_data) {
1312   DEPRECATION_WARNING();
1313   return AUL_SVC_RET_OK;
1314 }
1315
1316 extern "C" API int aul_svc_foreach_allowed_info_for_uid(
1317     int (*callback)(const char *, const char *, void *),
1318     uid_t uid, void* user_data) {
1319   DEPRECATION_WARNING();
1320   return AUL_SVC_RET_OK;
1321 }
1322
1323 extern "C" API int aul_svc_foreach_allowed_info_by_appid(
1324     int (*callback)(const char *, const char *, void *),
1325     const char* appid, void* user_data) {
1326   DEPRECATION_WARNING();
1327   return AUL_SVC_RET_OK;
1328 }
1329
1330 extern "C" API int aul_svc_foreach_allowed_info_by_appid_for_uid(
1331     int (*callback)(const char *, const char *, void *),
1332     const char* appid, uid_t uid, void* user_data) {
1333   DEPRECATION_WARNING();
1334   return AUL_SVC_RET_OK;
1335 }