• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 INTENTION_SERVICE_H
17 #define INTENTION_SERVICE_H
18 
19 #include "nocopyable.h"
20 
21 #include "boomerang_dumper.h"
22 #include "boomerang_server.h"
23 #include "cooperate_server.h"
24 #include "drag_server.h"
25 #include "intention_dumper.h"
26 #include "intention_stub.h"
27 #include "i_context.h"
28 #include "on_screen_server.h"
29 #include "sequenceable_drag_visible.h"
30 #include "socket_server.h"
31 #include "stationary_server.h"
32 
33 namespace OHOS {
34 namespace Msdp {
35 namespace DeviceStatus {
36 class IntentionService final : public IntentionStub {
37 public:
38     IntentionService(IContext *context);
39     ~IntentionService() = default;
40     DISALLOW_COPY_AND_MOVE(IntentionService);
41 
42     // Public
43     using TaskProtoType = std::function<int32_t(void)>;
44 
45     // Socket
46     ErrCode Socket(const std::string& programName, int32_t moduleType, int& socketFd, int32_t& tokenType) override;
47 
48     // Cooperate
49     ErrCode EnableCooperate(int32_t userData) override;
50     ErrCode DisableCooperate(int32_t userData) override;
51     ErrCode StartCooperate(const std::string& remoteNetworkId, int32_t userData, int32_t startDeviceId,
52         bool checkPermission) override;
53     ErrCode StartCooperateWithOptions(const std::string& remoteNetworkId, int32_t userData, int32_t startDeviceId,
54         bool checkPermission, const SequenceableCooperateOptions& options) override;
55     ErrCode StopCooperate(int32_t userData, bool isUnchained, bool checkPermission) override;
56     ErrCode RegisterCooperateListener() override;
57     ErrCode UnregisterCooperateListener() override;
58     ErrCode RegisterHotAreaListener(int32_t userData, bool checkPermission) override;
59     ErrCode UnregisterHotAreaListener() override;
60     ErrCode RegisterMouseEventListener(const std::string& networkId) override;
61     ErrCode UnregisterMouseEventListener(const std::string& networkId) override;
62     ErrCode GetCooperateStateSync(const std::string& udid, bool& state) override;
63     ErrCode GetCooperateStateAsync(const std::string& networkId, int32_t userData, bool isCheckPermission) override;
64     ErrCode SetDamplingCoefficient(uint32_t direction, double coefficient) override;
65 
66     // Drag
67     ErrCode StartDrag(const SequenceableDragData &sequenceableDragData) override;
68     ErrCode StopDrag(const SequenceableDragResult &sequenceableDragResult) override;
69     ErrCode EnableInternalDropAnimation(const std::string &animationInfo) override;
70     ErrCode AddDraglistener(bool isJsCaller) override;
71     ErrCode RemoveDraglistener(bool isJsCaller) override;
72     ErrCode SetDragWindowVisible(const SequenceableDragVisible &sequenceableDragVisible) override;
73     ErrCode AddSubscriptListener() override;
74     ErrCode RemoveSubscriptListener() override;
75     ErrCode UpdateDragStyle(int32_t style, int32_t eventId) override;
76     ErrCode UpdateShadowPic(const std::shared_ptr<PixelMap>& pixelMap, int32_t x, int32_t y) override;
77     ErrCode GetDragTargetPid(int32_t &targetPid) override;
78     ErrCode GetUdKey(std::string &udKey) override;
79     ErrCode GetShadowOffset(int32_t &offsetX, int32_t &offsetY, int32_t &width, int32_t &height) override;
80     ErrCode GetDragData(SequenceableDragData &sequenceableDragData) override;
81     ErrCode UpdatePreviewStyle(const SequenceablePreviewStyle &sequenceablePreviewStyle) override;
82     ErrCode UpdatePreviewStyleWithAnimation(const SequenceablePreviewAnimation &sequenceablePreviewAnimation) override;
83     ErrCode RotateDragWindowSync(const SequenceableRotateWindow &sequenceableRotateWindow) override;
84     ErrCode SetDragWindowScreenId(uint64_t displayId, uint64_t screenId) override;
85     ErrCode GetDragSummary(std::map<std::string, int64_t> &summarys, bool isJsCaller) override;
86     ErrCode GetDragSummaryInfo(SequenceableDragSummaryInfo &sequenceableDragSummaryInfo) override;
87     ErrCode SetDragSwitchState(bool enable, bool isJsCaller) override;
88     ErrCode SetAppDragSwitchState(bool enable, const std::string &pkgName, bool isJsCaller) override;
89     ErrCode GetDragState(int32_t &dragState) override;
90     ErrCode EnableUpperCenterMode(bool enable) override;
91     ErrCode GetDragAction(int32_t &dragAction) override;
92     ErrCode GetExtraInfo(std::string &extraInfo) override;
93     ErrCode AddPrivilege() override;
94     ErrCode EraseMouseIcon() override;
95     ErrCode SetMouseDragMonitorState(bool state) override;
96     ErrCode SetDraggableState(bool state) override;
97     ErrCode GetAppDragSwitchState(bool& state) override;
98     ErrCode SetDraggableStateAsync(bool state, int64_t downTime) override;
99     ErrCode GetDragBundleInfo(std::string &bundleName, bool &state) override;
100     ErrCode IsDragStart(bool &isStart) override;
101 
102     // Boomerang
103     ErrCode SubscribeCallback(int32_t type, const std::string& bundleName,
104         const sptr<IRemoteBoomerangCallback>& subCallback) override;
105     ErrCode UnsubscribeCallback(int32_t type, const std::string& bundleName,
106         const sptr<IRemoteBoomerangCallback>& unsubCallback) override;
107     ErrCode NotifyMetadataBindingEvent(const std::string& bundleName,
108         const sptr<IRemoteBoomerangCallback>& notifyCallback) override;
109     ErrCode SubmitMetadata(const std::string& metaData) override;
110     ErrCode BoomerangEncodeImage(const std::shared_ptr<PixelMap>& pixelMap, const std::string& metaData,
111         const sptr<IRemoteBoomerangCallback>& encodeCallback) override;
112     ErrCode BoomerangDecodeImage(const std::shared_ptr<PixelMap>& pixelMap,
113         const sptr<IRemoteBoomerangCallback>& decodeCallback) override;
114 
115     // Stationary
116     ErrCode SubscribeStationaryCallback(int32_t type, int32_t event,
117         int32_t latency, const sptr<IRemoteDevStaCallback> &subCallback) override;
118     ErrCode UnsubscribeStationaryCallback(int32_t type, int32_t event,
119         const sptr<IRemoteDevStaCallback> &unsubCallback) override;
120     ErrCode GetDeviceStatusData(int32_t type, int32_t &replyType, int32_t &replyValue) override;
121     ErrCode GetDevicePostureDataSync(SequenceablePostureData &data) override;
122 
123     // OnScreen
124     ErrCode GetPageContent(const OnScreen::SequenceableContentOption &contentOption,
125         OnScreen::SequenceablePageContent &pageContent) override;
126     ErrCode SendControlEvent(const OnScreen::SequenceableControlEvent &event) override;
127 
128 private:
129     CallingContext GetCallingContext();
130     void PrintCallingContext(const CallingContext &context);
131     int32_t PostSyncTask(TaskProtoType task);
132 private:
133     IContext *context_ { nullptr };
134     SocketServer socketServer_;
135     StationaryServer stationary_;
136     CooperateServer cooperate_;
137     DragServer drag_;
138     IntentionDumper dumper_;
139     BoomerangServer boomerang_;
140     BoomerangDumper boomerangDumper_;
141     OnScreen::OnScreenServer onScreen_;
142 };
143 } // namespace DeviceStatus
144 } // namespace Msdp
145 } // namespace OHOS
146 #endif // INTENTION_SERVICE_H
147