#include "IEventSource.h"
#include "Runnable.h"
#include "A11yEvent.h"
+#include <atspi/atspi.h>
#include <memory>
#include <vector>
*/
virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) = 0;
+ virtual std::map<AtspiAccessible *, std::shared_ptr<AccessibleApplication>> getActiveAppMap(void) = 0;
public:
/**
* @brief TBD
#include "AccessibleNode.h"
#include "AccessibleWatcher.h"
+#include "AtspiAccessibleApplication.h"
#include <atspi/atspi.h>
#include <gio/gio.h>
*/
virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) override;
+ virtual std::map<AtspiAccessible *, std::shared_ptr<AccessibleApplication>> getActiveAppMap(void) override;
+
public:
/**
* @brief TBD
/**
* @brief TBD
*/
- std::map<AtspiAccessible *, AtspiAccessible *> mWindowAppMap;
+ std::map<AtspiAccessible *, std::shared_ptr<AccessibleApplication>> mActiveAppMap;
/**
* @brief TBD
*/
virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) override;
+ std::map<AtspiAccessible *, std::shared_ptr<AccessibleApplication>> getActiveAppMap(void);
+
public:
/**
* @brief TBD
* @brief TBD
*/
std::vector<std::shared_ptr<AccessibleApplication>> mApplicationList;
+
+ std::map<AtspiAccessible *, std::shared_ptr<AccessibleApplication>> mActiveAppMap;
};
*/
bool sendKeyAndWaitForEvents(
const std::string keycode, const A11yEvent type, const int timeout) const;
-private:
+
bool executeAndWaitForEvents(
const Runnable *cmd, const A11yEvent type, const int timeout) const;
public:
if (app)
{
pkg = AtspiWrapper::Atspi_accessible_get_name(app, NULL);
- g_object_unref(app);
+ if (!strncmp(event->type, "window:activate", 15)) {
+ LOGI("window activated in app(%s)", pkg);
+ if (!instance->mActiveAppMap.count(app)) {
+ LOGI("add activated window's app in map");
+ instance->mActiveAppMap.insert(std::pair<AtspiAccessible *, std::shared_ptr<AccessibleApplication>>(app,
+ std::make_shared<AtspiAccessibleApplication>(std::make_shared<AtspiAccessibleNode>(app))));
+ }
+ else {
+ LOGI("app(%s) is already in map", pkg);
+ }
+ }
+ else if (!strncmp(event->type, "window:deactivate", 16)) {
+ LOGI("window deactivate in app(%s)", pkg);
+ if (!instance->mActiveAppMap.count(app)) {
+ LOGI("window deactivated delete app(%s) in map", pkg);
+ instance->mActiveAppMap.erase(app);
+ }
+ else {
+ LOGE("deactivated window's app(%s) is not in map", pkg);
+ }
+
+ g_object_unref(app);
+ }
}
else
pkg = strdup("");
return false;
}
+std::map<AtspiAccessible *, std::shared_ptr<AccessibleApplication>> AtspiAccessibleWatcher::getActiveAppMap(void)
+{
+ return mActiveAppMap;
+}
+
bool AtspiAccessibleWatcher::removeFromActivatedList(AtspiAccessible *node)
{
LOGI("remove from activelist node %p", node);
{
mApplicationList.push_back(application);
}
+std::map<AtspiAccessible *, std::shared_ptr<AccessibleApplication>> MockAccessibleWatcher::getActiveAppMap(void)
+{
+ return mActiveAppMap;
+}
std::shared_ptr<MockAccessibleApplication> MockAccessibleWatcher::addApplication(std::string pkgName, Rect<int> geometry, int ifaces, int properties)
{
#include "TizenDeviceImpl.h"
#endif
#include "MockDeviceImpl.h"
-
+#include "AtspiAccessibleWatcher.h"
#include <unistd.h>
#include <utility>
#include <vector>
{
std::vector<std::shared_ptr<AccessibleNode>> ret{};
- auto apps = AccessibleWatcher::getInstance()->getActiveApplications();
- for (auto &app : apps){
- auto activeWindows = app->getActiveWindows();
+ auto appsMap = AccessibleWatcher::getInstance()->getActiveAppMap();
+ LOGI("activeAppMap.size: %d" , appsMap.size());
+ for (auto itr = appsMap.begin(); itr != appsMap.end(); itr++)
+ {
+ auto activeWindows = itr->second->getActiveWindows();
std::transform(activeWindows.begin(), activeWindows.end(), std::back_inserter(ret),
[&](std::shared_ptr<AccessibleWindow> window){
- LOGI("Active pkg: %s, window: %s", window->getAccessibleNode()->getPkg().c_str(), window->getTitle().c_str());
+ LOGI("active pkg: %s, window: %s", window->getAccessibleNode()->getPkg().c_str(), window->getTitle().c_str());
return window->getAccessibleNode();
}
);
}
+
return ret;
}
LaunchAppCommand(const ::aurum::ReqLaunchApp *request,
::aurum::RspLaunchApp *response);
::grpc::Status execute() override;
- ::grpc::Status executePost() override;
};
\ No newline at end of file
--- /dev/null
+#pragma once
+
+#include <string>
+
+#include "Runnable.h"
+
+class LaunchAppRunnable : public Runnable {
+protected:
+ std::string mPkg;
+
+public:
+ LaunchAppRunnable(std::string pkg);
+ std::string getPkgName();
+ void run() const override;
+};
root_inc,
include_directories('inc'),
include_directories('inc/Commands'),
+ include_directories('inc/Runnable'),
]
bootstrap_svr_src = [
files('src/BootstrapServer.cc'),
files('src/AurumServiceImpl.cc'),
files('src/ObjectMapper.cc'),
+ files('src/Runnable/LaunchAppRunnable.cc'),
]
bootstrap_svr_src += [
#include "bootstrap.h"
#include "LaunchAppCommand.h"
+#include "LaunchAppRunnable.h"
+#include "UiDevice.h"
#include <chrono>
#include <thread>
-#ifdef GBSBUILD
-#include <app_control.h>
-#endif
+#define WAIT_APP_LAUNCH 10000
LaunchAppCommand::LaunchAppCommand(const ::aurum::ReqLaunchApp *request,
::aurum::RspLaunchApp *response)
::grpc::Status LaunchAppCommand::execute()
{
LOGI("LaunchApp --------------- ");
-#ifdef GBSBUILD
- app_control_h appControl;
- std::string packageName = mRequest->packagename();
- int ret = -1;
+ std::unique_ptr<LaunchAppRunnable> cmd = std::make_unique<LaunchAppRunnable>(mRequest->packagename());
+ std::shared_ptr<UiDevice> obj = UiDevice::getInstance();
+ obj->executeAndWaitForEvents(cmd.get(), A11yEvent::EVENT_WINDOW_ACTIVATE, WAIT_APP_LAUNCH);
- if (packageName.empty()) return grpc::Status::OK;
-
- ret = app_control_create(&appControl);
- if (ret) {
- LOGE("Launch Failed(1/3) Err Code : %ull", ret);
- mResponse->set_status(::aurum::RspStatus::ERROR);
- return grpc::Status::OK;
- }
-
- ret = app_control_set_app_id(appControl, packageName.c_str());
- if (ret) {
- LOGE("Launch Failed(2/3) Err Code : %ull", ret);
- mResponse->set_status(::aurum::RspStatus::ERROR);
- app_control_destroy(appControl);
- return grpc::Status::OK;
- }
-
- ret = app_control_send_launch_request(appControl, NULL, NULL);
- if (ret) {
- LOGE("Launch Failed(3/3) Err Code : %ull", ret);
- mResponse->set_status(::aurum::RspStatus::ERROR);
- app_control_destroy(appControl);
- return grpc::Status::OK;
- }
-
- app_control_destroy(appControl);
-#endif
return grpc::Status::OK;
-}
-::grpc::Status LaunchAppCommand::executePost()
-{
- LOGI("Wait for 2500ms");
- std::this_thread::sleep_for(std::chrono::milliseconds{2500});
- return grpc::Status::OK;
-}
+}
\ No newline at end of file
--- /dev/null
+#include "Aurum.h"
+#include "bootstrap.h"
+#include "LaunchAppCommand.h"
+#include "LaunchAppRunnable.h"
+
+#ifdef GBSBUILD
+#include <app_control.h>
+#endif
+
+LaunchAppRunnable::LaunchAppRunnable(std::string pkg)
+ : mPkg{pkg}
+{
+}
+
+void LaunchAppRunnable::run() const
+{
+#ifdef GBSBUILD
+ app_control_h appControl;
+ std::string packageName = mPkg;
+ int ret = -1;
+
+ if (packageName.empty()) return;
+
+ ret = app_control_create(&appControl);
+ if (ret) {
+ LOGE("Launch Failed(app_control_create) Err Code : %ull", ret);
+ return;
+ }
+
+ ret = app_control_set_app_id(appControl, packageName.c_str());
+ if (ret) {
+ LOGE("Launch Failed(app_control_set_app_id) Err Code : %ull", ret);
+ app_control_destroy(appControl);
+ return;
+ }
+
+ ret = app_control_send_launch_request(appControl, NULL, NULL);
+ if (ret) {
+ LOGE("Launch Failed(app_control_send_launch_request) Err Code : %ull", ret);
+ app_control_destroy(appControl);
+ return;
+ }
+
+ app_control_destroy(appControl);
+#endif
+}
+
+std::string LaunchAppRunnable::getPkgName()
+{
+ return mPkg;
+}
\ No newline at end of file