blob: ccd4d1b8d5bdb00a191a56a52a98f23b899ed1ac [file] [log] [blame]
// Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <base/memory/weak_ptr.h>
#include <brillo/daemons/dbus_daemon.h>
#include <dbus/exported_object.h>
#include <mojo/core/embedder/scoped_ipc_support.h>
#include "iioservice/daemon/sensor_hal_server_impl.h"
#include "iioservice/libiioservice_ipc/sensor_server_dbus.h"
namespace iioservice {
class Daemon : public brillo::DBusDaemon, public SensorServerDbus {
~Daemon() override;
// brillo::DBusDaemon:
int OnInit() override;
// This function initializes the D-Bus service. The primary function of the
// D-Bus interface is to get notified by mems_setup that a device is ready to
// be used.
void InitDBus();
// Method called when kMemsSetupDone is received from mems_setup.
// Handles reporting of a device is setup by mems_setup and ready to be used.
void HandleMemsSetupDone(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender);
// SensorServerDbus overrides:
void OnServerReceived(
mojo::PendingReceiver<cros::mojom::SensorHalServer> server) override;
void OnMojoDisconnect();
// IPC Support
std::unique_ptr<mojo::core::ScopedIPCSupport> ipc_support_;
SensorHalServerImpl::ScopedSensorHalServerImpl sensor_hal_server_ = {
nullptr, SensorHalServerImpl::SensorHalServerImplDeleter};
// TODO(chenghaoyang): Add metrics
// For periodic and on-demand UMA metrics logging.
// Metrics metrics_;
// Must be last class member.
base::WeakPtrFactory<Daemon> weak_factory_{this};
} // namespace iioservice