• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 #ifndef STATS_DIMENSIONS_VALUE_H
17 #define STATS_DIMENSIONS_VALUE_H
18 
19 #include <binder/Parcel.h>
20 #include <binder/Parcelable.h>
21 #include <binder/Status.h>
22 #include <utils/String16.h>
23 #include <vector>
24 
25 namespace android {
26 namespace os {
27 
28 // Represents a parcelable object. Used to send data from statsd to StatsCompanionService.java.
29 class StatsDimensionsValue : public android::Parcelable {
30 public:
31     StatsDimensionsValue();
32 
33     StatsDimensionsValue(int32_t field, String16 value);
34     StatsDimensionsValue(int32_t field, int32_t value);
35     StatsDimensionsValue(int32_t field, int64_t value);
36     StatsDimensionsValue(int32_t field, bool value);
37     StatsDimensionsValue(int32_t field, float value);
38     StatsDimensionsValue(int32_t field, std::vector<StatsDimensionsValue> value);
39 
40     virtual ~StatsDimensionsValue();
41 
42     virtual android::status_t writeToParcel(android::Parcel* out) const override;
43     virtual android::status_t readFromParcel(const android::Parcel* in) override;
44 
45 private:
46     // Keep constants in sync with android/os/StatsDimensionsValue.java
47     // and stats_log.proto's DimensionValue.
48     static const int kStrValueType = 2;
49     static const int kIntValueType = 3;
50     static const int kLongValueType = 4;
51     static const int kBoolValueType = 5;
52     static const int kFloatValueType = 6;
53     static const int kTupleValueType = 7;
54 
55     int32_t mField;
56     int32_t mValueType;
57 
58     // This isn't very clever, but it isn't used for long-term storage, so it'll do.
59     String16 mStrValue;
60     int32_t mIntValue;
61     int64_t mLongValue;
62     bool mBoolValue;
63     float mFloatValue;
64     std::vector<StatsDimensionsValue> mTupleValue;
65 };
66 
67 }  // namespace os
68 }  // namespace android
69 
70 #endif // STATS_DIMENSIONS_VALUE_H
71