1// 2// Copyright (C) 2014 The Android Open Source Project 3// 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 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 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. 15// 16 17#include "apmanager/daemon.h" 18 19#include <sysexits.h> 20 21#include <base/logging.h> 22 23#include "apmanager/dbus/dbus_control.h" 24 25namespace apmanager { 26 27// static 28#if !defined(__ANDROID__) 29const char Daemon::kAPManagerGroupName[] = "apmanager"; 30const char Daemon::kAPManagerUserName[] = "apmanager"; 31#else 32const char Daemon::kAPManagerGroupName[] = "system"; 33const char Daemon::kAPManagerUserName[] = "system"; 34#endif // __ANDROID__ 35 36Daemon::Daemon(const base::Closure& startup_callback) 37 : startup_callback_(startup_callback) { 38} 39 40int Daemon::OnInit() { 41 int return_code = brillo::Daemon::OnInit(); 42 if (return_code != EX_OK) { 43 return return_code; 44 } 45 46 // Setup control interface. The control interface will expose 47 // our service (Manager) through its RPC interface. 48 control_interface_.reset(new DBusControl()); 49 control_interface_->Init(); 50 51 // Signal that we've acquired all resources. 52 startup_callback_.Run(); 53 54 return EX_OK; 55} 56 57void Daemon::OnShutdown(int* return_code) { 58 control_interface_->Shutdown(); 59} 60 61} // namespace apmanager 62