• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_OPERATION_SERVICE_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_OPERATION_SERVICE_H
18 
19 #include <map>
20 #include <memory>
21 #include <string>
22 #include "iremote_stub.h"
23 #include "ans_log_wrapper.h"
24 #include "ability_manager_client.h"
25 #include "power_mgr_client.h"
26 #ifdef SCREENLOCK_MGR_ENABLE
27 #include "screenlock_callback_interface.h"
28 #endif
29 #include "notification_operation_info.h"
30 #include "ffrt.h"
31 
32 namespace OHOS {
33 namespace Notification {
34 
35 struct OperationInfo {
36     int32_t deviceTypeId;
37     OperationType type;
38     std::string eventId;
39     AAFwk::Want want;
40 };
41 
42 #ifdef SCREENLOCK_MGR_ENABLE
43 class UnlockScreenCallback : public IRemoteStub<ScreenLock::ScreenLockCallbackInterface> {
44 public:
45     explicit UnlockScreenCallback(const std::string& eventId);
46     ~UnlockScreenCallback() override;
47     void OnCallBack(int32_t screenLockResult) override;
48 
49 private:
50     std::string eventId_;
51 };
52 #endif
53 
54 class OperationService {
55 public:
56     static OperationService& GetInstance();
57     void AddOperation(OperationInfo operationInfo);
58     void HandleScreenEvent();
59     void TriggerOperation(std::string eventId);
60     void TimeOutOperation(std::string eventId);
61 
62 private:
63     OperationService() = default;
64     ~OperationService() = default;
65     ffrt::mutex operationMutex_;
66     std::map<std::string, OperationInfo> operationInfoMaps_;
67 };
68 }
69 }
70 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_OPERATION_SERVICE_H
71