mirror of
https://github.com/ReneLergner/WPinternals.git
synced 2026-06-17 04:40:12 +10:00
Code cleanup
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class AboutViewModel: ContextViewModel
|
||||
internal class AboutViewModel : ContextViewModel
|
||||
{
|
||||
internal AboutViewModel() : base() { }
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class BackupTargetSelectionViewModel: ContextViewModel
|
||||
internal class BackupTargetSelectionViewModel : ContextViewModel
|
||||
{
|
||||
private PhoneNotifierViewModel PhoneNotifier;
|
||||
private Action<string, string, string> BackupCallback;
|
||||
|
||||
@@ -26,7 +26,7 @@ using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class BackupViewModel: ContextViewModel
|
||||
internal class BackupViewModel : ContextViewModel
|
||||
{
|
||||
private PhoneNotifierViewModel PhoneNotifier;
|
||||
private Action Callback;
|
||||
@@ -413,7 +413,7 @@ namespace WPinternals
|
||||
{
|
||||
Partition = GPT.Partitions.Where(p => p.Name == "BACKUP_BS_NV").First();
|
||||
}
|
||||
|
||||
|
||||
TotalSizeSectors += Partition.SizeInSectors;
|
||||
PartitionCount++;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace WPinternals
|
||||
OnPropertyChanged("SubMessage");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int? _ProgressPercentage = null;
|
||||
public int? ProgressPercentage
|
||||
{
|
||||
@@ -148,7 +148,7 @@ namespace WPinternals
|
||||
{
|
||||
NewText = "Progress: " + ((int)ProgressPercentage).ToString() + "%";
|
||||
}
|
||||
if (TimeRemaining != null)
|
||||
if (TimeRemaining != null)
|
||||
{
|
||||
if (NewText == null)
|
||||
NewText = "";
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace WPinternals
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ContextViewModel _SubContextViewModel;
|
||||
public ContextViewModel SubContextViewModel
|
||||
{
|
||||
@@ -73,11 +73,11 @@ namespace WPinternals
|
||||
UIContext = SynchronizationContext.Current;
|
||||
}
|
||||
|
||||
internal ContextViewModel(MainViewModel Main): this()
|
||||
internal ContextViewModel(MainViewModel Main) : this()
|
||||
{
|
||||
}
|
||||
|
||||
internal ContextViewModel(MainViewModel Main, ContextViewModel SubContext): this(Main)
|
||||
internal ContextViewModel(MainViewModel Main, ContextViewModel SubContext) : this(Main)
|
||||
{
|
||||
SubContextViewModel = SubContext;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace WPinternals
|
||||
Action Accepted;
|
||||
|
||||
internal DisclaimerAndNdaViewModel(Action Accepted)
|
||||
: base()
|
||||
: base()
|
||||
{
|
||||
this.Accepted = Accepted;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace WPinternals
|
||||
Action Accepted;
|
||||
|
||||
internal DisclaimerViewModel(Action Accepted)
|
||||
: base()
|
||||
: base()
|
||||
{
|
||||
this.Accepted = Accepted;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ using System.Windows.Data;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class DownloadsViewModel: ContextViewModel
|
||||
internal class DownloadsViewModel : ContextViewModel
|
||||
{
|
||||
private PhoneNotifierViewModel Notifier;
|
||||
private Timer SpeedTimer;
|
||||
@@ -56,7 +56,7 @@ namespace WPinternals
|
||||
AddFFUCommand = new DelegateCommand(() =>
|
||||
{
|
||||
string FFUPath = null;
|
||||
|
||||
|
||||
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
|
||||
dlg.DefaultExt = ".ffu"; // Default file extension
|
||||
dlg.Filter = "ROM images (.ffu)|*.ffu"; // Filter files by extension
|
||||
@@ -82,7 +82,7 @@ namespace WPinternals
|
||||
{
|
||||
LastStatusText = "Error: File \"" + FFUFile + "\" was not added.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -496,7 +496,7 @@ namespace WPinternals
|
||||
Failed
|
||||
};
|
||||
|
||||
internal class DownloadEntry: INotifyPropertyChanged
|
||||
internal class DownloadEntry : INotifyPropertyChanged
|
||||
{
|
||||
private SynchronizationContext UIContext;
|
||||
public event PropertyChangedEventHandler PropertyChanged = delegate { };
|
||||
|
||||
@@ -23,7 +23,7 @@ using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class DumpRomTargetSelectionViewModel: ContextViewModel
|
||||
internal class DumpRomTargetSelectionViewModel : ContextViewModel
|
||||
{
|
||||
private Action<string, string, bool, string, bool, string, bool> DumpCallback;
|
||||
internal Action SwitchToUnlockBoot;
|
||||
|
||||
@@ -24,7 +24,7 @@ using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class DumpRomViewModel: ContextViewModel
|
||||
internal class DumpRomViewModel : ContextViewModel
|
||||
{
|
||||
private Action SwitchToUnlockBoot;
|
||||
private Action SwitchToUnlockRoot;
|
||||
@@ -56,7 +56,7 @@ namespace WPinternals
|
||||
ActivateSubContext(new BusyViewModel("Initializing ROM dump..."));
|
||||
|
||||
ulong TotalSizeSectors = 0;
|
||||
int PartitionCount = 0;
|
||||
int PartitionCount = 0;
|
||||
Partition Partition;
|
||||
FFU FFU = null;
|
||||
try
|
||||
|
||||
@@ -22,7 +22,7 @@ using System;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class GettingStartedViewModel: ContextViewModel
|
||||
internal class GettingStartedViewModel : ContextViewModel
|
||||
{
|
||||
internal Action ShowDisclaimer;
|
||||
internal Action SwitchToUnlockBoot;
|
||||
|
||||
@@ -23,7 +23,7 @@ using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class LumiaFlashRomSourceSelectionViewModel: ContextViewModel
|
||||
internal class LumiaFlashRomSourceSelectionViewModel : ContextViewModel
|
||||
{
|
||||
private PhoneNotifierViewModel PhoneNotifier;
|
||||
private Action<string, string, string> FlashPartitionsCallback;
|
||||
|
||||
@@ -28,7 +28,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class LumiaFlashRomViewModel: ContextViewModel
|
||||
internal class LumiaFlashRomViewModel : ContextViewModel
|
||||
{
|
||||
private PhoneNotifierViewModel PhoneNotifier;
|
||||
internal Action SwitchToUnlockBoot;
|
||||
@@ -178,7 +178,7 @@ namespace WPinternals
|
||||
else if ((MainOSNewSectorCount > 0) && (MainOSNewSectorCount > MainOSOldSectorCount))
|
||||
{
|
||||
LogFile.Log("Flash failed! Size of partition 'MainOS' is too big.");
|
||||
ExitFailure("Flash failed!", "Size of partition 'MainOS' is too big.");
|
||||
ExitFailure("Flash failed!", "Size of partition 'MainOS' is too big.");
|
||||
return;
|
||||
}
|
||||
else if ((DataNewSectorCount > 0) && (DataNewSectorCount > DataOldSectorCount))
|
||||
@@ -220,7 +220,7 @@ namespace WPinternals
|
||||
i++;
|
||||
Busy.Message = "Flashing partition MainOS (" + i.ToString() + @"/" + PartitionCount.ToString() + ")";
|
||||
Phone.FlashRawPartition(MainOSPath, "MainOS", Updater);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
@@ -249,7 +249,7 @@ namespace WPinternals
|
||||
|
||||
if (!Result)
|
||||
{
|
||||
ExitFailure("Flash failed!", null);
|
||||
ExitFailure("Flash failed!", null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ namespace WPinternals
|
||||
|
||||
TotalSizeSectors += StreamLengthInSectors;
|
||||
PartitionCount++;
|
||||
|
||||
|
||||
if (string.Compare(PartitionName, "MainOS", true) == 0)
|
||||
{
|
||||
MainOSOldSectorCount = Partition.SizeInSectors;
|
||||
@@ -467,7 +467,7 @@ namespace WPinternals
|
||||
ExitSuccess("Flash successful! Make sure you disable Windows Update on the phone!", null);
|
||||
}).Start();
|
||||
}
|
||||
|
||||
|
||||
// Called from an event-handler. So, "async void" is valid here.
|
||||
internal async void FlashFFU(string FFUPath)
|
||||
{
|
||||
@@ -628,7 +628,7 @@ namespace WPinternals
|
||||
NokiaFlashModel Phone = (NokiaFlashModel)PhoneNotifier.CurrentModel;
|
||||
if (PhoneNotifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader)
|
||||
Phone.SwitchToFlashAppContext();
|
||||
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
bool Result = true;
|
||||
@@ -722,7 +722,7 @@ namespace WPinternals
|
||||
|
||||
internal void ExitFailure(string Message, string SubMessage)
|
||||
{
|
||||
MessageViewModel ErrorMessageViewModel = new MessageViewModel(Message, () =>
|
||||
MessageViewModel ErrorMessageViewModel = new MessageViewModel(Message, () =>
|
||||
{
|
||||
IsSwitchingInterface = false;
|
||||
Callback();
|
||||
|
||||
@@ -22,7 +22,7 @@ using System;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class LumiaInfoViewModel: ContextViewModel
|
||||
internal class LumiaInfoViewModel : ContextViewModel
|
||||
{
|
||||
internal PhoneInterfaces? CurrentInterface;
|
||||
internal IDisposable CurrentModel;
|
||||
|
||||
@@ -111,7 +111,8 @@ namespace WPinternals
|
||||
catch (Exception Ex)
|
||||
{
|
||||
IsSwitchingInterface = false;
|
||||
ActivateSubContext(new MessageViewModel(Ex.Message, () => {
|
||||
ActivateSubContext(new MessageViewModel(Ex.Message, () =>
|
||||
{
|
||||
Callback();
|
||||
Refresh();
|
||||
}));
|
||||
|
||||
@@ -519,7 +519,7 @@ namespace WPinternals
|
||||
SuccessMessageViewModel.SubMessage = SubMessage;
|
||||
ActivateSubContext(SuccessMessageViewModel);
|
||||
}
|
||||
|
||||
|
||||
void NewDeviceArrived(ArrivalEventArgs Args)
|
||||
{
|
||||
// Do not start on a new thread, because EvaluateViewState will also create new ViewModels and those should be created on the UI thread.
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace WPinternals
|
||||
byte[] RebootCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x52 }; // NOKR
|
||||
FlashModel.ExecuteRawVoidMethod(RebootCommand);
|
||||
}
|
||||
|
||||
|
||||
private static void SendLoader(PhoneNotifierViewModel PhoneNotifier, List<QualcommPartition> PossibleLoaders)
|
||||
{
|
||||
// Assume 9008 mode
|
||||
@@ -123,13 +123,13 @@ namespace WPinternals
|
||||
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader)
|
||||
((NokiaFlashModel)Notifier.CurrentModel).ContinueBoot();
|
||||
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Normal)
|
||||
{
|
||||
ExitFailure("Failed to relock phone", "Your phone is half relocked. You may need to reflash a stock ROM");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ExitSuccess("Bootloader restored successfully!");
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace WPinternals
|
||||
ExitFailure("Failed to unlock phone", "Your phone is half unlocked. You may need to reflash a stock ROM");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ExitSuccess("Bootloader unlocked successfully!", null);
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace WPinternals
|
||||
if (UpdateWorkingStatus == null) UpdateWorkingStatus = (m, s, v, st) => { };
|
||||
if (ExitSuccess == null) ExitSuccess = (m, s) => { };
|
||||
if (ExitFailure == null) ExitFailure = (m, s) => { };
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (Notifier.CurrentModel is NokiaFlashModel)
|
||||
@@ -404,7 +404,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Parsing SBL3 from FFU failed.");
|
||||
}
|
||||
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
try
|
||||
@@ -481,7 +481,7 @@ namespace WPinternals
|
||||
LogFile.Log("Flash GPT at 0x" + ((UInt32)0x200).ToString("X8"));
|
||||
CurrentModel.FlashSectors(1, GPT, 0);
|
||||
Progress.SetProgress(0x21);
|
||||
|
||||
|
||||
LogFile.Log("Flash SBL2 at 0x" + ((UInt32)NewGPT.GetPartition("SBL2").FirstSector * 0x200).ToString("X8"));
|
||||
CurrentModel.FlashRawPartition(SBL2, "SBL2", Progress);
|
||||
LogFile.Log("Flash SBL3 at 0x" + ((UInt32)NewGPT.GetPartition("SBL3").FirstSector * 0x200).ToString("X8"));
|
||||
@@ -669,7 +669,7 @@ namespace WPinternals
|
||||
{
|
||||
LogFile.Log("Assembling data for unlock", LogType.FileAndConsole);
|
||||
SetWorkingStatus("Assembling data for unlock", null, null);
|
||||
|
||||
|
||||
if ((FFUPath == null) || (FFUPath.Length == 0))
|
||||
throw new ArgumentNullException("FFU path is missing");
|
||||
|
||||
@@ -679,7 +679,7 @@ namespace WPinternals
|
||||
bool DumpPartitions = false;
|
||||
string DumpFilePrefix = Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\") + DateTime.Now.ToString("yyyy-MM-dd hh.mm.ss") + " - ";
|
||||
bool IsBootLoaderUnlocked = false;
|
||||
|
||||
|
||||
FFU FFU = null;
|
||||
try
|
||||
{
|
||||
@@ -698,7 +698,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: The version of the Flash Application on the phone could not be determined.");
|
||||
if ((FlashVersion.ApplicationMajor < 1) || ((FlashVersion.ApplicationMajor == 1) && (FlashVersion.ApplicationMinor < 28)))
|
||||
throw new Exception("Error: The version of the Flash Application on the phone is too old. Update your phone using Windows Updates or flash a newer ROM to your phone. Then try again.");
|
||||
|
||||
|
||||
UefiSecurityStatusResponse SecurityStatus = ((NokiaFlashModel)Notifier.CurrentModel).ReadSecurityStatus();
|
||||
IsBootLoaderUnlocked = (SecurityStatus.AuthenticationStatus || SecurityStatus.RdcStatus || !SecurityStatus.SecureFfuEfuseStatus);
|
||||
}
|
||||
@@ -751,7 +751,7 @@ namespace WPinternals
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Bootloader)
|
||||
throw new WPinternalsException("Phone is in an unexpected mode.");
|
||||
|
||||
|
||||
NewGPT = ((NokiaFlashModel)Notifier.CurrentModel).ReadGPT();
|
||||
|
||||
await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
@@ -766,7 +766,7 @@ namespace WPinternals
|
||||
{
|
||||
NewGPT = FFU.GPT;
|
||||
}
|
||||
|
||||
|
||||
// Make sure all partitions are in range of the emergency flasher.
|
||||
NewGPT.RestoreBackupPartitions();
|
||||
|
||||
@@ -797,7 +797,7 @@ namespace WPinternals
|
||||
GPT = NewGPT.Rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
try
|
||||
@@ -1084,7 +1084,7 @@ namespace WPinternals
|
||||
{
|
||||
NokiaFlashModel CurrentModel = (NokiaFlashModel)Notifier.CurrentModel;
|
||||
LogFile.Log("Start flashing in Custom Flash mode");
|
||||
|
||||
|
||||
UInt64 TotalSectorCount = (UInt64)0x21 + 1 +
|
||||
(UInt64)(SBL2.Length / 0x200) +
|
||||
(UInt64)(SBL3.Length / 0x200) +
|
||||
@@ -1092,7 +1092,7 @@ namespace WPinternals
|
||||
|
||||
SetWorkingStatus("Flashing unlocked bootloader (part 1)...", MaxProgressValue: 100, Status: WPinternalsStatus.Flashing);
|
||||
ProgressUpdater Progress = new ProgressUpdater(TotalSectorCount, (int ProgressPercentage, TimeSpan? TimeSpan) => UpdateWorkingStatus("Flashing unlocked bootloader (part 1)...", CurrentProgressValue: (ulong)ProgressPercentage, Status: WPinternalsStatus.Flashing));
|
||||
|
||||
|
||||
LogFile.Log("Flash GPT at 0x" + ((UInt32)0x200).ToString("X8"));
|
||||
CurrentModel.FlashSectors(1, GPT, 0);
|
||||
Progress.SetProgress(0x21);
|
||||
@@ -1198,7 +1198,7 @@ namespace WPinternals
|
||||
Flasher.Flash(Start, FFU.GetPartition("WINSECAPP"), Progress, 0, Length);
|
||||
|
||||
Flasher.ClosePartition();
|
||||
|
||||
|
||||
LogFile.Log("Partition closed. Flashing ready. Rebooting.");
|
||||
|
||||
// Reboot phone to Flash app
|
||||
@@ -1359,7 +1359,7 @@ namespace WPinternals
|
||||
if (BackNV != null)
|
||||
UndoEFIESPPadding = true;
|
||||
}
|
||||
|
||||
|
||||
if (!IsSpecB)
|
||||
{
|
||||
await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
@@ -1809,7 +1809,7 @@ namespace WPinternals
|
||||
Parts[0].ProgressText = "Flashing unlocked bootloader (part 1)...";
|
||||
else
|
||||
Parts[0].ProgressText = "Flashing unlocked bootloader (part 2)...";
|
||||
|
||||
|
||||
// Now add NV partition
|
||||
Partition BACKUP_BS_NV = GPT.GetPartition("BACKUP_BS_NV");
|
||||
Partition UEFI_BS_NV;
|
||||
@@ -1861,7 +1861,7 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, false, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
|
||||
|
||||
if ((Notifier.CurrentInterface != PhoneInterfaces.Lumia_Bootloader) && (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash))
|
||||
await Notifier.WaitForArrival();
|
||||
|
||||
@@ -2145,12 +2145,12 @@ namespace WPinternals
|
||||
((NokiaFlashModel)Notifier.CurrentModel).SwitchToFlashAppContext();
|
||||
|
||||
Parts = LumiaUnlockBootloaderViewModel.LumiaGenerateEFIESPFlashPayload(UnlockedEFIESP, GPT, ProfileFFU, IsSpecB);
|
||||
|
||||
|
||||
if (IsSpecB)
|
||||
Parts[0].ProgressText = "Flashing unlocked bootloader (part 2)...";
|
||||
else
|
||||
Parts[0].ProgressText = "Flashing unlocked bootloader (part 3)...";
|
||||
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, true, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
|
||||
if (!IsSpecB)
|
||||
@@ -2181,7 +2181,7 @@ namespace WPinternals
|
||||
|
||||
Partition EFIESP = DeviceGPT.GetPartition("EFIESP");
|
||||
UInt16 ReservedOGSectors = ByteOperations.ReadUInt16(DeviceFFU.GetPartition("EFIESP"), 0xE);
|
||||
|
||||
|
||||
UInt16 ReservedSectors = LumiaGetFirstEFIESPSectorCount(DeviceGPT, DeviceFFU, IsSpecB);
|
||||
Int32 EFIESPFirstPartSize = IsSpecB ? DeviceFFU.ChunkSize : (int)SectorSize * ReservedOGSectors;
|
||||
|
||||
@@ -2218,7 +2218,7 @@ namespace WPinternals
|
||||
Int32 EFIESPFirstPartSize = IsSpecB ? DeviceFFU.ChunkSize : (int)SectorSize * ReservedOGSectors;
|
||||
|
||||
byte[] FirstSector = DeviceFFU.GetPartition("EFIESP").Take(EFIESPFirstPartSize).ToArray();
|
||||
|
||||
|
||||
List<FlashPart> Parts = new List<FlashPart>();
|
||||
|
||||
FlashPart Part = new FlashPart();
|
||||
@@ -2256,7 +2256,7 @@ namespace WPinternals
|
||||
|
||||
return ReservedSectors;
|
||||
}
|
||||
|
||||
|
||||
private static async Task LumiaFlashParts(PhoneNotifierViewModel Notifier, string FFUPath, bool PerformFullFlashFirst, bool SkipWrite, List<FlashPart> Parts, bool DoResetFirst = true, bool ClearFlashingStatusAtEnd = true, bool CheckSectorAlignment = true, bool ShowProgress = true, bool Experimental = false, SetWorkingStatus SetWorkingStatus = null, UpdateWorkingStatus UpdateWorkingStatus = null, ExitSuccess ExitSuccess = null, ExitFailure ExitFailure = null, string EDEPath = null)
|
||||
{
|
||||
PhoneInfo Info = ((NokiaFlashModel)Notifier.CurrentModel).ReadPhoneInfo();
|
||||
|
||||
@@ -23,19 +23,19 @@ using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class LumiaUnlockRootTargetSelectionViewModel: LumiaRootAccessTargetSelectionViewModel
|
||||
internal class LumiaUnlockRootTargetSelectionViewModel : LumiaRootAccessTargetSelectionViewModel
|
||||
{
|
||||
public LumiaUnlockRootTargetSelectionViewModel(PhoneNotifierViewModel PhoneNotifier, Action SwitchToUnlockBoot, Action SwitchToDumpRom, Action SwitchToFlashRom, Action UnlockPhoneCallback, Action<string, string> UnlockImageCallback)
|
||||
: base(PhoneNotifier, SwitchToUnlockBoot, SwitchToDumpRom, SwitchToFlashRom, UnlockPhoneCallback, UnlockImageCallback) { }
|
||||
}
|
||||
|
||||
internal class LumiaUndoRootTargetSelectionViewModel: LumiaRootAccessTargetSelectionViewModel
|
||||
internal class LumiaUndoRootTargetSelectionViewModel : LumiaRootAccessTargetSelectionViewModel
|
||||
{
|
||||
public LumiaUndoRootTargetSelectionViewModel(PhoneNotifierViewModel PhoneNotifier, Action SwitchToUnlockBoot, Action SwitchToDumpRom, Action SwitchToFlashRom, Action UnlockPhoneCallback, Action<string, string> UnlockImageCallback)
|
||||
: base(PhoneNotifier, SwitchToUnlockBoot, SwitchToDumpRom, SwitchToFlashRom, UnlockPhoneCallback, UnlockImageCallback) { }
|
||||
}
|
||||
|
||||
internal class LumiaRootAccessTargetSelectionViewModel: ContextViewModel
|
||||
internal class LumiaRootAccessTargetSelectionViewModel : ContextViewModel
|
||||
{
|
||||
private PhoneNotifierViewModel PhoneNotifier;
|
||||
internal Action SwitchToUnlockBoot;
|
||||
|
||||
@@ -24,7 +24,7 @@ using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class LumiaUnlockRootViewModel: ContextViewModel
|
||||
internal class LumiaUnlockRootViewModel : ContextViewModel
|
||||
{
|
||||
private PhoneNotifierViewModel PhoneNotifier;
|
||||
private Action SwitchToUnlockBoot;
|
||||
@@ -82,7 +82,8 @@ namespace WPinternals
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
ActivateSubContext(new MessageViewModel(Ex.Message, () => {
|
||||
ActivateSubContext(new MessageViewModel(Ex.Message, () =>
|
||||
{
|
||||
Callback();
|
||||
ActivateSubContext(null);
|
||||
}));
|
||||
|
||||
@@ -84,13 +84,13 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
private ContextViewModel _ContextViewModel;
|
||||
public ContextViewModel ContextViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ContextViewModel;
|
||||
}
|
||||
set
|
||||
public ContextViewModel ContextViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ContextViewModel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_ContextViewModel != value)
|
||||
{
|
||||
@@ -103,7 +103,7 @@ namespace WPinternals
|
||||
}
|
||||
OnPropertyChanged("ContextViewModel");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SynchronizationContext MainSyncContext;
|
||||
|
||||
@@ -22,7 +22,7 @@ using System;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class MessageViewModel: ContextViewModel
|
||||
internal class MessageViewModel : ContextViewModel
|
||||
{
|
||||
internal MessageViewModel(string Message, Action OkAction = null, Action CancelAction = null)
|
||||
: base()
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace WPinternals
|
||||
{
|
||||
SecurityFlags = (UInt32)CurrentModel.ReadSecurityFlags();
|
||||
LogFile.Log("Security flags: 0x" + SecurityFlags.ToString("X8"));
|
||||
|
||||
|
||||
FinalConfigDakStatus = CurrentModel.ReadFuseStatus(NokiaFlashModel.Fuse.Dak);
|
||||
FinalConfigFastBootStatus = CurrentModel.ReadFuseStatus(NokiaFlashModel.Fuse.FastBoot);
|
||||
FinalConfigFfuVerifyStatus = CurrentModel.ReadFuseStatus(NokiaFlashModel.Fuse.FfuVerify);
|
||||
|
||||
@@ -18,11 +18,9 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class NokiaMassStorageViewModel: ContextViewModel
|
||||
internal class NokiaMassStorageViewModel : ContextViewModel
|
||||
{
|
||||
private MassStorage CurrentModel;
|
||||
|
||||
|
||||
@@ -19,11 +19,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ using System;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class NokiaModeNormalViewModel: ContextViewModel
|
||||
internal class NokiaModeNormalViewModel : ContextViewModel
|
||||
{
|
||||
private NokiaPhoneModel CurrentModel;
|
||||
private Action<PhoneInterfaces?> RequestModeSwitch;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class NotImplementedViewModel: ContextViewModel
|
||||
internal class NotImplementedViewModel : ContextViewModel
|
||||
{
|
||||
internal string Message { get; set; }
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace WPinternals
|
||||
LogFile.Log("Mode: Label", LogType.FileAndConsole);
|
||||
NewDeviceArrived(new ArrivalEventArgs((PhoneInterfaces)CurrentInterface, CurrentModel));
|
||||
}
|
||||
else if ((e.DevicePath.IndexOf("VID_0421&PID_0661", StringComparison.OrdinalIgnoreCase) >= 0) ||
|
||||
else if ((e.DevicePath.IndexOf("VID_0421&PID_0661", StringComparison.OrdinalIgnoreCase) >= 0) ||
|
||||
(e.DevicePath.IndexOf("VID_0421&PID_06FC", StringComparison.OrdinalIgnoreCase) >= 0) || // VID_0421&PID_06FC is for Lumia 930
|
||||
(e.DevicePath.IndexOf("vid_045e&pid_0a00", StringComparison.OrdinalIgnoreCase) >= 0)) // vid_045e & pid_0a00 & mi_03 = Lumia 950 XL normal mode
|
||||
{
|
||||
@@ -256,7 +256,8 @@ namespace WPinternals
|
||||
// It is not possible to invoke COM objects from a WndProc.
|
||||
// MassStorage uses ManagementObjectSearcher, which is a COM object.
|
||||
// Therefore we use a new thread.
|
||||
ThreadPool.QueueUserWorkItem(s => {
|
||||
ThreadPool.QueueUserWorkItem(s =>
|
||||
{
|
||||
lock (ModelLock)
|
||||
{
|
||||
if (!(CurrentModel is MassStorage))
|
||||
@@ -392,7 +393,8 @@ namespace WPinternals
|
||||
(e.DevicePath.IndexOf("VID_05C6&PID_9008", StringComparison.OrdinalIgnoreCase) >= 0) ||
|
||||
(e.DevicePath.IndexOf(@"disk&ven_qualcomm&prod_mmc_storage", StringComparison.OrdinalIgnoreCase) >= 0) ||
|
||||
(e.DevicePath.IndexOf(@"DISK&VEN_MSFT&PROD_PHONE_MMC_STOR", StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (CurrentInterface != null)
|
||||
LastInterface = CurrentInterface;
|
||||
CurrentInterface = null;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace WPinternals
|
||||
Action Failed;
|
||||
|
||||
internal RegistrationViewModel(Action Completed, Action Failed)
|
||||
: base()
|
||||
: base()
|
||||
{
|
||||
this.Completed = Completed;
|
||||
this.Failed = Failed;
|
||||
|
||||
@@ -23,7 +23,7 @@ using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class RestoreSourceSelectionViewModel: ContextViewModel
|
||||
internal class RestoreSourceSelectionViewModel : ContextViewModel
|
||||
{
|
||||
private PhoneNotifierViewModel PhoneNotifier;
|
||||
private Action<string, string, string> RestoreCallback;
|
||||
|
||||
@@ -24,7 +24,7 @@ using System.Threading;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class RestoreViewModel: ContextViewModel
|
||||
internal class RestoreViewModel : ContextViewModel
|
||||
{
|
||||
private PhoneNotifierViewModel PhoneNotifier;
|
||||
private Action Callback;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace WPinternals
|
||||
internal delegate void ModeSwitchErrorHandler(string Message);
|
||||
internal delegate void ModeSwitchSuccessHandler(IDisposable NewModel, PhoneInterfaces NewInterface);
|
||||
|
||||
internal class SwitchModeViewModel: ContextViewModel
|
||||
internal class SwitchModeViewModel : ContextViewModel
|
||||
{
|
||||
protected PhoneNotifierViewModel PhoneNotifier;
|
||||
protected IDisposable CurrentModel;
|
||||
@@ -149,7 +149,8 @@ namespace WPinternals
|
||||
}
|
||||
else
|
||||
{
|
||||
UIContext.Post(s => {
|
||||
UIContext.Post(s =>
|
||||
{
|
||||
ModeSwitchProgress(Message, SubMessage);
|
||||
SetWorkingStatus(Message, SubMessage);
|
||||
}, null);
|
||||
@@ -555,7 +556,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
ModeSwitchErrorWrapper(Ex.Message);
|
||||
}
|
||||
|
||||
|
||||
LogFile.EndAction("SwitchToLabelMode");
|
||||
}).Start();
|
||||
}
|
||||
@@ -685,8 +686,8 @@ namespace WPinternals
|
||||
Part.StartSector = (uint)Target.FirstSector;
|
||||
Part.Stream = SB;
|
||||
Parts.Add(Part);
|
||||
await LumiaV2UnlockBootViewModel.LumiaV2CustomFlash(PhoneNotifier, null, false, false, Parts, DoResetFirst: true, ClearFlashingStatusAtEnd: false, ShowProgress: false,
|
||||
SetWorkingStatus: (m, s, v, a, st) =>
|
||||
await LumiaV2UnlockBootViewModel.LumiaV2CustomFlash(PhoneNotifier, null, false, false, Parts, DoResetFirst: true, ClearFlashingStatusAtEnd: false, ShowProgress: false,
|
||||
SetWorkingStatus: (m, s, v, a, st) =>
|
||||
{
|
||||
if (SetWorkingStatus != null)
|
||||
{
|
||||
@@ -697,7 +698,7 @@ namespace WPinternals
|
||||
LastStatus = st;
|
||||
}
|
||||
},
|
||||
UpdateWorkingStatus: (m, s, v, st) =>
|
||||
UpdateWorkingStatus: (m, s, v, st) =>
|
||||
{
|
||||
if (UpdateWorkingStatus != null)
|
||||
{
|
||||
@@ -775,14 +776,14 @@ namespace WPinternals
|
||||
AsyncAutoResetEvent Event = new AsyncAutoResetEvent(false);
|
||||
|
||||
SwitchModeViewModel Switch = new SwitchModeViewModel(
|
||||
Notifier,
|
||||
Notifier,
|
||||
TargetMode,
|
||||
ModeSwitchProgress,
|
||||
(string ErrorMessage) =>
|
||||
ModeSwitchProgress,
|
||||
(string ErrorMessage) =>
|
||||
{
|
||||
LocalErrorMessage = ErrorMessage;
|
||||
Event.Set();
|
||||
},
|
||||
},
|
||||
(IDisposable NewModel, PhoneInterfaces NewInterface) =>
|
||||
{
|
||||
Result = NewModel;
|
||||
|
||||
Reference in New Issue
Block a user