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 #include "power_efficiency_manager.h"
17 
18 #include "media_log.h"
19 
20 namespace OHOS {
21 namespace Media {
22 constexpr int32_t NORMAL_INTERNVAL = 2000;
23 constexpr int32_t OVERLOAD_INTERNVAL = 4000;
24 
25 int32_t PowerEfficiencyManager::sAlbumUpdateInterval_ = NORMAL_INTERNVAL;
26 bool PowerEfficiencyManager::isCharging_ = false;
27 bool PowerEfficiencyManager::isScreenOff_ = false;
28 
PowerEfficiencyManager()29 PowerEfficiencyManager::PowerEfficiencyManager()
30 {
31 }
32 
~PowerEfficiencyManager()33 PowerEfficiencyManager::~PowerEfficiencyManager()
34 {
35 }
36 
UpdateAlbumUpdateInterval(bool isNormal)37 void PowerEfficiencyManager::UpdateAlbumUpdateInterval(bool isNormal)
38 {
39     sAlbumUpdateInterval_ = isNormal ? NORMAL_INTERNVAL : OVERLOAD_INTERNVAL;
40     MEDIA_INFO_LOG("update album interval: %{public}d", sAlbumUpdateInterval_);
41 }
42 
GetAlbumUpdateInterval()43 int32_t PowerEfficiencyManager::GetAlbumUpdateInterval()
44 {
45     return sAlbumUpdateInterval_;
46 }
47 
SetSubscriberStatus(bool isCharging,bool isScreenOff)48 void PowerEfficiencyManager::SetSubscriberStatus(bool isCharging, bool isScreenOff)
49 {
50     isCharging_ = isCharging;
51     isScreenOff_ = isScreenOff;
52 }
53 
IsChargingAndScreenOff()54 bool PowerEfficiencyManager::IsChargingAndScreenOff()
55 {
56     return isCharging_ && isScreenOff_;
57 }
58 
59 } // namespace Media
60 } // namespace OHOS