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