• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_H
17 #define OHOS_ABILITY_RUNTIME_COMPONENT_INTERCEPTION_H
18 
19 #include "iremote_broker.h"
20 #include "iremote_object.h"
21 #include "want.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 using OHOS::AAFwk::Want;
26 
27 /**
28  * @brief Interface to monitor what is happening in component manager.
29  */
30 class IComponentInterception : public IRemoteBroker {
31 public:
32     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.IComponentInterception");
33 
34     /**
35      * The system is trying to start an component.
36      *
37      * @param want The want of component to start.
38      * @param callerToken Caller component token.
39      * @param requestCode the requestCode of the component to start.
40      * @param componentStatus the status of component.
41      * @param extraParam The extra param of component to start.
42      * @return Return true to allow component to start, or false to reject.
43      */
44     virtual bool AllowComponentStart(const Want &want, const sptr<IRemoteObject> &callerToken,
45         int requestCode, int componentStatus, sptr<Want> &extraParam) = 0;
46 
47     /**
48      * The system is trying to move ability to foreground/background.
49      *
50      * @param abilityToken Ability token.
51      * @param opCode the operation code of the ability.
52      */
53     virtual void NotifyHandleAbilityStateChange(const sptr<IRemoteObject> &abilityToken, int opCode) = 0;
54 
55     /**
56      * The system is trying to release call.
57      *
58      * @param connect Callback used to notify caller the result of connecting or disconnecting.
59      * @param element service ability's ElementName.
60      * @param extraParam The exra param of component to release.
61      * @return Return true when the call released, or false to reject.
62      */
63     virtual bool ReleaseCallInterception(const sptr<IRemoteObject> &connect, const AppExecFwk::ElementName &element,
64         sptr<Want> &extraParam) = 0;
65 
66     enum class Message {
67         TRANSACT_ON_ALLOW_COMPONENT_START = 1,
68         TRANSACT_ON_HANDLE_MOVE_ABILITY,
69         TRANSACT_ON_RELEASE_CALL,
70     };
71 };
72 }  // namespace AppExecFwk
73 }  // namespace OHOS
74 #endif  // OHOS_ABILITY_RUNTIME_COMPONENT_INTERCEPTION_H
75