• 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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_DISTRIBUTED_MANAGER_BUNDLE_DISTRIBUTED_MANAGER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_DISTRIBUTED_MANAGER_BUNDLE_DISTRIBUTED_MANAGER_H
18 
19 #include "event_handler.h"
20 #include "event_runner.h"
21 #include "iremote_broker.h"
22 #include "query_rpc_id_params.h"
23 #include "rpc_id_result.h"
24 #include "target_ability_info.h"
25 #include "want.h"
26 
27 namespace OHOS {
28 namespace AppExecFwk {
29 using namespace OHOS::AAFwk;
30 class BundleDistributedManager : public std::enable_shared_from_this<BundleDistributedManager> {
31 public:
32     BundleDistributedManager();
33     ~BundleDistributedManager();
34 
35     bool CheckAbilityEnableInstall(
36         const Want &want, int32_t missionId, int32_t userId, const sptr<IRemoteObject> &callerToken);
37 
38     void OnQueryRpcIdFinished(const std::string &queryRpcIdResult);
39 private:
40     void Init();
41     bool ConvertTargetAbilityInfo(const Want &want, TargetAbilityInfo &targetAbilityInfo);
42     bool QueryRpcIdByAbilityToServiceCenter(const TargetAbilityInfo &targetInfo);
43     void SendCallbackRequest(int32_t resultCode, const std::string &transactId);
44     void SendCallback(int32_t resultCode, const QueryRpcIdParams &queryRpcIdParams);
45     int32_t ComparePcIdString(const Want &want, const RpcIdResult &rpcIdResult);
46     void OutTimeMonitor(const std::string transactId);
GetTransactId()47     int GetTransactId() const
48     {
49         transactId_++;
50         return transactId_.load();
51     }
52 
53     mutable std::atomic<int> transactId_ = 0;
54     std::shared_ptr<OHOS::AppExecFwk::EventHandler> handler_;
55     std::shared_ptr<EventRunner> runner_;
56     std::map<std::string, QueryRpcIdParams> queryAbilityParamsMap_;
57 };
58 }  // namespace AppExecFwk
59 }  // namespace OHOS
60 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_DISTRIBUTED_MANAGER_BUNDLE_DISTRIBUTED_MANAGER_H