• 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 DRAG_SERVER_H
17 #define DRAG_SERVER_H
18 
19 #include "nocopyable.h"
20 
21 #include "accesstoken_kit.h"
22 #include "i_context.h"
23 #include "i_plugin.h"
24 #ifdef OHOS_BUILD_UNIVERSAL_DRAG
25 #include "universal_drag_wrapper.h"
26 #endif // OHOS_BUILD_UNIVERSAL_DRAG
27 
28 namespace OHOS {
29 namespace Msdp {
30 namespace DeviceStatus {
31 class DragServer final {
32 public:
33     DragServer(IContext *env);
34     ~DragServer() = default;
35     DISALLOW_COPY_AND_MOVE(DragServer);
36 
37     int32_t StartDrag(CallingContext &context, const DragData &dragData);
38     int32_t StopDrag(CallingContext &context, const DragDropResult &dropResult);
39     int32_t EnableInternalDropAnimation(CallingContext &context, const std::string &animationInfo);
40     int32_t AddDraglistener(CallingContext &context, bool isJsCaller);
41     int32_t RemoveDraglistener(CallingContext &context, bool isJsCaller);
42     int32_t UpdateDragStyle(CallingContext &context, DragCursorStyle style, int32_t eventId);
43     int32_t UpdateShadowPic(const ShadowInfo &shadowInfo);
44     int32_t AddSubscriptListener(CallingContext &context);
45     int32_t RemoveSubscriptListener(CallingContext &context);
46     int32_t SetDragWindowVisible(bool visible, bool isForce,
47         const std::shared_ptr<Rosen::RSTransaction>& rsTransaction);
48     int32_t GetDragTargetPid(CallingContext &context, int32_t &targetPid);
49     int32_t GetUdKey(std::string &udKey);
50     int32_t GetShadowOffset(ShadowOffset &shadowOffset);
51     int32_t GetDragData(CallingContext &context, DragData &dragData);
52     int32_t UpdatePreviewStyle(const PreviewStyle &previewStyle);
53     int32_t UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle, const PreviewAnimation &animation);
54     int32_t RotateDragWindowSync(CallingContext &context, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction);
55     int32_t SetDragWindowScreenId(CallingContext &context, uint64_t displayId, uint64_t screenId);
56     int32_t GetDragSummary(CallingContext &context, std::map<std::string, int64_t> &summarys, bool isJsCaller);
57     int32_t SetDragSwitchState(CallingContext &context, bool enable, bool isJsCaller);
58     int32_t SetAppDragSwitchState(CallingContext &context, bool enable, const std::string &pkgName, bool isJsCaller);
59     int32_t GetDragState(CallingContext &context, DragState &dragState);
60     int32_t EnableUpperCenterMode(bool enable);
61     int32_t GetDragAction(DragAction &dragAction);
62     int32_t GetExtraInfo(std::string &extraInfo);
63     int32_t AddPrivilege(CallingContext &context);
64     int32_t EraseMouseIcon(CallingContext &context);
65     int32_t SetMouseDragMonitorState(bool state);
66     int32_t SetDraggableState(bool state);
67     int32_t GetAppDragSwitchState(bool &state);
68     int32_t SetDraggableStateAsync(bool state, int64_t downTime);
69     int32_t GetDragBundleInfo(DragBundleInfo &dragBundleInfo);
70     int32_t IsDragStart(bool &isStart);
71     int32_t GetDragSummaryInfo(DragSummaryInfo &dragSummaryInfo);
72 
73 private:
74     std::string GetPackageName(Security::AccessToken::AccessTokenID tokenId);
75     bool IsSystemServiceCalling(CallingContext &context);
76     bool IsSystemHAPCalling(CallingContext &context);
77 private:
78     IContext *env_ { nullptr };
79 #ifdef OHOS_BUILD_UNIVERSAL_DRAG
80     UniversalDragWrapper universalDragWrapper_;
81 #endif // OHOS_BUILD_UNIVERSAL_DRAG
82 };
83 } // namespace DeviceStatus
84 } // namespace Msdp
85 } // namespace OHOS
86 #endif // DRAG_SERVER_H