mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-08-21 01:15:05 +00:00
Remove C++ service state
This commit is contained in:
parent
d479359613
commit
2433aeb2d8
@ -1,15 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <tactility/service/service_instance.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace tt::service {
|
namespace tt::service {
|
||||||
|
|
||||||
enum class State {
|
using State = ::ServiceState;
|
||||||
Starting,
|
|
||||||
Started,
|
|
||||||
Stopping,
|
|
||||||
Stopped
|
|
||||||
};
|
|
||||||
|
|
||||||
// Forward declaration
|
// Forward declaration
|
||||||
class ServiceContext;
|
class ServiceContext;
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include <tactility/error.h>
|
#include <tactility/error.h>
|
||||||
#include <tactility/service/service_paths.h>
|
#include <tactility/service/service_paths.h>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|||||||
@ -102,7 +102,7 @@ void attachDevices() {
|
|||||||
// We search for the manifest first, because during the initial start() during boot
|
// We search for the manifest first, because during the initial start() during boot
|
||||||
// the service won't be registered yet.
|
// the service won't be registered yet.
|
||||||
if (service::findManifestById("Gui") != nullptr) {
|
if (service::findManifestById("Gui") != nullptr) {
|
||||||
if (service::getState("Gui") == service::State::Stopped) {
|
if (service::getState("Gui") == SERVICE_STATE_STOPPED) {
|
||||||
service::startService("Gui");
|
service::startService("Gui");
|
||||||
} else {
|
} else {
|
||||||
LOG_E(TAG, "Gui service is not in Stopped state");
|
LOG_E(TAG, "Gui service is not in Stopped state");
|
||||||
@ -112,7 +112,7 @@ void attachDevices() {
|
|||||||
// We search for the manifest first, because during the initial start() during boot
|
// We search for the manifest first, because during the initial start() during boot
|
||||||
// the service won't be registered yet.
|
// the service won't be registered yet.
|
||||||
if (service::findManifestById("Statusbar") != nullptr) {
|
if (service::findManifestById("Statusbar") != nullptr) {
|
||||||
if (service::getState("Statusbar") == service::State::Stopped) {
|
if (service::getState("Statusbar") == SERVICE_STATE_STOPPED) {
|
||||||
service::startService("Statusbar");
|
service::startService("Statusbar");
|
||||||
} else {
|
} else {
|
||||||
LOG_E(TAG, "Statusbar service is not in Stopped state");
|
LOG_E(TAG, "Statusbar service is not in Stopped state");
|
||||||
|
|||||||
@ -13,16 +13,6 @@ namespace tt::service {
|
|||||||
|
|
||||||
constexpr auto* TAG = "ServiceRegistration";
|
constexpr auto* TAG = "ServiceRegistration";
|
||||||
|
|
||||||
static State toCppState(ServiceState state) {
|
|
||||||
switch (state) {
|
|
||||||
case SERVICE_STATE_STARTING: return State::Starting;
|
|
||||||
case SERVICE_STATE_STARTED: return State::Started;
|
|
||||||
case SERVICE_STATE_STOPPING: return State::Stopping;
|
|
||||||
case SERVICE_STATE_STOPPED:
|
|
||||||
default: return State::Stopped;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bridges the kernel's context-free C ServiceManifest/Service callbacks to the
|
// Bridges the kernel's context-free C ServiceManifest/Service callbacks to the
|
||||||
// C++ Service instances they wrap. Declared extern "C" to match the linkage of
|
// C++ Service instances they wrap. Declared extern "C" to match the linkage of
|
||||||
// the C function-pointer types they're assigned to (see e.g. gpio_controller.cpp).
|
// the C function-pointer types they're assigned to (see e.g. gpio_controller.cpp).
|
||||||
@ -136,7 +126,7 @@ bool stopService(const std::string& id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
State getState(const std::string& id) {
|
State getState(const std::string& id) {
|
||||||
return toCppState(service_registration_get_state(id.c_str()));
|
return service_registration_get_state(id.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user