2 * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "bootstrap.h"
19 #include "ActionAndWaitEventCommand.h"
20 #include "ActionAndWaitEventRunnable.h"
25 ActionAndWaitEventCommand::ActionAndWaitEventCommand(const ::aurum::ReqActionAndWaitEvent *request,
26 ::aurum::RspActionAndWaitEvent *response)
27 : mRequest{request}, mResponse{response}
31 A11yEvent convertEventType(const ::aurum::ReqActionAndWaitEvent_EventType type)
33 if (type == ::aurum::ReqActionAndWaitEvent_EventType::ReqActionAndWaitEvent_EventType_EVENT_WINDOW_ACTIVATE)
34 return A11yEvent::EVENT_WINDOW_ACTIVATE;
35 else if (type == ::aurum::ReqActionAndWaitEvent_EventType::ReqActionAndWaitEvent_EventType_EVENT_WINDOW_DEACTIVATE)
36 return A11yEvent::EVENT_WINDOW_DEACTIVATE;
37 else if (type == ::aurum::ReqActionAndWaitEvent_EventType::ReqActionAndWaitEvent_EventType_EVENT_WINDOW_IDLE)
38 return A11yEvent::EVENT_WINDOW_RENDER_POST;
39 else if (type == ::aurum::ReqActionAndWaitEvent_EventType::ReqActionAndWaitEvent_EventType_EVENT_WINDOW_MINIMIZE)
40 return A11yEvent::EVENT_WINDOW_MINIMIZE;
41 else if (type == ::aurum::ReqActionAndWaitEvent_EventType::ReqActionAndWaitEvent_EventType_EVENT_WINDOW_RAISE)
42 return A11yEvent::EVENT_WINDOW_RAISE;
44 return A11yEvent::EVENT_STATE_CHANGED_FOCUSED;
47 ::grpc::Status ActionAndWaitEventCommand::execute()
49 LOGI("ActionAndWaitEvent --------------- ");
50 std::unique_ptr<ActionAndWaitEventRunnable> cmd = std::make_unique<ActionAndWaitEventRunnable>(
51 mRequest->type(), mRequest->elementid(), mRequest->xf86keycode());
52 std::shared_ptr<UiDevice> obj = UiDevice::getInstance();
53 //FIXME: Separation of params according to event type
54 bool ret = obj->executeAndWaitForEvents(cmd.get(), convertEventType(mRequest->eventtype()), mRequest->timeoutms(), mRequest->packagename(), mRequest->count());
56 if (ret) mResponse->set_status(::aurum::RspStatus::OK);
57 else mResponse->set_status(::aurum::RspStatus::ERROR);
59 return grpc::Status::OK;