1 /* 2 * Copyright (c) 2020 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 OHOS_ABILITY_THREAD_H 17 #define OHOS_ABILITY_THREAD_H 18 19 #include <ability.h> 20 #include <map> 21 #include <memory> 22 23 #include "abilityms_client.h" 24 #include "ability_scheduler.h" 25 #include "ability_event_handler.h" 26 27 namespace OHOS { 28 class AbilityThread : public Scheduler, public NoCopyable { 29 public: 30 ~AbilityThread() override; 31 static void ThreadMain(uint64_t token); 32 33 private: 34 AbilityThread() = default; 35 36 void PerformAppInit(const AppInfo &appInfo) override; 37 void PerformAppExit() override; 38 void PerformTransactAbilityState(const Want &want, int state, uint64_t token, int abilityType) override; 39 void PerformConnectAbility(const Want &want, uint64_t token) override; 40 void PerformDisconnectAbility(const Want &want, uint64_t token) override; 41 void PerformDumpAbility(const Want &want, uint64_t token) override; 42 43 #ifdef ABILITY_WINDOW_SUPPORT 44 static void *UITaskPost(void *arg); 45 void InitUITaskEnv(); 46 #endif 47 void StartAbilityCallback(const Want &want); 48 static void HandleLifecycleTransaction(Ability &ability, const Want &want, int state); 49 void AttachBundle(uint64_t token); 50 void Run(); 51 52 AbilityEventHandler *eventHandler_ { nullptr }; 53 AbilityScheduler *abilityScheduler_ { nullptr }; 54 std::map<uint64_t, Ability *> abilities_ {}; 55 SvcIdentity *identity_ { nullptr }; 56 std::list<void *> handle_ {}; 57 static bool isNativeApp_; 58 static bool isAppRunning_; 59 static bool isDisplayInited_; 60 }; 61 } // namespace OHOS 62 #endif // OHOS_ABILITY_THREAD_H 63