• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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_DISTRIBUTED_SCHED_ADAPTER_H
17 #define OHOS_DISTRIBUTED_SCHED_ADAPTER_H
18 
19 #include "ability_info.h"
20 #include "ability_manager_client.h"
21 #include "caller_info.h"
22 #include "device_auth.h"
23 #include "distributed_sched_interface.h"
24 #include "event_handler.h"
25 #include "if_system_ability_manager.h"
26 #include "iremote_object.h"
27 #include "mission/distributed_mission_change_listener.h"
28 #include "mission/distributed_mission_info.h"
29 #include "single_instance.h"
30 #include "uri.h"
31 
32 namespace OHOS {
33 namespace DistributedSchedule {
34 class DistributedSchedAdapter {
35     DECLARE_SINGLE_INSTANCE(DistributedSchedAdapter);
36 
37 public:
38     using AccountInfo = IDistributedSched::AccountInfo;
39 
40     void Init();
41     void UnInit();
42 
43     int32_t ConnectAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
44         const sptr<IRemoteObject>& callerToken);
45     int32_t DisconnectAbility(const sptr<IRemoteObject>& connect);
46     void DeviceOnline(const std::string& deviceId);
47     void DeviceOffline(const std::string& deviceId);
48     void ProcessConnectDied(const sptr<IRemoteObject>& connect);
49     int32_t GetLocalMissionInfos(int32_t numMissions, std::vector<DstbMissionInfo>& missionInfos);
50     bool AllowMissionUid(int32_t uid);
51     int32_t RegisterMissionListener(const sptr<DistributedMissionChangeListener>& listener);
52     int32_t UnRegisterMissionListener(const sptr<DistributedMissionChangeListener>& listener);
53     int32_t GetOsdSwitch();
54     void OnOsdEventOccur(int32_t flag);
55     int32_t GetLocalMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
56         AAFwk::MissionSnapshot& missionSnapshot);
57     int32_t ReleaseAbility(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element);
58     int32_t StartAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
59         const sptr<IRemoteObject>& callerToken);
60     void ProcessCallerDied(const sptr<IRemoteObject>& connect);
61     void ProcessCalleeDied(const sptr<IRemoteObject>& connect);
62     bool InitHichainService();
63     bool CheckAccessToGroup(const std::string& groupId, const std::string& targetBundleName);
64     bool GetRelatedGroups(const std::string& udid, const std::string& bundleName, std::string& returnGroups);
65 private:
66     void ProcessDeviceOffline(const std::string& deviceId);
67 
68     std::shared_ptr<AppExecFwk::EventHandler> dmsAdapterHandler_;
69     const DeviceGroupManager* hichainGmInstance_ = nullptr;
70     std::mutex hichainLock_;
71 };
72 } // namespace DistributedSchedule
73 } // namespace OHOS
74 #endif // OHOS_DISTRIBUTED_SCHED_ADAPTER_H
75