1 /* 2 * Copyright (c) 2022 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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_HIDUMPE_HELPER_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_HIDUMPE_HELPER_H 18 19 #include <string> 20 #include <vector> 21 22 #include "bundle_data_mgr.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 enum class HidumpFlag { 27 UNKNOW = 0, 28 GET_HELP, 29 GET_ABILITY, 30 GET_ABILITY_LIST, 31 GET_ABILITY_BY_NAME, 32 GET_BUNDLE, 33 GET_BUNDLE_LIST, 34 GET_BUNDLE_BY_NAME, 35 GET_DEVICEID, 36 }; 37 38 struct HidumpParam { 39 HidumpFlag hidumpFlag = HidumpFlag::UNKNOW; 40 std::string args; 41 }; 42 43 class HidumpHelper { 44 public: 45 explicit HidumpHelper(const std::weak_ptr<BundleDataMgr> &dataMgr); 46 ~HidumpHelper() = default; 47 /** 48 * @brief Process hidump. 49 * @param args Indicates the args. 50 * @param result Indicates the result. 51 * @return Returns whether the interface is called successfully. 52 */ 53 bool Dump(const std::vector<std::string>& args, std::string &result); 54 55 private: 56 ErrCode ProcessOneParam(const std::string& args, std::string &result); 57 ErrCode ProcessTwoParam(const std::string& firstParam, 58 const std::string& secondParam, std::string &result); 59 void ShowHelp(std::string &result); 60 void ShowIllealInfomation(std::string &result); 61 ErrCode ProcessDump(const HidumpParam& hidumpParam, std::string &result); 62 63 ErrCode GetAllAbilityInfo(std::string &result); 64 ErrCode GetAllAbilityNameList(std::string &result); 65 ErrCode GetAbilityInfoByName(const std::string &name, std::string &result); 66 ErrCode GetAllBundleInfo(std::string &result); 67 ErrCode GetAllBundleNameList(std::string &result); 68 ErrCode GetBundleInfoByName(const std::string &name, std::string &result); 69 ErrCode GetAllDeviced(std::string &result); 70 71 std::weak_ptr<BundleDataMgr> dataMgr_; 72 }; 73 } // namespace AppExecFwk 74 } // namespace OHOS 75 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_HIDUMPE_HELPER_H 76