1 /* 2 * Copyright (c) 2022 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 "device_info_manager.h" 17 18 #include "transient_task_log.h" 19 20 using namespace std; 21 22 namespace OHOS { 23 namespace BackgroundTaskMgr { OnInputEvent(const EventInfo & eventInfo)24void DeviceInfoManager::OnInputEvent(const EventInfo& eventInfo) 25 { 26 if (isDump_) { 27 std::vector<std::string> strArg = eventInfo.GetStringArgs(); 28 if (strArg[0] != "dump") { 29 return; 30 } 31 } 32 33 switch (eventInfo.GetEventId()) { 34 case EVENT_SCREEN_ON: 35 isScreenOn_ = true; 36 break; 37 case EVENT_SCREEN_OFF: 38 isScreenOn_ = false; 39 isScreenUnlock_ = false; 40 break; 41 case EVENT_SCREEN_UNLOCK: 42 isScreenUnlock_ = true; 43 break; 44 case EVENT_BATTERY_LOW: 45 isLowPowerMode_ = true; 46 break; 47 case EVENT_BATTERY_OKAY: 48 isLowPowerMode_ = false; 49 break; 50 default: 51 break; 52 } 53 } 54 } // namespace BackgroundTaskMgr 55 } // namespace OHOS