2 * Copyright (c) 2017 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.
17 #include <AppHistoryService.h>
18 #include <SensorRecorderService.h>
19 #include <ContextStoreService.h>
20 #include <JobSchedulerService.h>
22 #include "ServiceLoader.h"
28 ServiceLoader::ServiceLoader() :
29 __activeUser(ROOT_UID)
33 ServiceLoader::~ServiceLoader()
35 for (auto& svc : __userServices) {
38 for (auto& svc : __systemServices) {
43 bool ServiceLoader::load(GDBusConnection* conn)
45 __create<AppHistoryService>(conn);
46 __create<SensorRecorderService>(conn);
47 __create<ContextStoreService>(conn);
48 __create<JobSchedulerService>(conn);
50 return (!__systemServices.empty() || !__userServices.empty());
53 void ServiceLoader::startSystem()
55 for (auto& svc : __systemServices) {
60 void ServiceLoader::stopSystem()
62 for (auto& svc : __systemServices) {
67 void ServiceLoader::startUser(uid_t uid)
69 IF_FAIL_VOID(__activeUser != uid);
70 _I("Starting services for %u", static_cast<unsigned int>(uid));
72 ServiceBase::setActiveUser(uid);
74 for (auto& svc : __userServices) {
78 for (auto& svc : __systemServices) {
85 void ServiceLoader::stopUser()
87 IF_FAIL_VOID(__activeUser != ROOT_UID);
88 _I("Stopping services for %u", static_cast<unsigned int>(__activeUser));
90 for (auto& svc : __userServices) {
94 ServiceBase::setActiveUser(ROOT_UID);
96 for (auto& svc : __systemServices) {
97 svc->notifyUserRemoved();
100 __activeUser = ROOT_UID;