• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PANDA_PLUGINS_ETS_RUNTIME_APP_STATE_H
17 #define PANDA_PLUGINS_ETS_RUNTIME_APP_STATE_H
18 
19 #include <atomic>
20 #include <cstdint>
21 #include <optional>
22 
23 namespace ark::ets {
24 
25 class AppState {
26 public:
27     enum class State { FOREGROUND, BACKGROUND, SENSITIVE_START, SENSITIVE_END, COLD_START_FINISHED };
28 
29     AppState() = default;
AppState(State state,int64_t timestamp)30     AppState(State state, int64_t timestamp) : state_(state), timestamp_(timestamp) {}
31 
GetState()32     std::optional<State> GetState() const
33     {
34         return state_;
35     }
36 
GetTimeStamp()37     int64_t GetTimeStamp() const
38     {
39         return timestamp_;
40     }
41 
42 private:
43     std::optional<State> state_;
44     int64_t timestamp_ {0};
45 };
46 }  // namespace ark::ets
47 
48 #endif  // PANDA_PLUGINS_ETS_RUNTIME_APP_STATE_H