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 service_ = parent_->CreateTask();
440 context_ = g_main_context_new();
441 std::string env = std::to_string(
442 reinterpret_cast<unsigned long int>(context_));
443 setenv("TIZEN_GLIB_CONTEXT", env.c_str(), 1);
445 thread_ = std::thread([&] {
446 SetComm("UIThread+");
447 parent_->DoRun(argc, argv);
450 service_->Run(argc, argv);
452 if (thread_.joinable())
455 setenv("TIZEN_GLIB_CONTEXT", "0", 1);
456 g_main_context_unref(context_);
461 parent_->DoRun(argc, argv);
464 void AppCoreUiBase::Impl::Exit() {
465 if (hint_ & HINT_DUAL_THREAD) {
466 GLib::IdleAdd(context_, [](gpointer user_data) {
467 auto* impl = static_cast<AppCoreUiBase::Impl*>(user_data);
468 impl->parent_->DoExit();
469 return G_SOURCE_REMOVE;
479 void AppCoreUiBase::Run(int argc, char** argv) {
480 impl_->Run(argc, argv);
483 void AppCoreUiBase::Exit() {
487 void AppCoreUiBase::Dispose() {
488 impl_->handler_->UnsetEvents();
491 impl_->appid_.clear();
493 AppCoreBase::Dispose();
495 impl_->handler_->Fini();
498 std::unique_ptr<AppCoreTaskBase> AppCoreUiBase::CreateTask() {
499 return std::make_unique<AppCoreTaskBase>();
502 void AppCoreUiBase::Impl::PrepareToSuspend() {
503 if (parent_->IsBgAllowed() && !parent_->IsSuspended()) {
504 SuspendedState suspend = SUSPENDED_STATE_WILL_ENTER_SUSPEND;
505 parent_->RaiseEvent(suspend, IEvent::Type::SUSPENDED_STATE_CHANGE);
506 parent_->ToggleSuspendedState();
510 void AppCoreUiBase::Impl::ExitFromSuspend() {
511 if (parent_->IsSuspended()) {
512 SuspendedState suspend = SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
513 parent_->RaiseEvent(suspend, IEvent::Type::SUSPENDED_STATE_CHANGE);
514 parent_->ToggleSuspendedState();
518 void AppCoreUiBase::Impl::DoPause() {
519 if (state_ == AS_RUNNING) {
520 aul_app_lifecycle_update_state(AUL_APP_LIFECYCLE_STATE_PAUSED);
522 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:PAUSE");
523 _D("Call pause callback");
524 if (parent_->GetHint() & HINT_DUAL_THREAD)
525 service_->Post(AppCoreTaskBase::UiState::PAUSED);
528 if (core_ui_delegator_)
529 ret = core_ui_delegator_->OnPause();
531 ret = parent_->OnPause();
533 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
534 if (ret >= 0 && resource_reclaiming_)
535 parent_->AddSuspendTimer();
540 aul_status_update(STATUS_BG);
543 void AppCoreUiBase::Impl::DoResume() {
544 if (state_ == AS_PAUSED || state_ == AS_CREATED) {
545 aul_app_lifecycle_update_state(AUL_APP_LIFECYCLE_STATE_RESUMED);
548 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]", appid_.c_str());
549 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:RESUME");
550 _D("Call resume callback");
551 if (parent_->GetHint() & HINT_DUAL_THREAD)
552 service_->Post(AppCoreTaskBase::UiState::RESUMED);
554 parent_->RemoveSuspendTimer();
555 if (core_ui_delegator_)
556 core_ui_delegator_->OnResume();
560 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
561 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]", appid_.c_str());
564 aul_status_update(STATUS_VISIBLE);
567 void AppCoreUiBase::Impl::DoStart(tizen_base::Bundle b) {
568 if (parent_->GetHint() & HINT_WINDOW_STACK_CONTROL)
569 below_app_ = b.GetString(AUL_SVC_K_RELOCATE_BELOW);
572 first_launch_ = false;
576 if (parent_->GetHint() & HINT_BG_LAUNCH_CONTROL) {
577 std::string bg_launch = b.GetString(AUL_SVC_K_BG_LAUNCH);
578 if (!bg_launch.empty() && bg_launch.compare("enable") == 0) {
579 if (!bg_state_ && state_ != AS_RUNNING)
587 if (parent_->GetHint() & HINT_WINDOW_AUTO_CONTROL) {
589 std::string rpc_port = b.GetString(AUL_K_RPC_PORT);
590 if (rpc_port.empty())
596 int AppCoreUiBase::Impl::IsLegacyLifecycle() {
597 static int is_legacy = -1;
598 if (__builtin_expect(is_legacy != -1, 1))
601 const char* api_version = getenv("TIZEN_API_VERSION");
603 if (strverscmp("2.4", api_version) > 0 &&
604 strverscmp("2.2.1", api_version) < 0)
615 int AppCoreUiBase::OnPause() {
619 int AppCoreUiBase::OnResume() {
623 int AppCoreUiBase::OnReceive(aul_type type, tizen_base::Bundle b) {
624 if (impl_->state_ == Impl::AS_DYING) {
625 _E("Skip the event in dying state");
629 if ((type == AUL_TERMINATE_BGAPP || type == AUL_TERMINATE_BG_INST) &&
630 impl_->state_ != Impl::AS_PAUSED)
633 if (type == AUL_START) {
634 impl_->ExitFromSuspend();
636 if (!b.GetString(K_SERVICE_THREAD).empty()) {
637 impl_->service_->OnReceive(type, std::move(b));
642 AppCoreBase::OnReceive(type, b);
647 if (GetHint() & HINT_LEGACY_CONTROL) {
648 if (impl_->bg_state_ && impl_->IsLegacyLifecycle()) {
649 _D("Legacy lifecycle");
655 if (impl_->bg_state_)
656 impl_->ApplyBgState(false);
661 if (impl_->state_ == Impl::AS_RUNNING) {
662 _D("Call pause callback");
663 if (impl_->core_ui_delegator_)
664 impl_->core_ui_delegator_->OnPause();
668 impl_->state_ = Impl::AS_DYING;
670 case AUL_TERMINATE_BGAPP:
671 case AUL_TERMINATE_BG_INST:
672 case AUL_TERMINATE_INST:
673 _D("[APP %d] TERMINATE", getpid());
674 if (impl_->state_ == Impl::AS_RUNNING) {
675 _D("Call pause callback");
676 if (impl_->core_ui_delegator_)
677 impl_->core_ui_delegator_->OnPause();
681 impl_->state_ = Impl::AS_DYING;
682 aul_status_update(STATUS_DYING);
695 int AppCoreUiBase::OnControl(tizen_base::Bundle b) {
696 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]",
697 impl_->appid_.c_str());
698 AppCoreBase::OnControl(std::move(b));
699 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]",
700 impl_->appid_.c_str());
704 int AppCoreUiBase::OnCreate() {
705 impl_->handler_->SetEvents();
706 AppCoreBase::OnCreate();
707 impl_->state_ = Impl::AS_CREATED;
708 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]",
709 impl_->appid_.c_str());
713 int AppCoreUiBase::OnTerminate() {
714 if (impl_->state_ == Impl::AS_RUNNING) {
715 _D("Call pause callback");
719 impl_->state_ = Impl::AS_DYING;
720 AppCoreBase::OnTerminate();
724 int AppCoreUiBase::OnTrimMemory() {
725 return AppCoreBase::OnTrimMemory();
728 int AppCoreUiBase::GroupAdd() {
730 static bool attached = false;
734 int wid = GetMainSurface();
736 _E("window wasn't ready");
740 int ret = aul_app_group_set_window(wid);
742 _E("Failed to set app group window. error(%d)", ret);
750 void AppCoreUiBase::GroupRemove() {
753 aul_app_group_lower(&exit);
760 void AppCoreUiBase::OnShow(int type, void* event) {
761 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Show*>(event);
762 if (ev->parent_win != 0)
765 unsigned int win = static_cast<unsigned int>(ev->win);
766 unsigned int surf = static_cast<unsigned int>(ev->data[0]);
767 _D("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN: %u, %u", win, surf);
769 if (!impl_->FindWin(win))
770 impl_->AddWin(win, surf);
772 impl_->UpdateWin(win, surf, Impl::VT_NONE);
778 bool AppCoreUiBase::Impl::CheckVisible() {
779 _D("[EVENT_TEST][EVENT] __check_visible");
780 for (auto& i : winnode_list_) {
781 _D("win : %u visibility : %d", i->win_, i->vis_);
782 if (i->vis_ == VT_UNOBSCURED)
789 void AppCoreUiBase::OnHide(int type, void* event) {
790 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Hide*>(event);
791 _D("[EVENT_TEST][EVENT] GET HIDE EVENT!!!. WIN :%d", ev->win);
792 if (impl_->FindWin((unsigned int)ev->win)) {
793 impl_->DeleteWin((unsigned int)ev->win);
794 bool bvisibility = impl_->CheckVisible();
795 if (!bvisibility && impl_->w_status_ != Impl::WS_PAUSE) {
796 _D("Go to Pasue state");
797 impl_->w_status_ = Impl::WS_PAUSE;
803 void AppCoreUiBase::OnLower(int type, void* event) {
804 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Lower*>(event);
808 _D("ECORE_WL2_EVENT_WINDOW_LOWER window id: %u", ev->win);
809 if (!(impl_->hint_ & HINT_WINDOW_GROUP_CONTROL))
815 void AppCoreUiBase::OnVisibility(int type, void* event) {
816 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Visibility_Change*>(event);
817 impl_->UpdateWin((unsigned int)ev->win, 0,
818 ev->fully_obscured ? Impl::VT_FULLY_OBSCURED : Impl::VT_UNOBSCURED);
819 bool bvisibility = impl_->CheckVisible();
820 _D("bvisibility %d, w_status_ %d", bvisibility, impl_->w_status_);
822 if (bvisibility && (impl_->hint_ & HINT_WINDOW_STACK_CONTROL) &&
823 !impl_->below_app_.empty()) {
824 aul_app_group_activate_below(impl_->below_app_.c_str());
825 impl_->below_app_.clear();
828 if (bvisibility && impl_->w_status_ != Impl::WS_RESUME) {
829 _D("Go to Resume state");
830 impl_->w_status_ = Impl::WS_RESUME;
832 } else if (!bvisibility && impl_->w_status_ != Impl::WS_PAUSE) {
833 _D("Go to Pasue state");
834 impl_->w_status_ = Impl::WS_PAUSE;
837 _D("No change state");
841 void AppCoreUiBase::OnPreVisibility(int type, void* event) {
842 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Window_Pre_Visibility_Change*>(
844 if (ev && ev->type == ECORE_WL2_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED) {
845 impl_->UpdateWin((unsigned int)ev->win, 0, Impl::VT_UNOBSCURED);
846 bool bvisibility = impl_->CheckVisible();
848 _D("bvisibility %d, w_status_ %d", bvisibility, impl_->w_status_);
849 if (bvisibility && impl_->w_status_ != Impl::WS_RESUME) {
850 _D(" Go to Resume state");
851 impl_->w_status_ = Impl::WS_RESUME;
857 void AppCoreUiBase::OnAuxMessage(int type, void* event) {
858 auto* ev = reinterpret_cast<Ecore_Wl2_Event_Aux_Message*>(event);
859 if (ev->key && !strcmp(ev->key, "dpms_wm")) {
860 if (ev->val && !strcmp(ev->val, "on")) {
861 _D("Display state: on");
862 SetDisplayState(DISPLAY_STATE_ON);
863 } else if (ev->val && !strcmp(ev->val, "off")) {
864 _D("Display state: off");
865 SetDisplayState(DISPLAY_STATE_OFF);
867 _E("Unknown state: %s", ev->val);
872 void AppCoreUiBase::Pause() {
876 void AppCoreUiBase::Resume() {
880 bool AppCoreUiBase::IsResumed() {
881 return impl_->state_ == Impl::AS_RUNNING;
884 int AppCoreUiBase::GetHint() {
888 bool AppCoreUiBase::GetBgState() {
889 return impl_->bg_state_;
892 void AppCoreUiBase::SetBgState(bool bg_state) {
893 impl_->bg_state_ = bg_state;
896 void AppCoreUiBase::SetSystemResourceReclaiming(bool enable) {
897 impl_->resource_reclaiming_ = enable;
900 } // namespace tizen_cpp