1 /* 2 * Copyright (c) 2023-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 OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_DEAL_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_DEAL_H 18 19 #include "ability_debug_response_interface.h" 20 #include "ability_debug_response_stub.h" 21 22 namespace OHOS { 23 namespace AAFwk { 24 class AbilityDebugDeal : public std::enable_shared_from_this<AbilityDebugDeal> { 25 public: 26 AbilityDebugDeal() = default; 27 ~AbilityDebugDeal() = default; 28 29 /** 30 * @brief Set ability attach debug flag to ability manager service. 31 * @param tokens The token of ability records. 32 */ 33 void OnAbilitysDebugStarted(const std::vector<sptr<IRemoteObject>> &tokens); 34 35 /** 36 * @brief Cancel ability attach debug flag to ability manager service. 37 * @param tokens The token of ability records. 38 */ 39 void OnAbilitysDebugStoped(const std::vector<sptr<IRemoteObject>> &tokens); 40 41 /** 42 * @brief Change ability assert debug flag. 43 * @param tokens The token of ability records. 44 * @param isAssertDebug Assert debug flag. 45 */ 46 void OnAbilitysAssertDebugChange(const std::vector<sptr<IRemoteObject>> &tokens, bool isAssertDebug); 47 48 /** 49 * @brief Register debug response in attach mode. 50 */ 51 void RegisterAbilityDebugResponse(); 52 53 private: 54 sptr<AppExecFwk::IAbilityDebugResponse> abilityDebugResponse_; 55 }; 56 57 class AbilityDebugResponse : public AppExecFwk::AbilityDebugResponseStub { 58 public: AbilityDebugResponse(const std::weak_ptr<AbilityDebugDeal> & deal)59 explicit AbilityDebugResponse(const std::weak_ptr<AbilityDebugDeal> &deal) : abilityDebugDeal_(deal) {} 60 virtual ~AbilityDebugResponse() = default; 61 62 private: 63 void OnAbilitysDebugStarted(const std::vector<sptr<IRemoteObject>> &tokens) override; 64 void OnAbilitysDebugStoped(const std::vector<sptr<IRemoteObject>> &tokens) override; 65 void OnAbilitysAssertDebugChange(const std::vector<sptr<IRemoteObject>> &tokens, bool isAssertDebug) override; 66 67 std::weak_ptr<AbilityDebugDeal> abilityDebugDeal_; 68 }; 69 } // namespace AAFwk 70 } // namespace OHOS 71 #endif // OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_DEAL_H 72