-
Notifications
You must be signed in to change notification settings - Fork 95
/
FastbootData.cs
110 lines (96 loc) · 3.26 KB
/
FastbootData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
namespace FastbootEnhance
{
class FastbootData
{
List<List<string>> raw_data;
public Dictionary<string, long> partition_size;
public Dictionary<string, bool?> partition_is_logical;
public string product;
public bool secure;
public string current_slot;
public bool fastbootd;
public long max_download_size;
public string snapshot_update_status;
public FastbootData(string real_raw_data)
{
raw_data = new List<List<string>>();
partition_size = new Dictionary<string, long>();
partition_is_logical = new Dictionary<string, bool?>();
product = null;
secure = false;
current_slot = null;
fastbootd = false;
max_download_size = -1;
snapshot_update_status = null;
foreach (string line in real_raw_data.Split(new char[] { '\n' },
StringSplitOptions.RemoveEmptyEntries))
{
List<string> tmp = new List<string>(line.Split(new char[] { ' ', ':', '\n', '\r', '\t' },
StringSplitOptions.RemoveEmptyEntries));
if (tmp[0].Contains("bootloader"))
raw_data.Add(tmp);
}
foreach (List<string> line in raw_data)
{
if (line[1] == "partition-size")
{
string raw_size = line[3];
raw_size = raw_size.Replace("0x", "");
try
{
partition_size.Add(line[2], Convert.ToInt64(raw_size, 16));
}
catch (Exception)
{
partition_size[line[2]] = -1;
}
continue;
}
if (line[1] == "is-logical")
{
try
{
partition_is_logical.Add(line[2], line[3] == "yes");
}
catch (Exception)
{
partition_is_logical[line[2]] = null;
}
continue;
}
if (line[1] == "product")
{
product = line[2];
continue;
}
if (line[1] == "secure")
{
secure = line[2] == "yes";
continue;
}
if (line[1] == "current-slot")
{
current_slot = line[2];
continue;
}
if (line[1] == "is-userspace")
{
fastbootd = line[2] == "yes";
continue;
}
if (line[1] == "max-download-size")
{
max_download_size = Convert.ToInt64(line[2], 16);
continue;
}
if (line[1] == "snapshot-update-status")
{
snapshot_update_status = line[2];
continue;
}
}
}
}
}