From c3c205a139f835bae07559605afbaf674c8febc9 Mon Sep 17 00:00:00 2001 From: Daehyeon Jung Date: Fri, 24 Apr 2020 20:17:03 +0900 Subject: [PATCH] Block top app surface feature Change-Id: I2828980a34209279594ba146e98d62aab8cbd1c2 Signed-off-by: Junghoon Park --- ambient-viewer/src/ambient-viewer.cc | 10 +++++++--- ambient-viewer/src/ambient-viewer.hh | 2 +- ambient-viewer/src/stub.cc | 22 ++++++++++++++++++++++ unittest/src/test_ambient_viewer.cc | 10 +++++----- unittest/src/test_ambient_viewer_stub.cc | 6 ++++-- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/ambient-viewer/src/ambient-viewer.cc b/ambient-viewer/src/ambient-viewer.cc index 56a06c0..56f4951 100644 --- a/ambient-viewer/src/ambient-viewer.cc +++ b/ambient-viewer/src/ambient-viewer.cc @@ -95,9 +95,13 @@ void AmbientViewer::OnChangedSignal(keynode_t *node, void *user_data) { } } -void AmbientViewer::Monitor() { - top_app_surface_ = CreateTopAppSurface( - make_shared(win_, false), this); +void AmbientViewer::Monitor(bool full) { + + if (full) { + top_app_surface_ = CreateTopAppSurface( + make_shared(win_, false), this); + } + if (vconf_notify_key_changed( VCONFKEY_WATCH_CURRENT_WATCH_INFO, OnChangedSignal, this) != 0) { LOGE("failed to listen on changed signal"); diff --git a/ambient-viewer/src/ambient-viewer.hh b/ambient-viewer/src/ambient-viewer.hh index bd643ea..a4172c1 100644 --- a/ambient-viewer/src/ambient-viewer.hh +++ b/ambient-viewer/src/ambient-viewer.hh @@ -53,7 +53,7 @@ class EXPORT_API AmbientViewer : public IAmbientViewer { public: AmbientViewer(Evas_Object* win); virtual ~AmbientViewer(); - void Monitor(); + void Monitor(bool full = false); void Unmonitor(); virtual void OnReceived(EventType ev, std::string sender, tizen_base::Bundle extra) = 0; int NotifyAmbientEvent(bool enter, Direction dir, tizen_base::Bundle extra); diff --git a/ambient-viewer/src/stub.cc b/ambient-viewer/src/stub.cc index bfb6dcd..be81a29 100644 --- a/ambient-viewer/src/stub.cc +++ b/ambient-viewer/src/stub.cc @@ -246,6 +246,28 @@ extern "C" EXPORT_API int ambient_viewer_monitor(ambient_viewer_h handle, return AMBIENT_VIEWER_ERROR_NONE; } +extern "C" int ambient_viewer_monitor_full(ambient_viewer_h handle, + ambient_viewer_lifecycle_s lifecycle, void *user_data) { + if (handle == nullptr) { + LOGE("Invalid parameter"); + return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER; + } + + AmbientViewerStub* stub = static_cast(handle); + + unique_ptr info( + new (nothrow) MonitorCallbackInfo(lifecycle, user_data)); + if (info.get() == nullptr) { + LOGE("out of memory"); + return AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY; + } + + stub->SetMonitorCallbackInfo(move(info)); + stub->Monitor(true); + + return AMBIENT_VIEWER_ERROR_NONE; +} + extern "C" EXPORT_API int ambient_viewer_unmonitor(ambient_viewer_h handle) { if (handle == nullptr) { LOGE("Invalid parameter"); diff --git a/unittest/src/test_ambient_viewer.cc b/unittest/src/test_ambient_viewer.cc index 87c4471..5f693a4 100644 --- a/unittest/src/test_ambient_viewer.cc +++ b/unittest/src/test_ambient_viewer.cc @@ -357,7 +357,7 @@ TEST_F(AmbientViewerTest, AmbientViewer_OnReceived) { } TEST_F(AmbientViewerTest, TopAppSurface_IsWatch) { - stub->Monitor(); + stub->Monitor(true); const auto& ws = AmbientViewerTest::stub->GetTopAppSurface(); ASSERT_NE(&ws, nullptr); @@ -367,7 +367,7 @@ TEST_F(AmbientViewerTest, TopAppSurface_IsWatch) { } TEST_F(AmbientViewerTest, TopAppSurface_GetAppId) { - stub->Monitor(); + stub->Monitor(true); const auto& ws = AmbientViewerTest::stub->GetTopAppSurface(); ASSERT_NE(&ws, nullptr); TopAppSurfaceMock* mock = const_cast( @@ -380,7 +380,7 @@ TEST_F(AmbientViewerTest, TopAppSurface_GetAppId) { } TEST_F(AmbientViewerTest, TopAppSurface_GetInstId) { - stub->Monitor(); + stub->Monitor(true); const auto& ws = AmbientViewerTest::stub->GetTopAppSurface(); ASSERT_NE(&ws, nullptr); TopAppSurfaceMock* mock = const_cast( @@ -396,7 +396,7 @@ TEST_F(AmbientViewerTest, TopAppSurface_GetInstId) { } TEST_F(AmbientViewerTest, TopAppSurface_GetOpr) { - stub->Monitor(); + stub->Monitor(true); const auto& ws = AmbientViewerTest::stub->GetTopAppSurface(); ASSERT_NE(&ws, nullptr); TopAppSurfaceMock* mock = const_cast( @@ -411,7 +411,7 @@ TEST_F(AmbientViewerTest, TopAppSurface_GetOpr) { } TEST_F(AmbientViewerTest, AmbientViewer_OnReceived2) { - stub->Monitor(); + stub->Monitor(true); const auto& ws = AmbientViewerTest::stub->GetWatchSurface(); ASSERT_NE(&ws, nullptr); stub->received_ = false; diff --git a/unittest/src/test_ambient_viewer_stub.cc b/unittest/src/test_ambient_viewer_stub.cc index 3739b86..426d83a 100644 --- a/unittest/src/test_ambient_viewer_stub.cc +++ b/unittest/src/test_ambient_viewer_stub.cc @@ -23,6 +23,8 @@ extern "C" int ambient_viewer_create_mock(Evas_Object *win, ambient_viewer_h *handle); +extern "C" int ambient_viewer_monitor_full(ambient_viewer_h handle, + ambient_viewer_lifecycle_s lifecycle, void *user_data); namespace { @@ -160,7 +162,7 @@ TEST_F(AmbientViewerStubTest, ambient_viewer_get_top_app_surface) { &handle), AMBIENT_VIEWER_ERROR_NONE); ASSERT_NE(handle, nullptr); ambient_viewer_lifecycle_s lifecycle = { 0, }; - ASSERT_EQ(ambient_viewer_monitor(handle, lifecycle, nullptr), + ASSERT_EQ(ambient_viewer_monitor_full(handle, lifecycle, nullptr), AMBIENT_VIEWER_ERROR_NONE); EXPECT_EQ(ambient_viewer_get_top_app_surface(handle, &surface), @@ -180,7 +182,7 @@ class AmbientViewerStubSurfaceTest : public ::testing::Test { &__not_null), &handle_), AMBIENT_VIEWER_ERROR_NONE); ASSERT_NE(handle_, nullptr); ambient_viewer_lifecycle_s lifecycle = { 0, }; - ASSERT_EQ(ambient_viewer_monitor(handle_, lifecycle, nullptr), + ASSERT_EQ(ambient_viewer_monitor_full(handle_, lifecycle, nullptr), AMBIENT_VIEWER_ERROR_NONE); ASSERT_EQ(ambient_viewer_get_top_app_surface(handle_, &surface_), -- 2.7.4