1 /* 2 * Copyright (c) 2023 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 OHOS_FILEMGMT_SCREEN_STATUS_LISTENER_H 17 #define OHOS_FILEMGMT_SCREEN_STATUS_LISTENER_H 18 19 #include "common_event_subscriber.h" 20 #include "data_sync_manager.h" 21 22 namespace OHOS { 23 namespace FileManagement { 24 namespace CloudSync { 25 class ScreenStatusListener : public std::enable_shared_from_this<ScreenStatusListener> { 26 public: 27 explicit ScreenStatusListener(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager); 28 ~ScreenStatusListener(); 29 void Start(); 30 void Stop(); 31 void ScreenOff(); 32 33 private: 34 std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager_; 35 std::shared_ptr<EventFwk::CommonEventSubscriber> commonEventSubscriber_ = nullptr; 36 }; 37 38 class ScreenStatusSubscriber : public EventFwk::CommonEventSubscriber { 39 public: 40 ScreenStatusSubscriber(const EventFwk::CommonEventSubscribeInfo &subscribeInfo, 41 std::shared_ptr<ScreenStatusListener> listener); ~ScreenStatusSubscriber()42 ~ScreenStatusSubscriber() override {} 43 void OnReceiveEvent(const EventFwk::CommonEventData &eventData) override; 44 private: 45 std::shared_ptr<ScreenStatusListener> listener_; 46 }; 47 } // namespace CloudSync 48 } // namespace FileManagement 49 } // namespace OHOS 50 51 #endif // OHOS_FILEMGMT_SCREEN_STATUS_LISTENER_H