Ejemplo n.º 1
0
        private void NewDeviceArrived(ArrivalEventArgs Args)
        {
            CurrentInterface = Args.NewInterface;
            CurrentModel     = Args.NewModel;

            // Determine SubcontextViewModel
            switch (CurrentInterface)
            {
            case null:
            case PhoneInterfaces.Lumia_Bootloader:
                ActivateSubContext(null);
                //ActivateSubContext(new NokiaBootloaderViewModel((NokiaFlashModel)CurrentModel, ModeSwitchRequestCallback, SwitchToGettingStarted));
                break;

            case PhoneInterfaces.Lumia_Normal:
                ActivateSubContext(new NokiaNormalViewModel((NokiaPhoneModel)CurrentModel, ModeSwitchRequestCallback));
                break;

            case PhoneInterfaces.Lumia_Flash:
                ActivateSubContext(new NokiaFlashViewModel((NokiaFlashModel)CurrentModel, ModeSwitchRequestCallback, SwitchToGettingStarted));
                break;

            case PhoneInterfaces.Lumia_Label:
                ActivateSubContext(new NokiaLabelViewModel((NokiaPhoneModel)CurrentModel, ModeSwitchRequestCallback));
                break;

            case PhoneInterfaces.Lumia_MassStorage:
                ActivateSubContext(new NokiaMassStorageViewModel((MassStorage)CurrentModel));
                break;
            }
        }
Ejemplo n.º 2
0
        private void NewDeviceArrived(ArrivalEventArgs Args)
        {
            CurrentInterface = Args.NewInterface;
            CurrentModel     = Args.NewModel;

            if (!IsSwitchingInterface && IsActive)
            {
                Refresh();
            }
        }
Ejemplo n.º 3
0
        private bool OnDeviceArrival(IDsDevice arrived)
        {
            var args = new ArrivalEventArgs(arrived);

            if (DeviceArrived != null)
            {
                DeviceArrived(this, args);
            }

            return(args.Handled);
        }
 void NewDeviceArrived(ArrivalEventArgs Args)
 {
     new Thread(() =>
     {
         try
         {
             EvaluateViewState();
         }
         catch { }
     }).Start();
 }
Ejemplo n.º 5
0
        private bool LogArrival(IDsDevice arrived)
        {
            var args = new ArrivalEventArgs(arrived);

            if (Arrival != null)
            {
                Arrival(this, args);
            }

            return(args.Handled);
        }
Ejemplo n.º 6
0
        private void NewDeviceArrived(ArrivalEventArgs Args)
        {
            PhoneNotifier.NewDeviceArrived -= NewDeviceArrived;

            if (Args.NewInterface != PhoneInterfaces.Lumia_Label)
            {
                ExitFailure("Flash failed!", "Phone unexpectedly switched mode while booting MMOS image.");
                return;
            }
            else
            {
                ExitSuccess("Flash successful!", null);
                return;
            }
        }
Ejemplo n.º 7
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.º 8
0
        internal void PhoneNotifier_NewDeviceArrived(ArrivalEventArgs Args)
        {
            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));
            }

            UIContext.Send(s =>
            {
                if (!App.InterruptBoot && Args.NewInterface == PhoneInterfaces.Lumia_Bootloader)
                {
                    StatusText.Content  = "Phone is booting...";
                    GifImage.Visibility = Visibility.Visible;
                }

                if (!App.InterruptBoot && Args.NewInterface != PhoneInterfaces.Lumia_Bootloader)
                {
                    StatusText.Content  = "Waiting for connection with phone...";
                    GifImage.Visibility = Visibility.Collapsed;
                }
            }, null);
        }
Ejemplo n.º 9
0
 private void NewDeviceArrived(ArrivalEventArgs Args)
 {
     new Thread(() => EvaluateViewState()).Start();
 }
Ejemplo n.º 10
0
        private void NewDeviceArrived(ArrivalEventArgs Args)
        {
            PhoneNotifier.NewDeviceArrived -= NewDeviceArrived;

            CurrentModel = (IDisposable)Args.NewModel;
            CurrentMode  = Args.NewInterface;

            if ((CurrentMode == PhoneInterfaces.Lumia_Bootloader) && (TargetMode == PhoneInterfaces.Lumia_Flash))
            {
                try
                {
                    // Going from BootMgr to FlashApp
                    // SwitchToFlashAppContext() will only switch context. Phone will not charge.
                    // ResetPhoneToFlashMode() reboots to real flash app. Phone will charge. Works when in BootMgrApp, not when already in FlashApp.

                    ((NokiaFlashModel)CurrentModel).ResetPhoneToFlashMode();
                    CurrentMode = PhoneInterfaces.Lumia_Flash;
                    PhoneNotifier.NotifyArrival();
                }
                catch { }
            }

            if (CurrentMode == TargetMode)
            {
                if (TargetMode == PhoneInterfaces.Lumia_Bootloader)
                {
                    ((NokiaFlashModel)CurrentModel).DisableRebootTimeOut();
                }

                ModeSwitchSuccessWrapper();
            }
            else if (!IsSwitching)
            {
                StartSwitch();
            }
            else if ((CurrentMode == PhoneInterfaces.Lumia_Bootloader) && (TargetMode == PhoneInterfaces.Lumia_Normal))
            {
                // Do nothing, because booting to Normal shortly goes into Flash mode too.
                // Just wait to arrive in Normal mode;
                PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
            }
            else if ((CurrentMode == PhoneInterfaces.Lumia_Flash) && (TargetMode == PhoneInterfaces.Lumia_MassStorage))
            {
                SwitchFromFlashToMassStorageMode(Continuation: true);
            }
            else if ((CurrentMode == PhoneInterfaces.Lumia_Flash) && (TargetMode == PhoneInterfaces.Qualcomm_Download))
            {
                byte[] RebootCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x52 };
                byte[] RebootToQualcommDownloadCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x58, 0x43, 0x42, 0x45 }; // NOKXCBE
                IsSwitchingInterface = true;
                LogFile.Log("Sending command for rebooting to Emergency Download mode");
                byte[] RebootCommandResult = ((NokiaPhoneModel)CurrentModel).ExecuteRawMethod(RebootToQualcommDownloadCommand);
                if ((RebootCommandResult != null) && (RebootCommandResult.Length >= 8))
                {
                    int ResultCode = (RebootCommandResult[6] << 8) + RebootCommandResult[7];
                    LogFile.Log("Resultcode: 0x" + ResultCode.ToString("X4"));
                }
                if ((RebootCommandResult != null) && (RebootCommandResult.Length == 4)) // This means fail: NOKU (unknow command)
                {
                    ModeSwitchErrorWrapper("Failed to switch to Qualcomm Download mode");
                    IsSwitchingInterface = false;
                }
                else
                {
                    PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
                    ModeSwitchProgressWrapper("And now rebooting phone to Qualcomm Download mode...", null);
                    LogFile.Log("Rebooting phone to Qualcomm Download mode");
                }
            }
            else
            {
                switch (TargetMode)
                {
                case PhoneInterfaces.Lumia_Normal:
                    ModeSwitchErrorWrapper("Failed to switch to Normal mode");
                    break;

                case PhoneInterfaces.Lumia_Flash:
                    ModeSwitchErrorWrapper("Failed to switch to Flash mode");
                    break;

                case PhoneInterfaces.Lumia_Label:
                    ModeSwitchErrorWrapper("Failed to switch to Label mode");
                    break;

                case PhoneInterfaces.Lumia_MassStorage:
                    ModeSwitchErrorWrapper("Failed to switch to Mass Storage mode");
                    break;
                }
            }
        }
Ejemplo n.º 11
0
 private void Notifier_NewDeviceArrived(ArrivalEventArgs Args)
 {
     EvaluateViewState();
 }
Ejemplo n.º 12
0
        private void NewDeviceArrivedFromMassStorageMode(ArrivalEventArgs Args)
        {
            PhoneNotifier.NewDeviceArrived -= NewDeviceArrivedFromMassStorageMode;

            CurrentModel = (IDisposable)Args.NewModel;
            CurrentMode  = Args.NewInterface;

            // After the mass storage mode reboot command, the phone must be in Bootloader mode.
            // If it isn't, something unexpected happened and the phone can't be switched.
            //
            if (CurrentMode == PhoneInterfaces.Lumia_Bootloader)
            {
                Task.Run(async() =>
                {
                    try
                    {
                        await SwitchToWithStatus(PhoneNotifier, TargetMode, SetWorkingStatus, UpdateWorkingStatus);
                        ModeSwitchSuccessWrapper();
                    }
                    catch
                    {
                        switch (TargetMode)
                        {
                        case PhoneInterfaces.Lumia_Flash:
                            ModeSwitchErrorWrapper("Failed to switch to Flash mode");
                            break;

                        case PhoneInterfaces.Lumia_Label:
                            ModeSwitchErrorWrapper("Failed to switch to Label mode");
                            break;

                        case PhoneInterfaces.Lumia_Normal:
                            ModeSwitchErrorWrapper("Failed to switch to Normal mode");
                            break;

                        case null:
                            ModeSwitchSuccessWrapper();
                            break;
                        }
                    }
                });
            }
            else
            {
                switch (TargetMode)
                {
                case PhoneInterfaces.Lumia_Flash:
                    ModeSwitchErrorWrapper("Failed to switch to Flash mode");
                    break;

                case PhoneInterfaces.Lumia_Label:
                    ModeSwitchErrorWrapper("Failed to switch to Label mode");
                    break;

                case PhoneInterfaces.Lumia_Normal:
                    ModeSwitchErrorWrapper("Failed to switch to Normal mode");
                    break;

                case null:
                    ModeSwitchErrorWrapper("Failed to shutdown");
                    break;
                }
            }
        }
 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.
     EvaluateViewState();
 }