Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53fbd580 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

update DeviceDetectedController, to load FlashingProcess into Phone instance

parent 2bcf8024
Loading
Loading
Loading
Loading
+25 −23
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ import ecorp.easy.installer.exceptions.TooManyDevicesException;
import ecorp.easy.installer.models.Phone;
import ecorp.easy.installer.tasks.DeviceDetectionTask;
import ecorp.easy.installer.utils.UiUtils;
import java.io.IOException;
import java.net.URL;
import java.text.ParseException;
import java.util.ResourceBundle;
import javafx.concurrent.WorkerStateEvent;
import javafx.fxml.FXML;
@@ -87,17 +89,10 @@ public class DeviceDetectedController extends AbstractSubController{

        });

        try{
        Thread thread = new Thread(detectorTask);
        thread.setDaemon(true);
        thread.start();
    }
        catch(Exception e){
            logger.error("startDetection(), error: {}", e.toString());
            //@TODO: handle  Too many device Found Exception
            
        }
    }

    /**
     * Handle result of the DeviceDetectionTask
@@ -121,23 +116,30 @@ public class DeviceDetectedController extends AbstractSubController{
        if(model == null || model.isEmpty()) displayUnknowDeviceFound();
        else{
            //check that there is config file for this device
            URL resourceUrl = getClass().getResource("/yaml/"+phone.getAdbDevice()+"_flash.yml");
            if(resourceUrl == null){
                //@TODO: this can be replaced or completed with a call to DeviceHelper
                displayIncompatibleDeviceFound(model);
            }else{
            detectionMsg.setText(String.format(i18n.getString("detect_lbl_compatibleDeviceFound"), model));
            if(parentController != null){
                // Fill last property of Phone object
                phone.setInternalCode(DeviceHelper.getDeviceInternalcode(phone.getAdbDevice()));

                try{
                    phone.setFlashingProcess(DeviceHelper.loadFlashProcess(phone.getAdbDevice()));
                }catch(IOException | NullPointerException | NumberFormatException | ParseException e){
                    logger.debug("Can't load Flashing Process from Yaml : {}", e.getMessage());
                    displayIncompatibleDeviceFound(model);
                    return;
                }

                AppConstants.setDeviceModel(phone.getAdbDevice()); //this line must be before the "parentController.setDevice(phone). If it's not the case,

                //the AppConstants.getSourceFolder() won't include the device model's name
                parentController.setDevice(phone);
                parentController.disableNextButton(false);
            }
        }
    }
    }

    
    //Note: Two below function could be merged and use a parameter to define detectionMsg.setText..
    /**
     * Update UI to indicate that an unknow Device is found
     */
+2 −3
Original line number Diff line number Diff line
@@ -105,5 +105,4 @@ public class DeviceHelper {
        
        return flashingProcess;
    }   
    
}
 No newline at end of file
+1 −4
Original line number Diff line number Diff line
@@ -46,9 +46,6 @@ import org.slf4j.LoggerFactory;
public class ConfigParser {
    private final static Logger logger = LoggerFactory.getLogger(ConfigParser.class);
    
    
    
    
    /**
     * Parse steps from yaml (both for preparation and flashing)
     * @param yaml The data map load from yaml file
+1 −1

File changed.

Contains only whitespace changes.