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 class storage_info_t { 28 protected: 29 FRIEND_TEST(storaged_test, storage_info_t); 30 // emmc lifetime 31 uint16_t eol; // pre-eol (end of life) information 32 uint16_t lifetime_a; // device life time estimation (type A) 33 uint16_t lifetime_b; // device life time estimation (type B) 34 string version; // version string 35 // free space 36 const string userdata_path = "/data"; 37 uint64_t userdata_total_kb; 38 uint64_t userdata_free_kb; 39 40 storage_info_t() : eol(0), lifetime_a(0), lifetime_b(0), 41 userdata_total_kb(0), userdata_free_kb(0) {} 42 void publish(); 43 storage_info_t* s_info; 44 public: 45 static storage_info_t* get_storage_info(); 46 virtual ~storage_info_t() {} 47 virtual void report() {}; 48 void refresh(); 49 }; 50 51 class emmc_info_t : public storage_info_t { 52 private: 53 bool report_sysfs(); 54 bool report_debugfs(); 55 public: 56 static const string emmc_sysfs; 57 static const string emmc_debugfs; 58 static const char* emmc_ver_str[]; 59 60 virtual ~emmc_info_t() {} 61 virtual void report(); 62 }; 63 64 class ufs_info_t : public storage_info_t { 65 public: 66 static const string health_file; 67 68 virtual ~ufs_info_t() {} 69 virtual void report(); 70 }; 71 72 #endif /* _STORAGED_INFO_H_ */ 73