1 /* 2 * Copyright (c) 2021-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 #ifndef POWER_SHELL_COMMAND_H 17 #define POWER_SHELL_COMMAND_H 18 19 #include <functional> 20 #include <getopt.h> 21 #include <map> 22 #include "shell_command.h" 23 24 #include "power_mgr_client.h" 25 26 namespace OHOS { 27 namespace PowerMgr { 28 class PowerShellCommand : public OHOS::AAFwk::ShellCommand { 29 public: 30 PowerShellCommand(int argc, char *argv[]); ~PowerShellCommand()31 ~PowerShellCommand() override {}; 32 33 private: 34 static bool IsDeveloperMode(); 35 ErrCode CreateCommandMap() override; 36 ErrCode CreateMessageMap() override; 37 ErrCode init() override; 38 ErrCode RunAsHelpCommand(); 39 ErrCode RunAsDumpCommand(); 40 ErrCode RunAsSetModeCommand(); 41 ErrCode RunAsWakeupCommand(); 42 ErrCode RunAsSuspendCommand(); 43 ErrCode RunAsHibernateCommand(); 44 ErrCode RunAsQueryLockCommand(); 45 ErrCode RunAsProxyLockCommand(); 46 ErrCode RunAsForceTimeOutCommand(); 47 ErrCode RunAsTimeOutScreenLockCommand(); 48 #ifdef HAS_DISPLAY_MANAGER_PART 49 ErrCode RunAsDisplayCommand(); 50 bool DisplayOptargEmpty(); 51 ErrCode RunAsDisplayCommandHelp(); 52 ErrCode RunAsDisplayCommandOverride(); 53 ErrCode RunAsDisplayCommandRestore(); 54 ErrCode RunAsDisplayCommandBoost(); 55 ErrCode RunAsDisplayCommandCancelBoost(); 56 ErrCode RunAsDisplayCommandSetValue(); 57 ErrCode RunAsDisplayCommandDiscount(); 58 std::map<char, std::function<int32_t()>> commandDisplay_; 59 #endif 60 ErrCode RunAsTimeOutCommand(); 61 }; 62 } // namespace PowerMgr 63 } // namespace OHOS 64 #endif // POWER_SHELL_COMMAND_H 65