Ejemplo n.º 1
0
        public MainViewModel()
        {
            MainSyncContext = SynchronizationContext.Current;

            LogFile.LogApplicationVersion();

            // Set global callback for cases where Dependency Injection is not possible.
            App.NavigateToGettingStarted = () => { GettingStartedCommand.Execute(null); };
            App.NavigateToUnlockBoot     = () => { BootUnlockCommand.Execute(null); };

            if (Registry.CurrentUser.OpenSubKey("Software\\WPInternals") == null)
            {
                Registry.CurrentUser.OpenSubKey("Software", true).CreateSubKey("WPInternals");
            }

            if ((Registration.IsPrerelease) && (Registry.CurrentUser.OpenSubKey("Software\\WPInternals").GetValue("NdaAccepted") == null))
            {
                this.ContextViewModel = new DisclaimerAndNdaViewModel(Disclaimer_Accepted);
            }
            else if (Registry.CurrentUser.OpenSubKey("Software\\WPInternals").GetValue("DisclaimerAccepted") == null)
            {
                this.ContextViewModel = new DisclaimerViewModel(Disclaimer_Accepted);
            }
            else if ((Registration.IsPrerelease) && !Registration.IsRegistered())
            {
                ContextViewModel = new RegistrationViewModel(Registration_Completed, Registration_Failed);
            }
            else
            {
                StartOperation();
            }
        }
Ejemplo n.º 2
0
        void Disclaimer_Accepted()
        {
            ContextViewModel = null;

            if ((Registration.IsPrerelease) && !Registration.IsRegistered())
            {
                ContextViewModel = new RegistrationViewModel(Registration_Completed, Registration_Failed);
            }
            else
            {
                StartOperation();
            }
        }
Ejemplo n.º 3
0
        void PhoneNotifier_NewDeviceArrived(ArrivalEventArgs Args)
        {
            PhoneInterfaces?PreviousInterface = LastInterface;

            LastInterface = Args.NewInterface;

            if (App.InterruptBoot && (Args.NewInterface == PhoneInterfaces.Lumia_Bootloader))
            {
                App.InterruptBoot = false;
                LogFile.Log("Found Lumia BootMgr and user forced to interrupt the boot process. Force to Flash-mode.");
                Task.Run(() => SwitchModeViewModel.SwitchTo(PhoneNotifier, PhoneInterfaces.Lumia_Flash));
            }
            else
            {
                if (Args.NewInterface != PhoneInterfaces.Qualcomm_Download)
                {
                    App.InterruptBoot = false;
                }

                if (ContextViewModel == null)
                {
                    ContextViewModel = InfoViewModel;
                }
                else if (ContextViewModel.IsFlashModeOperation)
                {
                    if ((!ContextViewModel.IsSwitchingInterface) && (Args.NewInterface == PhoneInterfaces.Lumia_Bootloader))
                    {
                        // The current screen is marked as "Flash operation".
                        // When the bootloader is detected at this stage, it means a phone is booting and
                        // it is possible that the phone is in a non-booting stage (not possible to boot past UEFI).
                        // We will try to boot straight to Flash-mode, so that it will be possible to flash a new ROM.
                        LogFile.Log("Found Lumia BootMgr while mode is not being switched. Screen is marked as Flash Operation. Force to Flash-mode.");
                        Task.Run(() => SwitchModeViewModel.SwitchTo(PhoneNotifier, PhoneInterfaces.Lumia_Flash));
                    }
                }
                else
                {
                    if ((!ContextViewModel.IsSwitchingInterface) && (Args.NewInterface != PhoneInterfaces.Lumia_Bootloader))
                    {
                        ContextViewModel = InfoViewModel;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 internal void ActivateSubContext(ContextViewModel NewSubContext)
 {
     if (_SubContextViewModel != null)
     {
         _SubContextViewModel.IsActive = false;
     }
     if (NewSubContext != null)
     {
         if (IsActive)
         {
             NewSubContext.Activate();
         }
         else
         {
             NewSubContext.IsActive = false;
         }
     }
     SubContextViewModel = NewSubContext;
 }
Ejemplo n.º 5
0
 internal void SwitchToDifferentInterface(PhoneInterfaces TargetInterface)
 {
     ModeViewModel.OnModeSwitchRequested(TargetInterface);
     ContextViewModel = ModeViewModel;
 }
Ejemplo n.º 6
0
 internal void SwitchToRestoreBoot()
 {
     ContextViewModel = BootRestoreViewModel;
 }
Ejemplo n.º 7
0
 internal void SwitchToDumpFFU()
 {
     ContextViewModel = DumpRomViewModel;
 }
Ejemplo n.º 8
0
 internal void SwitchToDownload()
 {
     ContextViewModel = DownloadsViewModel;
 }
Ejemplo n.º 9
0
 internal void SwitchToBackup()
 {
     ContextViewModel = BackupViewModel;
 }
Ejemplo n.º 10
0
 internal void SwitchToFlashRom()
 {
     ContextViewModel = LumiaFlashRomViewModel;
 }
Ejemplo n.º 11
0
 internal void SwitchToUnlockRoot()
 {
     ContextViewModel = RootUnlockViewModel;
 }
Ejemplo n.º 12
0
 internal void SwitchToUndoRoot()
 {
     ContextViewModel = RootRestoreViewModel;
 }
Ejemplo n.º 13
0
 internal ContextViewModel(MainViewModel Main, ContextViewModel SubContext) : this(Main)
 {
     SubContextViewModel = SubContext;
 }
Ejemplo n.º 14
0
 internal void SwitchToInfoViewModel()
 {
     ContextViewModel = InfoViewModel;
 }
Ejemplo n.º 15
0
        public void StartOperation()
        {
            IsMenuEnabled = true;

            _GettingStartedViewModel = new GettingStartedViewModel(
                () =>
            {
                ContextViewModel           = new DisclaimerViewModel(
                    () => ContextViewModel = _GettingStartedViewModel
                    );
            },
                SwitchToUnlockBoot,
                SwitchToUnlockRoot,
                SwitchToBackup,
                SwitchToDumpFFU,
                SwitchToFlashRom,
                SwitchToDownload
                );
            this.ContextViewModel = _GettingStartedViewModel;

            PhoneNotifier = new PhoneNotifierViewModel();
            PhoneNotifier.NewDeviceArrived += PhoneNotifier_NewDeviceArrived;
            PhoneNotifier.DeviceRemoved    += PhoneNotifier_DeviceRemoved;

            InfoViewModel = new LumiaInfoViewModel(PhoneNotifier, (TargetInterface) =>
            {
                ModeViewModel.OnModeSwitchRequested(TargetInterface);
                ContextViewModel = ModeViewModel;
            },
                                                   () =>
            {
                ContextViewModel = _GettingStartedViewModel;
            });
            InfoViewModel.ActivateSubContext(null);

            ModeViewModel = new LumiaModeViewModel(PhoneNotifier, SwitchToInfoViewModel);
            ModeViewModel.ActivateSubContext(null);

            BootUnlockViewModel = new LumiaUnlockBootViewModel(PhoneNotifier, SwitchToFlashRom, SwitchToUndoRoot, SwitchToDownload, true, SwitchToInfoViewModel);
            BootUnlockViewModel.ActivateSubContext(null);

            BootRestoreViewModel = new LumiaUnlockBootViewModel(PhoneNotifier, SwitchToFlashRom, SwitchToUndoRoot, SwitchToDownload, false, SwitchToInfoViewModel);
            BootRestoreViewModel.ActivateSubContext(null);

            RootUnlockViewModel = new LumiaUnlockRootViewModel(PhoneNotifier, SwitchToUnlockBoot, SwitchToDumpFFU, SwitchToFlashRom, true, SwitchToInfoViewModel);
            RootUnlockViewModel.ActivateSubContext(null);

            RootRestoreViewModel = new LumiaUnlockRootViewModel(PhoneNotifier, SwitchToUnlockBoot, SwitchToDumpFFU, SwitchToFlashRom, false, SwitchToInfoViewModel);
            RootRestoreViewModel.ActivateSubContext(null);

            BackupViewModel = new BackupViewModel(PhoneNotifier, SwitchToUnlockBoot, SwitchToInfoViewModel);
            BackupViewModel.ActivateSubContext(null);

            RestoreViewModel = new RestoreViewModel(PhoneNotifier, SwitchToDifferentInterface, SwitchToUnlockBoot, SwitchToFlashRom, SwitchToInfoViewModel);
            RestoreViewModel.ActivateSubContext(null);

            LumiaFlashRomViewModel = new LumiaFlashRomViewModel(PhoneNotifier, SwitchToUnlockBoot, SwitchToUnlockRoot, SwitchToDumpFFU, SwitchToBackup, SwitchToInfoViewModel);
            LumiaFlashRomViewModel.ActivateSubContext(null);

            DumpRomViewModel = new DumpRomViewModel(SwitchToUnlockBoot, SwitchToUnlockRoot, SwitchToFlashRom);
            DumpRomViewModel.ActivateSubContext(null);

            DownloadsViewModel  = new DownloadsViewModel(PhoneNotifier);
            App.DownloadManager = DownloadsViewModel;

            PhoneNotifier.Start();
        }
Ejemplo n.º 16
0
 void Registration_Failed()
 {
     ContextViewModel = new MessageViewModel("Registration failed", () => Environment.Exit(0));
     ((MessageViewModel)ContextViewModel).SubMessage = "Check your filewall settings";
 }
Ejemplo n.º 17
0
 void Registration_Completed()
 {
     ContextViewModel = null;
     StartOperation();
 }