• 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 #include "screenlock_callback_interface.h"
27 #include "notification_operation_info.h"
28 
29 namespace OHOS {
30 namespace Notification {
31 
32 struct OperationInfo {
33     OperationType type;
34     std::string eventId;
35     AAFwk::Want want;
36 };
37 
38 class UnlockScreenCallback : public IRemoteStub<ScreenLock::ScreenLockCallbackInterface> {
39 public:
40     explicit UnlockScreenCallback(const std::string& eventId);
41     ~UnlockScreenCallback() override;
42     void OnCallBack(int32_t screenLockResult) override;
43 
44 private:
45     std::string eventId_;
46     OperationType type_;
47 };
48 
49 class OperationService {
50 public:
51     static OperationService& GetInstance();
52     void AddOperation(OperationInfo operationInfo);
53     void HandleScreenEvent();
54     void TriggerOperation(std::string eventId);
55     void TimeOutOperation(std::string eventId);
56 
57 private:
58     OperationService() = default;
59     ~OperationService() = default;
60     std::mutex operationMutex_;
61     std::map<std::string, OperationInfo> operationInfoMaps_;
62 };
63 }
64 }
65 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_OPERATION_SERVICE_H
66