• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 MSDP_MANAGER_H
17 #define MSDP_MANAGER_H
18 
19 #include <cstdint>
20 #include <functional>
21 #include <map>
22 #include <vector>
23 #include <sstream>
24 #include "nocopyable.h"
25 #include "string_ex.h"
26 #include "parcel.h"
27 
28 namespace OHOS {
29 namespace Accessibility {
30 class UserStatusData : public Parcelable {
31 public:
32     UserStatusData();
33     virtual ~UserStatusData();
34 
35     uint32_t GetFeature() const;
36     void SetFeature(uint32_t feature);
37 
38     std::string GetStatus() const;
39     void SetStatus(const std::string &status);
40 
41     int32_t GetResult() const;
42     void SetResult(int32_t result);
43 
44     int32_t GetErrorCode() const;
45     void SetErrorCode(int32_t errorCode);
46 
47     std::vector<std::string> GetResultApps() const;
48     void SetResultApps(const std::vector<std::string>);
49 
50     std::string GetHpeDeviceId() const;
51     void SetHpeDeviceId(const std::string &hpeDeviceId);
52 
53     int32_t GetCoordinateX() const;
54     void SetCoordinateX(int32_t coordinateX);
55 
56     int32_t GetCoordinateY() const;
57     void SetCoordinateY(int32_t coordinateY);
58 
59     int32_t GetPointerAction() const;
60     void SetPointerAction(int32_t pointerAction);
61 
62     int32_t GetOrientation() const;
63     void SetOrientation(int32_t orientation);
64 
65     virtual std::string Dump();
66     virtual std::shared_ptr<UserStatusData> Unmarshalling(Parcel &parcel);
67     static int32_t UnMarshallingFeature(Parcel &parcel);
68     bool Marshalling(Parcel &parcel) const override;
69     bool WriteTimeTunnelData(Parcel &parcel) const;
70 
71 protected:
72     std::string DumpBaseData();
73     uint32_t feature_ { 0 };
74     int32_t result_ { 0 };
75     int32_t errorCode_ { 0 };
76     std::string status_;
77     int32_t coordinateX_ { 0 };
78     int32_t coordinateY_ { 0 };
79     int32_t pointerAction_ { 0 };
80     int32_t orientation_ { 0 };
81     virtual bool ReadFromParcel(Parcel &parcel);
82 
83 private:
84     std::vector<std::string> resultApps_;
85     std::string hpeDeviceId_;
86 };
87 
88 using UserStatusDataCallbackFunc = std::function<void(int32_t, std::shared_ptr<UserStatusData>)>;
89 
90 class MsdpManager {
91 public:
92     static MsdpManager &GetInstance();
93 
94     int32_t SubscribeVoiceRecognition();
95 
96     void UnSubscribeVoiceRecognition();
97 
98     MsdpManager(const MsdpManager&) = delete;
99 
100     MsdpManager(MsdpManager&&) = delete;
101 
102     MsdpManager& operator=(const MsdpManager&) = delete;
103 
104     MsdpManager& operator=(MsdpManager&&) = delete;
105 
106 private:
107     MsdpManager();
108 
109     ~MsdpManager();
110 
111     void* handle_;
112 };
113 } // namespace Accessibility
114 } // namespace OHOS
115 #endif // MSDP_MANAGER_H