Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [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 | #pragma once |
| 18 | |
| 19 | #include <log/logprint.h> |
| 20 | #include <set> |
| 21 | #include <vector> |
| 22 | #include "frameworks/base/cmds/statsd/src/stats_log.pb.h" |
| 23 | #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" |
| 24 | #include "field_util.h" |
| 25 | |
| 26 | namespace android { |
| 27 | namespace os { |
| 28 | namespace statsd { |
| 29 | |
| 30 | |
| 31 | // Returns the leaf node from the DimensionsValue proto. It assume that the input has only one |
| 32 | // leaf node at most. |
| 33 | const DimensionsValue* getSingleLeafValue(const DimensionsValue* value); |
| 34 | DimensionsValue getSingleLeafValue(const DimensionsValue& value); |
| 35 | |
| 36 | // Constructs the DimensionsValue protos from the FieldMatcher. Each DimensionsValue proto |
| 37 | // represents a tree. When the input proto has repeated fields and the input "dimensions" wants |
| 38 | // "ANY" locations, it will return multiple trees. |
| 39 | void findDimensionsValues( |
| 40 | const FieldValueMap& fieldValueMap, |
| 41 | const FieldMatcher& matcher, |
| 42 | std::vector<DimensionsValue>* rootDimensionsValues); |
| 43 | |
| 44 | // Utils to build FieldMatcher proto for simple one-depth atoms. |
| 45 | FieldMatcher buildSimpleAtomFieldMatcher(const int tagId, const int atomFieldNum); |
| 46 | FieldMatcher buildSimpleAtomFieldMatcher(const int tagId); |
| 47 | |
| 48 | // Utils to build FieldMatcher proto for attribution nodes. |
| 49 | FieldMatcher buildAttributionUidFieldMatcher(const int tagId, const Position position); |
| 50 | FieldMatcher buildAttributionTagFieldMatcher(const int tagId, const Position position); |
| 51 | FieldMatcher buildAttributionFieldMatcher(const int tagId, const Position position); |
| 52 | |
| 53 | // Utils to print pretty string for DimensionsValue proto. |
| 54 | std::string DimensionsValueToString(const DimensionsValue& value); |
| 55 | void DimensionsValueToString(const DimensionsValue& value, std::string *flattened); |
| 56 | |
| 57 | bool IsSubDimension(const DimensionsValue& dimension, const DimensionsValue& sub); |
| 58 | |
Yangster-mac | a7fb12d | 2018-01-03 17:17:20 -0800 | [diff] [blame^] | 59 | // Helper function to get long value from the DimensionsValue proto. |
| 60 | long getLongFromDimenValue(const DimensionsValue& dimensionValue); |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 61 | } // namespace statsd |
| 62 | } // namespace os |
| 63 | } // namespace android |