2 * Copyright (c) 2021 - 2022 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "app-core-ui-cpp/app_core_ui_base.hh"
19 #include <Ecore_Wl2.h>
20 #include <aul_app_lifecycle.h>
21 #include <aul_rpc_port.h>
23 #include <bundle_internal.h>
26 #include <sys/syscall.h>
27 #include <sys/types.h>
36 #include "app-core-cpp/app_core_base.hh"
37 #include "app-core-ui-cpp/api/app_core_ui_base.h"
38 #include "app-core-ui-cpp/app_core_task_base.hh"
39 #include "app-core-ui-cpp/app_core_ui_delegator_private.hh"
40 #include "app-core-ui-cpp/app_core_ui_plugin_private.hh"
41 #include "app-core-ui-cpp/wayland_handler_private.hh"
42 #include "common/ecore_handler.hh"
43 #include "common/glib_private.hh"
44 #include "common/log_private.hh"
48 constexpr const char K_SERVICE_THREAD[] = "__K_SERVICE_THREAD";
50 void SetComm(const std::string& name) {
51 pid_t tid = syscall(__NR_gettid);
52 std::string path = "/proc/" + std::to_string(tid) + "/comm";
53 int fd = open(path.c_str(), O_WRONLY);
55 _E("open(%s) is failed. errno(%d)", path.c_str(), errno);
59 ssize_t bytes_written = write(fd, name.c_str(), name.length() + 1);
60 if (bytes_written < 0)
61 _E("write(%d) is failed. errno(%d)", fd, errno);
66 class AppCoreUiBase::Impl {
68 Impl(AppCoreUiBase* parent, unsigned int hint)
71 handler_(std::make_shared<EcoreHandler>(parent)),
72 wl_handler_(new WaylandHandler()) {
76 friend class AppCoreUiBase;
77 AppCoreUiBase* parent_;
103 WinNode(unsigned int win, unsigned int surf)
104 : win_(win), surf_(surf), vis_(VT_NONE) {
108 void ExitFromSuspend();
109 void PrepareToSuspend();
110 void DoStart(tizen_base::Bundle b);
114 int IsLegacyLifecycle();
115 std::shared_ptr<struct WinNode> FindWin(unsigned int win);
116 bool AddWin(unsigned int win, unsigned int surf);
117 bool DeleteWin(unsigned int win);
118 bool UpdateWin(unsigned int win, unsigned int surf, int vis);
121 void ApplyBgState(bool bg_state);
125 void PluginInit(int argc, char** argv);
127 void Run(int argc, char** argv);
130 std::list<std::shared_ptr<WinNode>> winnode_list_;
132 std::string below_app_;
133 bool first_launch_ = true;
134 bool bg_state_ = false;
135 bool resource_reclaiming_ = true;
137 AppState state_ = AS_NONE;
138 WinStatus w_status_ = WS_NONE;
139 std::shared_ptr<EcoreHandler> handler_;
140 std::unique_ptr<WaylandHandler> wl_handler_;
141 IAppCoreUi* core_ui_delegator_ = nullptr;
142 std::unique_ptr<AppCoreUiDelegator> plugin_delegator_;
143 std::unique_ptr<AppCoreUiPlugin> plugin_;
144 std::unique_ptr<AppCoreTaskBase> service_;
145 GMainContext* context_ = nullptr;
149 AppCoreUiBase::AppCoreUiBase(unsigned int hint)
150 : impl_(new Impl(this, hint)) {
153 AppCoreUiBase::~AppCoreUiBase() = default;
155 std::shared_ptr<AppCoreUiBase::Impl::WinNode> AppCoreUiBase::Impl::FindWin(
157 for (auto& i : winnode_list_) {
165 bool AppCoreUiBase::Impl::AddWin(unsigned int win, unsigned int surf) {
166 _D("[EVENT_TEST][EVENT] __add_win WIN: %u", win);
167 std::shared_ptr<AppCoreUiBase::Impl::WinNode> node = FindWin(win);
168 if (node != nullptr) {
169 _D("[EVENT_TEST][EVENT] ERROR There is already window: %u", win);
173 winnode_list_.emplace_back(new WinNode(win, surf));
177 bool AppCoreUiBase::Impl::DeleteWin(unsigned int win) {
178 std::shared_ptr<struct AppCoreUiBase::Impl::WinNode> node = FindWin(win);
179 if (node == nullptr) {
180 _D("[EVENT_TEST][EVENT] ERROR There is no window: %u", win);
184 winnode_list_.remove_if(
185 [win](std::shared_ptr<struct AppCoreUiBase::Impl::WinNode> node) {
186 return node->win_ == win;
191 bool AppCoreUiBase::Impl::UpdateWin(unsigned int win, unsigned int surf,
193 std::shared_ptr<AppCoreUiBase::Impl::WinNode> node = FindWin(win);
194 if (node == nullptr) {
195 _D("[EVENT_TEST][EVENT] ERROR There is no window: %u", win);
208 void AppCoreUiBase::Impl::RaiseWin() {
209 if (!(hint_ & HINT_WINDOW_STACK_CONTROL))
212 unsigned int win_id = parent_->GetMainWindow();
213 _I("Raise window: %u", win_id);
214 handler_->RaiseWin(win_id);
217 void AppCoreUiBase::Impl::PauseWin() {
218 if (!(hint_ & HINT_WINDOW_STACK_CONTROL))
222 for (auto& i : winnode_list_) {
223 _D("Pause window: %u", i->win_);
224 handler_->PauseWin(i->win_);
228 unsigned int AppCoreUiBase::GetMainWindow() {
229 if (impl_->winnode_list_.empty())
232 return impl_->winnode_list_.begin()->get()->win_;
235 unsigned int AppCoreUiBase::GetMainSurface() {
236 if (impl_->winnode_list_.empty())
239 return impl_->winnode_list_.begin()->get()->surf_;
242 void AppCoreUiBase::SetCoreUiDelegator(IAppCoreUi* delegator) {
243 impl_->core_ui_delegator_ = delegator;
246 void AppCoreUiBase::SetWindowDelegator(IWindow* delegator) {
247 impl_->handler_->SetWindow(delegator);
250 int AppCoreUiBase::Impl::InitWl() {
251 return wl_handler_->Init();
254 int AppCoreUiBase::Impl::FiniWl() {
259 void AppCoreUiBase::Impl::ApplyBgState(bool bg_state) {
260 if (wl_handler_->Init() < 0)
264 wl_handler_->SetBgState();
266 wl_handler_->UnsetBgState();
268 parent_->SetBgState(bg_state);
271 void AppCoreUiBase::Impl::SetAppId() {
272 if (wl_handler_->Init() < 0)
275 wl_handler_->SetAppId(appid_);
278 void AppCoreUiBase::Impl::PluginInit(int argc, char** argv) {
279 plugin_.reset(AppCoreUiPlugin::Load());
280 if (plugin_ == nullptr)
283 app_core_ui_base_ops ops;
284 ops.base.create = [](void* data) -> int {
285 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
286 return base->OnCreate();
289 ops.base.control = [](bundle* b, void* data) -> int {
290 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
291 return base->OnControl(tizen_base::Bundle(b));
294 ops.base.terminate = [](void* data) -> int {
295 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
296 return base->OnTerminate();
299 ops.base.receive = [](aul_type type, bundle* b, void* data) -> int {
300 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
301 return base->OnReceive(type, tizen_base::Bundle(b));
304 ops.base.set_i18n = [](void* data) -> int {
305 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
306 return base->OnSetI18n();
309 ops.base.init = [](int argc, char** argv, void* data) {
310 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
311 base->OnLoopInit(argc, argv);
314 ops.base.finish = [](void* data) {
315 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
316 base->OnLoopFinish();
319 ops.base.run = [](void* data) {
320 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
324 ops.base.exit = [](void* data) {
325 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
329 ops.base.set_event = [](app_core_ui_base_event_e event, void* data) {
330 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
331 base->OnSetEvent(static_cast<IAppCore::IEvent::Type>(event));
334 ops.base.unset_event = [](app_core_ui_base_event_e event, void* data) {
335 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
336 base->OnUnsetEvent(static_cast<IAppCore::IEvent::Type>(event));
339 ops.base.trim_memory = [](void* data) {
340 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
341 base->OnTrimMemory();
344 ops.pause = [](void* data) -> int {
345 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
346 return base->OnPause();
349 ops.resume = [](void* data) -> int {
350 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
351 return base->OnResume();
354 ops.window.show = [](int type, void* event, void* data) {
355 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
356 base->OnShow(type, event);
359 ops.window.hide = [](int type, void* event, void* data) {
360 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
361 base->OnHide(type, event);
364 ops.window.lower = [](int type, void* event, void* data) {
365 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
366 base->OnLower(type, event);
369 ops.window.visibility = [](int type, void* event, void* data) {
370 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
371 base->OnVisibility(type, event);
374 ops.window.pre_visibility = [](int type, void* event, void* data) {
375 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
376 base->OnPreVisibility(type, event);
379 ops.window.aux_message = [](int type, void* event, void* data) {
380 auto* base = reinterpret_cast<AppCoreUiBase*>(data);
381 base->OnAuxMessage(type, event);
384 plugin_->Init(parent_, &ops, argc, argv, &hint_);
385 plugin_delegator_.reset(new AppCoreUiDelegator(ops, parent_));
386 parent_->SetCoreDelegator(plugin_delegator_.get());
387 parent_->SetLoopDelegator(plugin_delegator_.get());
388 parent_->SetCoreUiDelegator(plugin_delegator_.get());
389 parent_->SetWindowDelegator(plugin_delegator_.get());
392 void AppCoreUiBase::Impl::PluginFini() {
393 if (plugin_ == nullptr)
396 plugin_->Fini(parent_);
399 void AppCoreUiBase::DoRun(int argc, char** argv) {
400 SetCoreDelegator(nullptr);
401 SetLoopDelegator(nullptr);
402 SetCoreUiDelegator(nullptr);
403 SetWindowDelegator(this);
404 impl_->plugin_delegator_.reset();
406 impl_->handler_->Init();
407 impl_->PluginInit(argc, argv);
409 char appid[PATH_MAX] = {0, };
410 int ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
412 _E("Fail to get appid. pid(%d)", getpid());
414 impl_->state_ = Impl::AS_NONE;
415 impl_->w_status_ = Impl::WS_NONE;
416 impl_->appid_ = std::string(appid);
417 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", appid);
418 if (impl_->hint_ & HINT_BG_LAUNCH_CONTROL) {
419 tizen_base::Bundle b(bundle_import_from_argv(argc, argv), false, true);
421 std::string bg_launch = b.GetString(AUL_SVC_K_BG_LAUNCH);
422 if (bg_launch.compare("enable") == 0)
423 impl_->ApplyBgState(true);
427 if (impl_->hint_ & HINT_WINDOW_ID_CONTROL)
430 AppCoreBase::Run(argc, argv);
433 void AppCoreUiBase::DoExit() {
437 void AppCoreUiBase::Impl::Run(int argc, char** argv) {
438 if (hint_ & HINT_DUAL_THREAD) {
439 // For the loader case
440 while (ecore_shutdown() != 0);
442 service_ = parent_->CreateTask();
443 context_ = g_main_context_new();
444 std::string env = std::to_string(
445 reinterpret_cast<unsigned long int>(context_));
446 setenv("TIZEN_GLIB_CONTEXT", env.c_str(), 1);
448 thread_ = std::thread([&] {
449 SetComm("UIThread+");
450 parent_->DoRun(argc, argv);
453 service_->Run(argc, argv);
455 if (thread_.joinable())
458 setenv("TIZEN_GLIB_CONTEXT", "0", 1);
459 g_main_context_unref(context_);
464 parent_->DoRun(argc, argv);
467 void AppCoreUiBase::Impl::Exit() {
468 if (hint_ & HINT_DUAL_THREAD) {
469 GLib::IdleAdd(context_, [](gpointer user_data) {
470 auto* impl = static_cast<AppCoreUiBase::Impl*>(user_data);
471 impl->parent_->DoExit();
472 return G_SOURCE_REMOVE;
482 void AppCoreUiBase::Run(int argc, char** argv) {
483 impl_->Run(argc, argv);
486 void AppCoreUiBase::Exit() {
490 void AppCoreUiBase::Dispose() {
491 impl_->handler_->UnsetEvents();
494 impl_->appid_.clear();
496 AppCoreBase::Dispose();
498 impl_->handler_->Fini();
501 std::unique_ptr<AppCoreTaskBase> AppCoreUiBase::CreateTask() {
502 return std::make_unique<AppCoreTaskBase>();
505 void AppCoreUiBase::Impl::PrepareToSuspend() {
506 if (parent_->IsBgAllowed() && !parent_->IsSuspended()) {
507 SuspendedState suspend = SUSPENDED_STATE_WILL_ENTER_SUSPEND;
508 parent_->RaiseEvent(suspend, IEvent::Type::SUSPENDED_STATE_CHANGE);
509 parent_->ToggleSuspendedState();
513 void AppCoreUiBase::Impl::ExitFromSuspend() {
514 if (parent_->IsSuspended()) {
515 SuspendedState suspend = SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
516 parent_->RaiseEvent(suspend, IEvent::Type::SUSPENDED_STATE_CHANGE);
517 parent_->ToggleSuspendedState();
521 void AppCoreUiBase::Impl::DoPause() {
522 if (state_ == AS_RUNNING) {
523 aul_app_lifecycle_update_state(AUL_APP_LIFECYCLE_STATE_PAUSED);
525 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:PAUSE");
526 _D("Call pause callback");
527 if (parent_->GetHint() & HINT_DUAL_THREAD)
528 service_->Post(AppCoreTaskBase::UiState::PAUSED);
531 if (core_ui_delegator_)
532 ret = core_ui_delegator_->OnPause();
534 ret = parent_->OnPause();
536 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
537 if (ret >= 0 && resource_reclaiming_)
538 parent_->AddSuspendTimer();
543 aul_status_update(STATUS_BG);
546 void AppCoreUiBase::Impl::DoResume() {
547 if (state_ == AS_PAUSED || state_ == AS_CREATED) {
548 aul_app_lifecycle_update_state(AUL_APP_LIFECYCLE_STATE_RESUMED);
551 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]", appid_.c_str());
552 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:RESUME");
553 _D("Call resume callback");
554 if (parent_->GetHint() & HINT_DUAL_THREAD)
555 service_->Post(AppCoreTaskBase::UiState::RESUMED);
557 parent_->RemoveSuspendTimer();
558 if (core_ui_delegator_)
559 core_ui_delegator_->OnResume();
563 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
564 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]", appid_.c_str());
567 aul_status_update(STATUS_VISIBLE);
570 void AppCoreUiBase::Impl::DoStart(tizen_base::Bundle b) {
571 if (parent_->GetHint() & HINT_WINDOW_STACK_CONTROL)
572 below_app_ = b.GetString(AUL_SVC_K_RELOCATE_BELOW);
575 first_launch_ = false;
579 std::string rpc_port = b.GetString(AUL_K_RPC_PORT);
580 if (parent_->GetHint() & HINT_BG_LAUNCH_CONTROL) {
581 std::string bg_launch = b.GetString(AUL_SVC_K_BG_LAUNCH);
582 if (!bg_launch.empty() && bg_launch.compare("enable") == 0) {
583 if (!bg_state_ && state_ != AS_RUNNING)
586 if (bg_state_ && rpc_port.empty())
591 if (parent_->GetHint() & HINT_WINDOW_AUTO_CONTROL) {
592 if (!bg_state_ && rpc_port.empty())
597 int AppCoreUiBase::Impl::IsLegacyLifecycle() {
598 static int is_legacy = -1;
599 if (__builtin_expect(is_legacy != -1, 1))
602 const char* api_version = getenv("TIZEN_API_VERSION");
604 if (strverscmp("2.4", api_version) > 0 &&
605 strverscmp("2.2.1", api_version) < 0)
616 int AppCoreUiBase::OnPause() {
620 int AppCoreUiBase::OnResume() {
624 int AppCoreUiBase::OnReceive(aul_type type, tizen_base::Bundle b) {
625 if (impl_->state_ == Impl::AS_DYING) {
626 _E("Skip the event in dying state");
630 if ((type == AUL_TERMINATE_BGAPP || type == AUL_TERMINATE_BG_INST) &&
631 impl_->state_ != Impl::AS_PAUSED)
634 if (type == AUL_START) {
635 impl_->ExitFromSuspend();
637 if (!b.GetString(K_SERVICE_THREAD).empty()) {
638 impl_->service_->OnReceive(type, std::move(b));
643 AppCoreBase::OnReceive(type, b);
648 if (GetHint() & HINT_LEGACY_CONTROL) {
649 if (impl_->bg_state_ && impl_->IsLegacyLifecycle()) {
650 _D("Legacy lifecycle");
656 if (impl_->bg_state_)
657 impl_->ApplyBgState(false);
662 if (impl_->state_ == Impl::AS_RUNNING) {
663 _D("Call pause callback");
664 if (impl_->core_ui_delegator_)
665 impl_->core_ui_delegator_->OnPause();
669 impl_->state_ = Impl::AS_DYING;
671 case AUL_TERMINATE_BGAPP:
672 case AUL_TERMINATE_BG_INST:
673 case AUL_TERMINATE_INST:
674 _D("[APP %d] TERMINATE", getpid());
675 if (impl_->state_ == Impl::AS_RUNNING) {
676 _D("Call pause callback");
677 if (impl_->core_ui_delegator_)
678 impl_->core_ui_delegator_->OnPause();
682 impl_->state_ = Impl::AS_DYING;
683 aul_status_update(STATUS_DYING);
696 int AppCoreUiBase::OnControl(tizen_base::Bundle b) {
697 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]",
698 impl_->appid_.c_str());
699 AppCoreBase::OnControl(std::move(b));
700 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]",
701 impl_->appid_.c_str());
705 int AppCoreUiBase::OnCreate() {
706 impl_->handler_->SetEvents();
707 AppCoreBase::OnCreate();
708 impl_->state_ = Impl::AS_CREATED;
709 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]",
710 impl_->appid_.c_str());
714 int AppCoreUiBase::OnTerminate() {
715 if (impl_->state_ == Impl::AS_RUNNING) {
716 _D("Call pause callback");
720 impl_->state_ = Impl::AS_DYING;
721 AppCoreBase::OnTerminate();
725 int AppCoreUiBase::OnTrimMemory() {
726 return AppCoreBase::OnTrimMemory();
729 int AppCoreUiBase::GroupAdd() {
731 static bool attached = false;
735 int wid = GetMainSurface();
737 _E("window wasn't ready");
741 int ret = aul_app_group_set_window(wid);
743 _E("Failed to set app group window. error(%d)", ret);
751 void AppCoreUiBase::GroupRemove() {
754 aul_app_group_lower(&exit);
761 void AppCoreUiBase::OnShow(int type, void* event) {
762 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Show*>(event);
763 if (ev->parent_win != 0)
766 unsigned int win = static_cast<unsigned int>(ev->win);
767 unsigned int surf = static_cast<unsigned int>(ev->data[0]);
768 _D("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN: %u, %u", win, surf);
770 if (!impl_->FindWin(win))
771 impl_->AddWin(win, surf);
773 impl_->UpdateWin(win, surf, Impl::VT_NONE);
779 bool AppCoreUiBase::Impl::CheckVisible() {
780 _D("[EVENT_TEST][EVENT] __check_visible");
781 for (auto& i : winnode_list_) {
782 _D("win : %u visibility : %d", i->win_, i->vis_);
783 if (i->vis_ == VT_UNOBSCURED)
790 void AppCoreUiBase::OnHide(int type, void* event) {
791 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Hide*>(event);
792 _D("[EVENT_TEST][EVENT] GET HIDE EVENT!!!. WIN :%d", ev->win);
793 if (impl_->FindWin((unsigned int)ev->win)) {
794 impl_->DeleteWin((unsigned int)ev->win);
795 bool bvisibility = impl_->CheckVisible();
796 if (!bvisibility && impl_->w_status_ != Impl::WS_PAUSE) {
797 _D("Go to Pasue state");
798 impl_->w_status_ = Impl::WS_PAUSE;
804 void AppCoreUiBase::OnLower(int type, void* event) {
805 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Lower*>(event);
809 _D("ECORE_WL2_EVENT_WINDOW_LOWER window id: %u", ev->win);
810 if (!(impl_->hint_ & HINT_WINDOW_GROUP_CONTROL))
816 void AppCoreUiBase::OnVisibility(int type, void* event) {
817 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Visibility_Change*>(event);
818 impl_->UpdateWin((unsigned int)ev->win, 0,
819 ev->fully_obscured ? Impl::VT_FULLY_OBSCURED : Impl::VT_UNOBSCURED);
820 bool bvisibility = impl_->CheckVisible();
821 _D("bvisibility %d, w_status_ %d", bvisibility, impl_->w_status_);
823 if (bvisibility && (impl_->hint_ & HINT_WINDOW_STACK_CONTROL) &&
824 !impl_->below_app_.empty()) {
825 aul_app_group_activate_below(impl_->below_app_.c_str());
826 impl_->below_app_.clear();
829 if (bvisibility && impl_->w_status_ != Impl::WS_RESUME) {
830 _D("Go to Resume state");
831 impl_->w_status_ = Impl::WS_RESUME;
833 } else if (!bvisibility && impl_->w_status_ != Impl::WS_PAUSE) {
834 _D("Go to Pasue state");
835 impl_->w_status_ = Impl::WS_PAUSE;
838 _D("No change state");
842 void AppCoreUiBase::OnPreVisibility(int type, void* event) {
843 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Pre_Visibility_Change*>(
845 if (ev && ev->type == ECORE_WL2_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED) {
846 impl_->UpdateWin((unsigned int)ev->win, 0, Impl::VT_UNOBSCURED);
847 bool bvisibility = impl_->CheckVisible();
849 _D("bvisibility %d, w_status_ %d", bvisibility, impl_->w_status_);
850 if (bvisibility && impl_->w_status_ != Impl::WS_RESUME) {
851 _D(" Go to Resume state");
852 impl_->w_status_ = Impl::WS_RESUME;
858 void AppCoreUiBase::OnAuxMessage(int type, void* event) {
859 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Aux_Message*>(event);
860 if (ev->key && !strcmp(ev->key, "dpms_wm")) {
861 if (ev->val && !strcmp(ev->val, "on")) {
862 _D("Display state: on");
863 SetDisplayState(DISPLAY_STATE_ON);
864 } else if (ev->val && !strcmp(ev->val, "off")) {
865 _D("Display state: off");
866 SetDisplayState(DISPLAY_STATE_OFF);
868 _E("Unknown state: %s", ev->val);
873 void AppCoreUiBase::Pause() {
877 void AppCoreUiBase::Resume() {
881 bool AppCoreUiBase::IsResumed() {
882 return impl_->state_ == Impl::AS_RUNNING;
885 int AppCoreUiBase::GetHint() {
889 bool AppCoreUiBase::GetBgState() {
890 return impl_->bg_state_;
893 void AppCoreUiBase::SetBgState(bool bg_state) {
894 impl_->bg_state_ = bg_state;
897 void AppCoreUiBase::SetSystemResourceReclaiming(bool enable) {
898 impl_->resource_reclaiming_ = enable;
901 } // namespace tizen_cpp