• 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 
16 #ifndef POWERMGR_POWER_MANAGE_FEATURE_H
17 #define POWERMGR_POWER_MANAGE_FEATURE_H
18 
19 #include <feature.h>
20 
21 #include "power_manage_interface.h"
22 #include "running_lock_mgr.h"
23 
24 typedef struct {
25     INHERIT_FEATURE;
26     INHERIT_IUNKNOWNENTRY(PowerManageInterface);
27     Identity identity;
28 } PowerManageFeature;
29 
30 const char *GetPowerManageFeatureName(Feature *feature);
31 void OnPowerManageFeatureInitialize(Feature *feature, Service *parent, Identity identity);
32 void OnPowerManageFeatureStop(Feature *feature, Identity identity);
33 BOOL OnPowerManageFeatureMessage(Feature *feature, Request *request);
34 int32_t OnAcquireRunningLockEntry(IUnknown *iUnknown, RunningLockEntry *entry, int32_t timeoutMs);
35 int32_t OnReleaseRunningLockEntry(IUnknown *iUnknown, RunningLockEntry *entry);
36 BOOL OnIsAnyRunningLockHolding(IUnknown *iUnknown);
37 void OnSuspendDevice(IUnknown *iUnknown, SuspendDeviceType reason, BOOL suspendImmed);
38 void OnWakeupDevice(IUnknown *iUnknown, WakeupDeviceType reason, const char* details);
39 
40 #define POWER_MANAGE_FEATURE_INTERFACE_IMPL             \
41     .GetName = GetPowerManageFeatureName,               \
42     .OnInitialize = OnPowerManageFeatureInitialize,     \
43     .OnStop = OnPowerManageFeatureStop,                 \
44     .OnMessage = OnPowerManageFeatureMessage
45 
46 #define POWER_MANAGE_INTERFACE_IMPL                                 \
47     .AcquireRunningLockEntryFunc = OnAcquireRunningLockEntry,       \
48     .ReleaseRunningLockEntryFunc = OnReleaseRunningLockEntry,       \
49     .IsAnyRunningLockHoldingFunc = OnIsAnyRunningLockHolding,       \
50     .SuspendDeviceFunc = OnSuspendDevice,                           \
51     .WakeupDeviceFunc = OnWakeupDevice
52 
53 PowerManageFeature *GetPowerManageFeatureImpl(void);
54 
55 #endif // POWERMGR_POWER_MANAGE_FEATURE_H
56