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_STUB_H 17 #define OHOS_ABILITY_RUNTIME_COMPONENT_INTERCEPTION_STUB_H 18 19 #include "iremote_stub.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 ComponentInterceptionStub : public IRemoteStub<IComponentInterception> { 28 public: 29 ComponentInterceptionStub(); 30 virtual ~ComponentInterceptionStub(); 31 32 virtual int OnRemoteRequest( 33 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 34 35 /** 36 * The system is trying to start an component. 37 * 38 * @param want The want of component to start. 39 * @param callerToken Caller component token. 40 * @param requestCode the requestCode of the component to start. 41 * @param componentStatus the status of component. 42 * @param extraParam The extra param of component to start. 43 * @return Return true to allow component to start, or false to reject. 44 */ 45 virtual bool AllowComponentStart(const Want &want, const sptr<IRemoteObject> &callerToken, 46 int requestCode, int componentStatus, sptr<Want> &extraParam) override; 47 48 private: 49 using ComponentInterceptionFunc = int32_t (ComponentInterceptionStub::*) 50 (MessageParcel &data, MessageParcel &reply); 51 std::map<uint32_t, ComponentInterceptionFunc> requestFuncMap_; 52 int32_t HandleAllowComponentStart(MessageParcel &data, MessageParcel &reply); 53 54 DISALLOW_COPY_AND_MOVE(ComponentInterceptionStub); 55 }; 56 } // namespace AppExecFwk 57 } // namespace OHOS 58 #endif // OHOS_ABILITY_RUNTIME_COMPONENT_INTERCEPTION_STUB_H 59