Various improvements (#264)
- Replace C function pointers with C++ `std::function` in `Thread`, `Timer` and `DispatcherThread` - Rename `SystemEvent`-related functions - WiFi: fix auto-connect when WiFi disconnects from bad signal - WiFi: fix auto-connect when WiFi fails to auto-connect - WiFi: implement disconnect() when tapping connected WiFi ap in WiFi management app
This commit is contained in:
committed by
GitHub
parent
d72852a6e2
commit
3f1bfee3f5
@@ -1,6 +1,5 @@
|
||||
#include "Tactility/app/AppManifest.h"
|
||||
#include "Tactility/app/ManifestRegistry.h"
|
||||
#include "Tactility/service/gui/Gui.h"
|
||||
#include "Tactility/service/loader/Loader_i.h"
|
||||
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
@@ -54,9 +53,6 @@ private:
|
||||
*/
|
||||
std::unique_ptr<DispatcherThread> dispatcherThread = std::make_unique<DispatcherThread>("loader_dispatcher", 6144); // Files app requires ~5k
|
||||
|
||||
static void onStartAppMessageCallback(std::shared_ptr<void> message);
|
||||
static void onStopAppMessageCallback(std::shared_ptr<void> message);
|
||||
|
||||
void onStartAppMessage(const std::string& id, std::shared_ptr<const Bundle> parameters);
|
||||
void onStopAppMessage(const std::string& id);
|
||||
|
||||
@@ -86,14 +82,6 @@ std::shared_ptr<LoaderService> _Nullable optScreenshotService() {
|
||||
return service::findServiceById<LoaderService>(manifest.id);
|
||||
}
|
||||
|
||||
void LoaderService::onStartAppMessageCallback(std::shared_ptr<void> message) {
|
||||
auto start_message = std::reinterpret_pointer_cast<LoaderMessageAppStart>(message);
|
||||
auto& id = start_message->id;
|
||||
auto& parameters = start_message->parameters;
|
||||
|
||||
optScreenshotService()->onStartAppMessage(id, parameters);
|
||||
}
|
||||
|
||||
void LoaderService::onStartAppMessage(const std::string& id, std::shared_ptr<const Bundle> parameters) {
|
||||
|
||||
TT_LOG_I(TAG, "Start by id %s", id.c_str());
|
||||
@@ -130,12 +118,6 @@ void LoaderService::onStartAppMessage(const std::string& id, std::shared_ptr<con
|
||||
pubsubExternal->publish(&event_external);
|
||||
}
|
||||
|
||||
void LoaderService::onStopAppMessageCallback(std::shared_ptr<void> message) {
|
||||
TT_LOG_I(TAG, "OnStopAppMessageCallback");
|
||||
auto stop_message = std::reinterpret_pointer_cast<LoaderMessageAppStop>(message);
|
||||
optScreenshotService()->onStopAppMessage(stop_message->id);
|
||||
}
|
||||
|
||||
void LoaderService::onStopAppMessage(const std::string& id) {
|
||||
|
||||
auto lock = mutex.asScopedLock();
|
||||
@@ -271,14 +253,17 @@ void LoaderService::transitionAppToState(const std::shared_ptr<app::AppInstance>
|
||||
|
||||
void LoaderService::startApp(const std::string& id, std::shared_ptr<const Bundle> parameters) {
|
||||
auto message = std::make_shared<LoaderMessageAppStart>(id, std::move(parameters));
|
||||
dispatcherThread->dispatch(onStartAppMessageCallback, message);
|
||||
dispatcherThread->dispatch([this, id, parameters]() {
|
||||
onStartAppMessage(id, parameters);
|
||||
});
|
||||
}
|
||||
|
||||
void LoaderService::stopApp() {
|
||||
TT_LOG_I(TAG, "stopApp()");
|
||||
auto id = getCurrentAppContext()->getManifest().id;
|
||||
auto message = std::make_shared<LoaderMessageAppStop>(id);
|
||||
dispatcherThread->dispatch(onStopAppMessageCallback, message);
|
||||
dispatcherThread->dispatch([this, id]() {
|
||||
onStopAppMessage(id);
|
||||
});
|
||||
TT_LOG_I(TAG, "dispatched");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user