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_ABILITY_RUNTIME_DISTRIBUTED_CLIENT_H 17 #define OHOS_ABILITY_RUNTIME_DISTRIBUTED_CLIENT_H 18 19 20 #include <string> 21 22 #include "mission_info.h" 23 #include "mission_snapshot.h" 24 #include "want_params.h" 25 #include "want.h" 26 #include "iremote_broker.h" 27 28 namespace OHOS { 29 namespace AAFwk { 30 class DistributedClient { 31 public: 32 DistributedClient() = default; 33 virtual ~DistributedClient() = default; 34 int32_t StartRemoteAbility(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode, 35 uint32_t accessToken); 36 int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId, 37 int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams); 38 int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid, 39 int32_t status, uint32_t accessToken); 40 int32_t NotifyCompleteContinuation(const std::u16string &devId, int32_t sessionId, bool isSuccess); 41 int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect); 42 int32_t DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid, uint32_t accessToken); 43 int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag); 44 int32_t StopSyncRemoteMissions(const std::string& devId); 45 int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj); 46 int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj); 47 int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions, 48 std::vector<AAFwk::MissionInfo>& missionInfos); 49 int32_t GetRemoteMissionSnapshotInfo(const std::string& deviceId, int32_t missionId, 50 std::unique_ptr<MissionSnapshot>& missionSnapshot); 51 int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect); 52 int32_t ReleaseRemoteAbility(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element); 53 int32_t StartRemoteFreeInstall(const OHOS::AAFwk::Want& want, 54 int32_t callerUid, int32_t requestCode, uint32_t accessToken, const sptr<IRemoteObject>& callback); 55 enum { 56 START_REMOTE_ABILITY = 1, 57 CONNECT_REMOTE_ABILITY = 6, 58 DISCONNECT_REMOTE_ABILITY = 7, 59 START_CONTINUATION = 11, 60 NOTIFY_COMPLETE_CONTINUATION = 12, 61 CONTINUE_MISSION = 36, 62 GET_MISSION_INFOS = 80, 63 REGISTER_MISSION_LISTENER = 84, 64 UNREGISTER_MISSION_LISTENER = 85, 65 START_SYNC_MISSIONS = 92, 66 STOP_SYNC_MISSIONS = 98, 67 GET_REMOTE_MISSION_SNAPSHOT_INFO = 99, 68 START_REMOTE_ABILITY_BY_CALL = 150, 69 RELEASE_REMOTE_ABILITY = 151, 70 START_REMOTE_FREE_INSTALL = 200, 71 }; 72 private: 73 sptr<IRemoteObject> GetDmsProxy(); 74 bool ReadMissionInfosFromParcel(Parcel& parcel, std::vector<AAFwk::MissionInfo>& missionInfos); 75 bool WriteInfosToParcel(MessageParcel& data, const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect); 76 }; 77 } // namespace AAFwk 78 } // namespace OHOS 79 #endif 80