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

Commit 63fab92a authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

remove ThreadFactory.java

parent 3ce3b13c
Loading
Loading
Loading
Loading
+0 −70
Original line number Diff line number Diff line
/*
 * Copyright 2019-2021 - ECORP SAS 
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
package ecorp.easy.installer.threads;
import ecorp.easy.installer.AppConstants;
import java.security.InvalidParameterException;
import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This is the class in charge of Thread's creation
 * @TODO: in BuildFlashThread Method, let the Steps load from yaml to be a kind of static ressource used as mould. 
 * And create parameters field in Command so the Parameters of Step object stay unchanged and aren't specific to each Thread.
 * We'll safe memory by doing that.
 * @author Vincent
 */
public class ThreadFactory {
    private final static Logger logger = LoggerFactory.getLogger(ThreadFactory.class);
    private final HashMap<String, String> sourcesToDownload;

    /**
     * Constructor of the ThreadFactory object
     */
    public ThreadFactory(){
        this.sourcesToDownload = new HashMap<>();
    }
   
    
    /**
     * Load Preparation steps from yaml
     * @param sources Map containing steps of preparation
     */
    protected void loadSourcesToDownload( Map sources){
        logger.info("loadSourcesToDownload(...)");
        
        if(sources == null || sources.isEmpty()){ throw new InvalidParameterException("Preparation steps loaded from YAML are invalid"); }
        
        for(String key : (Set<String>) sources.keySet() ){
            Map source = (Map) sources.get(key); 
            if(key.equals("rom")){
                AppConstants.setEArchivePath((String) source.get("filePath"));
            }
            if(key.equals("twrp")){
                AppConstants.setTwrpImgPath((String) source.get("filePath"));
            }
            sourcesToDownload.put((String) source.get("url"), (String) source.get("filePath"));
        }
    }
    
    public HashMap<String, String> getSourcesToDownload(){
        return sourcesToDownload;
    }

}
 No newline at end of file