1 /*
2  * Copyright (c) 2022-2023 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_INFO_CALLBACK_PROXY_H
17 #define OHOS_ABILITY_RUNTIME_ABILITY_INFO_CALLBACK_PROXY_H
18 
19 #include "iability_info_callback.h"
20 #include "iremote_proxy.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
24 /**
25  * @brief Transfer abilityInfo to the initiator.
26  */
27 class AbilityInfoCallbackProxy : public IRemoteProxy<IAbilityInfoCallback> {
28 public:
29     explicit AbilityInfoCallbackProxy(const sptr<IRemoteObject> &impl);
30     virtual ~AbilityInfoCallbackProxy() = default;
31 
32     /**
33      * Notify the initiator of the ability token.
34      *
35      * @param token The token of ability.
36      * @param want The want of ability to start.
37      */
38     virtual void NotifyAbilityToken(const sptr<IRemoteObject> token, const Want &want) override;
39 
40     /**
41      * Notify to start specified ability.
42      *
43      * @param callerToken The token of caller.
44      * @param want The want of ability to start.
45      * @param requestCode The request code of start ability.
46      * @param extraParam The extra param of ability to start.
47      */
48     virtual void NotifyStartSpecifiedAbility(const sptr<IRemoteObject> &callerToken, const Want &want, int requestCode,
49         sptr<Want> &extraParam) override;
50 
51     virtual void NotifyRestartSpecifiedAbility(const sptr<IRemoteObject> &token) override;
52 
53     /**
54      * Notify the result of start ability.
55      *
56      * @param want The want of ability to start.
57      * @param result The result of start ability.
58      */
59     virtual void NotifyStartAbilityResult(const Want &want, int result) override;
60 
61 private:
62     bool WriteInterfaceToken(MessageParcel &data);
63     void SetExtraParam(const sptr<Want> &want, sptr<Want> &extraParam);
64     static inline BrokerDelegator<AbilityInfoCallbackProxy> delegator_;
65     int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
66 };
67 }  // namespace AppExecFwk
68 }  // namespace OHOS
69 #endif
70