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

Commit a7ae3e50 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

fix parsing configFile

parent 79a8207f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ public class DeviceDetectedController extends AbstractSubController{
                    phone.setFlashingProcess(DeviceHelper.loadFlashProcess(phone.getAdbDevice()));
                    phone.setPrepProcess(DeviceHelper.loadPreparationProcess(phone.getAdbDevice()));
                }catch(IOException | NullPointerException | NumberFormatException | ParseException e){
                    logger.debug("Can't load Flashing Process from Yaml : {}", e.getMessage());
                    logger.debug("Can't load Flashing Process from Yaml : {}", e.getClass());
                    displayIncompatibleDeviceFound(model);
                    return;
                }
+11 −2
Original line number Diff line number Diff line
@@ -119,8 +119,17 @@ public class DeviceHelper {
    public static PreparationProcess loadPreparationProcess(String adbDevice) throws IOException, ParseException, NumberFormatException, NullPointerException{

        final HashMap yamlContent = loadYaml(adbDevice+"_preparation.yml");
        final int stepsCount = (Integer) yamlContent.get("stepsCount");
        final HashMap<String, IStep> steps = parseSteps( (HashMap) yamlContent.get("steps") );
        final int stepsCount = (Integer) yamlContent.getOrDefault("stepsCount", 0);
        
        final HashMap<String, IStep> steps; 
        if(yamlContent.containsKey("steps"))
            steps = parseSteps( (HashMap) yamlContent.get("steps") ); //What to do if null...
        else{
            logger.debug("Preparation config file has no specific steps");
            steps = new HashMap<>();
        }
        
        if(!yamlContent.containsKey("sources")) throw new NullPointerException("Invalid prepration config file. Doesn't contains \"sources\" entry");
        final HashMap<String, RomSource> sourcesToDownload = ConfigParser.parseSourcesToDownload( (HashMap) yamlContent.get("sources"));
        
        //@TODO: check if steps is null, etc.