1 /* 2 * Copyright (C) 2024-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_TASKS_TASK_AMS_H 17 #define FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_TASKS_TASK_AMS_H 18 19 #include "task.h" 20 21 #include "actions/action_wait.h" 22 #include "global.h" 23 #include "task_manager.h" 24 25 namespace OHOS { 26 namespace MiscServices { 27 const uint32_t AMS_INIT_TIMEOUT_MS = 5000; 28 29 class TaskAmsInit : public Task { 30 public: TaskAmsInit()31 TaskAmsInit() : Task(TASK_TYPE_AMS_INIT) 32 { 33 auto action = std::make_unique<ActionWait>(seqId_, AMS_INIT_TIMEOUT_MS, 34 std::bind(&TaskAmsInit::OnComplete, this), std::bind(&TaskAmsInit::OnTimeout, this)); 35 actions_.push_back(std::move(action)); 36 } 37 ~TaskAmsInit() = default; 38 39 private: OnComplete()40 void OnComplete() 41 { 42 IMSA_HILOGI("TaskAmsInit::OnComplete"); 43 TaskManager::GetInstance().SetInited(true); 44 } OnTimeout()45 void OnTimeout() 46 { 47 IMSA_HILOGW("TaskAmsInit::OnTimeout"); 48 } 49 }; 50 } // namespace MiscServices 51 } // namespace OHOS 52 53 #endif // FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_TASKS_TASK_AMS_H