Skip to content

Commit 6efb920

Browse files
committed
Advancedflash: add Delete COW & Erase Data
Add UI and logic to Advancedflash to optionally delete COW partitions and erase userdata/metadata. Introduces two new localized strings (Advancedflash_DeleteCow, Advancedflash_Waiting) in Resources.resx and Resources.zh-CN.resx and corresponding properties in Resources.Designer.cs. Updated AdvancedflashView.axaml to add DelCow and ErasData checkboxes, adjust layout/heights and set BusyText to the new waiting string. AdvancedflashView.axaml.cs now calls fastboot to delete -cow logical partitions when DelCow is checked and erases metadata/userdata when ErasData is checked, including logging and basic error handling.
1 parent 3228689 commit 6efb920

5 files changed

Lines changed: 100 additions & 4 deletions

File tree

UotanToolbox/Assets/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UotanToolbox/Assets/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,4 +1793,10 @@ If you don't understand the above, please ignore it. The selection command only
17931793
<data name="Advancedflash_Meow" xml:space="preserve">
17941794
<value>↓↓↓The log is below, meow~↓↓↓</value>
17951795
</data>
1796+
<data name="Advancedflash_DeleteCow" xml:space="preserve">
1797+
<value>Deletc COW</value>
1798+
</data>
1799+
<data name="Advancedflash_Waiting" xml:space="preserve">
1800+
<value>During the process, unpacking may take a long time, please be patient.</value>
1801+
</data>
17961802
</root>

UotanToolbox/Assets/Resources.zh-CN.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,4 +1793,10 @@ ADB下填写序号,一次一个!</value>
17931793
<data name="Advancedflash_Meow" xml:space="preserve">
17941794
<value>↓↓↓日志在下方喵~↓↓↓</value>
17951795
</data>
1796+
<data name="Advancedflash_DeleteCow" xml:space="preserve">
1797+
<value>删除COW分区</value>
1798+
</data>
1799+
<data name="Advancedflash_Waiting" xml:space="preserve">
1800+
<value>执行中,解包可能时间较长请耐心等待</value>
1801+
</data>
17961802
</root>

UotanToolbox/Features/Advancedflash/AdvancedflashView.axaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<ToggleSwitch Name="ShowAllPart" />
6363
</StackPanel>
6464
<suki:BusyArea Name="BusyFlash"
65-
BusyText="{x:Static assets:Resources.Common_Executing}">
65+
BusyText="{x:Static assets:Resources.Advancedflash_Waiting}">
6666
<DataGrid Name="ImgList"
6767
ItemsSource="{Binding FalshPartModel}"
6868
Width="625"
@@ -100,7 +100,7 @@
100100
</StackPanel>
101101
<StackPanel>
102102
<StackPanel Orientation="Vertical">
103-
<suki:GlassCard Classes="Card" Margin="15 10 0 10" Width="265" Height="285">
103+
<suki:GlassCard Classes="Card" Margin="15 10 0 10" Width="265" Height="310">
104104
<StackPanel Orientation="Vertical">
105105
<TextBlock HorizontalAlignment="Left"
106106
VerticalAlignment="Top"
@@ -152,6 +152,22 @@
152152
Text="{x:Static assets:Resources.Wiredflash_DisVbmeta}" />
153153
</StackPanel>
154154
</StackPanel>
155+
<StackPanel Orientation="Horizontal" Margin="0 5 0 0">
156+
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Spacing="5">
157+
<CheckBox Name="DelCow" IsChecked="False"/>
158+
<TextBlock VerticalAlignment="Center"
159+
FontSize="14"
160+
Width="90"
161+
Text="{x:Static assets:Resources.Advancedflash_DeleteCow}" />
162+
</StackPanel>
163+
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Spacing="5">
164+
<CheckBox Name="ErasData" IsChecked="False"/>
165+
<TextBlock VerticalAlignment="Center"
166+
FontSize="14"
167+
Width="90"
168+
Text="{x:Static assets:Resources.Wiredflash_ClearAllData}" />
169+
</StackPanel>
170+
</StackPanel>
155171
</StackPanel>
156172
</suki:GlassCard>
157173
<suki:GlassCard Classes="Card" Margin="15 10 0 10" Width="265" Height="161.5">
@@ -178,7 +194,7 @@
178194
</StackPanel>
179195
</StackPanel>
180196
</suki:GlassCard>
181-
<suki:GlassCard Classes="Card" Margin="15 10 0 10" Width="265" Height="157">
197+
<suki:GlassCard Classes="Card" Margin="15 10 0 10" Width="265" Height="132">
182198
<!--<StackPanel Orientation="Vertical">
183199
<TextBlock HorizontalAlignment="Left"
184200
VerticalAlignment="Top"
@@ -198,7 +214,7 @@
198214
</StackPanel>-->
199215
<StackPanel Orientation="Vertical">
200216
<TextBlock HorizontalAlignment="Center"
201-
Margin="0 45 0 0"
217+
Margin="0 35 0 0"
202218
FontWeight="DemiBold"
203219
Text="{x:Static assets:Resources.Advancedflash_Meow}" />
204220
</StackPanel>

UotanToolbox/Features/Advancedflash/AdvancedflashView.axaml.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,26 @@ private async void FlashSelect(object sender, RoutedEventArgs args)
11951195
{
11961196
_parsedFileType = ParsedFileType.Script;
11971197
AdvancedflashLog.Text += $"\nSkip script type: {Path.GetFileName(path)}";
1198+
if (DelCow.IsChecked == true)
1199+
{
1200+
string cow = await CallExternalProgram.Fastboot($"-s {Global.thisdevice} getvar all");
1201+
string[] cowparts = FeaturesHelper.GetVPartList(cow);
1202+
for (int i = 0; i < cowparts.Length; i++)
1203+
{
1204+
if (cowparts[i].Contains("-cow"))
1205+
{
1206+
await Fastboot($"-s {Global.thisdevice} delete-logical-partition {cowparts[i]}");
1207+
}
1208+
FileHelper.Write(fastboot_log_path, output);
1209+
if (output.Contains("FAILED") || output.Contains("error"))
1210+
{
1211+
Global.MainDialogManager.CreateDialog().WithTitle(GetTranslation("Common_Error")).OfType(NotificationType.Error).WithContent(GetTranslation("Wiredflash_FlashError")).Dismiss().ByClickingBackground().TryShow();
1212+
SetEnabled(false);
1213+
Global.checkdevice = true;
1214+
return;
1215+
}
1216+
}
1217+
}
11981218
//检测后的脚本逻辑写这里
11991219
foreach (var item in vm.FalshPartModel)
12001220
{
@@ -1290,6 +1310,11 @@ private async void FlashSelect(object sender, RoutedEventArgs args)
12901310
}
12911311
}
12921312
}
1313+
if (ErasData.IsChecked == true)
1314+
{
1315+
await Fastboot($"-s {Global.thisdevice} erase metadata");
1316+
await Fastboot($"-s {Global.thisdevice} erase userdata");
1317+
}
12931318
Global.MainDialogManager.CreateDialog()
12941319
.WithTitle(GetTranslation("Common_Succ"))
12951320
.WithContent(GetTranslation("Wiredflash_ROMFlash"))
@@ -1366,6 +1391,26 @@ private async void FlashSelect(object sender, RoutedEventArgs args)
13661391
Global.checkdevice = false;
13671392
AdvancedflashLog.Text = "";
13681393
output = "";
1394+
if (DelCow.IsChecked == true)
1395+
{
1396+
string cow = await CallExternalProgram.Fastboot($"-s {Global.thisdevice} getvar all");
1397+
string[] cowparts = FeaturesHelper.GetVPartList(cow);
1398+
for (int i = 0; i < cowparts.Length; i++)
1399+
{
1400+
if (cowparts[i].Contains("-cow"))
1401+
{
1402+
await Fastboot($"-s {Global.thisdevice} delete-logical-partition {cowparts[i]}");
1403+
}
1404+
FileHelper.Write(fastboot_log_path, output);
1405+
if (output.Contains("FAILED") || output.Contains("error"))
1406+
{
1407+
Global.MainDialogManager.CreateDialog().WithTitle(GetTranslation("Common_Error")).OfType(NotificationType.Error).WithContent(GetTranslation("Wiredflash_FlashError")).Dismiss().ByClickingBackground().TryShow();
1408+
SetEnabled(false);
1409+
Global.checkdevice = true;
1410+
return;
1411+
}
1412+
}
1413+
}
13691414
foreach (var item in vm.FalshPartModel)
13701415
{
13711416
if (item.Select == true)
@@ -1409,6 +1454,11 @@ private async void FlashSelect(object sender, RoutedEventArgs args)
14091454
}
14101455
}
14111456
}
1457+
if (ErasData.IsChecked == true)
1458+
{
1459+
await Fastboot($"-s {Global.thisdevice} erase metadata");
1460+
await Fastboot($"-s {Global.thisdevice} erase userdata");
1461+
}
14121462
Global.checkdevice = true;
14131463
Global.MainDialogManager.CreateDialog()
14141464
.WithTitle(GetTranslation("Common_Succ"))

0 commit comments

Comments
 (0)