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 POWERMGR_RUNNING_LOCK_INFO_H 17 #define POWERMGR_RUNNING_LOCK_INFO_H 18 19 #include <list> 20 #include <string> 21 22 #include <parcel.h> 23 24 namespace OHOS { 25 namespace PowerMgr { 26 /** 27 * Runninglock acquisition type 28 */ 29 enum class RunningLockType : uint32_t { 30 /** 31 * RunningLock type: used to keep screen on. 32 */ 33 RUNNINGLOCK_SCREEN = 0, 34 /** 35 * RunningLock type: used to keep cpu running. 36 */ 37 RUNNINGLOCK_BACKGROUND = 1, 38 /** 39 * RunningLock type: used to keep the screen on/off when the proximity sensor is active. 40 */ 41 RUNNINGLOCK_PROXIMITY_SCREEN_CONTROL = 2, 42 /** 43 * Background runningLock type, keeping phone background task active. 44 */ 45 RUNNINGLOCK_BACKGROUND_PHONE = RUNNINGLOCK_BACKGROUND | 1 << 1, // 0b00000011 46 /** 47 * Background runningLock type, keeping notification background task active. 48 */ 49 RUNNINGLOCK_BACKGROUND_NOTIFICATION = RUNNINGLOCK_BACKGROUND | 1 << 2, // 0b00000101 50 /** 51 * Background runningLock type, keeping audio background task active. 52 */ 53 RUNNINGLOCK_BACKGROUND_AUDIO = RUNNINGLOCK_BACKGROUND | 1 << 3, // 0b00001001 54 /** 55 * Background runningLock type, keeping sport background task active. 56 */ 57 RUNNINGLOCK_BACKGROUND_SPORT = RUNNINGLOCK_BACKGROUND | 1 << 4, // 0b00010001 58 /** 59 * Background runningLock type, keeping navigation background task active. 60 */ 61 RUNNINGLOCK_BACKGROUND_NAVIGATION = RUNNINGLOCK_BACKGROUND | 1 << 5, // 0b00100001 62 /** 63 * Background runningLock type, keeping common background task active. 64 */ 65 RUNNINGLOCK_BACKGROUND_TASK = RUNNINGLOCK_BACKGROUND | 1 << 6, // 0b01000001 66 /** 67 * RunningLock reserved type. 68 */ 69 RUNNINGLOCK_BUTT 70 }; 71 72 /** 73 * Maintain runninglock information. 74 */ 75 struct RunningLockInfo : public Parcelable { 76 /** 77 * RunningLock name: used to identify user of the runninglock. 78 * You are advised to set it to a combination of information, 79 * such as package name and class name and a unique name. 80 */ 81 std::string name; 82 83 /** 84 * RunningLock type: used to identify the type of RunningLock. 85 */ 86 RunningLockType type; 87 RunningLockInfo() = default; RunningLockInfoRunningLockInfo88 RunningLockInfo(const std::string& namestr, RunningLockType locktype) : name(namestr), type(locktype) {} 89 bool ReadFromParcel(Parcel& parcel); 90 bool Marshalling(Parcel& parcel) const override; 91 static RunningLockInfo* Unmarshalling(Parcel& parcel); 92 }; 93 } // namespace PowerMgr 94 } // namespace OHOS 95 #endif // POWERMGR_RUNNING_LOCK_INFO_H 96