1 /*
2  * Copyright (C) 2019, 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 #pragma once
17 
18 #include <utils/RefBase.h>
19 
20 #include "HashableDimensionKey.h"
21 
22 namespace android {
23 namespace os {
24 namespace statsd {
25 
26 class StateListener : public virtual RefBase {
27 public:
StateListener()28     StateListener(){};
29 
~StateListener()30     virtual ~StateListener(){};
31 
32     /**
33      * Interface for handling a state change.
34      *
35      * The old and new state values map to the original state values.
36      * StateTrackers only track the original state values and are unaware
37      * of higher-level state groups. MetricProducers hold information on
38      * state groups and are responsible for mapping original state values to
39      * the correct state group.
40      *
41      * [eventTimeNs]: Time of the state change log event.
42      * [atomId]: The id of the state atom
43      * [primaryKey]: The primary field values of the state atom
44      * [oldState]: Previous state value before state change
45      * [newState]: Current state value after state change
46      */
47     virtual void onStateChanged(const int64_t eventTimeNs, const int32_t atomId,
48                                 const HashableDimensionKey& primaryKey, const FieldValue& oldState,
49                                 const FieldValue& newState) = 0;
50 };
51 
52 }  // namespace statsd
53 }  // namespace os
54 }  // namespace android
55