2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include <FBaseSysLog.h>
19 #include "CommonService.h"
20 #include "FApp_PackageManagerStub.h"
21 #include "FUi_UiManagerStub.h"
24 using namespace Tizen::App;
25 using namespace Tizen::Base;
26 using namespace Tizen::System;
27 using namespace Tizen::Ui;
29 CommonService::CommonService(void)
30 : __pPackageManagerStub(null)
35 CommonService::~CommonService(void)
37 delete __pPackageManagerStub;
41 CommonService::CreateInstance(void)
43 // Create the instance through the constructor.
44 return new CommonService();
48 CommonService::OnAppInitializing(AppRegistry& appRegistry)
51 // Initialize App specific data.
52 // The App's permanent data and context can be obtained from the appRegistry.
54 // If this method is successful, return true; otherwise, return false.
55 // If this method returns false, the App will be terminated.
57 // TODO: Add your initialization code here
63 CommonService::OnAppInitialized(void)
71 CommonService::OnAppWillTerminate(void)
80 CommonService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
83 // Deallocate resources allocated by this App for termination.
84 // The App's permanent data and context can be saved via appRegistry.
86 // TODO: Add your termination code here
92 CommonService::OnLowMemory(void)
95 // Free unused resources or close the App.
99 CommonService::OnBatteryLevelChanged(BatteryLevel batteryLevel)
102 // Handle any changes in battery level here.
103 // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL.
107 CommonService::InitializeServices(void)
109 __pPackageManagerStub = new (std::nothrow) _PackageManagerStub();
110 SysAssert(__pPackageManagerStub != null);
112 result r = __pPackageManagerStub->Construct();
113 SysAssert(!IsFailed(r));
115 unique_ptr<_UiManagerStub> pUiManagerStub(new (std::nothrow) _UiManagerStub());
116 SysTryReturnVoidResult(NID_UI, pUiManagerStub, E_OUT_OF_MEMORY, "Memory is insufficient.");
118 r = pUiManagerStub->Construct();
119 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "Propagating.");
121 __pUiManagerStub = move(pUiManagerStub);