1 // This file is a dummy section_list.cpp used for test only. 2 #include "section_list.h" 3 4 #include "frameworks/base/cmds/incidentd/tests/test_proto.pb.h" 5 6 7 namespace android { 8 namespace os { 9 namespace incidentd { 10 11 class TestSection: public Section { 12 public: 13 TestSection(int id); 14 ~TestSection(); 15 virtual status_t Execute(ReportWriter* writer) const; 16 }; 17 18 TestSection::TestSection(int id) 19 :Section(id, 5000 /* ms timeout */) { 20 } 21 22 TestSection::~TestSection() { 23 } 24 25 status_t TestSection::Execute(ReportWriter* writer) const { 26 uint8_t buf[1024]; 27 status_t err; 28 29 TestSectionProto proto; 30 proto.set_field_1(this->id); 31 proto.set_field_2(this->id * 10); 32 33 // Not infinitely scalable, but we know that our TestSectionProto will always 34 // fit in this many bytes. 35 if (!proto.SerializeToArray(buf, sizeof(buf))) { 36 return -1; 37 } 38 FdBuffer buffer; 39 err = buffer.write(buf, proto.ByteSize()); 40 if (err != NO_ERROR) { 41 return err; 42 } 43 44 return writer->writeSection(buffer); 45 } 46 47 TestSection section1(1); 48 TestSection section2(2); 49 50 const Section* SECTION_LIST[] = { 51 §ion1, 52 §ion2, 53 NULL 54 }; 55 56 Privacy sub_field_1{1, 1, NULL, PRIVACY_POLICY_LOCAL, NULL}; 57 Privacy sub_field_2{2, 9, NULL, PRIVACY_POLICY_AUTOMATIC, NULL}; 58 59 Privacy* list[] = {&sub_field_1, &sub_field_2, NULL}; 60 61 Privacy field_0{0, 11, list, PRIVACY_POLICY_EXPLICIT, NULL}; 62 Privacy field_1{1, 9, NULL, PRIVACY_POLICY_AUTOMATIC, NULL}; 63 64 Privacy* final_list[] = {&field_0, &field_1}; 65 66 const Privacy** PRIVACY_POLICY_LIST = const_cast<const Privacy**>(final_list); 67 68 const int PRIVACY_POLICY_COUNT = 2; 69 70 } // namespace incidentd 71 } // namespace os 72 } // namespace android 73