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