mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-08-17 23:55:04 +00:00
Remove C++ service state
This commit is contained in:
parent
d479359613
commit
2433aeb2d8
@ -1,15 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <tactility/service/service_instance.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace tt::service {
|
||||
|
||||
enum class State {
|
||||
Starting,
|
||||
Started,
|
||||
Stopping,
|
||||
Stopped
|
||||
};
|
||||
using State = ::ServiceState;
|
||||
|
||||
// Forward declaration
|
||||
class ServiceContext;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include <tactility/error.h>
|
||||
#include <tactility/service/service_paths.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ void attachDevices() {
|
||||
// We search for the manifest first, because during the initial start() during boot
|
||||
// the service won't be registered yet.
|
||||
if (service::findManifestById("Gui") != nullptr) {
|
||||
if (service::getState("Gui") == service::State::Stopped) {
|
||||
if (service::getState("Gui") == SERVICE_STATE_STOPPED) {
|
||||
service::startService("Gui");
|
||||
} else {
|
||||
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
|
||||
// the service won't be registered yet.
|
||||
if (service::findManifestById("Statusbar") != nullptr) {
|
||||
if (service::getState("Statusbar") == service::State::Stopped) {
|
||||
if (service::getState("Statusbar") == SERVICE_STATE_STOPPED) {
|
||||
service::startService("Statusbar");
|
||||
} else {
|
||||
LOG_E(TAG, "Statusbar service is not in Stopped state");
|
||||
|
||||
@ -13,16 +13,6 @@ namespace tt::service {
|
||||
|
||||
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
|
||||
// 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).
|
||||
@ -136,7 +126,7 @@ bool stopService(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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user