summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Kobec <s.kobec@samsung.com>2017-08-30 14:51:03 +0300
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>2017-08-31 12:51:42 +0000
commit59d4ce76cda779e06bdeea7199f0a525e16bc04e (patch)
tree134d9de6809d74a39476c621c194da016c8de126
parentee99263625e70b59da1838d3861469230c4c1aff (diff)
downloadalarm-59d4ce76cda779e06bdeea7199f0a525e16bc04e.tar.gz
alarm-59d4ce76cda779e06bdeea7199f0a525e16bc04e.tar.bz2
alarm-59d4ce76cda779e06bdeea7199f0a525e16bc04e.zip
TizenRefApp-8950 Alert interrupts callsubmit/tizen/20170906.124850
Change-Id: I54d419021b04e08c137780dbcf1b5bf8abbc4acf Signed-off-by: Sergei Kobec <s.kobec@samsung.com>
-rw-r--r--alarm-app/inc/Alert/AlertView.h8
-rw-r--r--alarm-app/src/AlarmApp.cpp19
-rw-r--r--alarm-app/src/Alert/AlertView.cpp44
-rw-r--r--lib-apps-common/src/Ui/Window.cpp1
-rw-r--r--lib-common/inc/Common/SoundManager.h33
-rw-r--r--lib-common/src/Common/SoundManager.cpp54
6 files changed, 94 insertions, 65 deletions
diff --git a/alarm-app/inc/Alert/AlertView.h b/alarm-app/inc/Alert/AlertView.h
index 1196acf..b077020 100644
--- a/alarm-app/inc/Alert/AlertView.h
+++ b/alarm-app/inc/Alert/AlertView.h
@@ -42,7 +42,6 @@ namespace Alert
private:
virtual Evas_Object *onCreate(Evas_Object *parent) override;
virtual void onNavigation(bool isCurrent) override;
- virtual void onPageAttached(Ui::NavigatorPage *page) override;
virtual bool onBackPressed() override;
player_h createPlayer();
@@ -55,11 +54,10 @@ namespace Alert
Evas_Object *createSnoozeButton(Evas_Object *parent);
Eina_Bool onRotaryEvent(Evas_Object *obj, Eext_Rotary_Event_Info *eventInfo);
- bool onClose(bool isAutoClose = false);
+ bool onClose();
void onDismissClicked(Evas_Object *button, void *eventInfo);
void onSnoozeClicked(Evas_Object *button, void *eventInfo);
- void onFocusChanged(sound_stream_focus_mask_e mask, sound_stream_focus_state_e state,
- sound_stream_focus_change_reason_e reason);
+ void onFocusChanged(sound_stream_focus_state_e state);
static void onButtonPressed(const char *signal, Evas_Object *button, void *eventInfo);
static Eina_Bool onButtonActivated(Evas_Object *button, Evas_Object *obj,
Elm_Access_Action_Info *accessInfo);
@@ -69,8 +67,8 @@ namespace Alert
Evas_Object *m_SnoozeButton;
Ecore_Timer *m_Timer;
Ecore_Timer *m_FeedbackTimer;
- player_h m_Player;
Common::SoundManager m_SoundManager;
+ player_h m_Player;
Common::Model::Alarm m_Alarm;
};
}
diff --git a/alarm-app/src/AlarmApp.cpp b/alarm-app/src/AlarmApp.cpp
index 47b6fcd..cb6b99e 100644
--- a/alarm-app/src/AlarmApp.cpp
+++ b/alarm-app/src/AlarmApp.cpp
@@ -34,21 +34,28 @@
App::OperationController *AlarmApp::createController(const char *operation)
{
+ bool showWindow = true;
+ App::OperationController *controller = nullptr;
if (strcmp(operation, APP_CONTROL_OPERATION_DEFAULT) == 0
|| strcmp(operation, APP_CONTROL_OPERATION_MAIN) == 0) {
- return new OperationDefaultController();
+ controller = new OperationDefaultController();
} else if (strcmp(operation, APP_CONTROL_OPERATION_ADD) == 0) {
- return new OperationAddController();
+ controller = new OperationAddController();
} else if (strcmp(operation, APP_CONTROL_OPERATION_PICK) == 0) {
- return new OperationPickController();
+ controller = new OperationPickController();
} else if (strcmp(operation, APP_CONTROL_OPERATION_EDIT) == 0) {
- return new OperationEditController();
+ controller = new OperationEditController();
} else if (strcmp(operation, APP_CONTROL_OPERATION_LAUNCH_ON_EVENT) == 0) {
- return new OperationAlertController();
+ showWindow = false;
+ controller = new OperationAlertController();
}
- return nullptr;
+ if (showWindow) {
+ evas_object_show(getWindow()->getEvasObject());
+ }
+
+ return controller;
}
bool AlarmApp::onCreate()
diff --git a/alarm-app/src/Alert/AlertView.cpp b/alarm-app/src/Alert/AlertView.cpp
index 2131880..b418014 100644
--- a/alarm-app/src/Alert/AlertView.cpp
+++ b/alarm-app/src/Alert/AlertView.cpp
@@ -30,7 +30,7 @@
#define SNOOZE_MAX_COUNT 3
#define ALERT_MAX_TIME 60
#define FEEDBACK_TIME 1.0
-#define DEFAULT_SOUND_PATH "/opt/share/settings/Alarms/Alarms_on_call.ogg"
+#define DEFAULT_SOUND_PATH "/opt/usr/data/settings/Alarms/Alarms_on_call.ogg"
using namespace Alert;
using namespace Common;
@@ -40,12 +40,11 @@ using namespace std::placeholders;
AlertView::AlertView(Common::Model::Alarm alarm)
: m_DismissButton(nullptr), m_SnoozeButton(nullptr),
m_Timer(nullptr), m_FeedbackTimer(nullptr),
- m_Player(createPlayer()), m_SoundManager(SOUND_STREAM_TYPE_ALARM),
+ m_SoundManager(SOUND_STREAM_TYPE_ALARM, SoundManager::MediaTypePlayer), m_Player(createPlayer()),
m_Alarm(std::move(alarm))
{
- player_set_sound_stream_info(m_Player, m_SoundManager.getStreamInfo());
m_SoundManager.acquireFocus();
- m_SoundManager.setFocusChangeCallback(std::bind(&AlertView::onFocusChanged, this, _1, _2, _3));
+ m_SoundManager.setFocusChangeCallback(std::bind(&AlertView::onFocusChanged, this, _1));
}
AlertView::~AlertView()
@@ -90,9 +89,13 @@ Evas_Object *AlertView::onCreate(Evas_Object *parent)
elm_object_color_class_color_set(layout, COLOR_CLASS_SNOOZE_HIDDEN,
COLOR_BUTTON_SNOOZE, 0);
+ if (!SoundManager::isSoundFocusedByCall(SoundManager::MediaTypePlayer)) {
+ evas_object_show(findParent<Ui::Window>(layout)->getEvasObject());
+ }
+
m_Timer = ecore_timer_add(ALERT_MAX_TIME, [](void *data) -> Eina_Bool {
auto view = (AlertView *)data;
- return view->onClose(true);
+ return view->onClose();
}, this);
return layout;
}
@@ -107,19 +110,15 @@ void AlertView::onNavigation(bool isCurrent)
} else {
player_stop(m_Player);
ecore_timer_del(m_FeedbackTimer);
- m_FeedbackTimer = nullptr;;
+ m_FeedbackTimer = nullptr;
if (!elm_win_focus_get(findParent<Ui::Window>()->getEvasObject())) {
- //Todo: Check if sound focus taken by someone else
- onClose();
+ if (!SoundManager::isSoundFocusedByCall(SoundManager::MediaTypePlayer)) {
+ onClose();
+ }
}
}
}
-void AlertView::onPageAttached(Ui::NavigatorPage *page)
-{
- page->setStyle("empty");
-}
-
bool AlertView::onBackPressed()
{
return onClose();
@@ -132,6 +131,8 @@ player_h AlertView::createPlayer()
player_set_looping(player, true);
player_set_uri(player, DEFAULT_SOUND_PATH);
+ player_set_sound_stream_info(player, m_SoundManager.getStreamInfo());
+
int err = player_prepare(player);
WARN_IF_ERR(err, "player_prepare() failed.");
@@ -208,16 +209,12 @@ Eina_Bool AlertView::onRotaryEvent(Evas_Object *obj, Eext_Rotary_Event_Info *eve
return EINA_TRUE;
}
-bool AlertView::onClose(bool isAutoClose)
+bool AlertView::onClose()
{
- if (isAutoClose && SoundManager::isSoundFocusedByCall(SoundManager::MediaTypePlayer)) {
- m_Alarm.dismiss();
+ if (m_Alarm.getSnoozeCount() < SNOOZE_MAX_COUNT) {
+ m_Alarm.snooze();
} else {
- if (m_Alarm.getSnoozeCount() < SNOOZE_MAX_COUNT) {
- m_Alarm.snooze();
- } else {
- m_Alarm.dismiss();
- }
+ m_Alarm.dismiss();
}
AlarmConsumer::getInstance().updateDataItem(m_Alarm, nullptr);
getPage()->close();
@@ -239,13 +236,14 @@ void AlertView::onSnoozeClicked(Evas_Object *button, void *eventInfo)
getPage()->close();
}
-void AlertView::onFocusChanged(sound_stream_focus_mask_e mask, sound_stream_focus_state_e state,
- sound_stream_focus_change_reason_e reason)
+void AlertView::onFocusChanged(sound_stream_focus_state_e state)
{
switch (state) {
case SOUND_STREAM_FOCUS_STATE_ACQUIRED:
player_start(m_Player);
ecore_timer_thaw(m_FeedbackTimer);
+
+ evas_object_show(findParent<Ui::Window>()->getEvasObject());
break;
case SOUND_STREAM_FOCUS_STATE_RELEASED:
ecore_timer_freeze(m_FeedbackTimer);
diff --git a/lib-apps-common/src/Ui/Window.cpp b/lib-apps-common/src/Ui/Window.cpp
index db6f34a..7a1fc97 100644
--- a/lib-apps-common/src/Ui/Window.cpp
+++ b/lib-apps-common/src/Ui/Window.cpp
@@ -121,7 +121,6 @@ Evas_Object *Window::onWindowCreate()
elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
elm_win_indicator_opacity_set(window, ELM_WIN_INDICATOR_OPAQUE);
elm_win_conformant_set(window, EINA_TRUE);
- evas_object_show(window);
return window;
}
diff --git a/lib-common/inc/Common/SoundManager.h b/lib-common/inc/Common/SoundManager.h
index 8638985..09815f4 100644
--- a/lib-common/inc/Common/SoundManager.h
+++ b/lib-common/inc/Common/SoundManager.h
@@ -40,21 +40,17 @@ namespace Common
};
/**
* @brief Called when the focus changed.
- * @param[in] mask The focus mask.
- * @param[in] state The focus state.
- * @param[in] reason The change reason.
- * @see sound_stream_focus_mask_e
+ * @param[in] state The focus state
* @see sound_stream_focus_state_e
- * @see sound_stream_focus_change_reason_e
*/
- typedef std::function<void(sound_stream_focus_mask_e mask, sound_stream_focus_state_e state,
- sound_stream_focus_change_reason_e reason)> FocusChangeCallback;
+ typedef std::function<void(sound_stream_focus_state_e state)> FocusChangeCallback;
/**
* @brief Create sound manager.
- * @param[in] type Stream type.
+ * @param[in] streamType Sound stream type
+ * @param[in] mediaType Media type
*/
- explicit SoundManager(sound_stream_type_e type);
+ SoundManager(sound_stream_type_e streamType, MediaType mediaType);
~SoundManager();
SoundManager(const SoundManager &) = delete;
SoundManager &operator=(const SoundManager &) = delete;
@@ -67,8 +63,9 @@ namespace Common
/**
* @brief Acquires the stream focus.
* @see releaseFocus()
+ * @return true if focus was acquired, false if not.
*/
- void acquireFocus();
+ bool acquireFocus();
/**
* @brief Release the stream focus.
@@ -79,36 +76,42 @@ namespace Common
/**
* @brief Set focus change callback.
- * @param[in] callback Recording callback.
+ * @param[in] callback Changed sound focus callback
*/
void setFocusChangeCallback(FocusChangeCallback callback);
/**
* @brief Whether the sound is focused by a call.
- * @param[in] type Media type.
+ * @param[in] type Media type
* @return true if focused by call.
*/
static bool isSoundFocusedByCall(MediaType type);
/**
* @brief Get the reason of sound focus change.
- * @param[in] type Media type.
+ * @param[in] type Media type
* @return sound_stream_focus_change_reason_e on success, SOUND_STREAM_FOCUS_CHANGED_BY_NONE - otherwise.
* @see sound_stream_focus_change_reason_e
*/
static int getSoundFocusChangedReason(MediaType type);
private:
- void onFocusState(sound_stream_info_h streamInfo, sound_stream_focus_mask_e focusMask,
+ void onStreamFocusChanged(sound_stream_info_h streamInfo, sound_stream_focus_mask_e focusMask,
sound_stream_focus_state_e focusState, sound_stream_focus_change_reason_e reason,
int soundBehavior, const char *extraInfo);
+ void onGlobalFocusChanged(int id, sound_stream_focus_mask_e focusMask,
+ sound_stream_focus_state_e focusState, sound_stream_focus_change_reason_e reason,
+ const char *extraInfo);
+ sound_stream_type_e m_StreamType;
+ MediaType m_MediaType;
sound_stream_info_h m_StreamInfo;
FocusChangeCallback m_OnFocusChanged;
- sound_stream_focus_mask_e m_FocusMask;
sound_stream_focus_state_e m_FocusState;
sound_stream_focus_change_reason_e m_ChangeReason;
+
+ int m_FocusCallbackId;
};
}
diff --git a/lib-common/src/Common/SoundManager.cpp b/lib-common/src/Common/SoundManager.cpp
index a562c5b..7e87dd0 100644
--- a/lib-common/src/Common/SoundManager.cpp
+++ b/lib-common/src/Common/SoundManager.cpp
@@ -21,18 +21,22 @@
using namespace Common;
-SoundManager::SoundManager(sound_stream_type_e type)
- : m_FocusMask(SOUND_STREAM_FOCUS_FOR_BOTH)
- , m_FocusState(SOUND_STREAM_FOCUS_STATE_RELEASED)
- , m_ChangeReason(SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA)
+SoundManager::SoundManager(sound_stream_type_e streamType, MediaType mediaType)
+ : m_StreamType(streamType), m_MediaType(mediaType),
+ m_FocusState(SOUND_STREAM_FOCUS_STATE_RELEASED),
+ m_ChangeReason(SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA),
+ m_FocusCallbackId(0)
{
- sound_manager_create_stream_information(type,
- makeCallbackWithLastParam(&SoundManager::onFocusState), this, &m_StreamInfo);
+ sound_manager_create_stream_information(m_StreamType,
+ makeCallbackWithLastParam(&SoundManager::onStreamFocusChanged), this, &m_StreamInfo);
}
SoundManager::~SoundManager()
{
releaseFocus();
+ if (m_FocusCallbackId) {
+ sound_manager_remove_focus_state_watch_cb(m_FocusCallbackId);
+ }
sound_manager_destroy_stream_information(m_StreamInfo);
}
@@ -41,15 +45,20 @@ sound_stream_info_h SoundManager::getStreamInfo() const
return m_StreamInfo;
}
-void SoundManager::acquireFocus()
+bool SoundManager::acquireFocus()
{
- sound_manager_set_focus_reacquisition(m_StreamInfo, true);
- sound_manager_acquire_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_BOTH, SOUND_BEHAVIOR_NONE, nullptr);
+ int err = sound_manager_acquire_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_BOTH, SOUND_BEHAVIOR_NONE, nullptr);
+ if (err == SOUND_MANAGER_ERROR_POLICY) {
+ m_ChangeReason = (sound_stream_focus_change_reason_e)getSoundFocusChangedReason(m_MediaType);
+ sound_manager_add_focus_state_watch_cb(SOUND_STREAM_FOCUS_FOR_BOTH,
+ makeCallbackWithLastParam(&SoundManager::onGlobalFocusChanged), this, &m_FocusCallbackId);
+ }
+
+ return err == SOUND_MANAGER_ERROR_NONE;
}
void SoundManager::releaseFocus()
{
- sound_manager_set_focus_reacquisition(m_StreamInfo, false);
sound_manager_release_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_BOTH, SOUND_BEHAVIOR_NONE, nullptr);
}
@@ -80,18 +89,33 @@ int SoundManager::getSoundFocusChangedReason(MediaType type)
return (err == SOUND_MANAGER_ERROR_NONE) ? acquiredBy : SOUND_STREAM_FOCUS_CHANGED_BY_NONE;
}
-void SoundManager::onFocusState(sound_stream_info_h streamInfo, sound_stream_focus_mask_e focusMask,
+void SoundManager::onStreamFocusChanged(sound_stream_info_h streamInfo, sound_stream_focus_mask_e focusMask,
sound_stream_focus_state_e focusState, sound_stream_focus_change_reason_e reason,
int soundBehavior, const char *extraInfo)
{
- m_FocusMask = focusMask;
m_FocusState = focusState;
- m_ChangeReason = reason;
ecore_main_loop_thread_safe_call_async([](void *data) {
- SoundManager *manager = (SoundManager *)data;
+ auto manager = (SoundManager *)data;
if (manager->m_OnFocusChanged) {
- manager->m_OnFocusChanged(manager->m_FocusMask, manager->m_FocusState, manager->m_ChangeReason);
+ manager->m_OnFocusChanged(manager->m_FocusState);
}
}, this);
}
+
+void SoundManager::onGlobalFocusChanged(int id, sound_stream_focus_mask_e focusMask,
+ sound_stream_focus_state_e focusState, sound_stream_focus_change_reason_e reason,
+ const char *extraInfo)
+{
+ sound_manager_remove_focus_state_watch_cb(m_FocusCallbackId);
+ m_FocusCallbackId = 0;
+
+ if (focusState == SOUND_STREAM_FOCUS_STATE_RELEASED && reason == m_ChangeReason) {
+ ecore_main_loop_thread_safe_call_async([](void *data) {
+ auto manager = (SoundManager *)data;
+ if (manager->acquireFocus() && manager->m_OnFocusChanged) {
+ manager->m_OnFocusChanged(SOUND_STREAM_FOCUS_STATE_ACQUIRED);
+ }
+ }, this);
+ }
+}