1 /* 2 * Copyright (c) 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_INTERCEPTOR_INTERFACE_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_INTERCEPTOR_INTERFACE_H 18 19 #include "ability_info.h" 20 #include "ability_manager_errors.h" 21 #include "want.h" 22 #include "task_handler_wrap.h" 23 24 namespace OHOS { 25 namespace AAFwk { 26 struct AbilityInterceptorParam { AbilityInterceptorParamAbilityInterceptorParam27 AbilityInterceptorParam(const Want &want, int requestCode, int32_t userId, bool isWithUI, 28 const sptr<IRemoteObject> &callerToken) : want(want), requestCode(requestCode), userId(userId), 29 isWithUI(isWithUI), callerToken(callerToken){}; 30 AbilityInterceptorParam(const Want &want, int requestCode, int32_t userId, bool isWithUI, 31 const sptr<IRemoteObject> &callerToken, const std::shared_ptr<AppExecFwk::AbilityInfo> &abilityInfo, 32 bool isStartAsCaller = false, int32_t appIndex = 0) : want(want), 33 requestCode(requestCode), userId(userId), isWithUI(isWithUI), callerToken(callerToken), 34 abilityInfo(abilityInfo), isStartAsCaller(isStartAsCaller), appIndex(appIndex){}; 35 const Want &want; 36 int32_t requestCode; 37 int32_t userId; 38 bool isWithUI = false; 39 const sptr<IRemoteObject> &callerToken; 40 std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo; // target abilityInfo get in afterCheckExecuter_ 41 bool isStartAsCaller = false; 42 int32_t appIndex = 0; 43 }; 44 45 /** 46 * @class IAbilityInterceptor 47 * IAbilityInterceptor is used to intercept a different type of start request. 48 */ 49 class IAbilityInterceptor { 50 public: 51 virtual ~IAbilityInterceptor() = default; 52 53 /** 54 * Excute interception processing. 55 */ 56 virtual ErrCode DoProcess(AbilityInterceptorParam param) = 0; 57 58 /** 59 * Set handler for async task executing. 60 */ SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler)61 virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) {}; 62 }; 63 } // namespace AAFwk 64 } // namespace OHOS 65 #endif // OHOS_ABILITY_RUNTIME_ABILITY_INTERCEPTOR_INTERFACE_H