2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file SecurityService.cpp
19 * @brief This is the implementation file for SecurityService class.
22 #include <FAppAppRegistry.h>
23 #include <FSysBattery.h>
26 #include "SecurityService.h"
27 #include "PrivilegeService.h"
28 #include "CertificateService.h"
30 using namespace Tizen::System;
31 using namespace Tizen::App;
32 using namespace Tizen::Base::Collection;
35 static SecurityService* __pSecurityService = null;
37 SecurityService::SecurityService(void)
38 : __pPrivilegeService(null)
39 , __pCertificateService(null)
44 SecurityService::~SecurityService(void)
50 SecurityService::CreateInstance(void)
56 if (__pSecurityService == null)
58 __pSecurityService = new (std::nothrow) SecurityService();
59 if (__pSecurityService == null)
61 AppLogException("[E_OUT_OF_MEMORY] The memory is insufficient.");
68 return __pSecurityService;
72 SecurityService::OnAppInitializing(AppRegistry& appRegistry)
79 __pPrivilegeService = new (std::nothrow) PrivilegeService();
80 TryCatchTag(OSP_SECURITY_SERVICE, __pPrivilegeService != null, r = E_OUT_OF_MEMORY; ret = false, "[E_OUT_OF_MEMORY] The memory is insufficient.");
82 r = __pPrivilegeService->Construct();
83 TryCatchTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, r = E_SYSTEM; ret = false, "[E_SYSTEM] An unexpected system error occurred.");
85 __pCertificateService = new (std::nothrow) CertificateService(); //return true even if error occured
86 //because privilege must be running.
87 TryCatchTag(OSP_SECURITY_SERVICE, __pCertificateService != null, r = E_OUT_OF_MEMORY; ret = true, "[E_OUT_OF_MEMORY] The memory is insufficient.");
89 r = __pCertificateService->Construct();
90 TryCatchTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, r = E_SYSTEM; ret = true, "[E_SYSTEM] An unexpected system error occurred.");
105 SecurityService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
109 delete __pPrivilegeService;
110 delete __pCertificateService;
117 SecurityService::OnLowMemory(void)
123 SecurityService::OnBatteryLevelChanged(BatteryLevel batteryLevel)
129 SecurityService::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList *pArgs)