• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "chre/platform/power_control_manager.h"
18 
19 #include "chre/platform/slpi/power_control_util.h"
20 #include "chre/platform/slpi/see/island_vote_client.h"
21 #include "chre/platform/system_time.h"
22 #include "chre/util/lock_guard.h"
23 
24 namespace chre {
25 
voteBigImage(bool bigImage)26 bool PowerControlManagerBase::voteBigImage(bool bigImage) {
27   return IslandVoteClientSingleton::get()->voteBigImage(bigImage);
28 }
29 
onHostWakeSuspendEvent(bool awake)30 void PowerControlManagerBase::onHostWakeSuspendEvent(bool awake) {
31   if (mHostIsAwake != awake) {
32     mHostIsAwake = awake;
33 
34     EventLoopManagerSingleton::get()->getEventLoop().postEvent(
35         mHostIsAwake ? CHRE_EVENT_HOST_AWAKE : CHRE_EVENT_HOST_ASLEEP,
36         nullptr /* eventData */, nullptr /* freeCallback */);
37   }
38 }
39 
postEventLoopProcess(size_t numPendingEvents)40 void PowerControlManager::postEventLoopProcess(size_t numPendingEvents) {
41   if (numPendingEvents == 0 && !slpiInUImage()) {
42     voteBigImage(false /* bigImage */);
43   }
44 }
45 
hostIsAwake()46 bool PowerControlManager::hostIsAwake() {
47   return mHostIsAwake;
48 }
49 
50 } // namespace chre
51