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_DISPOSED_RULE_INTERCEPTOR_H 17 #define OHOS_ABILITY_RUNTIME_DISPOSED_RULE_INTERCEPTOR_H 18 19 #include "ability_interceptor_interface.h" 20 21 #include "app_mgr_interface.h" 22 #include "disposed_observer.h" 23 #include "task_utils_wrap.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 struct DisposedRule; 28 } 29 namespace AAFwk { 30 class DisposedRuleInterceptor : public IAbilityInterceptor, 31 public std::enable_shared_from_this<DisposedRuleInterceptor> { 32 public: 33 DisposedRuleInterceptor() = default; 34 ~DisposedRuleInterceptor() = default; 35 ErrCode DoProcess(AbilityInterceptorParam param) override; SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler)36 void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override 37 { 38 taskHandler_ = taskHandler; 39 }; 40 void UnregisterObserver(const std::string &bundleName); 41 private: 42 bool CheckControl(const Want &want, int32_t userId, AppExecFwk::DisposedRule &disposedRule, int32_t appIndex); 43 bool CheckDisposedRule(const Want &want, AppExecFwk::DisposedRule &disposedRule); 44 ErrCode StartNonBlockRule(const Want &want, AppExecFwk::DisposedRule &disposedRule); 45 sptr<AppExecFwk::IAppMgr> GetAppMgr(); 46 ErrCode CreateModalUIExtension(const Want &want, const sptr<IRemoteObject> &callerToken); 47 void SetInterceptInfo(const Want &want, AppExecFwk::DisposedRule &disposedRule); 48 private: 49 std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler_; 50 std::map<std::string, sptr<DisposedObserver>> disposedObserverMap_; 51 ffrt::mutex observerLock_; 52 }; 53 } // namespace AAFwk 54 } // namespace OHOS 55 #endif // OHOS_ABILITY_RUNTIME_DISPOSED_RULE_INTERCEPTOR_H