summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2023-11-15 15:30:58 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2023-11-15 15:30:58 +0900
commit545552205ecbc8631f03fc13818abc5bad75d48d (patch)
tree36ef812122298bfaee83fb6a943eda5091acfc41
parent6a0b7fda92831fa6fca339aaf8b70553c1915446 (diff)
downloadaul-1-545552205ecbc8631f03fc13818abc5bad75d48d.tar.gz
aul-1-545552205ecbc8631f03fc13818abc5bad75d48d.tar.bz2
aul-1-545552205ecbc8631f03fc13818abc5bad75d48d.zip
Print warning messages
Currently, product developers are using the aul_app_get_status() API in the aul_app_info_iter_fn callback function. This behavior has an adverse effect on AMD latency. This patch adds the output of a warning message to the developer when the aul_app_get_status() API is used within the aul_app_info_iter_fn callback. Whether or not to call the callback was processed using thread local storage. Change-Id: Iacb5ff451775b340e88cbd39ca20ff845321a89d Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--src/pkginfo.cc10
-rw-r--r--src/status.cc15
2 files changed, 25 insertions, 0 deletions
diff --git a/src/pkginfo.cc b/src/pkginfo.cc
index 307980df..b0503e7d 100644
--- a/src/pkginfo.cc
+++ b/src/pkginfo.cc
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "pkginfo_internal.h"
+
#include <bundle_cpp.h>
#include <bundle_internal.h>
#include <glib-unix.h>
@@ -26,6 +28,7 @@
#include <exception>
#include <memory>
#include <string>
+#include <thread>
#include "app_request.h"
#include "aul_api.h"
@@ -243,6 +246,7 @@ int SetAppInfo(aul_app_info* info, const tizen_base::Bundle& b) {
return 0;
}
+thread_local bool calling_appinfo_cb = false;
int GetRunningAppInfoWithCb(int cmd, uid_t uid, aul_app_info_iter_fn cb,
void* user_data) {
if (cb == nullptr)
@@ -253,6 +257,7 @@ int GetRunningAppInfoWithCb(int cmd, uid_t uid, aul_app_info_iter_fn cb,
if (ret != AUL_R_OK)
return ret;
+ calling_appinfo_cb = true;
aul_app_info info;
for (auto const& b : results) {
if (SetAppInfo(&info, b) != 0)
@@ -260,6 +265,7 @@ int GetRunningAppInfoWithCb(int cmd, uid_t uid, aul_app_info_iter_fn cb,
cb(&info, user_data);
}
+ calling_appinfo_cb = false;
return AUL_R_OK;
}
@@ -286,6 +292,10 @@ int GetPkgIdFromDB(int pid, char* buf, int len, uid_t uid) {
} // namespace
+extern "C" bool aul_is_calling_appinfo_cb() {
+ return calling_appinfo_cb;
+}
+
extern "C" API int aul_app_get_pid(const char* appid) {
return aul_app_get_pid_for_uid(appid, getuid());
}
diff --git a/src/status.cc b/src/status.cc
index e40ee1c7..27d1b035 100644
--- a/src/status.cc
+++ b/src/status.cc
@@ -34,6 +34,7 @@
#include "app_request.h"
#include "aul/common/exception.hh"
+#include "pkginfo_internal.h"
using namespace aul::internal;
@@ -207,6 +208,12 @@ extern "C" API int aul_app_get_status_bypid_for_uid(int pid, uid_t uid) {
if (pid == getpid())
return context.GetStatus();
+ if (aul_is_calling_appinfo_cb()) {
+ _E("=====================================================================");
+ _E("=> Do not use this function within the aul_app_info_iter_fn callback.");
+ _E("=====================================================================");
+ }
+
return AppRequest(APP_GET_STATUS, uid)
.SetPid(pid)
.SendSimply();
@@ -222,6 +229,14 @@ extern "C" API int aul_app_get_status_for_uid(const char* appid, uid_t uid) {
return AUL_R_EINVAL;
}
+ if (aul_is_calling_appinfo_cb()) {
+ _E("=====================================================================");
+ _E("=> Do not use this function within the aul_app_info_iter_fn callback.");
+ _E("=> The status info is already included in the aul_app_info structure.");
+ _E("=> If you want focused pid information, use the aul_window_get_focused_pid() function.");
+ _E("=====================================================================");
+ }
+
return AppRequest(APP_GET_STATUS_BY_APPID, uid)
.SetAppId(appid)
.SendSimply();