--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALLUI_PRESENTERS_DEVICE_STATE_PRESENTER_H__
+#define __CALLUI_PRESENTERS_DEVICE_STATE_PRESENTER_H__
+
+#include "ucl/gui/Window.h"
+
+#include "types.h"
+
+namespace callui {
+
+ class DeviceStatePresenter final {
+ public:
+ class Builder {
+ public:
+ Builder();
+ Builder &setDisplayState(DisplayState state);
+ Builder &setDisplayMode(DisplayMode mode);
+ Builder &setCpuLockState(bool lockState);
+ DeviceStatePresenterSRef build(
+ const ucl::WindowSRef &window) const;
+ private:
+ DisplayState m_state;
+ DisplayMode m_mode;
+ bool m_lockState;
+ };
+
+ public:
+ ucl::Result setDisplayState(DisplayState state,
+ bool forse = false);
+ ucl::Result setDisplayMode(DisplayMode mode);
+ ucl::Result setCpuLockState(bool lockState);
+
+ private:
+ friend class ucl::RefCountObj<DeviceStatePresenter>;
+ DeviceStatePresenter(ucl::RefCountObjBase &rc,
+ const ucl::WindowSRef &window);
+ ~DeviceStatePresenter() = default;
+
+ ucl::Result prepare(DisplayState state,
+ DisplayMode mode,
+ bool lockState);
+
+ private:
+ ucl::WindowSRef m_window;
+ DisplayMode m_mode;
+ bool m_lockState;
+ };
+}
+
+#endif // __CALLUI_PRESENTERS_DEVICE_STATE_PRESENTER_H__
bool detectMuteControlDisableState();
+ ucl::Result updateDeviceState(CallMode prevMode, CallMode curMode);
+
+ ucl::Result createWidget();
+ ucl::Result createIndicatorPresenter();
+ ucl::Result createDisplayPresenter();
+
// Presenter
virtual void onActivateBy(const DeactivatorInfo &info) final override;
ucl::LayoutSRef m_widget;
ucl::LayoutSRef m_rmLy;
ucl::StyledWidgetSRef m_bottomBtn;
+
ICallSRef m_call;
ICallManagerSRef m_cm;
IndicatorSRef m_indicator;
AcceptRejectPresenterSRef m_acceptRejectPrs;
RejectMsgPresenterSRef m_rmPrs;
AccessoryPresenterSRef m_accessoryPrs;
- MoreOptionsPresenterSRef m_moreOptions;
+ MoreOptionsPresenterSRef m_moreOptionsPrs;
+ DeviceStatePresenterSRef m_devicePrs;
+
CallMode m_mode;
Ecore_Timer *m_ecTimer;
bool m_ecTimerBtnReq;
SHOWN
};
+ enum class DisplayState {
+ UNDEFINED,
+ ON,
+ OFF,
+ DIM
+ };
+
+ enum class DisplayMode {
+ UNDEFINED,
+ REGULAR,
+ TOP_PRIORITY
+ };
+
UCL_DECLARE_REF_ALIASES(Page);
UCL_DECLARE_REF_ALIASES(MainPage);
UCL_DECLARE_REF_ALIASES(KeypadPage);
UCL_DECLARE_REF_ALIASES(AccessoryPresenter);
UCL_DECLARE_REF_ALIASES(MoreOptionsPresenter);
+ UCL_DECLARE_REF_ALIASES(DeviceStatePresenter);
+
using AcceptDialogHandler = ucl::WeakDelegate<bool(AcceptDialog &, AcceptDialogEvent)>;
using RejectMsgStateHandler = ucl::WeakDelegate<void(RejectMsgState)>;
using RejectMsgSelectHandler = ucl::WeakDelegate<void(const IRejectMsgSRef &rm)>;
{
auto ret = bt_audio_initialize();
if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed");
+ LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed. [%d][%s]",
+ ret, get_error_message(ret));
}
m_btAudioInitialized = true;
ret = bt_ag_set_speaker_gain_changed_cb(
CALLBACK_B(BluetoothVolume::onVolumeChanged), this);
if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed");
+ LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed. [%d][%s]",
+ ret, get_error_message(ret));
}
return RES_OK;
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "presenters/DeviceStatePresenter.h"
+
+#include <device/power.h>
+#include <device/display.h>
+#include <efl_util.h>
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ // DeviceStatePresenter::Builder
+
+ DeviceStatePresenter::Builder::Builder():
+ m_state(DisplayState::UNDEFINED),
+ m_mode(DisplayMode::UNDEFINED),
+ m_lockState(false)
+ {
+ }
+
+ DeviceStatePresenter::Builder &
+ DeviceStatePresenter::Builder::setDisplayState(DisplayState state)
+ {
+ m_state = state;
+ return *this;
+ }
+
+ DeviceStatePresenter::Builder &
+ DeviceStatePresenter::Builder::setDisplayMode(DisplayMode mode)
+ {
+ m_mode = mode;
+ return *this;
+ }
+
+ DeviceStatePresenter::Builder &
+ DeviceStatePresenter::Builder::setCpuLockState(bool lockState)
+ {
+ m_lockState = lockState;
+ return *this;
+ }
+
+ DeviceStatePresenterSRef
+ DeviceStatePresenter::Builder::build(const ucl::WindowSRef &window) const
+ {
+ auto result = makeShared<DeviceStatePresenter>(window);
+ FAIL_RETURN_VALUE(result->prepare(m_state,
+ m_mode, m_lockState), {},
+ "result->prepare() failed!");
+ return result;
+ }
+
+ // DeviceStatePresenter
+
+ DeviceStatePresenter::DeviceStatePresenter(RefCountObjBase &rc,
+ const ucl::WindowSRef &window):
+ m_window(window),
+ m_mode(DisplayMode::UNDEFINED),
+ m_lockState(false)
+ {
+ }
+
+ Result DeviceStatePresenter::prepare(DisplayState state,
+ DisplayMode mode,
+ bool lockState)
+ {
+ if (state != DisplayState::UNDEFINED) {
+ FAIL_RETURN(setDisplayState(state, true),
+ "setDisplayState() failed");
+ }
+
+ if (mode != DisplayMode::UNDEFINED) {
+ FAIL_RETURN(setDisplayMode(mode),
+ "setDisplayMode() failed");
+ }
+
+ if (lockState) {
+ FAIL_RETURN(setCpuLockState(lockState),
+ "setCpuLockState() failed");
+ }
+
+ return RES_OK;
+ }
+
+ Result DeviceStatePresenter::setDisplayState(DisplayState state, bool forse)
+ {
+ if (state == DisplayState::UNDEFINED) {
+ LOG_RETURN(RES_FAIL, "State is undefined");
+ }
+
+ display_state_e dispState = DISPLAY_STATE_NORMAL;
+
+ if (!forse) {
+ int res = device_display_get_state(&dispState);
+ if (res != DEVICE_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "device_display_get_state() failed."
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+ if ((state == DisplayState::ON
+ && dispState == DISPLAY_STATE_NORMAL)
+ || (state == DisplayState::DIM
+ && dispState == DISPLAY_STATE_SCREEN_DIM)
+ || (state == DisplayState::OFF
+ && dispState == DISPLAY_STATE_SCREEN_OFF)) {
+ LOG_RETURN(RES_OK,
+ "Display state already set into needed state");
+ }
+ }
+
+ switch (state) {
+ case DisplayState::ON:
+ dispState = DISPLAY_STATE_NORMAL;
+ break;
+ case DisplayState::DIM:
+ dispState = DISPLAY_STATE_SCREEN_DIM;
+ break;
+ case DisplayState::OFF:
+ dispState = DISPLAY_STATE_SCREEN_OFF;
+ break;
+ default:
+ LOG_RETURN(RES_FAIL, "Undefined state");
+ break;
+ }
+
+ int res = device_display_change_state(dispState);
+ if (res != DEVICE_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "device_display_change_state() failed."
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+
+ return RES_OK;
+ }
+
+ Result DeviceStatePresenter::setDisplayMode(DisplayMode mode)
+ {
+ if (mode == DisplayMode::UNDEFINED) {
+ LOG_RETURN(RES_FAIL, "Mode is undefined");
+ }
+
+ if (mode == m_mode) {
+ LOG_RETURN(RES_OK, "Display mode already set");
+ }
+
+ m_mode = mode;
+
+ efl_util_screen_mode_e setScreenMode =
+ (m_mode == DisplayMode::TOP_PRIORITY) ?
+ EFL_UTIL_SCREEN_MODE_ALWAYS_ON :
+ EFL_UTIL_SCREEN_MODE_DEFAULT;
+
+ int res = efl_util_set_window_screen_mode(*m_window, setScreenMode);
+ if (res != EFL_UTIL_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "Set window screen mode failed."
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+
+ return RES_OK;
+ }
+
+ Result DeviceStatePresenter::setCpuLockState(bool lockState)
+ {
+ if (lockState == m_lockState) {
+ LOG_RETURN(RES_OK, "Cpu lock state already set %s",
+ lockState ? "locked" : "unlocked");
+ }
+
+ m_lockState = lockState;
+
+ int res = m_lockState ?
+ device_power_request_lock(POWER_LOCK_CPU, 0) :
+ device_power_release_lock(POWER_LOCK_CPU);
+
+ if (res != DEVICE_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "Device power request %s failed.",
+ m_lockState ? "lock" : "unlock",
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+
+ return RES_OK;
+ }
+
+}
#include "presenters/RejectMsgPresenter.h"
#include "presenters/AccessoryPresenter.h"
#include "presenters/MoreOptionsPresenter.h"
+#include "presenters/DeviceStatePresenter.h"
#include "resources.h"
#include "common.h"
Result MainPage::prepare()
{
- DLOG();
m_cm = m_call->getCallManager();
if (!m_cm) {
LOG_RETURN(RES_FAIL, "Call manager is NULL!");
}
- m_widget = Layout::Builder().
- setTheme(impl::LAYOUT_MAIN_WIDGET).
- setIsOwner(true).
- build(getNaviframe());
- if (!m_widget) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- m_indicator = Indicator::Builder().
- setIndicatorStateProvider(m_call->getIndicatorStateProvider()).
- build(*m_widget);
- if (!m_indicator) {
- LOG_RETURN(RES_FAIL, "Indicator::build() failed!");
- }
-
- m_widget->setContent(m_indicator->getWidget().getEo(), impl::PART_SWL_INDICATOR);
+ FAIL_RETURN(createWidget(), "createWidget() failed!");
+ FAIL_RETURN(createIndicatorPresenter(), "createIndicatorPresenter() failed!");
+ FAIL_RETURN(createDisplayPresenter(), "createDisplayPresenter() failed!");
auto win = m_widget->getWindow();
if (!win) {
MainPage::onPowerKeyUp, asWeak(*this)));
return Page::prepare([this]() {
- return getNaviframe().
- push(*m_widget);
+ return getNaviframe().push(*m_widget);
});
}
stopEndCallTimer();
+ CallMode prevMode = m_mode;
updateCallMode();
+
if (m_mode == CallMode::UNDEFINED) {
requestExit();
return;
if (m_mode == CallMode::INCOMING) {
m_accessoryPrs.reset();
- m_moreOptions.reset();
+ m_moreOptionsPrs.reset();
FAIL_RETURN_VOID(processIncomingCall(),
"processIncomingCall() failed!");
if (m_mode == CallMode::END) {
m_accessoryPrs.reset();
- m_moreOptions.reset();
+ m_moreOptionsPrs.reset();
startEndCallTimer();
} else {
FAIL_RETURN_VOID(createAccessoryPresenter(),
"createMoreOptionsPresenter() failed");
FAIL_RETURN_VOID(createBottomBtn(impl::STYLE_BB_END_CALL),
"createBottomBtn() failed");
-
- if (m_mode == CallMode::OUTGOING ||
- (m_mode == CallMode::DURING &&
- (m_cm->getAvailableCalls() == CALL_FLAG_HELD))) {
- m_accessoryPrs->setMuteControlDisabled(true);
- } else {
- m_accessoryPrs->setMuteControlDisabled(false);
- }
}
}
FAIL_RETURN_VOID(createCallInfoPresenter(m_mode),
"createCallInfoPresenter() failed!");
+
+ FAIL_RETURN_VOID(updateDeviceState(prevMode, m_mode),
+ "createCallInfoPresenter() failed!");
+ }
+
+ Result MainPage::updateDeviceState(CallMode prevMode, CallMode curMode)
+ {
+ if (curMode == CallMode::INCOMING && curMode != prevMode) {
+ m_devicePrs->setDisplayState(DisplayState::ON);
+ m_devicePrs->setDisplayMode(DisplayMode::TOP_PRIORITY);
+ m_devicePrs->setCpuLockState(true);
+ } else if (prevMode == CallMode::INCOMING && prevMode != curMode) {
+ m_devicePrs->setDisplayMode(DisplayMode::REGULAR);
+ m_devicePrs->setCpuLockState(false);
+ }
+
+ if (curMode == CallMode::END) {
+ m_devicePrs->setDisplayState(DisplayState::ON);
+ }
+
+ return RES_OK;
}
bool MainPage::detectMuteControlDisableState()
(m_cm->getAvailableCalls() == CALL_FLAG_HELD)));
}
+ Result MainPage::createWidget()
+ {
+ m_widget = Layout::Builder().
+ setTheme(impl::LAYOUT_MAIN_WIDGET).
+ setIsOwner(true).
+ build(getNaviframe());
+
+ if (!m_widget) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result MainPage::createIndicatorPresenter()
+ {
+ m_indicator = Indicator::Builder().
+ setIndicatorStateProvider(
+ m_call->getIndicatorStateProvider()).
+ build(*m_widget);
+
+ if (!m_indicator) {
+ LOG_RETURN(RES_FAIL, "Indicator::build() failed!");
+ }
+
+ m_widget->setContent(m_indicator->getWidget().getEo(), impl::PART_SWL_INDICATOR);
+
+ return RES_OK;
+ }
+
+ Result MainPage::createDisplayPresenter()
+ {
+ auto win = m_widget->getWindow();
+ if (!win) {
+ LOG_RETURN(RES_FAIL, "win is NULL!");
+ }
+
+ m_devicePrs = DeviceStatePresenter::Builder().
+ setDisplayState(DisplayState::ON).
+ build(asShared(win));
+
+ if (!m_devicePrs) {
+ LOG_RETURN(RES_FAIL, "DisplayPresenter::build() failed!");
+ }
+
+ return RES_OK;
+ }
+
Result MainPage::createAccessoryPresenter()
{
if (m_accessoryPrs) {
Result MainPage::createMoreOptionsPresenter()
{
- if (m_moreOptions) {
+ if (m_moreOptionsPrs) {
ILOG("Already exists. No need to create new one. Just update.");
- m_moreOptions->update();
+ m_moreOptionsPrs->update();
return RES_OK;
}
- m_moreOptions = MoreOptionsPresenter::Builder().
+ m_moreOptionsPrs = MoreOptionsPresenter::Builder().
setCallManager(m_cm).
setSoundManager(m_call->getSoundManager()).
setNaviframe(asShared(getNaviframe())).
build(*m_widget);
- if (!m_moreOptions) {
+ if (!m_moreOptionsPrs) {
LOG_RETURN(RES_FAIL,
"MoreOptionsPresenter::build() failed!");
}
- m_widget->setContent(m_moreOptions->getWidget(),
+ m_widget->setContent(m_moreOptionsPrs->getWidget(),
impl::PART_SWL_MORE_OPTION);
- addDeactivatorSource(m_moreOptions->getWidget());
+ addDeactivatorSource(m_moreOptionsPrs->getWidget());
return RES_OK;
}
void MainPage::RejectMsgStateCb(RejectMsgState state)
{
- if (state == RejectMsgState::HIDDEN) {
- show(*m_rmLy);
- } else {
- hide(*m_rmLy);
- }
+ (state == RejectMsgState::HIDDEN) ?
+ show(*m_rmLy) : hide(*m_rmLy);
}
void MainPage::RejectMsgSelectCb(const IRejectMsgSRef &rm)
build(*m_widget);
if (!m_callInfoPrs) {
- LOG_RETURN(RES_FAIL,
- "CallerInfo::build() failed!");
+ LOG_RETURN(RES_FAIL, "CallerInfo::build() failed!");
}
m_widget->setContent(m_callInfoPrs->getWidget().getEo(),
impl::PART_SWL_CALL_INFO);
void tryUpdateCallDurationTime(
struct tm &curTime, struct tm &compTime,
ucl::EdjeWidget &widget, const ucl::EdjePart &part);
+
}
#endif // __CALLUI_PRESENTERS_HELPERS_H__
<privilege>http://tizen.org/privilege/notification</privilege>
<privilege>http://tizen.org/privilege/message.read</privilege>
<privilege>http://tizen.org/privilege/callhistory.read</privilege>
+ <privilege>http://tizen.org/privilege/display</privilege>
</privileges>
</manifest>