From 9bee0e036278d9eef50c162a6ff043c8c018be7f Mon Sep 17 00:00:00 2001 From: "ravi.n2" Date: Mon, 1 Jul 2013 14:06:54 +0530 Subject: [PATCH] NABI issue 43925 Change-Id: I7c48a3c61fd60ee300636ea8a2435f44803b8af2 --- inc/CmBaseForm.h | 2 + inc/CmCameraApp.h | 2 +- inc/CmCameraPresentationModel.h | 1 + inc/CmCameraSettingsPresentationModel.h | 3 ++ inc/CmUtility.h | 37 ++++++++++++++++++ src/CmBaseForm.cpp | 41 +++++++++++++++++++ src/CmCamcorderForm.cpp | 7 ++++ src/CmCameraApp.cpp | 65 ++----------------------------- src/CmCameraForm.cpp | 7 ++++ src/CmCameraPresentationModel.cpp | 5 +-- src/CmCameraSettingsPresentationModel.cpp | 9 +++-- src/CmUtility.cpp | 44 +++++++++++++++++++++ 12 files changed, 154 insertions(+), 69 deletions(-) create mode 100644 inc/CmUtility.h create mode 100644 src/CmUtility.cpp diff --git a/inc/CmBaseForm.h b/inc/CmBaseForm.h index 0a7e798..1a27576 100644 --- a/inc/CmBaseForm.h +++ b/inc/CmBaseForm.h @@ -42,6 +42,7 @@ #include "CmCameraResourceManager.h" #include "CmCameraThumbnailPanel.h" #include "CmCameraInfoPanel.h" +#include "CmUtility.h" class BaseForm : public Tizen::Ui::Controls::Form @@ -151,6 +152,7 @@ protected: void HideScreenOverlayHelp(); void OnHelpCloseTimerExpired(void); bool CheckCallStatus(void); + void ShowMemoryFullPopup(void); protected: CameraPresentationModel* _pCameraPresentationModel; diff --git a/inc/CmCameraApp.h b/inc/CmCameraApp.h index ac875c8..8b39f3d 100644 --- a/inc/CmCameraApp.h +++ b/inc/CmCameraApp.h @@ -28,6 +28,7 @@ #include #include #include "CmTypes.h" +#include "CmUtility.h" class CameraPresentationModel; class CameraSettingsPresentationModel; @@ -76,7 +77,6 @@ public: private: void OnRequestAppControlTest(void); result OnRequestAppControl(void); - long long GetAvailableMemory(void); private: RequestId __requestId; diff --git a/inc/CmCameraPresentationModel.h b/inc/CmCameraPresentationModel.h index fcd8260..323e1d6 100644 --- a/inc/CmCameraPresentationModel.h +++ b/inc/CmCameraPresentationModel.h @@ -33,6 +33,7 @@ #include #include "CmICameraEventListener.h" #include "CmTypes.h" +#include "CmUtility.h" class CameraSettingsPresentationModel; diff --git a/inc/CmCameraSettingsPresentationModel.h b/inc/CmCameraSettingsPresentationModel.h index 4f7c17c..8a4cf5d 100644 --- a/inc/CmCameraSettingsPresentationModel.h +++ b/inc/CmCameraSettingsPresentationModel.h @@ -24,8 +24,11 @@ #include #include +#include #include +#include #include "CmTypes.h" +#include "CmUtility.h" class CameraSettingsPresentationModel { diff --git a/inc/CmUtility.h b/inc/CmUtility.h new file mode 100644 index 0000000..cf47ed9 --- /dev/null +++ b/inc/CmUtility.h @@ -0,0 +1,37 @@ +// +// Copyright (c) 2012 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. +// + +/** + * @file: MfUtility.h + * @brief: This file contains the declaration of MfUtility class, which is a common utility function class and + * contains helper functions which are used throughout the Application. + */ + +#ifndef _CM_UTILITY_H_ +#define _CM_UTILITY_H_ + +#include +#include +#include +#include + +class CmUtility +{ +public: + static long long GetAvailableMemory(void); +}; + +#endif /* _CM_UTILITY_H_ */ diff --git a/src/CmBaseForm.cpp b/src/CmBaseForm.cpp index c27a316..c3cf85c 100644 --- a/src/CmBaseForm.cpp +++ b/src/CmBaseForm.cpp @@ -1153,3 +1153,44 @@ BaseForm::OnAccessibilityScreenReaderStatusChanged (const Control &control, cons AppLogDebug("Enter"); AppLogDebug("Exit"); } + + +void +BaseForm::ShowMemoryFullPopup(void) +{ + AppLogDebug("ENTER"); + int modalResult = 0; + MessageBox msgBox; + AppResource* pAppResource = null; + String memoryLowTitle; + String memoryLowMessage; + result r = E_SUCCESS; + + pAppResource = Application::GetInstance()->GetAppResource(); + TryReturnVoid(pAppResource != null, "Failed to allocate memory for pAppResource"); + + pAppResource->GetString(L"IDS_LOW_MEMORY_MSG_TITLE", memoryLowTitle); + pAppResource->GetString(L"IDS_LOW_MEMORY_MSG", memoryLowMessage); + + + r = msgBox.Construct(memoryLowTitle, memoryLowMessage, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC); + TryReturnVoid(r == E_SUCCESS, "msgBox::Construct() failed by [%s]", GetErrorMessage(r)); + msgBox.ShowAndWait(modalResult); + + switch (modalResult) + { + case MSGBOX_RESULT_CLOSE: + { + AppLogDebug("MSGBOX_RESULT_CLOSE"); + _pCameraPresentationModel->SetAppControlRequestType(CameraPresentationModel::APP_CONTROL_REQUEST_TYPE_FAILED); + + r = TerminateApp(); + AppLogDebug("TerminateApp fail [%s]", GetErrorMessage(r)); + } + break; + + default: + break; + } + AppLogDebug("EXIT"); +} diff --git a/src/CmCamcorderForm.cpp b/src/CmCamcorderForm.cpp index b8b5e81..3cb948d 100644 --- a/src/CmCamcorderForm.cpp +++ b/src/CmCamcorderForm.cpp @@ -1994,6 +1994,7 @@ CamcorderForm::OnCameraActionPerformed(CameraActionEvent event) bool isInitCameraStaus = false; bool isCharging = false; + int mem = 0; BatteryLevel batteryLevel; CameraApp* pCameraApp = static_cast(CameraApp::GetInstance()); @@ -2053,6 +2054,12 @@ CamcorderForm::OnCameraActionPerformed(CameraActionEvent event) _pCameraPresentationModel->SetStartPreviewException(false); } + if(mem < MIN_MEMORY_NEEDED) + { + ShowMemoryFullPopup(); + return; + } + batteryLevel = _pCameraPresentationModel->GetBatteryLevel(); isCharging = _pCameraPresentationModel->IsCharging(); diff --git a/src/CmCameraApp.cpp b/src/CmCameraApp.cpp index 617ab74..da153e8 100644 --- a/src/CmCameraApp.cpp +++ b/src/CmCameraApp.cpp @@ -182,49 +182,18 @@ CameraApp::OnAppInitialized(void) int mode = 0; NotificationManager notiMgr; String errorMessage; - String memoryLowTitle; - String memoryLowMessage; - - MessageBox errorMsgBox; - int badgeNumber = 0, modResult=0; - - long long mem = GetAvailableMemory(); - AppResource* pAppResource = null; - pAppResource = Application::GetInstance()->GetAppResource(); - - pAppResource->GetString(L"IDS_LOW_MEMORY_MSG_TITLE", memoryLowTitle); - pAppResource->GetString(L"IDS_LOW_MEMORY_MSG", memoryLowMessage); - - AppLogDebug("%lld",mem); - if(mem < MIN_MEMORY_NEEDED) - { - MessageBox LowMemory; - String msg = L""; - LowMemory.Construct(memoryLowTitle, memoryLowMessage, MSGBOX_STYLE_NONE,1000); - int modalResult = 0; - // Calls ShowAndWait() : Draws and Shows itself and processes events - LowMemory.ShowAndWait(modalResult); - - if ( GetAppControlType() == APP_CONTROL_TYPE_REQUESET) - { - r = AppControlProviderManager::GetInstance()->SendAppControlResult(__requestId, APP_CTRL_RESULT_FAILED, null); - AppLogDebug("Appcontrol result is %s",GetErrorMessage(r)); - } - - return false; - - } + CameraPresentationModel* pCameraPresentationModel = null; MainFrame* pCameraAppFrame = new (std::nothrow) MainFrame(); r = pCameraAppFrame->Construct(); - CameraPresentationModel* pCameraPresentationModel = CameraPresentationModel::GetInstance(); - TryCatch(pCameraPresentationModel != null, r = GetLastResult(), "pCameraPresentationModel is null"); - pCameraAppFrame->SetName(STRING_FRAME_NAME); r = AddFrame(*pCameraAppFrame); TryCatch(r == E_SUCCESS, , "UiApp::AddFrame() fail[%s]", GetErrorMessage(r)); + pCameraPresentationModel = CameraPresentationModel::GetInstance(); + TryCatch(pCameraPresentationModel != null, r = GetLastResult(), "pCameraPresentationModel is null"); + r = pCameraPresentationModel->GetValue(CURRENT_MODE, mode); AppLogDebug("Registry :GetvalueResult : %s", GetErrorMessage(r)); @@ -241,7 +210,6 @@ CameraApp::OnAppInitialized(void) errorMessage =L"Camera can't launch due to unknown exception, try again!!!"; } - TryCatch(r == E_SUCCESS, , "Read register GetValue() fail[%s]", GetErrorMessage(r)); r = pCameraAppFrame->Initialize(mode); TryCatch(r == E_SUCCESS, , "MainFrame::Initialize() fail[%s]", GetErrorMessage(r)); @@ -249,14 +217,6 @@ CameraApp::OnAppInitialized(void) return true; CATCH: - r = notiMgr.Construct(); - badgeNumber = notiMgr.GetBadgeNumber(); - badgeNumber++; - - notiMgr.Notify(errorMessage, 1); - - errorMsgBox.Construct(L"Camera launch failed", errorMessage, MSGBOX_STYLE_NONE, 3000); - errorMsgBox.ShowAndWait(modResult); if ( GetAppControlType() == APP_CONTROL_TYPE_REQUESET) AppControlProviderManager::GetInstance()->SendAppControlResult(__requestId, APP_CTRL_RESULT_FAILED, null); @@ -606,20 +566,3 @@ CameraApp::GetAppControlSwitch(void) return switchEnabled; AppLogDebug("Exit"); } - -long long -CameraApp::GetAvailableMemory(void) -{ - result r = E_SUCCESS; - - String key(L"http://tizen.org/runtime/storage.available.internal"); - long long allocatedMemory = 0; - - r = RuntimeInfo::GetValue(key, allocatedMemory); - TryCatch(r == E_SUCCESS, , "MyRuntimeInfo: Failed to get value"); - - return allocatedMemory; - - CATCH: - return 0; -} diff --git a/src/CmCameraForm.cpp b/src/CmCameraForm.cpp index dc7c67a..033458d 100644 --- a/src/CmCameraForm.cpp +++ b/src/CmCameraForm.cpp @@ -1148,6 +1148,7 @@ CameraForm::OnCameraActionPerformed(CameraActionEvent event) bool isInitCameraStaus = false; bool isCharging = false; BatteryLevel batteryLevel = BATTERY_FULL; + int mem = 0; __formStatusFrameDeattivated = false; @@ -1192,6 +1193,12 @@ CameraForm::OnCameraActionPerformed(CameraActionEvent event) isCharging = _pCameraPresentationModel->IsCharging(); AppLogDebug("batteryLevel = %d", batteryLevel); + + if(mem < MIN_MEMORY_NEEDED) + { + ShowMemoryFullPopup(); + return; + } if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY) { diff --git a/src/CmCameraPresentationModel.cpp b/src/CmCameraPresentationModel.cpp index c4c8ed5..bc54bd4 100644 --- a/src/CmCameraPresentationModel.cpp +++ b/src/CmCameraPresentationModel.cpp @@ -4272,13 +4272,10 @@ CameraPresentationModel::SetMemoryFullException(bool status) bool CameraPresentationModel::GetMemoryFullExceptionStatus(void) { - String key(L"http://tizen.org/runtime/storage.available.internal"); long long allocatedMemory = 0; bool memoryStatus = false; - result r = E_SUCCESS; - r = RuntimeInfo::GetValue(key, allocatedMemory); - AppLogDebug("available memory is %lld",allocatedMemory); + allocatedMemory = CmUtility::GetAvailableMemory(); if (__memoryFullException && allocatedMemory < MIN_MEMORY_NEEDED) { diff --git a/src/CmCameraSettingsPresentationModel.cpp b/src/CmCameraSettingsPresentationModel.cpp index 9db7d68..cb33070 100644 --- a/src/CmCameraSettingsPresentationModel.cpp +++ b/src/CmCameraSettingsPresentationModel.cpp @@ -28,6 +28,7 @@ using namespace Tizen::Base; using namespace Tizen::Io; using namespace Tizen::Media; using namespace Tizen::Graphics; +using namespace Tizen::System; static const int DEFAULT_VALUE_ZERO = 0; static const int DEFAULT_VALUE_ONE = 1; @@ -433,9 +434,11 @@ CameraSettingsPresentationModel::CreateRegistry(bool bResetSettings) r = __pDefaultCameraRegistry->AddValue(SECTION_CAMCORDER, OVERLAY_HELP_ENABLE, DEFAULT_VALUE_ZERO); TryCatch(r == E_SUCCESS, , "Registry::AddValue() failed[%s]", GetErrorMessage(r)); - r = __pDefaultCameraRegistry->Flush(); - TryCatch(r == E_SUCCESS, , "Registry::Flush() failed[%s]", GetErrorMessage(r)); - + if (!(CmUtility::GetAvailableMemory() < MIN_MEMORY_NEEDED)) + { + r = __pDefaultCameraRegistry->Flush(); + TryCatch(r == E_SUCCESS, , "Registry::Flush() failed[%s]", GetErrorMessage(r)); + } AppLogDebug("Exit"); return r; diff --git a/src/CmUtility.cpp b/src/CmUtility.cpp new file mode 100644 index 0000000..34a33c0 --- /dev/null +++ b/src/CmUtility.cpp @@ -0,0 +1,44 @@ +// +// Copyright (c) 2012 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. +// + +/** + * @file: MfUtility.cpp + * @brief: This file contains the implementation of MfUtility class, which is a common utility function class and + * contains helper functions which are used throughout the Application. + */ + +#include "CmUtility.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::System; + +long long +CmUtility::GetAvailableMemory(void) +{ + result r = E_SUCCESS; + + String key(L"http://tizen.org/runtime/storage.available.internal"); + long long allocatedMemory = 0; + + r = RuntimeInfo::GetValue(key, allocatedMemory); + TryCatch(r == E_SUCCESS, , "MyRuntimeInfo: Failed to get value"); + + return allocatedMemory; + +CATCH: + return 0; +} -- 2.7.4