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

Commit 379ce95e authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

add loadPreparationProcess in DeviceHelper.java & and replace...

add loadPreparationProcess  in DeviceHelper.java & and replace PreparationProcess.putSourceToDownload(String, RomSource) by setSourceToDownload(HashMap<String, RomSource)
parent 756f7867
Loading
Loading
Loading
Loading
+30 −18
Original line number Diff line number Diff line
@@ -15,8 +15,10 @@
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
package ecorp.easy.installer.helpers;
import ecorp.easy.installer.models.PreparationProcess;
import ecorp.easy.installer.models.steps.IStep;
import ecorp.easy.installer.models.Process;
import ecorp.easy.installer.models.RomSource;
import ecorp.easy.installer.utils.ConfigParser;
import static ecorp.easy.installer.utils.ConfigParser.parseSteps;
import java.io.IOException;
@@ -61,23 +63,6 @@ public class DeviceHelper {
        return map.get(key);
    }
    
    
    /**
     * Get data relatives to sources to download from config file
     * @param adbDevice
     * @return
     * @throws IOException
     * @throws ParseException
     * @throws ClassCastException
     * 
     * todo: definitively need  more tests 
     */
    public static HashMap<String, String> getSourcesToDownload(String adbDevice) throws IOException,ParseException, ClassCastException{

        return ConfigParser.parseSourcesToDownload( (HashMap) loadYaml(adbDevice+"_fs.yml").get("sources") );
    }
    
    
    /**
     * Load a yaml file 
     * @param filename the filename (don't forget extension)
@@ -121,4 +106,31 @@ public class DeviceHelper {
        
        return flashingProcess;
    }
    
    
    /**
     * Load the preparation process
     * @param adbDevice
     * @return
     * @throws IOException
     * @throws ParseException
     * @throws NumberFormatException
     * @throws NullPointerException 
     */
    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 PreparationProcess prepProcess = new PreparationProcess(stepsCount);
        HashMap<String, IStep> steps = parseSteps( (HashMap) yamlContent.get("steps") );
        
        prepProcess.setSteps(steps );
        
        final HashMap<String, RomSource> sourcesToDownload = ConfigParser.parseSourcesToDownload( (HashMap) yamlContent.get("sources"));

        prepProcess.setSourcesToDownload(sourcesToDownload);

        return prepProcess;
        
    }
}
 No newline at end of file
+8 −9
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
 */
package ecorp.easy.installer.models;

import ecorp.easy.installer.models.RomSource;
import java.util.HashMap;

/**
@@ -25,10 +24,11 @@ import java.util.HashMap;
 */
public class PreparationProcess extends Process{
    
    private final HashMap<String, RomSource> sourcesToDownload;
    private HashMap<String, RomSource> sourcesToDownload;

    /**
     * Constructor of PreparationProcess
     * Create an empty list of Sources to download
     * 
     * @param stepCount number of step in the process 
     */
@@ -45,13 +45,12 @@ public class PreparationProcess extends Process{
        return sourcesToDownload;
    }
    

    /**
     * Add a source to download
     * @param key the key associated to the RomSource instance
     * @param source  The source to Download
     * define list of sources to download
     * @param sourcesToDownload 
     */
    public void putSourceToDownload(String key, RomSource source){
        sourcesToDownload.put(key, source);
    public void setSourcesToDownload(HashMap<String, RomSource> sourcesToDownload) {
        this.sourcesToDownload = sourcesToDownload;
    }    
    
}
 No newline at end of file