• 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 OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_STATE_REPLY_CALLBACK_SERVICE_H
17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_STATE_REPLY_CALLBACK_SERVICE_H
18 
19 #include "os_account_state_reply_callback_stub.h"
20 
21 #include "ios_account_state_reply_callback.h"
22 #include "os_account_subscribe_info.h"
23 #include "safe_queue.h"
24 
25 namespace OHOS {
26 namespace AccountSA {
27 class OsAccountStateReplyCallbackService : public OsAccountStateReplyCallbackStub {
28 public:
29     OsAccountStateReplyCallbackService(int32_t accountId, OsAccountState state,
30         const std::shared_ptr<std::condition_variable> &cvPtr, const std::shared_ptr<SafeQueue<uint8_t>> &safeQueue,
31         int32_t subscriberUid);
32     ~OsAccountStateReplyCallbackService() override;
33     ErrCode OnComplete() override;
34     void SetStartTime(const std::chrono::system_clock::time_point &startTime);
35     int32_t GetSubscriberUid() const;
36 
37 private:
38     int32_t accountId_;
39     OsAccountState state_;
40     std::shared_ptr<std::condition_variable> cvPtr_;
41     std::shared_ptr<SafeQueue<uint8_t>> safeQueue_;
42     int32_t subscriberUid_;
43     std::mutex mutex_;
44     bool isCompleted_ = false;
45     std::chrono::system_clock::time_point startTime_;
46     DISALLOW_COPY_AND_MOVE(OsAccountStateReplyCallbackService);
47 };
48 }  // namespace AccountSA
49 }  // namespace OHOS
50 #endif  // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_STATE_REPLY_CALLBACK_SERVICE_H