blob: d0f96a2abe6b4f593a7827f7321746399951b198 [file] [log] [blame]
Yangster-mac20877162017-12-22 17:19:39 -08001/*
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
26namespace android {
27namespace os {
28namespace statsd {
29
Yangster-mac20877162017-12-22 17:19:39 -080030// Returns the leaf node from the DimensionsValue proto. It assume that the input has only one
31// leaf node at most.
32const DimensionsValue* getSingleLeafValue(const DimensionsValue* value);
33DimensionsValue getSingleLeafValue(const DimensionsValue& value);
34
Yangster-mac87718e22018-01-11 16:16:26 -080035// Appends the leaf node to the parent tree.
36void appendLeafNodeToParent(const Field& field, const DimensionsValue& value,
37 DimensionsValue* parentValue);
38
Yangster-mac20877162017-12-22 17:19:39 -080039// Constructs the DimensionsValue protos from the FieldMatcher. Each DimensionsValue proto
40// represents a tree. When the input proto has repeated fields and the input "dimensions" wants
41// "ANY" locations, it will return multiple trees.
42void findDimensionsValues(
43 const FieldValueMap& fieldValueMap,
44 const FieldMatcher& matcher,
45 std::vector<DimensionsValue>* rootDimensionsValues);
46
47// Utils to build FieldMatcher proto for simple one-depth atoms.
48FieldMatcher buildSimpleAtomFieldMatcher(const int tagId, const int atomFieldNum);
49FieldMatcher buildSimpleAtomFieldMatcher(const int tagId);
50
51// Utils to build FieldMatcher proto for attribution nodes.
52FieldMatcher buildAttributionUidFieldMatcher(const int tagId, const Position position);
53FieldMatcher buildAttributionTagFieldMatcher(const int tagId, const Position position);
54FieldMatcher buildAttributionFieldMatcher(const int tagId, const Position position);
55
56// Utils to print pretty string for DimensionsValue proto.
57std::string DimensionsValueToString(const DimensionsValue& value);
58void DimensionsValueToString(const DimensionsValue& value, std::string *flattened);
59
60bool IsSubDimension(const DimensionsValue& dimension, const DimensionsValue& sub);
61
Yangster-maca7fb12d2018-01-03 17:17:20 -080062// Helper function to get long value from the DimensionsValue proto.
63long getLongFromDimenValue(const DimensionsValue& dimensionValue);
Yangster-mac20877162017-12-22 17:19:39 -080064} // namespace statsd
65} // namespace os
66} // namespace android