| Harpreet "Eli" Sangha | e47ae68 | 2019-06-05 16:52:47 +0900 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2019 The Android Open Source Project * | 
|  | 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 "utils.h" | 
|  | 17 | #include "vibrator.h" | 
|  | 18 |  | 
|  | 19 | namespace android { | 
|  | 20 | namespace idlcli { | 
|  | 21 |  | 
|  | 22 | class CommandVibrator; | 
|  | 23 |  | 
|  | 24 | namespace vibrator { | 
|  | 25 |  | 
|  | 26 | class CommandOff : public Command { | 
|  | 27 | std::string getDescription() const override { return "Turn off vibrator."; } | 
|  | 28 |  | 
|  | 29 | std::string getUsageSummary() const override { return ""; } | 
|  | 30 |  | 
|  | 31 | UsageDetails getUsageDetails() const override { | 
|  | 32 | UsageDetails details{}; | 
|  | 33 | return details; | 
|  | 34 | } | 
|  | 35 |  | 
|  | 36 | Status doArgs(Args &args) override { | 
|  | 37 | if (!args.empty()) { | 
|  | 38 | std::cerr << "Unexpected Arguments!" << std::endl; | 
|  | 39 | return USAGE; | 
|  | 40 | } | 
|  | 41 | return OK; | 
|  | 42 | } | 
|  | 43 |  | 
|  | 44 | Status doMain(Args && /*args*/) override { | 
|  | 45 | auto ret = halCall(&V1_0::IVibrator::off); | 
|  | 46 |  | 
|  | 47 | if (!ret.isOk()) { | 
|  | 48 | return UNAVAILABLE; | 
|  | 49 | } | 
|  | 50 |  | 
|  | 51 | std::cout << "Status: " << toString(ret) << std::endl; | 
|  | 52 |  | 
|  | 53 | return ret == V1_0::Status::OK ? OK : ERROR; | 
|  | 54 | } | 
|  | 55 | }; | 
|  | 56 |  | 
|  | 57 | static const auto Command = CommandRegistry<CommandVibrator>::Register<CommandOff>("off"); | 
|  | 58 |  | 
|  | 59 | } // namespace vibrator | 
|  | 60 | } // namespace idlcli | 
|  | 61 | } // namespace android |