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 OHOS_ABILITY_RUNTIME_COMPONENT_INTERCEPTION_PROXY_H 17 #define OHOS_ABILITY_RUNTIME_COMPONENT_INTERCEPTION_PROXY_H 18 19 #include "iremote_proxy.h" 20 #include "icomponent_interception.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 /** 25 * @brief Interface to monitor what is happening in component manager. 26 */ 27 class ComponentInterceptionProxy : public IRemoteProxy<IComponentInterception> { 28 public: 29 explicit ComponentInterceptionProxy(const sptr<IRemoteObject> &impl); 30 virtual ~ComponentInterceptionProxy() = default; 31 32 /** 33 * The system is trying to start an component. 34 * 35 * @param want The want of component to start. 36 * @param callerToken Caller component token. 37 * @param requestCode the requestCode of the component to start. 38 * @param componentStatus the status of component. 39 * @param extraParam The extra param of component to start. 40 * @return Return true to allow component to start, or false to reject. 41 */ 42 virtual bool AllowComponentStart(const Want &want, const sptr<IRemoteObject> &callerToken, 43 int requestCode, int componentStatus, sptr<Want> &extraParam) override; 44 45 /** 46 * The system is trying to move ability to foreground/background. 47 * 48 * @param abilityToken Ability token. 49 * @param opCode the operation code of the ability. 50 */ 51 virtual void NotifyHandleAbilityStateChange(const sptr<IRemoteObject> &abilityToken, int opCode) override; 52 53 /** 54 * The system is trying to release call. 55 * 56 * @param connect Callback used to notify caller the result of connecting or disconnecting. 57 * @param element service ability's ElementName. 58 * @param extraParam The exra param of component to release. 59 * @return Return true when the call released, or false to reject. 60 */ 61 virtual bool ReleaseCallInterception(const sptr<IRemoteObject> &connect, const AppExecFwk::ElementName &element, 62 sptr<Want> &extraParam) override; 63 64 private: 65 bool WriteInterfaceToken(MessageParcel &data); 66 void SetExtraParam(const sptr<Want> &want, sptr<Want> &extraParam); 67 static inline BrokerDelegator<ComponentInterceptionProxy> delegator_; 68 }; 69 } // namespace AppExecFwk 70 } // namespace OHOS 71 #endif 72