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