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 
17 #ifndef DEVICE_GOOGLE_WAHOO_HEALTH_CYCLECOUNTBACKUPRESTORE_H
18 #define DEVICE_GOOGLE_WAHOO_HEALTH_CYCLECOUNTBACKUPRESTORE_H
19 
20 #include <string>
21 #include <android-base/file.h>
22 #include <android-base/strings.h>
23 #include <android-base/logging.h>
24 
25 namespace device {
26 namespace google {
27 namespace wahoo {
28 namespace health {
29 
30 static constexpr int kBucketCount = 8;
31 
32 class CycleCountBackupRestore {
33 public:
34     CycleCountBackupRestore();
35     void Restore();
36     void Backup();
37 
38 private:
39     int sw_bins_[kBucketCount];
40     int hw_bins_[kBucketCount];
41 
42     void ReadFromStorage();
43     void SaveToStorage();
44     void ReadFromSRAM();
45     void SaveToSRAM();
46     void UpdateAndSave();
47 };
48 
49 } // namespace health
50 } // namespace wahoo
51 } // namespace google
52 } // namespace device
53 
54 #endif // #ifndef DEVICE_GOOGLE_WAHOO_HEALTH_CYCLECOUNTBACKUPRESTORE_H
55