blob: 5bb64a9cf5ee7472af9c69da32b71e1f0e444516 [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
30
31// Returns the leaf node from the DimensionsValue proto. It assume that the input has only one
32// leaf node at most.
33const DimensionsValue* getSingleLeafValue(const DimensionsValue* value);
34DimensionsValue 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.
39void 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.
45FieldMatcher buildSimpleAtomFieldMatcher(const int tagId, const int atomFieldNum);
46FieldMatcher buildSimpleAtomFieldMatcher(const int tagId);
47
48// Utils to build FieldMatcher proto for attribution nodes.
49FieldMatcher buildAttributionUidFieldMatcher(const int tagId, const Position position);
50FieldMatcher buildAttributionTagFieldMatcher(const int tagId, const Position position);
51FieldMatcher buildAttributionFieldMatcher(const int tagId, const Position position);
52
53// Utils to print pretty string for DimensionsValue proto.
54std::string DimensionsValueToString(const DimensionsValue& value);
55void DimensionsValueToString(const DimensionsValue& value, std::string *flattened);
56
57bool IsSubDimension(const DimensionsValue& dimension, const DimensionsValue& sub);
58
Yangster-maca7fb12d2018-01-03 17:17:20 -080059// Helper function to get long value from the DimensionsValue proto.
60long getLongFromDimenValue(const DimensionsValue& dimensionValue);
Yangster-mac20877162017-12-22 17:19:39 -080061} // namespace statsd
62} // namespace os
63} // namespace android