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_INSIGHT_INTENT_EXECUTE_PARAM_H 17 #define OHOS_ABILITY_RUNTIME_INSIGHT_INTENT_EXECUTE_PARAM_H 18 19 #include <string> 20 #include <vector> 21 22 #include "parcel.h" 23 #include "want.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 using WantParams = OHOS::AAFwk::WantParams; 28 /** 29 * @enum ExecuteMode 30 * ExecuteMode defines the supported execute mode. 31 */ 32 enum ExecuteMode { 33 UI_ABILITY_FOREGROUND = 0, 34 UI_ABILITY_BACKGROUND, 35 UI_EXTENSION_ABILITY, 36 SERVICE_EXTENSION_ABILITY, 37 }; 38 39 constexpr char INSIGHT_INTENT_EXECUTE_PARAM_NAME[] = "ohos.insightIntent.executeParam.name"; 40 constexpr char INSIGHT_INTENT_EXECUTE_PARAM_PARAM[] = "ohos.insightIntent.executeParam.param"; 41 constexpr char INSIGHT_INTENT_EXECUTE_PARAM_MODE[] = "ohos.insightIntent.executeParam.mode"; 42 constexpr char INSIGHT_INTENT_EXECUTE_PARAM_ID[] = "ohos.insightIntent.executeParam.id"; 43 constexpr char INSIGHT_INTENT_EXECUTE_PARAM_URI[] = "ohos.insightIntent.executeParam.uris"; 44 constexpr char INSIGHT_INTENT_EXECUTE_PARAM_FLAGS[] = "ohos.insightIntent.executeParam.flags"; 45 constexpr char INSIGHT_INTENT_SRC_ENTRY[] = "ohos.insightIntent.srcEntry"; 46 constexpr char INSIGHT_INTENT_EXECUTE_OPENLINK_FLAG[] = "ohos.insightIntent.execute.openlink.flag"; 47 constexpr char INSIGHT_INTENT_DECORATOR_TYPE[] = "ohos.insightIntent.decoratorType"; 48 constexpr char INSIGHT_INTENT_SRC_ENTRANCE[] = "ohos.insightIntent.srcEntrance"; 49 constexpr char INSIGHT_INTENT_FUNC_PARAM_CLASSNAME[] = "ohos.insightIntent.funcParam.className"; 50 constexpr char INSIGHT_INTENT_FUNC_PARAM_METHODNAME[] = "ohos.insightIntent.funcParam.methodName"; 51 constexpr char INSIGHT_INTENT_FUNC_PARAM_METHODPARAMS[] = "ohos.insightIntent.funcParam.methodParams"; 52 constexpr char INSIGHT_INTENT_PAGE_PARAM_PAGEPATH[] = "ohos.insightIntent.pageParam.pagePath"; 53 constexpr char INSIGHT_INTENT_PAGE_PARAM_NAVIGATIONID[] = "ohos.insightIntent.pageParam.navigationId"; 54 constexpr char INSIGHT_INTENT_PAGE_PARAM_NAVDESTINATIONNAME[] = "ohos.insightIntent.pageParam.navDestinationName"; 55 56 constexpr int32_t INVALID_DISPLAY_ID = -1; 57 58 class InsightIntentExecuteParam : public Parcelable { 59 public: 60 InsightIntentExecuteParam() = default; 61 ~InsightIntentExecuteParam() = default; 62 63 bool ReadFromParcel(Parcel &parcel); 64 virtual bool Marshalling(Parcel &parcel) const override; 65 static InsightIntentExecuteParam *Unmarshalling(Parcel &parcel); 66 static bool IsInsightIntentExecute(const AAFwk::Want &want); 67 static bool IsInsightIntentPage(const AAFwk::Want &want); 68 static bool GenerateFromWant(const AAFwk::Want &want, InsightIntentExecuteParam &executeParam); 69 static bool RemoveInsightIntent(AAFwk::Want &want); 70 static void UpdateInsightIntentCallerInfo(const WantParams &wantParams, WantParams &insightIntentParam); 71 72 int32_t executeMode_ = -1; 73 int32_t displayId_ = INVALID_DISPLAY_ID; 74 int32_t flags_ = 0; 75 uint64_t insightIntentId_ = 0; 76 std::shared_ptr<WantParams> insightIntentParam_; 77 std::string bundleName_; 78 std::string moduleName_; 79 std::string abilityName_; 80 std::string insightIntentName_; 81 std::vector<std::string> uris_; 82 int8_t decoratorType_ = 0; // default is InsightIntentType::DECOR_NONE 83 std::string srcEntrance_; 84 85 // params below belongs to InsightIntentFunc 86 std::string className_; 87 std::string methodName_; 88 std::vector<std::string> methodParams_; 89 90 // params below belongs to InsightIntentPage 91 std::string pagePath_; 92 std::string navigationId_; 93 std::string navDestinationName_; 94 }; 95 } // namespace AppExecFwk 96 } // namespace OHOS 97 #endif // OHOS_ABILITY_RUNTIME_INSIGHT_INTENT_EXECUTE_PARAM_H 98