diff options
author | Jin Qian | 2017-03-15 21:03:06 -0500 |
---|---|---|
committer | Jin Qian | 2017-03-16 18:12:55 -0500 |
commit | 4fc338e60bf1d85212f1540d109beb1b248c4830 (patch) | |
tree | 0c2911d0119f8dcec09a81cda517895b319a4030 /storaged/include/storaged_info.h | |
parent | bb82a5a53c437a778ae4a090f7bca7f76f86bc0c (diff) | |
download | platform-system-core-4fc338e60bf1d85212f1540d109beb1b248c4830.tar.gz platform-system-core-4fc338e60bf1d85212f1540d109beb1b248c4830.tar.xz platform-system-core-4fc338e60bf1d85212f1540d109beb1b248c4830.zip |
storaged: rewrite emmc info class
Test: adb logcat -d -b events | grep storaged_emmc_info
Bug: 36228467
Change-Id: Ib799e60ed65661a9fb99be8ad4c930f547339975
Diffstat (limited to 'storaged/include/storaged_info.h')
-rw-r--r-- | storaged/include/storaged_info.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/storaged/include/storaged_info.h b/storaged/include/storaged_info.h new file mode 100644 index 000000000..cb5b8a8e2 --- /dev/null +++ b/storaged/include/storaged_info.h | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 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 _STORAGED_INFO_H_ | ||
18 | #define _STORAGED_INFO_H_ | ||
19 | |||
20 | #include <string.h> | ||
21 | |||
22 | #define FRIEND_TEST(test_case_name, test_name) \ | ||
23 | friend class test_case_name##_##test_name##_Test | ||
24 | |||
25 | using namespace std; | ||
26 | |||
27 | // two characters in string for each byte | ||
28 | struct str_hex { | ||
29 | char str[2]; | ||
30 | }; | ||
31 | |||
32 | class storage_info_t { | ||
33 | protected: | ||
34 | FRIEND_TEST(storaged_test, storage_info_t); | ||
35 | uint8_t eol; // pre-eol (end of life) information | ||
36 | uint8_t lifetime_a; // device life time estimation (type A) | ||
37 | uint8_t lifetime_b; // device life time estimation (type B) | ||
38 | string version; // version string | ||
39 | public: | ||
40 | void publish(); | ||
41 | virtual ~storage_info_t() {} | ||
42 | virtual bool init() = 0; | ||
43 | virtual bool update() = 0; | ||
44 | }; | ||
45 | |||
46 | class emmc_info_t : public storage_info_t { | ||
47 | private: | ||
48 | // minimum size of a ext_csd file | ||
49 | const int EXT_CSD_FILE_MIN_SIZE = 1024; | ||
50 | // List of interesting offsets | ||
51 | const size_t EXT_CSD_REV_IDX = 192 * sizeof(str_hex); | ||
52 | const size_t EXT_PRE_EOL_INFO_IDX = 267 * sizeof(str_hex); | ||
53 | const size_t EXT_DEVICE_LIFE_TIME_EST_A_IDX = 268 * sizeof(str_hex); | ||
54 | const size_t EXT_DEVICE_LIFE_TIME_EST_B_IDX = 269 * sizeof(str_hex); | ||
55 | |||
56 | const char* ext_csd_file = "/d/mmc0/mmc0:0001/ext_csd"; | ||
57 | const char* emmc_ver_str[8] = { | ||
58 | "4.0", "4.1", "4.2", "4.3", "Obsolete", "4.41", "4.5", "5.0" | ||
59 | }; | ||
60 | public: | ||
61 | virtual ~emmc_info_t() {} | ||
62 | bool init(); | ||
63 | bool update(); | ||
64 | }; | ||
65 | |||
66 | #endif /* _STORAGED_INFO_H_ */ | ||