Vishnu Nair | 33fd3be | 2017-09-27 11:06:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "include/PriorityDumper.h" |
| 18 | |
| 19 | namespace android { |
| 20 | |
| 21 | static void getStrippedArgs(Vector<String16>& dest, const Vector<String16>& source, |
| 22 | std::size_t numArgsToStrip) { |
| 23 | for (auto it = source.begin() + numArgsToStrip; it != source.end(); it++) { |
| 24 | dest.add(*it); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | void priorityDump(PriorityDumper& dumper, int fd, const Vector<String16>& args) { |
| 29 | if (args.size() >= 2 && args[0] == PRIORITY_ARG) { |
| 30 | String16 priority = args[1]; |
| 31 | Vector<String16> strippedArgs; |
| 32 | getStrippedArgs(strippedArgs, args, 2); |
| 33 | if (priority == PRIORITY_ARG_CRITICAL) { |
| 34 | dumper.dumpCritical(fd, strippedArgs); |
| 35 | } else if (priority == PRIORITY_ARG_HIGH) { |
| 36 | dumper.dumpHigh(fd, strippedArgs); |
| 37 | } else if (priority == PRIORITY_ARG_NORMAL) { |
| 38 | dumper.dumpNormal(fd, strippedArgs); |
| 39 | } else { |
| 40 | dumper.dump(fd, args); |
| 41 | } |
| 42 | } else { |
| 43 | dumper.dump(fd, args); |
| 44 | } |
| 45 | } |
| 46 | } // namespace android |