blob: 0430fa393eaaeb531a4e09c5da13fdfdd2adc22f [file] [log] [blame]
Stan Rokitad0cd57d2019-09-17 15:52:51 -07001/*
2 * Copyright (C) 2019 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 "ScopedWakelock.h"
18
19namespace android {
20namespace hardware {
21namespace sensors {
22namespace V2_0 {
23namespace implementation {
24
25ScopedWakelock::ScopedWakelock(IScopedWakelockRefCounter* refCounter, bool locked)
26 : mRefCounter(refCounter), mLocked(locked) {
27 // TODO: Move this implementation into HalProxy object instead
28 if (mLocked) {
29 mRefCounter->incrementRefCountAndMaybeAcquireWakelock();
30 }
31}
32
33ScopedWakelock::~ScopedWakelock() {
34 // TODO: Move this implementation into HalProxy object instead
35 if (mLocked) {
36 mRefCounter->decrementRefCountAndMaybeReleaseWakelock();
37 }
38}
39
40} // namespace implementation
41} // namespace V2_0
42} // namespace sensors
43} // namespace hardware
44} // namespace android