• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef STORAGE_MANAGER_ACCOUNT_SUBSCRIBER_H
16 #define STORAGE_MANAGER_ACCOUNT_SUBSCRIBER_H
17 
18 #include <mutex>
19 #include <unordered_map>
20 
21 #include "common_event_manager.h"
22 #include "common_event_subscribe_info.h"
23 #include "common_event_subscriber.h"
24 #include "common_event_support.h"
25 #include "matching_skills.h"
26 #include "datashare_helper.h"
27 
28 namespace OHOS {
29 namespace StorageManager {
30 enum {
31     USER_UNLOCK_BIT,
32     USER_SWITCH_BIT
33 };
34 
35 class AccountSubscriber : public EventFwk::CommonEventSubscriber {
36 public:
37     AccountSubscriber() = default;
38     explicit AccountSubscriber(const EventFwk::CommonEventSubscribeInfo &subscriberInfo);
39     static bool Subscriber(void);
40     virtual ~AccountSubscriber() = default;
41     virtual void OnReceiveEvent(const EventFwk::CommonEventData &eventData) override;
SetMediaShare(std::shared_ptr<DataShare::DataShareHelper> & sptr)42     static void SetMediaShare(std::shared_ptr<DataShare::DataShareHelper> &sptr)
43     {
44         mediaShare_ = sptr;
45     }
46 
47 private:
48     static std::shared_ptr<DataShare::DataShareHelper> mediaShare_;
49     std::mutex mutex_;
50 
51     int32_t userId_ = 0;
52     std::unordered_map<int32_t, uint32_t> userRecord_;
53 };
54 }  // namespace StorageManager
55 }  // namespace OHOS
56 
57 #endif // STORAGE_MANAGER_ACCOUNT_SUBSCRIBER_H