AMBIENT_VIEWER_DIRECTION_ALL, /**<All */
} ambient_viewer_direction_e;
+typedef enum {
+ AMBIENT_VIEWER_AMBIENT_STATE_LEAVE, /**<AMBIENT LEAVE */
+ AMBIENT_VIEWER_AMBIENT_STATE_ENTER, /**<AMBIENT ENTER */
+ AMBIENT_VIEWER_AMBIENT_STATE_BLOCK_TICK, /**<AMBIENT BLOCK TICK */
+} ambient_viewer_state_e;
+
/**
* @brief The callback function for lifecycle added.
* @remarks This function only for internal applications.
* @brief Notifies the ambient event.
* @remarks This function only for internal applications.
* @param[in] handle The ambient viewer handle
- * @param[in] enter Whether to enter ambient mode
+ * @param[in] state Ambient state
* @param[in] dir Direction to notify
* @param[in] extra The bundle handle
* @return #AMBIENT_VIEWER_ERROR_NONE On success, other value on failure
* @retval #AMBIENT_VIEWER_ERROR_INVALID_PARAMETER Invalid parameter
* @see #ambient_viewer_direction_e
*/
-int ambient_viewer_notify_ambient_event(ambient_viewer_h handle, bool enter,
+int ambient_viewer_notify_ambient_event(ambient_viewer_h handle, ambient_viewer_state_e state,
ambient_viewer_direction_e dir, bundle *extra);
/**
Bundle extra) {
}
-int AmbientViewer::NotifyAmbientEvent(bool enter, AmbientViewer::Direction dir,
+int AmbientViewer::NotifyAmbientEvent(AmbientState state, AmbientViewer::Direction dir,
Bundle extra) {
bundle* b;
bundle* extra_data;
extra_data = extra.GetHandle();
- snprintf(ambient_mode, sizeof(ambient_mode), "%d", (int)enter);
+ snprintf(ambient_mode, sizeof(ambient_mode), "%d", (int)state);
bundle_add_str(b, "__AMBIENT_MODE__", ambient_mode);
bundle_encode(extra_data, &raw, &len);
EVENT_WATCH_CHANGED,
};
+ enum AmbientState {
+ AMBIENT_LEAVE,
+ AMBIENT_ENTER,
+ AMBIENT_BLOCK_TICK,
+ };
+
enum Direction {
DIRECTION_VIEWER_AND_WATCH,
DIRECTION_VIEWER_AND_TOP_APP,
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);
+ int NotifyAmbientEvent(AmbientState state, Direction dir, tizen_base::Bundle extra);
const ISurface& GetWatchSurface() const;
const ISurface& GetTopAppSurface() const;
void BlockUpdate(bool enable);
}
extern "C" EXPORT_API int ambient_viewer_notify_ambient_event(
- ambient_viewer_h handle, bool enter,
+ ambient_viewer_h handle, ambient_viewer_state_e state,
ambient_viewer_direction_e dir, bundle *extra) {
if (handle == nullptr) {
LOGE("Invalid parameter");
}
AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
- stub->NotifyAmbientEvent(enter, static_cast<AmbientViewer::Direction>(dir),
- Bundle(extra, false, false));
+ stub->NotifyAmbientEvent((AmbientViewer::AmbientState)state,
+ static_cast<AmbientViewer::Direction>(dir), Bundle(extra, false, false));
return AMBIENT_VIEWER_ERROR_NONE;
}
TEST_F(AmbientViewerTest, NotifyAmbientEvent) {
Bundle b;
- EXPECT_EQ(AmbientViewerTest::stub->NotifyAmbientEvent(true,
+ EXPECT_EQ(AmbientViewerTest::stub->NotifyAmbientEvent(AmbientViewer::AMBIENT_ENTER,
AmbientViewer::DIRECTION_ALL, b), 0);
}
TEST_F(AmbientViewerTest, NotifyAmbientEvent2) {
Bundle b;
- EXPECT_EQ(AmbientViewerTest::stub->NotifyAmbientEvent(true,
+ EXPECT_EQ(AmbientViewerTest::stub->NotifyAmbientEvent(AmbientViewer::AMBIENT_ENTER,
AmbientViewer::DIRECTION_VIEWER_AND_WATCH, b), 0);
}
TEST_F(AmbientViewerTest, NotifyAmbientEvent3) {
Bundle b;
- EXPECT_EQ(AmbientViewerTest::stub->NotifyAmbientEvent(true,
+ EXPECT_EQ(AmbientViewerTest::stub->NotifyAmbientEvent(AmbientViewer::AMBIENT_ENTER,
AmbientViewer::DIRECTION_VIEWER_AND_TOP_APP, b), 0);
}
}
TEST_F(AmbientViewerStubTest, ambient_viewer_notify_ambient_event_n) {
- EXPECT_EQ(ambient_viewer_notify_ambient_event(nullptr, true,
+ EXPECT_EQ(ambient_viewer_notify_ambient_event(nullptr, AMBIENT_VIEWER_AMBIENT_STATE_ENTER,
AMBIENT_VIEWER_DIRECTION_ALL, nullptr),
AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
}
bool enter;
try {
extra_data = tizen_base::Bundle(extra);
- enter = (bool)stoi(mode);
+ AmbientState state = (AmbientState)stoi(mode);
+ if (state != AMBIENT_ENTER && state != AMBIENT_LEAVE) {
+ LOGW("Invalid state (%d)", (int)state);
+ return 0;
+ }
+ enter = (state == AMBIENT_ENTER);
} catch (const std::exception& e) {
LOGE("Exception (%s)", e.what());
return 0;
EVENT_AOD_READY,
EVENT_AOD_NOTIFIED
};
+
+ enum AmbientState {
+ AMBIENT_LEAVE,
+ AMBIENT_ENTER,
+ AMBIENT_BLOCK_TICK,
+ };
AmbientListener();
virtual ~AmbientListener();
static int OnAmbientChangedSignal(const char *endpoint,