}
}
-void AmbientViewer::Monitor() {
- top_app_surface_ = CreateTopAppSurface(
- make_shared<screen_connector::EvasObject>(win_, false), this);
+void AmbientViewer::Monitor(bool full) {
+
+ if (full) {
+ top_app_surface_ = CreateTopAppSurface(
+ make_shared<screen_connector::EvasObject>(win_, false), this);
+ }
+
if (vconf_notify_key_changed(
VCONFKEY_WATCH_CURRENT_WATCH_INFO, OnChangedSignal, this) != 0) {
LOGE("failed to listen on changed signal");
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);
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<AmbientViewerStub*>(handle);
+
+ unique_ptr<MonitorCallbackInfo> 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");
}
TEST_F(AmbientViewerTest, TopAppSurface_IsWatch) {
- stub->Monitor();
+ stub->Monitor(true);
const auto& ws = AmbientViewerTest::stub->GetTopAppSurface();
ASSERT_NE(&ws, nullptr);
}
TEST_F(AmbientViewerTest, TopAppSurface_GetAppId) {
- stub->Monitor();
+ stub->Monitor(true);
const auto& ws = AmbientViewerTest::stub->GetTopAppSurface();
ASSERT_NE(&ws, nullptr);
TopAppSurfaceMock* mock = const_cast<TopAppSurfaceMock*>(
}
TEST_F(AmbientViewerTest, TopAppSurface_GetInstId) {
- stub->Monitor();
+ stub->Monitor(true);
const auto& ws = AmbientViewerTest::stub->GetTopAppSurface();
ASSERT_NE(&ws, nullptr);
TopAppSurfaceMock* mock = const_cast<TopAppSurfaceMock*>(
}
TEST_F(AmbientViewerTest, TopAppSurface_GetOpr) {
- stub->Monitor();
+ stub->Monitor(true);
const auto& ws = AmbientViewerTest::stub->GetTopAppSurface();
ASSERT_NE(&ws, nullptr);
TopAppSurfaceMock* mock = const_cast<TopAppSurfaceMock*>(
}
TEST_F(AmbientViewerTest, AmbientViewer_OnReceived2) {
- stub->Monitor();
+ stub->Monitor(true);
const auto& ws = AmbientViewerTest::stub->GetWatchSurface();
ASSERT_NE(&ws, nullptr);
stub->received_ = false;
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 {
&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),
&__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_),