Enable downloading ENOSW via Download Page

This commit is contained in:
Gustave Monce
2024-08-31 19:45:24 +02:00
parent 7d8aad0e88
commit c269cfe839
5 changed files with 299 additions and 94 deletions
+39 -40
View File
@@ -158,7 +158,7 @@ namespace WPinternals
return FfuUrl; return FfuUrl;
} }
internal static string SearchENOSW(string ProductType, string PhoneFirmwareRevision) internal static (string SecureWIMUrl, string DPLUrl) SearchENOSW(string ProductType, string PhoneFirmwareRevision)
{ {
if (ProductType?.Length == 0) if (ProductType?.Length == 0)
{ {
@@ -182,6 +182,7 @@ namespace WPinternals
packageClass = "Public", packageClass = "Public",
manufacturerHardwareModel = ProductType manufacturerHardwareModel = ProductType
}; };
DiscoveryParameters DiscoveryParams = new() DiscoveryParameters DiscoveryParams = new()
{ {
query = DiscoveryQueryParams query = DiscoveryQueryParams
@@ -212,16 +213,15 @@ namespace WPinternals
} }
SoftwarePackage Package = null; SoftwarePackage Package = null;
using (MemoryStream JsonResultStream = new(Encoding.UTF8.GetBytes(JsonResultString))) using MemoryStream JsonResultStream = new(Encoding.UTF8.GetBytes(JsonResultString));
DataContractJsonSerializer SoftwarePackagesJsonSerializer = new(typeof(SoftwarePackages));
SoftwarePackages SoftwarePackages = (SoftwarePackages)SoftwarePackagesJsonSerializer.ReadObject(JsonResultStream);
if (SoftwarePackages != null)
{ {
DataContractJsonSerializer SoftwarePackagesJsonSerializer = new(typeof(SoftwarePackages)); foreach (SoftwarePackage pkg in SoftwarePackages.softwarePackages)
SoftwarePackages SoftwarePackages = (SoftwarePackages)SoftwarePackagesJsonSerializer.ReadObject(JsonResultStream);
if (SoftwarePackages != null)
{ {
foreach (SoftwarePackage pkg in SoftwarePackages.softwarePackages) Package = SoftwarePackages.softwarePackages.FirstOrDefault();
{
Package = SoftwarePackages.softwarePackages.FirstOrDefault();
}
} }
} }
@@ -230,41 +230,40 @@ namespace WPinternals
throw new WPinternalsException("ENOSW package not found", "No ENOSW package has been found in the remote software repository for the requested model."); throw new WPinternalsException("ENOSW package not found", "No ENOSW package has been found in the remote software repository for the requested model.");
} }
SoftwareFile FileInfo = Package.files.First(f => f.fileName.EndsWith(".secwim", StringComparison.OrdinalIgnoreCase)); SoftwareFile SecureWimSoftwareFile = Package.files.First(f => f.fileName.EndsWith(".secwim", StringComparison.OrdinalIgnoreCase));
SoftwareFile DPLSoftwareFile = Package.files.First(f => f.fileName.EndsWith(".dpl", StringComparison.OrdinalIgnoreCase));
SoftwareFile DPLF = Package.files.First(f => f.fileName.EndsWith(".dpl", StringComparison.OrdinalIgnoreCase)); Uri DPLFileUrlUri = new($"https://api.swrepository.com/rest-api/discovery/fileurl/1/{Package.id}/{DPLSoftwareFile.fileName}");
Uri DPLUri = new("https://api.swrepository.com/rest-api/discovery/fileurl/1/" + Package.id + "/" + DPLF.fileName);
Task<string> GetDPLTask = HttpClient.GetStringAsync(DPLUri); Task<string> GetDPLTask = HttpClient.GetStringAsync(DPLFileUrlUri);
GetDPLTask.Wait(); GetDPLTask.Wait();
string DPLString = GetDPLTask.Result;
string DPLUrl = ""; string DPLFileUrlResultContent = GetDPLTask.Result;
FileUrlResult FileUrlDPL = null; FileUrlResult DPLFileUrlResult = null;
using (MemoryStream JsonStream3 = new(Encoding.UTF8.GetBytes(DPLString))) using MemoryStream DPLFileUrlResultStream = new(Encoding.UTF8.GetBytes(DPLFileUrlResultContent));
DataContractJsonSerializer DPLFileUrlResultSerializer = new(typeof(FileUrlResult));
DPLFileUrlResult = (FileUrlResult)DPLFileUrlResultSerializer.ReadObject(DPLFileUrlResultStream);
string DPLFileUrl = "";
if (DPLFileUrlResult != null)
{ {
DataContractJsonSerializer Serializer3 = new(typeof(FileUrlResult)); DPLFileUrl = DPLFileUrlResult.url.Replace("sr.azureedge.net", "softwarerepo.blob.core.windows.net");
FileUrlDPL = (FileUrlResult)Serializer3.ReadObject(JsonStream3);
if (FileUrlDPL != null)
{
DPLUrl = FileUrlDPL.url.Replace("sr.azureedge.net", "softwarerepo.blob.core.windows.net");
}
} }
if (DPLUrl?.Length == 0) if (DPLFileUrl?.Length == 0)
{ {
throw new WPinternalsException("DPL not found", "No DPL has been found in the remote software repository for the requested model."); throw new WPinternalsException("DPL not found", "No DPL has been found in the remote software repository for the requested model.");
} }
Task<string> GetDPLStrTask = HttpClient.GetStringAsync(DPLUrl); Task<string> GetDPLStrTask = HttpClient.GetStringAsync(DPLFileUrl);
GetDPLStrTask.Wait(); GetDPLStrTask.Wait();
string DPLStrString = GetDPLStrTask.Result; string DPLStrString = GetDPLStrTask.Result;
DPL.Package dpl; DPL.Package dpl;
XmlSerializer serializer = new(typeof(DPL.Package)); XmlSerializer serializer = new(typeof(DPL.Package));
using (StringReader reader = new(DPLStrString.Replace("ft:", "").Replace("dpl:", "").Replace("typedes:", ""))) using StringReader reader = new(DPLStrString.Replace("ft:", "").Replace("dpl:", "").Replace("typedes:", ""));
{ dpl = (DPL.Package)serializer.Deserialize(reader);
dpl = (DPL.Package)serializer.Deserialize(reader);
}
foreach (DPL.File file in dpl.Content.Files.File) foreach (DPL.File file in dpl.Content.Files.File)
{ {
@@ -274,30 +273,30 @@ namespace WPinternals
if (IsFirmwareBetween(PhoneFirmwareRevision, range.From, range.To)) if (IsFirmwareBetween(PhoneFirmwareRevision, range.From, range.To))
{ {
FileInfo = Package.files.First(f => f.fileName.EndsWith(name, StringComparison.OrdinalIgnoreCase)); SecureWimSoftwareFile = Package.files.First(f => f.fileName.EndsWith(name, StringComparison.OrdinalIgnoreCase));
} }
} }
Uri FileInfoUri = new("https://api.swrepository.com/rest-api/discovery/fileurl/1/" + Package.id + "/" + FileInfo.fileName); Uri FileInfoUri = new("https://api.swrepository.com/rest-api/discovery/fileurl/1/" + Package.id + "/" + SecureWimSoftwareFile.fileName);
Task<string> GetFileInfoTask = HttpClient.GetStringAsync(FileInfoUri); Task<string> GetFileInfoTask = HttpClient.GetStringAsync(FileInfoUri);
GetFileInfoTask.Wait(); GetFileInfoTask.Wait();
string FileInfoString = GetFileInfoTask.Result; string FileInfoString = GetFileInfoTask.Result;
string ENOSWUrl = ""; string ENOSWFileUrl = "";
FileUrlResult FileUrl = null; FileUrlResult FileUrl = null;
using (MemoryStream JsonStream3 = new(Encoding.UTF8.GetBytes(FileInfoString)))
using MemoryStream JsonStream4 = new(Encoding.UTF8.GetBytes(FileInfoString));
DataContractJsonSerializer Serializer4 = new(typeof(FileUrlResult));
FileUrl = (FileUrlResult)Serializer4.ReadObject(JsonStream4);
if (FileUrl != null)
{ {
DataContractJsonSerializer Serializer3 = new(typeof(FileUrlResult)); ENOSWFileUrl = FileUrl.url.Replace("sr.azureedge.net", "softwarerepo.blob.core.windows.net");
FileUrl = (FileUrlResult)Serializer3.ReadObject(JsonStream3);
if (FileUrl != null)
{
ENOSWUrl = FileUrl.url.Replace("sr.azureedge.net", "softwarerepo.blob.core.windows.net");
}
} }
HttpClient.Dispose(); HttpClient.Dispose();
return ENOSWUrl; return (ENOSWFileUrl, DPLFileUrl);
} }
private static bool IsFirmwareBetween(string PhoneFirmwareRevision, string Limit1, string Limit2) private static bool IsFirmwareBetween(string PhoneFirmwareRevision, string Limit1, string Limit2)
+152 -8
View File
@@ -73,15 +73,15 @@ namespace WPinternals
{ {
App.Config.AddFfuToRepository(FFUPath); App.Config.AddFfuToRepository(FFUPath);
App.Config.WriteConfig(); App.Config.WriteConfig();
LastStatusText = "File \"" + FFUFile + "\" was added to the repository."; LastStatusText = $"File \"{FFUFile}\" was added to the repository.";
} }
catch (WPinternalsException Ex) catch (WPinternalsException Ex)
{ {
LastStatusText = "Error: " + Ex.Message + ". File \"" + FFUFile + "\" was not added."; LastStatusText = $"Error: {Ex.Message}. File \"{FFUFile}\" was not added.";
} }
catch catch
{ {
LastStatusText = "Error: File \"" + FFUFile + "\" was not added."; LastStatusText = $"Error: File \"{FFUFile}\" was not added.";
} }
} }
else else
@@ -174,6 +174,8 @@ namespace WPinternals
{ {
string FFUURL = null; string FFUURL = null;
string[] EmergencyURLs = null; string[] EmergencyURLs = null;
string SecureWIMURL = null;
try try
{ {
string TempProductType = ProductType.ToUpper(); string TempProductType = ProductType.ToUpper();
@@ -183,7 +185,17 @@ namespace WPinternals
} }
ProductType = TempProductType; ProductType = TempProductType;
FFUURL = LumiaDownloadModel.SearchFFU(ProductType, ProductCode, OperatorCode, out TempProductType);
try
{
FFUURL = LumiaDownloadModel.SearchFFU(ProductType, ProductCode, OperatorCode, out TempProductType);
}
catch (WPinternalsException ex)
{
LogFile.LogException(ex, LogType.FileOnly);
FFUURL = LumiaDownloadModel.SearchFFU(ProductType, null, OperatorCode, out TempProductType);
}
if (TempProductType != null) if (TempProductType != null)
{ {
ProductType = TempProductType; ProductType = TempProductType;
@@ -193,6 +205,11 @@ namespace WPinternals
{ {
EmergencyURLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType); EmergencyURLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
} }
if (ProductType != null && FirmwareVersion != null)
{
(SecureWIMURL, string _) = LumiaDownloadModel.SearchENOSW(ProductType, FirmwareVersion);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -208,7 +225,12 @@ namespace WPinternals
if (EmergencyURLs != null) if (EmergencyURLs != null)
{ {
SearchResultList.Add(new SearchResult(ProductType + " emergency-files", EmergencyURLs, ProductType, EmergencyDownloaded, ProductType)); SearchResultList.Add(new SearchResult($"{ProductType} emergency-files", EmergencyURLs, ProductType, EmergencyDownloaded, ProductType));
}
if (SecureWIMURL != null)
{
SearchResultList.Add(new SearchResult($"{ProductType} ENOSW-files", SecureWIMURL, ProductType, ENOSWDownloaded, FirmwareVersion));
} }
}, null); }, null);
@@ -239,6 +261,7 @@ namespace WPinternals
{ {
string FFUURL = null; string FFUURL = null;
string[] EmergencyURLs = null; string[] EmergencyURLs = null;
string SecureWIMURL = null;
try try
{ {
string TempProductType = ProductType.ToUpper(); string TempProductType = ProductType.ToUpper();
@@ -258,6 +281,11 @@ namespace WPinternals
{ {
EmergencyURLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType); EmergencyURLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
} }
if (ProductType != null && FirmwareVersion != null)
{
(SecureWIMURL, string _) = LumiaDownloadModel.SearchENOSW(ProductType, FirmwareVersion);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -275,6 +303,11 @@ namespace WPinternals
{ {
Download(EmergencyURLs, ProductType, EmergencyDownloaded, ProductType); Download(EmergencyURLs, ProductType, EmergencyDownloaded, ProductType);
} }
if (SecureWIMURL != null)
{
Download(SecureWIMURL, ProductType, ENOSWDownloaded, FirmwareVersion);
}
}, null); }, null);
}).Start(); }).Start();
} }
@@ -328,6 +361,12 @@ namespace WPinternals
App.Config.AddEmergencyToRepository(Type, ProgrammerPath, PayloadPath); App.Config.AddEmergencyToRepository(Type, ProgrammerPath, PayloadPath);
} }
} }
private void ENOSWDownloaded(string[] Files, object State)
{
App.Config.AddSecWimToRepository(Files[0], (string)State);
}
public ObservableCollection<DownloadEntry> DownloadList { get; } = new(); public ObservableCollection<DownloadEntry> DownloadList { get; } = new();
public ObservableCollection<SearchResult> SearchResultList { get; } = new(); public ObservableCollection<SearchResult> SearchResultList { get; } = new();
@@ -442,6 +481,24 @@ namespace WPinternals
} }
} }
private string _FirmwareVersion = null;
public string FirmwareVersion
{
get
{
return _FirmwareVersion;
}
set
{
if (_FirmwareVersion != value)
{
_FirmwareVersion = value;
OnPropertyChanged(nameof(FirmwareVersion));
}
}
}
private string _OperatorCode = null; private string _OperatorCode = null;
public string OperatorCode public string OperatorCode
{ {
@@ -460,8 +517,13 @@ namespace WPinternals
} }
} }
internal override void EvaluateViewState() internal override async void EvaluateViewState()
{ {
if (IsSwitchingInterface)
{
return;
}
if (!IsActive) if (!IsActive)
{ {
return; return;
@@ -469,11 +531,81 @@ namespace WPinternals
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Flash) if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Flash)
{ {
LumiaFlashAppModel LumiaFlashModel = (LumiaFlashAppModel)Notifier.CurrentModel; PhoneInfo FlashAppInfo = ((LumiaFlashAppModel)Notifier.CurrentModel).ReadPhoneInfo(ExtendedInfo: true);
PhoneInfo Info = LumiaFlashModel.ReadPhoneInfo(); FirmwareVersion = FlashAppInfo.Firmware;
IsSwitchingInterface = true;
(Notifier.CurrentModel as LumiaFlashAppModel).SwitchToPhoneInfoAppContext();
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
{
await Notifier.WaitForArrival();
}
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
{
throw new WPinternalsException("Unexpected Mode");
}
LumiaPhoneInfoAppModel LumiaPhoneInfoModel = (LumiaPhoneInfoAppModel)Notifier.CurrentModel;
PhoneInfo Info = LumiaPhoneInfoModel.ReadPhoneInfo();
ProductType = Info.Type; ProductType = Info.Type;
OperatorCode = ""; OperatorCode = "";
ProductCode = Info.ProductCode; ProductCode = Info.ProductCode;
((LumiaPhoneInfoAppModel)Notifier.CurrentModel).SwitchToFlashAppContext();
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
{
await Notifier.WaitForArrival();
}
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
{
throw new WPinternalsException("Unexpected Mode");
}
IsSwitchingInterface = false;
}
else if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_PhoneInfo)
{
LumiaPhoneInfoAppModel LumiaPhoneInfoModel = (LumiaPhoneInfoAppModel)Notifier.CurrentModel;
PhoneInfo Info = LumiaPhoneInfoModel.ReadPhoneInfo();
ProductType = Info.Type;
OperatorCode = "";
ProductCode = Info.ProductCode;
IsSwitchingInterface = true;
((LumiaPhoneInfoAppModel)Notifier.CurrentModel).SwitchToFlashAppContext();
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
{
await Notifier.WaitForArrival();
}
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
{
throw new WPinternalsException("Unexpected Mode");
}
PhoneInfo FlashAppInfo = ((LumiaFlashAppModel)Notifier.CurrentModel).ReadPhoneInfo(ExtendedInfo: true);
FirmwareVersion = FlashAppInfo.Firmware;
(Notifier.CurrentModel as LumiaFlashAppModel).SwitchToPhoneInfoAppContext();
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
{
await Notifier.WaitForArrival();
}
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
{
throw new WPinternalsException("Unexpected Mode");
}
IsSwitchingInterface = false;
} }
else if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Normal) else if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Normal)
{ {
@@ -724,6 +856,18 @@ namespace WPinternals
GetSize(); GetSize();
} }
internal SearchResult(string Name, string URL, string Category, Action<string[], object> Callback, object State)
{
UIContext = SynchronizationContext.Current;
URLs = new string[1];
URLs[0] = URL;
this.Name = Name;
this.Callback = Callback;
this.State = State;
this.Category = Category;
GetSize();
}
private void GetSize() private void GetSize()
{ {
new Thread(() => new Thread(() =>
+47 -45
View File
@@ -751,18 +751,39 @@ namespace WPinternals
{ {
ModeSwitchProgressWrapper(ProgressText, null); ModeSwitchProgressWrapper(ProgressText, null);
string TempFolder = Environment.GetEnvironmentVariable("TEMP") + @"\WPInternals"; string TempFolder = $@"{Environment.GetEnvironmentVariable("TEMP")}\WPInternals";
if (PhoneInfoAppInfo.Type == "RM-1152") if (PhoneInfoAppInfo.Type == "RM-1152")
{ {
PhoneInfoAppInfo.Type = "RM-1151"; PhoneInfoAppInfo.Type = "RM-1151";
} }
string ENOSWPackage = LumiaDownloadModel.SearchENOSW(PhoneInfoAppInfo.Type, Info.Firmware); (string ENOSWFileUrl, string DPLFileUrl) = LumiaDownloadModel.SearchENOSW(PhoneInfoAppInfo.Type, Info.Firmware);
SetWorkingStatus($"Downloading {Info.Type} Test Mode package...", MaxProgressValue: 100); SetWorkingStatus($"Downloading {Info.Type} Test Mode package...", MaxProgressValue: 100);
DownloadEntry downloadEntry = new(ENOSWPackage, TempFolder, null, null, null); DownloadEntry downloadEntry = new(ENOSWFileUrl, TempFolder, null, (string[] Files, object State) =>
{
App.Config.AddSecWimToRepository(ENOSWFileUrl, Info.Firmware);
ModeSwitchProgressWrapper("Initializing Flash...", null);
string MMOSPath = $"{TempFolder}\\{DownloadsViewModel.GetFileNameFromURL(ENOSWFileUrl)}";
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
FileInfo info = new(MMOSPath);
uint length = uint.Parse(info.Length.ToString());
const int maximumbuffersize = 0x00240000;
uint totalcounts = (uint)Math.Truncate((decimal)length / maximumbuffersize);
SetWorkingStatus("Flashing Test Mode package...", MaxProgressValue: 100);
ProgressUpdater progressUpdater = new(totalcounts + 1, (int i, TimeSpan? time) => UpdateWorkingStatus(null, CurrentProgressValue: (ulong)i));
FlashModel.FlashMMOS(MMOSPath, progressUpdater);
SetWorkingStatus("And now booting phone to MMOS...", "If the phone stays on the lightning cog screen for a while, you may need to unplug and replug the phone to continue the boot process.");
}, null);
downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) =>
{ {
@@ -771,26 +792,6 @@ namespace WPinternals
int progress = (sender as DownloadEntry)?.Progress ?? 0; int progress = (sender as DownloadEntry)?.Progress ?? 0;
ulong.TryParse(progress.ToString(), out ulong progressret); ulong.TryParse(progress.ToString(), out ulong progressret);
UpdateWorkingStatus(null, CurrentProgressValue: progressret); UpdateWorkingStatus(null, CurrentProgressValue: progressret);
if (progress == 100)
{
ModeSwitchProgressWrapper("Initializing Flash...", null);
string MMOSPath = TempFolder + "\\" + (sender as DownloadEntry)?.Name;
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
FileInfo info = new(MMOSPath);
uint length = uint.Parse(info.Length.ToString());
const int maximumbuffersize = 0x00240000;
uint totalcounts = (uint)Math.Truncate((decimal)length / maximumbuffersize);
SetWorkingStatus("Flashing Test Mode package...", MaxProgressValue: 100);
ProgressUpdater progressUpdater = new(totalcounts + 1, (int i, TimeSpan? time) => UpdateWorkingStatus(null, CurrentProgressValue: (ulong)i));
FlashModel.FlashMMOS(MMOSPath, progressUpdater);
SetWorkingStatus("And now booting phone to MMOS...", "If the phone stays on the lightning cog screen for a while, you may need to unplug and replug the phone to continue the boot process.");
}
} }
}; };
} }
@@ -877,11 +878,32 @@ namespace WPinternals
PhoneInfoAppInfo.Type = "RM-1151"; PhoneInfoAppInfo.Type = "RM-1151";
} }
string ENOSWPackage = LumiaDownloadModel.SearchENOSW(PhoneInfoAppInfo.Type, Info.Firmware); (string ENOSWFileUrl, string DPLFileUrl) = LumiaDownloadModel.SearchENOSW(PhoneInfoAppInfo.Type, Info.Firmware);
SetWorkingStatus($"Downloading {PhoneInfoAppInfo.Type} Test Mode package...", MaxProgressValue: 100); SetWorkingStatus($"Downloading {PhoneInfoAppInfo.Type} Test Mode package...", MaxProgressValue: 100);
DownloadEntry downloadEntry = new(ENOSWPackage, TempFolder, null, null, null); DownloadEntry downloadEntry = new(ENOSWFileUrl, TempFolder, null, (string[] Files, object State) =>
{
App.Config.AddSecWimToRepository(ENOSWFileUrl, Info.Firmware);
ModeSwitchProgressWrapper("Initializing Flash...", null);
string MMOSPath = $"{TempFolder}\\{DownloadsViewModel.GetFileNameFromURL(ENOSWFileUrl)}";
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
FileInfo info = new(MMOSPath);
uint length = uint.Parse(info.Length.ToString());
const int maximumbuffersize = 0x00240000;
uint totalcounts = (uint)Math.Truncate((decimal)length / maximumbuffersize);
SetWorkingStatus("Flashing Test Mode package...", MaxProgressValue: 100);
ProgressUpdater progressUpdater = new(totalcounts + 1, (int i, TimeSpan? time) => UpdateWorkingStatus(null, CurrentProgressValue: (ulong)i));
FlashModel.FlashMMOS(MMOSPath, progressUpdater);
SetWorkingStatus("And now booting phone to MMOS...", "If the phone stays on the lightning cog screen for a while, you may need to unplug and replug the phone to continue the boot process.");
}, null);
downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) =>
{ {
@@ -890,26 +912,6 @@ namespace WPinternals
int progress = (sender as DownloadEntry)?.Progress ?? 0; int progress = (sender as DownloadEntry)?.Progress ?? 0;
ulong.TryParse(progress.ToString(), out ulong progressret); ulong.TryParse(progress.ToString(), out ulong progressret);
UpdateWorkingStatus(null, CurrentProgressValue: progressret); UpdateWorkingStatus(null, CurrentProgressValue: progressret);
if (progress == 100)
{
ModeSwitchProgressWrapper("Initializing Flash...", null);
string MMOSPath = TempFolder + "\\" + (sender as DownloadEntry)?.Name;
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
FileInfo info = new(MMOSPath);
uint length = uint.Parse(info.Length.ToString());
const int maximumbuffersize = 0x00240000;
uint totalcounts = (uint)Math.Truncate((decimal)length / maximumbuffersize);
SetWorkingStatus("Flashing Test Mode package...", MaxProgressValue: 100);
ProgressUpdater progressUpdater = new(totalcounts + 1, (int i, TimeSpan? time) => UpdateWorkingStatus(null, CurrentProgressValue: (ulong)i));
FlashModel.FlashMMOS(MMOSPath, progressUpdater);
SetWorkingStatus("And now booting phone to MMOS...", "If the phone stays on the lightning cog screen for a while, you may need to unplug and replug the phone to continue the boot process.");
}
} }
}; };
} }
+4 -1
View File
@@ -159,13 +159,16 @@ DEALINGS IN THE SOFTWARE.
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
<RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0">Producttype</TextBlock> <TextBlock Grid.Column="0" Grid.Row="0">Producttype</TextBlock>
<TextBlock Grid.Column="0" Grid.Row="1">Productcode</TextBlock> <TextBlock Grid.Column="0" Grid.Row="1">Productcode</TextBlock>
<TextBlock Grid.Column="0" Grid.Row="2">Operatorcode</TextBlock> <TextBlock Grid.Column="0" Grid.Row="2">Operatorcode</TextBlock>
<TextBlock Grid.Column="0" Grid.Row="3">Firmwareversion</TextBlock>
<TextBox Grid.Column="1" Grid.Row="0" Width="Auto" Margin="0,0,0,8" Text="{Binding ProductType, Mode=TwoWay}"/> <TextBox Grid.Column="1" Grid.Row="0" Width="Auto" Margin="0,0,0,8" Text="{Binding ProductType, Mode=TwoWay}"/>
<TextBox Grid.Column="1" Grid.Row="1" Width="Auto" Margin="0,0,0,8" Text="{Binding ProductCode, Mode=TwoWay}"/> <TextBox Grid.Column="1" Grid.Row="1" Width="Auto" Margin="0,0,0,8" Text="{Binding ProductCode, Mode=TwoWay}"/>
<TextBox Grid.Column="1" Grid.Row="2" Width="Auto" Text="{Binding OperatorCode, Mode=TwoWay}"/> <TextBox Grid.Column="1" Grid.Row="2" Width="Auto" Margin="0,0,0,8" Text="{Binding OperatorCode, Mode=TwoWay}"/>
<TextBox Grid.Column="1" Grid.Row="3" Width="Auto" Text="{Binding FirmwareVersion, Mode=TwoWay}"/>
</Grid> </Grid>
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal"> <StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal">
<Button Content="Search" Padding="0,5" Width="120" Margin="0,0,20,0" Command="{Binding Path=SearchCommand, Mode=OneWay}" IsDefault="True"/> <Button Content="Search" Padding="0,5" Width="120" Margin="0,0,20,0" Command="{Binding Path=SearchCommand, Mode=OneWay}" IsDefault="True"/>
+57
View File
@@ -220,6 +220,52 @@ namespace WPinternals
public List<FFUEntry> FFURepository = new(); public List<FFUEntry> FFURepository = new();
internal void AddSecWimToRepository(string SecWimPath, string FirmwareVersion)
{
SecWimEntry Entry = SecWimRepository.Find(e => (e.FirmwareVersion == FirmwareVersion) && string.Equals(e.Path, SecWimPath, StringComparison.CurrentCultureIgnoreCase));
if (Entry == null)
{
LogFile.Log("Adding Secure WIM to repository: " + SecWimPath, LogType.FileAndConsole);
if (FirmwareVersion != null)
{
LogFile.Log("Firmware version: " + FirmwareVersion, LogType.FileAndConsole);
}
Entry = new SecWimEntry
{
Path = SecWimPath,
FirmwareVersion = FirmwareVersion
};
SecWimRepository.Add(Entry);
WriteConfig();
}
else
{
LogFile.Log("Secure WIM not added, because it was already present in the repository.", LogType.FileAndConsole);
}
}
internal void RemoveSecWimFromRepository(string SecWimPath)
{
int Count = 0;
SecWimRepository.Where(e => string.Equals(e.Path, SecWimPath, StringComparison.CurrentCultureIgnoreCase)).ToList().ForEach(e =>
{
Count++;
SecWimRepository.Remove(e);
});
if (Count == 0)
{
LogFile.Log("Secure WIM was not removed from repository because it was not present.", LogType.FileAndConsole);
}
else
{
LogFile.Log("Removed Secure WIM from repository: " + SecWimPath, LogType.FileAndConsole);
WriteConfig();
}
}
public List<SecWimEntry> SecWimRepository = new();
public List<EmergencyFileEntry> EmergencyRepository = new(); public List<EmergencyFileEntry> EmergencyRepository = new();
internal void AddEmergencyToRepository(string Type, string ProgrammerPath, string PayloadPath) internal void AddEmergencyToRepository(string Type, string ProgrammerPath, string PayloadPath)
@@ -344,6 +390,17 @@ namespace WPinternals
} }
} }
public class SecWimEntry
{
public string FirmwareVersion;
public string Path;
internal bool Exists()
{
return File.Exists(Path);
}
}
public class EmergencyFileEntry public class EmergencyFileEntry
{ {
public string Type; public string Type;