From 0fe74a0a3a9be8df3428e12a609e8dab558fa5ca Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 9 Sep 2021 18:38:21 +0200 Subject: [PATCH 001/102] add base for separation of command data and command execution --- .../ecorp/easy/installer/models/Command.java | 246 +++++------------- .../installer/tasks/CommandExecutionTask.java | 118 +++++++++ 2 files changed, 180 insertions(+), 184 deletions(-) create mode 100644 src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java diff --git a/src/main/java/ecorp/easy/installer/models/Command.java b/src/main/java/ecorp/easy/installer/models/Command.java index 096eaea6..b8364d25 100644 --- a/src/main/java/ecorp/easy/installer/models/Command.java +++ b/src/main/java/ecorp/easy/installer/models/Command.java @@ -30,229 +30,107 @@ import org.slf4j.LoggerFactory; * @author Vincent Bourgmayer */ public class Command { - String command; //String containing command to perform - volatile boolean cancelled = false; //boolean to tell if it is cancelled or not - Map parameters; //Parameters to add to the command - private int exitValue; //the exit value of the script. - private String shellOutput; //The shell text output of the execution of the script - Process pc; //Process which run the command - Step step; //Object which contain data about the command like next step, ... private final static Logger logger = LoggerFactory.getLogger(Command.class); - - /** - * Constructor for instance in context of FlashThread - * @param runScriptCmd - * @param step - */ - public Command(String runScriptCmd, Step step){ - this.step = step; - this.command = runScriptCmd+step.getScript(); - this.parameters = step.getParameters(); - } - + private final String commandBase; //String containing command to perform + private String outputKey; //The variable key to use to associate output value + private final static HashMap COMMON_PARAMS = new HashMap<>(); + private Map parameters; //Parameters to add to the command + private Map okCodes; + private Map koCodes; + /** - * Constructor for command object in context of PreparationThread - * @param command - */ - public Command(String command){ - this.command = command; + * Instanciate a command object + * @param commandBase + */ + public Command(String commandBase){ + this.commandBase = commandBase; + this.outputKey = ""; this.parameters = new HashMap<>(); + this.okCodes = new HashMap<>(); + this.koCodes = new HashMap<>(); } /** - * Update a parameter only if already exist - * @param key the key of parameter to update - * @param value the new value of the param - * @return false if param isn't already in the map + * Build a command instance with an already existing set of parameters + * @param commandBase + * @param parameters */ - public boolean updateParameter(String key, String value){ - if(parameters.containsKey(key)){ - this.parameters.put(key, value); - return true; - } - return false; + public Command(String commandBase, Map parameters){ + this.commandBase = commandBase; + this.parameters = parameters; + this.outputKey = ""; + this.okCodes = new HashMap<>(); + this.koCodes = new HashMap<>(); } /** - * Get the currend command that will be run in a shell - * note: without it's parameters! + * Return the key to store output * @return */ - public String getCommand() { - return command; + public String getOutputKey() { + return outputKey; } - public Map getParameters() { - return parameters; - } - /** - * Add a new parameter for the current command - * @param key the key to identify the parameter in the list - * @param value the value of the parameter + * Define the key to store output + * @param outputKey */ - public void addParameter(String key, String value){ - this.parameters.put(key, value); - } - - /** - * @return the value returned by the execution of the current command - */ - public int getExitValue() { - return exitValue; + public void setOutputKey(String outputKey) { + this.outputKey = outputKey; } /** - * Get the output of the execution of the current command - * @return could return null - */ - public String getShellOutput() { - return shellOutput; - } - - /** - * Build the string that contain full command with its parameters - * @return String command and its parameters - */ - public String[] getFinalCmd(){ - StringBuilder sb = new StringBuilder(command); - if(parameters != null){ - parameters.values().forEach((param) -> { - sb.append(" ").append(param); - }); - } - - logger.debug("getFinalCmd(), Splitted command = {}", sb.toString()); - return sb.toString().split(" "); - } - - /** - * This is the method which execute the current command - * @throws IOException - * @throws InterruptedException + * Get map of parameters < key, value > + * @return */ - public void execAndReadOutput() throws IOException, InterruptedException{ - ProcessBuilder pb; - if(AppConstants.isWindowsOs()) - { - //@TODO REWRITE THIS PART AND MOVE IT TO getFinalCmd() - final int cmdArraySize = parameters.size()+3; - String[] commandArray= new String[cmdArraySize]; - - int cmdArrayIndex = 0; - commandArray[cmdArrayIndex++] = "cmd.exe"; - commandArray[cmdArrayIndex++] = "/c"; - - commandArray[cmdArrayIndex++] = "\"\""+command+(parameters.isEmpty() ? "\"\"":"\""); - //if empty param: commandArray[2] = ""scriptFolder/scriptname.bat"" - //else : commandArray[2] = ""scriptFolder/scriptname.bat" - - for(String param : parameters.values()){ - String quotedParam = "\""+param+"\""; - //If this is the last parameter in the list - if(cmdArrayIndex == cmdArraySize-1){ - quotedParam += "\""; //add a closing <<">> - } - //add the quoted param in the cmdArray - commandArray[cmdArrayIndex++] = quotedParam; - } - pb = new ProcessBuilder(commandArray); - logger.debug("command: {}", pb.command()); - }else{ - pb = new ProcessBuilder(getFinalCmd()); - } - - pb.redirectErrorStream(true); - pc= pb.start(); - logger.info("Command's Process started"); - InputStream stdout = pc.getInputStream(); - InputStreamReader isr = new InputStreamReader (stdout); - BufferedReader br = new BufferedReader(isr); - - StringBuilder sb = new StringBuilder(); - String line; - try{ - while(pc.isAlive() && !cancelled){ - line = br.readLine(); - if( line != null && !line.equals("null") ){ - sb.append("\n\n").append(line); - logger.debug("\n (debug)"+line); - } - } - this.exitValue = pc.exitValue(); - }catch(IOException e){ - logger.error("execAndReadOutput(), error = {}", e.toString() ); - this.exitValue = -1; - } - br.close(); - isr.close(); - - this.shellOutput = sb.toString(); - if(pc.isAlive()) - pc.destroy(); - } - - public void cancel(){ - logger.info("cancel()"); - this.cancelled = true; - if(pc != null && pc.isAlive()) - pc.destroy(); + public Map getParameters() { + return parameters; } - /** - * Return the new values for the UI but can be null if there is nothing to change in UI - * @return null or StepUI instance + * Set the map of parameters < key, value > + * @param parameters */ - public StepUi getNewUIValues(){ - return step.getUI(); - } - - /** - * Retourne the key define for output of script - * the value is stored in this class property: shellOutput. - * @return String can be null - */ - public String getOutputKey(){ - return this.step.getOutput(); + public void setParameters(Map parameters) { + this.parameters = parameters; } /** - * Return the message associated with the exit Value - * @return String can be null if exitValue is not define for this step + * get map of success code < int, string> + * where int is the result code + * and the string the text associated + * @return */ + public Map getOkCodes() { + return okCodes; + } - public String getErrorMsg(){ - return this.step.getKoCode().getOrDefault(this.exitValue, null); + public void setOkCodes(Map okCodes) { + this.okCodes = okCodes; } - /** - * Return true if the execution of the command succeeded - * @return - */ - public boolean isSuccess(){ - if(step.getOkCode() == null ) return (exitValue == 0); + public Map getKoCodes() { + return koCodes; + } - return this.step.getOkCode().keySet().contains(this.exitValue); + public void setKoCodes(Map koCodes) { + this.koCodes = koCodes; } /** - * Return the key of the next step + * Get list of parameters available for every command * @return */ - public String getNextCommandKey(){ - if(isSuccess() && !cancelled){ - return step.getAfterSuccess(); - } - return step.getAfterFail(); + public static HashMap getCOMMON_PARAMS() { + return COMMON_PARAMS; } - /** - * tell if the command has a script registered - * @return false if step's script is null else return true + * Return the message associated with the exit Value + * @param exitValue + * @return String can be null if exitValue is not define for this step */ - public boolean hasScript(){ - return (step.getScript() != null); + public String getErrorMsg(String exitValue){ + return this.koCodes.getOrDefault(exitValue, null); } -} +} \ No newline at end of file diff --git a/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java b/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java new file mode 100644 index 00000000..7cd95fda --- /dev/null +++ b/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java @@ -0,0 +1,118 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.tasks; + +import ecorp.easy.installer.AppConstants; +import ecorp.easy.installer.models.Command; +import ecorp.easy.installer.models.Device; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; +import javafx.concurrent.Task; + +/** + * + * @author vincent + */ +public class CommandExecutionTask

extends Task

{ + + final protected Command command; + protected String shellOutput; + protected int exitCode; + + public CommandExecutionTask(Command command){ + this.command = command; + } + + @Override + protected P call() throws Exception { + executeCommand( getProcessBuilder() ); + return null; + } + + protected void executeCommand(ProcessBuilder pb) throws IOException{ + final Process pc= pb.start(); + //logger.info("Command's Process started"); + + final StringBuilder sb = new StringBuilder(); + String line; + try( InputStream stdout = pc.getInputStream(); + InputStreamReader isr = new InputStreamReader (stdout); + BufferedReader br = new BufferedReader(isr); ){ + while(pc.isAlive() && !this.isCancelled()){ + line = br.readLine(); + if( line != null && !line.equals("null") ){ + sb.append("\n\n").append(line); + //logger.debug("\n (debug)"+line); + } + } + this.exitCode = pc.exitValue(); + }catch(IOException e){ + //logger.error("execAndReadOutput(), error = {}", e.toString() ); + this.exitCode = -1; + } + + this.shellOutput = sb.toString(); + if(pc.isAlive()) + pc.destroy(); + } + + /** + * Build the ProcessBuilder to execute Command + * @return + */ + protected ProcessBuilder getProcessBuilder(){ + ProcessBuilder pb; + final Map parameters = command.getParameters(); + + if(AppConstants.isWindowsOs()) + { + //@TODO REWRITE THIS PART AND MOVE IT TO getFinalCmd() + final int cmdArraySize = parameters.size()+3; + String[] commandArray= new String[cmdArraySize]; + + int cmdArrayIndex = 0; + commandArray[cmdArrayIndex++] = "cmd.exe"; + commandArray[cmdArrayIndex++] = "/c"; + + commandArray[cmdArrayIndex++] = "\"\""+command.getCommandBase()+(parameters.isEmpty() ? "\"\"":"\""); + //if empty param: commandArray[2] = ""scriptFolder/scriptname.bat"" + //else : commandArray[2] = ""scriptFolder/scriptname.bat" + + for(String param : parameters.values()){ + String quotedParam = "\""+param+"\""; + //If this is the last parameter in the list + if(cmdArrayIndex == cmdArraySize-1){ + quotedParam += "\""; //add a closing <<">> + } + //add the quoted param in the cmdArray + commandArray[cmdArrayIndex++] = quotedParam; + } + pb = new ProcessBuilder(commandArray); + //logger.debug("command: {}", pb.command()); + }else{ + //@TODO implement linux equivalent + pb = new ProcessBuilder(getFinalCmd()); + } + + pb.redirectErrorStream(true); + return pb; + } + + + private String[] getFinalCmd(){ + StringBuilder sb = new StringBuilder(command.getCommandBase()); + if(command.getParameters() != null){ + command.getParameters().values().forEach((param) -> { + sb.append(" ").append(param); + }); + } + //logger.debug("getFinalCmd(), Splitted command = {}", sb.toString()); + return sb.toString().split(" "); + } +} -- GitLab From d8d595ce3765be31880a4127c480761297b9a146 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 9 Sep 2021 18:51:28 +0200 Subject: [PATCH 002/102] update DeviceDetectionTask to implement super class CommandExecutionTask --- .../ecorp/easy/installer/models/Command.java | 17 +++++++++++++++++ .../installer/tasks/DeviceDetectionTask.java | 18 +++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/models/Command.java b/src/main/java/ecorp/easy/installer/models/Command.java index b8364d25..f59c4b73 100644 --- a/src/main/java/ecorp/easy/installer/models/Command.java +++ b/src/main/java/ecorp/easy/installer/models/Command.java @@ -64,6 +64,23 @@ public class Command { this.koCodes = new HashMap<>(); } + /** + * Add a new parameter for the current command + * @param key the key to identify the parameter in the list + * @param value the value of the parameter + */ + public void addParameter(String key, String value){ + this.parameters.put(key, value); + } + + + + + /* Getter & setters */ + public String getCommandBase() { + return commandBase; + } + /** * Return the key to store output * @return diff --git a/src/main/java/ecorp/easy/installer/tasks/DeviceDetectionTask.java b/src/main/java/ecorp/easy/installer/tasks/DeviceDetectionTask.java index abfcb344..f49e59db 100644 --- a/src/main/java/ecorp/easy/installer/tasks/DeviceDetectionTask.java +++ b/src/main/java/ecorp/easy/installer/tasks/DeviceDetectionTask.java @@ -30,12 +30,19 @@ import org.slf4j.LoggerFactory; * @author vincent Bourgmayer * @author Ingo */ -public class DeviceDetectionTask extends Task{ +public class DeviceDetectionTask extends CommandExecutionTask{ final String CMD_adbDevices = "devices"; private final static Logger logger = LoggerFactory.getLogger(DeviceDetectionTask.class); private final static Pattern LINEBREAK_PATTERN = Pattern.compile("\\R"); private final static Pattern SPACE_PATTERN = Pattern.compile("\\s+"); + public DeviceDetectionTask() { + super(new Command(AppConstants.getADBFolderPath()+"adb")); + this.command.addParameter("1", CMD_adbDevices); + this.command.addParameter("2", "-l"); + + } + /** * @inheritDoc * @return Device object @@ -62,14 +69,11 @@ public class DeviceDetectionTask extends Task{ private Device runAdbDevicesCmd(String baseCmdString) throws Exception{ logger.info("runADBDevicesCmd({})", baseCmdString); - Command cmd = new Command(baseCmdString); - cmd.addParameter("1", CMD_adbDevices); - cmd.addParameter("2", "-l"); - cmd.execAndReadOutput(); + super.executeCommand(super.getProcessBuilder()); Device detectedDevice = null; - String[] outputs = LINEBREAK_PATTERN.split(cmd.getShellOutput()); - logger.debug(" raw shell outputs = {} ", cmd.getShellOutput()); + String[] outputs = LINEBREAK_PATTERN.split(shellOutput); + logger.debug(" raw shell outputs = {} ", shellOutput); if(outputs.length <=1){ logger.info(" Waiting"); Thread.sleep(2250); -- GitLab From 9ef9f498585f938699867e516fc7f212b26b3bd7 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 10 Sep 2021 11:32:59 +0200 Subject: [PATCH 003/102] remove unused import and fix parameter error in Command.java --- src/main/java/ecorp/easy/installer/models/Command.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/models/Command.java b/src/main/java/ecorp/easy/installer/models/Command.java index f59c4b73..15a69925 100644 --- a/src/main/java/ecorp/easy/installer/models/Command.java +++ b/src/main/java/ecorp/easy/installer/models/Command.java @@ -17,10 +17,6 @@ package ecorp.easy.installer.models; import ecorp.easy.installer.AppConstants; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import org.slf4j.Logger; @@ -147,7 +143,7 @@ public class Command { * @param exitValue * @return String can be null if exitValue is not define for this step */ - public String getErrorMsg(String exitValue){ + public String getErrorMsg(int exitValue){ return this.koCodes.getOrDefault(exitValue, null); } } \ No newline at end of file -- GitLab From ec05ab7e1d3095363eb896dd9e4a7284c8520e1b Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 10 Sep 2021 11:33:30 +0200 Subject: [PATCH 004/102] rewrite CommandExecutionTask.java --- .../installer/tasks/CommandExecutionTask.java | 112 ++++++++++-------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java b/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java index 7cd95fda..8d942cd9 100644 --- a/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java +++ b/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java @@ -7,112 +7,122 @@ package ecorp.easy.installer.tasks; import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.models.Command; -import ecorp.easy.installer.models.Device; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.util.Map; import javafx.concurrent.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** - * + * The

is present for eventual subclass. + * It is useless for CommandExecutionTask itself + * but required for DeviceDetectionTask by example * @author vincent */ public class CommandExecutionTask

extends Task

{ - - final protected Command command; - protected String shellOutput; - protected int exitCode; + protected final static Logger logger = LoggerFactory.getLogger(CommandExecutionTask.class); + final protected Command command; //The command to run + protected String shellOutput; //The stdout of the process + protected int exitCode; //The result code of the command + /** + * Instanciate a CommandExecutionTask + * @param command the Command to execute + */ public CommandExecutionTask(Command command){ this.command = command; } + /** + * run the command + * @return always null because "P" is for subclass + * @throws Exception + */ @Override protected P call() throws Exception { executeCommand( getProcessBuilder() ); return null; } + /** + * Execute the command + * @param pb + * @throws IOException + */ protected void executeCommand(ProcessBuilder pb) throws IOException{ final Process pc= pb.start(); - //logger.info("Command's Process started"); + /* Collect stdout for further usage */ final StringBuilder sb = new StringBuilder(); - String line; + try( InputStream stdout = pc.getInputStream(); InputStreamReader isr = new InputStreamReader (stdout); BufferedReader br = new BufferedReader(isr); ){ + String line; + while(pc.isAlive() && !this.isCancelled()){ line = br.readLine(); + + //I don't remember the reason of the second part of the below test... if( line != null && !line.equals("null") ){ sb.append("\n\n").append(line); - //logger.debug("\n (debug)"+line); } } + this.exitCode = pc.exitValue(); }catch(IOException e){ - //logger.error("execAndReadOutput(), error = {}", e.toString() ); this.exitCode = -1; } this.shellOutput = sb.toString(); + if(pc.isAlive()) pc.destroy(); } /** * Build the ProcessBuilder to execute Command - * @return + * @return ProcessBuilder instance containing the full command to run */ protected ProcessBuilder getProcessBuilder(){ - ProcessBuilder pb; - final Map parameters = command.getParameters(); - - if(AppConstants.isWindowsOs()) - { - //@TODO REWRITE THIS PART AND MOVE IT TO getFinalCmd() - final int cmdArraySize = parameters.size()+3; - String[] commandArray= new String[cmdArraySize]; - - int cmdArrayIndex = 0; - commandArray[cmdArrayIndex++] = "cmd.exe"; - commandArray[cmdArrayIndex++] = "/c"; - - commandArray[cmdArrayIndex++] = "\"\""+command.getCommandBase()+(parameters.isEmpty() ? "\"\"":"\""); - //if empty param: commandArray[2] = ""scriptFolder/scriptname.bat"" - //else : commandArray[2] = ""scriptFolder/scriptname.bat" - - for(String param : parameters.values()){ - String quotedParam = "\""+param+"\""; - //If this is the last parameter in the list - if(cmdArrayIndex == cmdArraySize-1){ - quotedParam += "\""; //add a closing <<">> - } - //add the quoted param in the cmdArray - commandArray[cmdArrayIndex++] = quotedParam; - } - pb = new ProcessBuilder(commandArray); - //logger.debug("command: {}", pb.command()); - }else{ - //@TODO implement linux equivalent - pb = new ProcessBuilder(getFinalCmd()); - } - + final ProcessBuilder pb = new ProcessBuilder(getFullCmd().split(" ")); pb.redirectErrorStream(true); return pb; } - private String[] getFinalCmd(){ - StringBuilder sb = new StringBuilder(command.getCommandBase()); - if(command.getParameters() != null){ + /** + * Concatenate command base with parameters to obtain + * the full command to be run + * @return String the full command + */ + protected String getFullCmd(){ + final StringBuilder sb = new StringBuilder(); + + // Prepare base of the command + String cmdBase = command.getCommandBase(); + if(AppConstants.isWindowsOs()){ + cmdBase = "cmd.exe /c \"\""+cmdBase+"\""; + } + sb.append(cmdBase); + + //Add the parameters + if(command.getParameters() != null && !command.getParameters().isEmpty()){ command.getParameters().values().forEach((param) -> { + if(AppConstants.isWindowsOs()){ + param = "\""+param+"\""; + } sb.append(" ").append(param); }); } - //logger.debug("getFinalCmd(), Splitted command = {}", sb.toString()); - return sb.toString().split(" "); + // Close the full command + if(AppConstants.isWindowsOs()){ + sb.append("\""); + } + + logger.debug("getFullCmd(), full command = {}", sb.toString()); + return sb.toString(); } -} +} \ No newline at end of file -- GitLab From 44af05e8df2e7303fce43b62b7fbfa7bfe3aa6c4 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 10 Sep 2021 11:49:14 +0200 Subject: [PATCH 005/102] replace field of Step class by Command instance and update ThreadFactory to use this Command field from step --- .../ecorp/easy/installer/models/Step.java | 106 ++---------------- .../easy/installer/threads/ThreadFactory.java | 25 +++-- 2 files changed, 20 insertions(+), 111 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/models/Step.java b/src/main/java/ecorp/easy/installer/models/Step.java index 2c798335..5b31967e 100644 --- a/src/main/java/ecorp/easy/installer/models/Step.java +++ b/src/main/java/ecorp/easy/installer/models/Step.java @@ -14,8 +14,6 @@ */ package ecorp.easy.installer.models; -import java.util.LinkedHashMap; -import java.util.Map; /** * This class encapsulate data about a step in the flashing process @@ -23,14 +21,10 @@ import java.util.Map; */ public class Step { private StepUi ui; //Datas about user interface - private String script; //script's file script - private String output; //Key of output to store as common parameter + private Command command; private String afterSuccess; // index of next script if succeed private String afterFail; //index of next script if failure - private Map okCode; - private Map koCode; - private Map parameters; //parameters to add to the script //@TODO think if is possible to set only one map in Thread instance instead of in each Step. - + /** * Default constructor */ @@ -42,69 +36,18 @@ public class Step { * @param s the step to copy */ public Step (Step s){ - this.script = s.script; afterSuccess = s.afterSuccess; afterFail = s.afterFail; ui = s.ui; - okCode = s.okCode; - koCode = s.koCode; - output = s.output; - if(s.parameters != null){ - parameters = new LinkedHashMap<>(); - for(Map.Entry param : s.parameters.entrySet()){ - parameters.put(param.getKey(), param.getValue()); - } - } - } - - /** - * Get the name of the script to run - * @return can be null - */ - public String getScript() { - return script; - } - - /** - * Set the name of the script to execute into this step - * @param name - */ - public void setScript(String name) { - this.script = name; - } - - /** - * In some particular case, a step can produce an output - * that could be use later. This is the "output" of the step - * @return can be null - */ - public String getOutput() { - return output; + this.command = s.getCommand(); } - /** - * Set the output of the step - * @param output - */ - public void setOutput(String output) { - this.output = output; + public Command getCommand() { + return command; } - /** - * List of parameters that should be integrated in - * the command to execute the step - * @return - */ - public Map getParameters() { - return parameters; - } - - /** - * Replace the parameter list by a new one - * @param parameters - */ - public void setParameters(LinkedHashMap parameters) { - this.parameters = parameters; + public void setCommand(Command command) { + this.command = command; } /** @@ -142,41 +85,6 @@ public class Step { public void setAfterFail(String afterFail) { this.afterFail = afterFail; } - - /** - * Get the list of result code that correspond - * to a success - * @return can be null if not set - */ - public Map getOkCode() { - return okCode; - } - - /** - * Define the list of success result's code - * @param okCode - */ - public void setOkCode(Map okCode) { - this.okCode = okCode; - } - - /** - * Get the list of result code that - * corresponds to a failure - * @return can be null if not set - */ - public Map getKoCode() { - return koCode; - } - - /** - * Set the list of result's codes that correspond - * to a failure - * @param koCode - */ - public void setKoCode(Map koCode) { - this.koCode = koCode; - } /** * Get the StepUI object which encapsulate new value for UI. diff --git a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java index 0a5a9973..3add7bb3 100644 --- a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java +++ b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java @@ -136,23 +136,23 @@ public class ThreadFactory { //1. Does the step contain a script ? if(stepData.get("script") != null){ - step.setScript(stepData.get("script")+( AppConstants.isWindowsOs() ? ".bat" : ".sh" ) ); + final String baseCmd = AppConstants.getScriptsFolderPath()+stepData.get("script")+( AppConstants.isWindowsOs() ? ".bat" : ".sh" ); + Command cmd = new Command(baseCmd, (LinkedHashMap) stepData.get("parameters")); //Fill the result codes fields Map codes = (Map) stepData.get("codes"); if(codes != null){ - step.setOkCode ( (Map) codes.get("ok") ); - step.setKoCode ( (Map) codes.get("ko") ); + cmd.setOkCodes ( (Map) codes.get("ok") ); + cmd.setKoCodes ( (Map) codes.get("ko") ); } - - //Fill the parameters field - step.setParameters ((LinkedHashMap) stepData.get("parameters") ); - - //Fill the output to read - this is the name of a variable - //to create and store in CommonParams for use in another step - step.setOutput ((String) stepData.get("output") ); + + //this is the key to store output of the script as a variable + //it is used by example to get and store phone's serial number from ADB + cmd.setOutputKey ((String) stepData.get("output") ); + + step.setCommand(cmd); }else{ //This is for step without script to run - step.setScript(null); + step.setCommand(null); } //Fill the step's key of the next step in case of success or failure step.setAfterSuccess ((String) stepData.get("succeed") ); @@ -235,7 +235,8 @@ public class ThreadFactory { flashMould.getSteps().entrySet().forEach((entry) -> { - result.addCommand(entry.getKey(), new Command(AppConstants.getScriptsFolderPath(), new Step( entry.getValue() ) ) ); + final Step step = entry.getValue(); + result.addCommand(entry.getKey(), step.getCommand() ); }); return result; } -- GitLab From 81d465eda4f8ab066a732480b249240991504203 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 10 Sep 2021 13:41:13 +0200 Subject: [PATCH 006/102] update Command.java --- src/main/java/ecorp/easy/installer/models/Command.java | 2 +- .../java/ecorp/easy/installer/tasks/DeviceDetectionTask.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/ecorp/easy/installer/models/Command.java b/src/main/java/ecorp/easy/installer/models/Command.java index 15a69925..c9f32aaa 100644 --- a/src/main/java/ecorp/easy/installer/models/Command.java +++ b/src/main/java/ecorp/easy/installer/models/Command.java @@ -61,7 +61,7 @@ public class Command { } /** - * Add a new parameter for the current command + * Map.put(key, value) a new parameter for the current command * @param key the key to identify the parameter in the list * @param value the value of the parameter */ diff --git a/src/main/java/ecorp/easy/installer/tasks/DeviceDetectionTask.java b/src/main/java/ecorp/easy/installer/tasks/DeviceDetectionTask.java index f49e59db..3a9f7874 100644 --- a/src/main/java/ecorp/easy/installer/tasks/DeviceDetectionTask.java +++ b/src/main/java/ecorp/easy/installer/tasks/DeviceDetectionTask.java @@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory; */ public class DeviceDetectionTask extends CommandExecutionTask{ final String CMD_adbDevices = "devices"; + private final static Logger logger = LoggerFactory.getLogger(DeviceDetectionTask.class); private final static Pattern LINEBREAK_PATTERN = Pattern.compile("\\R"); private final static Pattern SPACE_PATTERN = Pattern.compile("\\s+"); -- GitLab From 71818c05b9a9fc80e95181347040be0c1615b36a Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 10 Sep 2021 13:42:11 +0200 Subject: [PATCH 007/102] fix FlashThread & ThreadFactory to use Step.java & Command.java --- .../installer/tasks/CommandExecutionTask.java | 15 ++ .../easy/installer/threads/FlashThread.java | 154 +++++++++--------- .../easy/installer/threads/ThreadFactory.java | 9 +- 3 files changed, 91 insertions(+), 87 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java b/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java index 8d942cd9..19933eb1 100644 --- a/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java +++ b/src/main/java/ecorp/easy/installer/tasks/CommandExecutionTask.java @@ -125,4 +125,19 @@ public class CommandExecutionTask

extends Task

{ logger.debug("getFullCmd(), full command = {}", sb.toString()); return sb.toString(); } + + /* Getter */ + + public Command getCommand() { + return command; + } + + public String getShellOutput() { + return shellOutput; + } + + public int getExitCode() { + return exitCode; + } + } \ No newline at end of file diff --git a/src/main/java/ecorp/easy/installer/threads/FlashThread.java b/src/main/java/ecorp/easy/installer/threads/FlashThread.java index 4a9303bb..2bf54849 100644 --- a/src/main/java/ecorp/easy/installer/threads/FlashThread.java +++ b/src/main/java/ecorp/easy/installer/threads/FlashThread.java @@ -19,13 +19,17 @@ import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.models.Device; import ecorp.easy.installer.models.Command; import ecorp.easy.installer.models.DataBundle; +import ecorp.easy.installer.models.Step; import ecorp.easy.installer.models.StepUi; +import ecorp.easy.installer.tasks.CommandExecutionTask; import ecorp.easy.installer.utils.IFlashHandler; import javafx.application.Platform; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javafx.concurrent.Task; +import javafx.concurrent.Worker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,21 +53,22 @@ public class FlashThread extends Thread { final Device device; protected final Map commonParameters; // this is parameters that are define by a script output and that can be use as parameter by another script - protected final Map commands; + protected final Map steps; protected String currentStepCode = ""; - protected final String firstCommandKey; - + protected final String firstStepKey; + protected CommandExecutionTask currentCmdTask; + /** * Constructor for flashThread * @param controller This is the controller which change the UI depending on the flash thread result - * @param firstCommandKey The command key to use to get the first step to perform + * @param firstStepKey The command key to use to get the first step to perform * @param pauseLock a semaphor to stop allow to pause and restart the thread * @param device Object containing device info */ - public FlashThread(IFlashHandler controller, String firstCommandKey, Object pauseLock, Device device){ - this.commands = new HashMap<>(); + public FlashThread(IFlashHandler controller, String firstStepKey, Object pauseLock, Device device, Map steps){ + this.steps = steps; this.commonParameters = new HashMap<>(); - this.firstCommandKey = firstCommandKey; //this is the key of the command's hashmap + this.firstStepKey = firstStepKey; //this is the key of the command's hashmap this.application = controller; this.pauseLock = pauseLock; this.device = device; @@ -80,32 +85,22 @@ public class FlashThread extends Thread { this.commonParameters.put("JAVA_FOLDER_PATH", AppConstants.JavaHome); } - /** - * Add a command associated to a specific key - * @param key must unique or the value associated with will be replaced by new one - * @param command Command to add - */ - public void addCommand(String key, Command command){ - if(command != null && key!= null) - commands.put(key, command); - } - /** * Handle result of a command * @param command * @return boolean true is success false either */ - private boolean handleResult(final Command command){ + private boolean handleResult(final CommandExecutionTask cmdExecTask){ logger.info("handleResult()"); //read result from command object - final int exitValue = command.getExitValue(); - final String shellOutput = command.getShellOutput(); + final int exitValue = cmdExecTask.getExitCode(); + final String shellOutput = cmdExecTask.getShellOutput(); logger.debug(" Shell output= {}\nexit value = {}\n", shellOutput, exitValue); - if(command.isSuccess()){ - String outputKey = command.getOutputKey(); + if(cmdExecTask.getState().equals(Task.State.SUCCEEDED)){ + String outputKey = cmdExecTask.getCommand().getOutputKey(); //If an output is expected from succeed script if( outputKey != null && outputKey.charAt(0) == COMMON_PARAM_IDENTIFIER){ final int lastIndex = shellOutput.lastIndexOf("\n"); @@ -117,7 +112,7 @@ public class FlashThread extends Thread { return true; }else{ //fails case - String errorMsgKey = command.getErrorMsg(); + String errorMsgKey = cmdExecTask.getCommand().getErrorMsg(exitValue); if(errorMsgKey == null || errorMsgKey.isEmpty()){ errorMsgKey = "script_error_unknown"; } @@ -132,7 +127,6 @@ public class FlashThread extends Thread { * @param errorMsgKey the error message translation key to send to UI */ protected void showError(String errorMsgKey) { - //@TODO remove below specific code final DataBundle bundle = new DataBundle(); bundle.putString("errorMsgKey", errorMsgKey); //@Todo: put errorMsgKey as staticaly defined somewhere @@ -147,9 +141,8 @@ public class FlashThread extends Thread { */ synchronized public void cancel(boolean sendLog){ logger.info("cancel()"); - if(running && commands.containsKey(currentStepCode)){ //@TODO the second part of the test won't work, as we include some "error" steps. So the commands.size isn't good. - Command cmd = commands.get(currentStepCode); - if(cmd != null) cmd.cancel(); + if(running && steps.containsKey(currentStepCode)){ + if(currentCmdTask != null) currentCmdTask.cancel(); } else{ //if in success showError("flash_process_cancelled"); @@ -171,22 +164,19 @@ public class FlashThread extends Thread { /** * Execute some code before to execute the current command - * It is runned in the While loop which loops over commands - * It's executed in a Try catch. - * @throws java.lang.Exception */ - protected void doBeforeToRunCommand() throws Exception{ + protected void doBeforeToRunCommand(){ //Update UI - final Command cmd = commands.get(currentStepCode); + final Step step = steps.get(currentStepCode); final DataBundle bundle = new DataBundle(); //Prepare datas for UI - final String stepType = cmd.getNewUIValues().getType(); + final String stepType = step.getUI().getType(); bundle.putString("stepType", stepType); if( stepType.equals(AppConstants.USER_ACTION_KEY) || stepType.equals(AppConstants.LOAD_KEY)){ //UpdateUI - final StepUi newUIValues = (StepUi) cmd.getNewUIValues(); + final StepUi newUIValues = (StepUi) step.getUI(); if(newUIValues != null) { //@todo: Must define bundle key as a static String at a single place. if(stepType.equals(AppConstants.USER_ACTION_KEY)){ @@ -196,7 +186,7 @@ public class FlashThread extends Thread { } bundle.putString("stepTitle", newUIValues.getTitle()); bundle.putList("stepInstructions", String.class.getSimpleName(), newUIValues.getInstructions()); - bundle.putBoolean("hasScript", cmd.hasScript()); + bundle.putBoolean("hasScript", step.getCommand() != null); } } @@ -210,9 +200,8 @@ public class FlashThread extends Thread { * Execute some code after the current command has been * It is runned in the While loop which loops over commands * It's executed in a Try catch. - * @throws java.lang.Exception */ - protected void doAfterToRunCommand() throws Exception{ + protected void doAfterToRunCommand(){ atLeastOneError = (atLeastOneError || !success || cancelled); sendIssueLog = (atLeastOneError && !cancelled); } @@ -245,48 +234,57 @@ public class FlashThread extends Thread { }); } + /** + * Run a CommandExecutionTask + * @param stepKey + */ + private void runCommand(String stepKey){ + if(stepKey == null){ + onRunEnd(); + return; + } + final Step step = steps.get(stepKey); + final String stepType = step.getUI().getType(); + //UpdateUI + doBeforeToRunCommand(); + + if( step.getCommand() != null && + ( stepType.equals(AppConstants.USER_ACTION_KEY) || + stepType.equals(AppConstants.LOAD_KEY) ) ) + { + updateParameters(step.getCommand()); + + CommandExecutionTask cmdExecTask = new CommandExecutionTask(step.getCommand()); + cmdExecTask.setOnSucceeded( eh -> { + success = handleResult(cmdExecTask); + doAfterToRunCommand(); + runCommand(step.getAfterSuccess() ); + }); + + cmdExecTask.run(); + + }else{ + logger.debug("run a no script step. Waiting for user's validation"); + try{ + synchronized(pauseLock){ pauseLock.wait(); } + }catch( InterruptedException e){ + onErrorRaised(e); + return; + } + success = true; + runCommand(step.getAfterSuccess()); + } + } + + /** * @inheritDoc */ @Override public void run(){ - if(commands.isEmpty()) return; + if(steps.isEmpty()) return; running = true; - try{ - //execute scripts - String nextCommandKey = firstCommandKey; - while(nextCommandKey != null ){ - currentStepCode = nextCommandKey; - final Command cmd = commands.get(nextCommandKey); - final String stepType = cmd.getNewUIValues().getType(); - - //UpdateUI - doBeforeToRunCommand(); - - if( cmd.hasScript() && - ( stepType.equals(AppConstants.USER_ACTION_KEY) || - stepType.equals(AppConstants.LOAD_KEY) ) ) - { - - updateParameters(); - - logger.debug("Run(), Command = "+cmd.getCommand()); - cmd.execAndReadOutput(); - success = handleResult(cmd); - - doAfterToRunCommand(); - }else{ - logger.debug("run a no script step. Waiting for user's validation"); - synchronized(pauseLock){ pauseLock.wait(); } - success = true; - } - nextCommandKey = cmd.getNextCommandKey(); - } - - }catch(Exception e){ - onErrorRaised(e); - } - onRunEnd(); + runCommand(firstStepKey); } /** @@ -294,7 +292,7 @@ public class FlashThread extends Thread { * @return */ public int getCommandsSize(){ - return this.commands.size(); + return this.steps.size(); } @@ -302,18 +300,16 @@ public class FlashThread extends Thread { * Update parameters of the current command * It is called before to execute the command */ - protected void updateParameters(){ - final Command cmd = commands.get(currentStepCode); + protected void updateParameters(Command cmd){ + //Update Parameters if(cmd.getParameters() != null){ //@TODO: remove functionnal and rewrite it as it was before with simple loop. cmd.getParameters().entrySet().stream().filter((param) -> (param.getValue().contains("$"))).forEachOrdered((param) -> { Matcher matcher = REGEX_FIND_PARAM.matcher(param.getValue()); while(matcher.find()){ - cmd.updateParameter(param.getKey(), param.getValue().replace(matcher.group(0), commonParameters.get(matcher.group(1)))); + cmd.addParameter(param.getKey(), param.getValue().replace(matcher.group(0), commonParameters.get(matcher.group(1)))); } }); - - logger.debug("updateParameters(), Parameters = "+cmd.getParameters().toString()); } } } \ No newline at end of file diff --git a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java index 3add7bb3..c895df42 100644 --- a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java +++ b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java @@ -228,16 +228,9 @@ public class ThreadFactory { * @return FlashThread */ public FlashThread buildFlashThread( IFlashHandler application, Object pauseLock){ - if(flashMould == null || flashMould.getSteps() == null || device == null) return null; + FlashThread result = new FlashThread(application, "f1", pauseLock, device, flashMould.getSteps()); - FlashThread result = new FlashThread(application, "f1", pauseLock, device); - - - flashMould.getSteps().entrySet().forEach((entry) -> { - final Step step = entry.getValue(); - result.addCommand(entry.getKey(), step.getCommand() ); - }); return result; } -- GitLab From c18cae5959c898f65d02d36a1e4448cc99573ee2 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 10 Sep 2021 14:25:42 +0200 Subject: [PATCH 008/102] fix loading UI error --- .../java/ecorp/easy/installer/threads/FlashThread.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/threads/FlashThread.java b/src/main/java/ecorp/easy/installer/threads/FlashThread.java index 2bf54849..11fc4d82 100644 --- a/src/main/java/ecorp/easy/installer/threads/FlashThread.java +++ b/src/main/java/ecorp/easy/installer/threads/FlashThread.java @@ -165,9 +165,9 @@ public class FlashThread extends Thread { /** * Execute some code before to execute the current command */ - protected void doBeforeToRunCommand(){ + protected void doBeforeToRunCommand(final Step step){ + //Update UI - final Step step = steps.get(currentStepCode); final DataBundle bundle = new DataBundle(); //Prepare datas for UI @@ -243,10 +243,11 @@ public class FlashThread extends Thread { onRunEnd(); return; } + currentStepCode = stepKey; final Step step = steps.get(stepKey); final String stepType = step.getUI().getType(); //UpdateUI - doBeforeToRunCommand(); + doBeforeToRunCommand(step); if( step.getCommand() != null && ( stepType.equals(AppConstants.USER_ACTION_KEY) || @@ -303,7 +304,7 @@ public class FlashThread extends Thread { protected void updateParameters(Command cmd){ //Update Parameters - if(cmd.getParameters() != null){ //@TODO: remove functionnal and rewrite it as it was before with simple loop. + if(cmd.getParameters() != null){ cmd.getParameters().entrySet().stream().filter((param) -> (param.getValue().contains("$"))).forEachOrdered((param) -> { Matcher matcher = REGEX_FIND_PARAM.matcher(param.getValue()); while(matcher.find()){ -- GitLab From 9b9e4d18bb3aad2fbdc2fb3ba60eccaafb46eafd Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 10 Sep 2021 14:57:54 +0200 Subject: [PATCH 009/102] fix thread issue --- .../ecorp/easy/installer/threads/FlashThread.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/threads/FlashThread.java b/src/main/java/ecorp/easy/installer/threads/FlashThread.java index 11fc4d82..07898feb 100644 --- a/src/main/java/ecorp/easy/installer/threads/FlashThread.java +++ b/src/main/java/ecorp/easy/installer/threads/FlashThread.java @@ -167,6 +167,7 @@ public class FlashThread extends Thread { */ protected void doBeforeToRunCommand(final Step step){ + logger.debug("prepare data to update UI!"); //Update UI final DataBundle bundle = new DataBundle(); @@ -192,6 +193,7 @@ public class FlashThread extends Thread { //Update UI Platform.runLater(()->{ + logger.debug("update UI!"); application.onStepStart(bundle); }); } @@ -239,6 +241,7 @@ public class FlashThread extends Thread { * @param stepKey */ private void runCommand(String stepKey){ + logger.debug("runCommand (stepKey):"+stepKey); if(stepKey == null){ onRunEnd(); return; @@ -253,16 +256,20 @@ public class FlashThread extends Thread { ( stepType.equals(AppConstants.USER_ACTION_KEY) || stepType.equals(AppConstants.LOAD_KEY) ) ) { + updateParameters(step.getCommand()); - + logger.debug("runCommand updated param"); CommandExecutionTask cmdExecTask = new CommandExecutionTask(step.getCommand()); cmdExecTask.setOnSucceeded( eh -> { success = handleResult(cmdExecTask); doAfterToRunCommand(); runCommand(step.getAfterSuccess() ); }); - - cmdExecTask.run(); + logger.debug("runCommand ready to run"); + + Thread thread = new Thread(cmdExecTask); + thread.setDaemon(true); + thread.start(); }else{ logger.debug("run a no script step. Waiting for user's validation"); -- GitLab From 370a1595278e64a2f23e85b3e498d0ccca7b9cd2 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 14 Sep 2021 17:50:30 +0200 Subject: [PATCH 010/102] fix changing step at end of a step --- .../easy/installer/threads/FlashThread.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/threads/FlashThread.java b/src/main/java/ecorp/easy/installer/threads/FlashThread.java index c41d7549..dfa23179 100644 --- a/src/main/java/ecorp/easy/installer/threads/FlashThread.java +++ b/src/main/java/ecorp/easy/installer/threads/FlashThread.java @@ -93,7 +93,7 @@ public class FlashThread extends Thread { logger.debug(" Shell output= {}\nexit value = {}\n", shellOutput, exitValue); - if(cmdExecTask.getState().equals(Task.State.SUCCEEDED)){ + if(exitValue == 0){ String outputKey = cmdExecTask.getCommand().getOutputKey(); //If an output is expected from succeed script if( outputKey != null && outputKey.charAt(0) == COMMON_PARAM_IDENTIFIER){ @@ -181,11 +181,11 @@ public class FlashThread extends Thread { * Run a CommandExecutionTask * @param stepKey */ - private void runCommand(String stepKey){ + private boolean runCommand(String stepKey){ logger.debug("runCommand (stepKey):"+stepKey); if(stepKey == null){ onRunEnd(); - return; + return true; } currentStepCode = stepKey; final Step step = steps.get(stepKey); @@ -201,25 +201,27 @@ public class FlashThread extends Thread { updateParameters(step.getCommand()); logger.debug("runCommand updated param"); CommandExecutionTask cmdExecTask = new CommandExecutionTask(step.getCommand()); - cmdExecTask.setOnSucceeded( eh -> { - handleResult(cmdExecTask); - runCommand(step.getAfterSuccess() ); - }); logger.debug("runCommand ready to run"); - - Thread thread = new Thread(cmdExecTask); - thread.setDaemon(true); - thread.start(); - + cmdExecTask.setOnSucceeded(eh -> { + synchronized(pauseLock){ pauseLock.notify(); } + }); + cmdExecTask.run(); + try{ + synchronized(pauseLock){ pauseLock.wait(); } + }catch( InterruptedException e){ + logger.error("Java exception: "+ e.toString()); + return false; + } + return handleResult(cmdExecTask); }else{ logger.debug("run a no script step. Waiting for user's validation"); try{ synchronized(pauseLock){ pauseLock.wait(); } }catch( InterruptedException e){ logger.error("Java exception: "+ e.toString()); - return; + return false; } - runCommand(step.getAfterSuccess()); + return true; } } @@ -230,7 +232,13 @@ public class FlashThread extends Thread { @Override public void run(){ if(steps.isEmpty()) return; - runCommand(firstStepKey); + boolean success = true; + int stepPassed = 0; + currentStepCode = firstStepKey; + while(success && stepPassed++ < steps.size()){ + success = runCommand(currentStepCode); + if(success) currentStepCode = steps.get(currentStepCode).getAfterSuccess(); + } } /** -- GitLab From 0990ac41f79dd0424f3097e2b0540d34ef76cb55 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 14 Sep 2021 17:59:10 +0200 Subject: [PATCH 011/102] fix ending of flashThread after every command ran --- src/main/java/ecorp/easy/installer/threads/FlashThread.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ecorp/easy/installer/threads/FlashThread.java b/src/main/java/ecorp/easy/installer/threads/FlashThread.java index dfa23179..3a0211a9 100644 --- a/src/main/java/ecorp/easy/installer/threads/FlashThread.java +++ b/src/main/java/ecorp/easy/installer/threads/FlashThread.java @@ -184,7 +184,6 @@ public class FlashThread extends Thread { private boolean runCommand(String stepKey){ logger.debug("runCommand (stepKey):"+stepKey); if(stepKey == null){ - onRunEnd(); return true; } currentStepCode = stepKey; @@ -239,6 +238,7 @@ public class FlashThread extends Thread { success = runCommand(currentStepCode); if(success) currentStepCode = steps.get(currentStepCode).getAfterSuccess(); } + if(success) onRunEnd(); } /** -- GitLab From 022f5ba47703eb753d3b24d489223c010d7400d1 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 15 Sep 2021 11:49:27 +0200 Subject: [PATCH 012/102] fix UI in case of issue in flash thread --- .../controllers/subcontrollers/FlashSceneController.java | 5 +++++ src/main/resources/css/style.css | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java index 201ac8ca..69f085cb 100644 --- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java +++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java @@ -345,7 +345,12 @@ public class FlashSceneController extends AbstractSubSteppedController implement public void onFlashError(DataBundle db) { logger.warn("onFlashError()"); String errorMsgKey = db.getString("errorMsgKey"); + + //if load step + timeline.stop(); + loadStepProgressIndicator.getStyleClass().add("errorBar"); + if(errorMsgKey == null || errorMsgKey.isEmpty() || !i18n.containsKey(errorMsgKey)) errorMsgKey ="script_error_unknown"; stepTitleLabel.setText(i18n.getString(errorMsgKey)); diff --git a/src/main/resources/css/style.css b/src/main/resources/css/style.css index 8384590a..34537c3a 100644 --- a/src/main/resources/css/style.css +++ b/src/main/resources/css/style.css @@ -159,6 +159,10 @@ Button:pressed{ -fx-background-radius: 20; } +.errorBar .bar { + -fx-background-color: #be1e38; +} + #logScrollPane { -fx-background-color: #E5E5E5; -fx-border-color: #979797; -- GitLab From 4fdd9b0edc31b802224c93d58aa65dbd0b6f9139 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 15 Sep 2021 11:53:04 +0200 Subject: [PATCH 013/102] fix possible NPE on FlashSceneController --- .../controllers/subcontrollers/FlashSceneController.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java index 69f085cb..01f7b98b 100644 --- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java +++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java @@ -348,9 +348,11 @@ public class FlashSceneController extends AbstractSubSteppedController implement //if load step - timeline.stop(); - loadStepProgressIndicator.getStyleClass().add("errorBar"); - + if(timeline != null) { + timeline.stop(); + loadStepProgressIndicator.getStyleClass().add("errorBar"); + } + if(errorMsgKey == null || errorMsgKey.isEmpty() || !i18n.containsKey(errorMsgKey)) errorMsgKey ="script_error_unknown"; stepTitleLabel.setText(i18n.getString(errorMsgKey)); -- GitLab From 9215bf805bb2c7605b4435f5cb9ba67ed7cbb733 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 20 Sep 2021 16:29:59 +0200 Subject: [PATCH 014/102] add Step.java in steps package --- .../easy/installer/models/steps/Step.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/main/java/ecorp/easy/installer/models/steps/Step.java diff --git a/src/main/java/ecorp/easy/installer/models/steps/Step.java b/src/main/java/ecorp/easy/installer/models/steps/Step.java new file mode 100644 index 00000000..95dffa19 --- /dev/null +++ b/src/main/java/ecorp/easy/installer/models/steps/Step.java @@ -0,0 +1,65 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.models.steps; + +/** + * This class encapsulate basic data about a step of a process + * @idea: this class and subclass could define setters to allow to update ConfigParser + * and make it to be a builder design pattern + * @author Vincent Bourgmayer + */ +public class Step { + public final static String LAST_STEP_KEY = "L"; //When a next step key has this value, it means that this is the last step of the process + private final String type; + private final int stepNumber; //This is the number of the step in the process + private String nextStepKey; //This is the key to the next Step + + /** + * Create an instance of Step + * @param type the type of the step + * @param stepNumber the number of the step in the whole process + */ + public Step(String type, int stepNumber) { + this.type = type; + this.stepNumber = stepNumber; + } + + /** + * Get the type of the step + * @return + */ + public String getType() { + return type; + } + + /** + * Get the number of the step in the whole process + * @return e.g 1, which means 1/5 if there is 5 steps + * in the whole process + */ + public int getStepNumber() { + return stepNumber; + } + + /** + * get the key of the next step to call + * @return String + */ + public String getNextStepKey() { + return nextStepKey; + } + + /** + * Define the key of the next step to call. + * @param nextStepKey String if null, the value is then LAST_STEP_KEY's value. + */ + public void setNextStepKey(String nextStepKey) { + if( nextStepKey == null ) + this.nextStepKey = LAST_STEP_KEY; + else + this.nextStepKey = nextStepKey; + } +} -- GitLab From e879af877d0735a7f56a93166a4eb5bd962fee99 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 20 Sep 2021 16:56:35 +0200 Subject: [PATCH 015/102] add Step interfaces --- .../installer/models/steps/ICustomStep.java | 45 +++++++++++++++++++ .../models/steps/IExecutableStep.java | 32 +++++++++++++ .../easy/installer/models/steps/IStep.java | 35 +++++++++++++++ .../easy/installer/models/steps/Step.java | 5 ++- 4 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java create mode 100644 src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java create mode 100644 src/main/java/ecorp/easy/installer/models/steps/IStep.java diff --git a/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java b/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java new file mode 100644 index 00000000..69b53a48 --- /dev/null +++ b/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java @@ -0,0 +1,45 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.models.steps; + +import java.util.ArrayList; + +/** + * This interface describe a Step that could + * have UI content's define in config file: + * Title, title's icon, instructions, pictures + * + * This is basically a step where user have to + * do something on the phone + * @author vincent Bourgmayer + */ +public interface ICustomStep extends IStep{ + + /** + * Get the resources's key to get Title + * @return String + */ + public String getTitleKey(); + + /** + * Get the name of an images to use as icon + * associated with a title + * @return String + */ + public String getTitleIconName(); + + /** + * Get the keys of content (instructions and pictures) + * to load from resources + * @return ArrayList le list of keys + */ + public ArrayList getTextContentKeys(); + + @Override + default String getType(){ + return "action"; + } +} diff --git a/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java new file mode 100644 index 00000000..4644fcdb --- /dev/null +++ b/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.models.steps; + +import ecorp.easy.installer.models.Command; + +/** + * Represent a step where the computer + * has to run some command to + * interact with the phone + * + * Example is: detecting the phone, + * pushing content on the phone, ... + * @author vincent Bourgmayer + */ +public interface IExecutableStep extends IStep{ + /** + * Return the command to execute in background + * @return Command instance + */ + public Command getCommand(); + + /** + * Return the key of the next step to + * run in case of failure of the command + * @return + */ + public String getNextKoStepKey(); +} diff --git a/src/main/java/ecorp/easy/installer/models/steps/IStep.java b/src/main/java/ecorp/easy/installer/models/steps/IStep.java new file mode 100644 index 00000000..6214b9c5 --- /dev/null +++ b/src/main/java/ecorp/easy/installer/models/steps/IStep.java @@ -0,0 +1,35 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.models.steps; + +/** + * Just a trial + * Represent a basic Step type + * @author vincent + */ +public interface IStep { + public final static String LAST_STEP_KEY = "L"; //When a next step key has this value, it means that this is the last step of the process + + /** + * Get the type of the step + * @return + */ + public String getType(); + + /** + * Get the number of the step in the whole process + * @return e.g 1, which means 1/5 if there is 5 steps + * in the whole process + */ + public int getStepNumber(); + + /** + * get the key of the next step to call + * @return String + */ + public String getNextStepKey(); + +} diff --git a/src/main/java/ecorp/easy/installer/models/steps/Step.java b/src/main/java/ecorp/easy/installer/models/steps/Step.java index 95dffa19..91d86cef 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/Step.java +++ b/src/main/java/ecorp/easy/installer/models/steps/Step.java @@ -11,7 +11,7 @@ package ecorp.easy.installer.models.steps; * and make it to be a builder design pattern * @author Vincent Bourgmayer */ -public class Step { +public class Step implements IStep{ public final static String LAST_STEP_KEY = "L"; //When a next step key has this value, it means that this is the last step of the process private final String type; private final int stepNumber; //This is the number of the step in the process @@ -31,6 +31,7 @@ public class Step { * Get the type of the step * @return */ + @Override public String getType() { return type; } @@ -40,6 +41,7 @@ public class Step { * @return e.g 1, which means 1/5 if there is 5 steps * in the whole process */ + @Override public int getStepNumber() { return stepNumber; } @@ -48,6 +50,7 @@ public class Step { * get the key of the next step to call * @return String */ + @Override public String getNextStepKey() { return nextStepKey; } -- GitLab From c07fccaef267956eecf69b9376f79a578aeb923a Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 20 Sep 2021 17:15:31 +0200 Subject: [PATCH 016/102] rename steps.Step into steps.BasicStep. Implement CustomStep --- .../steps/{Step.java => BasicStep.java} | 17 +------ .../installer/models/steps/CustomStep.java | 47 +++++++++++++++++++ 2 files changed, 49 insertions(+), 15 deletions(-) rename src/main/java/ecorp/easy/installer/models/steps/{Step.java => BasicStep.java} (80%) create mode 100644 src/main/java/ecorp/easy/installer/models/steps/CustomStep.java diff --git a/src/main/java/ecorp/easy/installer/models/steps/Step.java b/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java similarity index 80% rename from src/main/java/ecorp/easy/installer/models/steps/Step.java rename to src/main/java/ecorp/easy/installer/models/steps/BasicStep.java index 91d86cef..b96f4f4e 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/Step.java +++ b/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java @@ -11,7 +11,7 @@ package ecorp.easy.installer.models.steps; * and make it to be a builder design pattern * @author Vincent Bourgmayer */ -public class Step implements IStep{ +public class BasicStep implements IStep{ public final static String LAST_STEP_KEY = "L"; //When a next step key has this value, it means that this is the last step of the process private final String type; private final int stepNumber; //This is the number of the step in the process @@ -22,34 +22,21 @@ public class Step implements IStep{ * @param type the type of the step * @param stepNumber the number of the step in the whole process */ - public Step(String type, int stepNumber) { + public BasicStep(String type, int stepNumber) { this.type = type; this.stepNumber = stepNumber; } - /** - * Get the type of the step - * @return - */ @Override public String getType() { return type; } - /** - * Get the number of the step in the whole process - * @return e.g 1, which means 1/5 if there is 5 steps - * in the whole process - */ @Override public int getStepNumber() { return stepNumber; } - /** - * get the key of the next step to call - * @return String - */ @Override public String getNextStepKey() { return nextStepKey; diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java new file mode 100644 index 00000000..d8d88edd --- /dev/null +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java @@ -0,0 +1,47 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.models.steps; + +import java.util.ArrayList; + +/** + * This class represent a step with some instructions + * but WITHOUT script or command to run + * @author vincent Bourgmayer + */ +public class CustomStep extends BasicStep implements ICustomStep{ + + private String titleKey; + private String titleIconName; + private ArrayList textContentKeys; + + public CustomStep(String type, int stepNumber, String titleKey, String titleIconName, ArrayList contentKeys) { + super(type, stepNumber); + this.titleKey = titleKey; + this.titleIconName = titleIconName; + this.textContentKeys = contentKeys; + } + + @Override + public String getTitleKey() { + return this.titleKey; + } + + @Override + public String getTitleIconName() { + return this.titleIconName; + } + + @Override + public ArrayList getTextContentKeys() { + return this.textContentKeys; + } + + @Override + public String getType() { + return ICustomStep.super.getType(); //To change body of generated methods, choose Tools | Templates. + } +} -- GitLab From e70037a1c61e39852a8cae6ef6037212ed41d46d Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 20 Sep 2021 17:21:36 +0200 Subject: [PATCH 017/102] add ExecutableStep.java --- .../models/steps/ExecutableStep.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java diff --git a/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java new file mode 100644 index 00000000..8fd493ea --- /dev/null +++ b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java @@ -0,0 +1,36 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.models.steps; + +import ecorp.easy.installer.models.Command; + +/** + * This concern step with Fixed UI + * but which run command in Background + * E.g :Device detection + * @author vincent Bourgmayer + */ +public class ExecutableStep extends BasicStep implements IExecutableStep{ + + private Command command; + private String nextKoStepKey; + + public ExecutableStep(String type, int stepNumber, String nextKoStepKey, Command command) { + super(type, stepNumber); + this.command = command; + this.nextKoStepKey = nextKoStepKey; + } + + @Override + public Command getCommand() { + return command; + } + + @Override + public String getNextKoStepKey() { + return this.nextKoStepKey; + } +} -- GitLab From b9f671c109b90344556be5b889b083055e43e769 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 20 Sep 2021 17:29:18 +0200 Subject: [PATCH 018/102] add CustomExecutableStep.java --- .../models/steps/CustomExecutableStep.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java new file mode 100644 index 00000000..d7bb3690 --- /dev/null +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java @@ -0,0 +1,53 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.models.steps; + +import ecorp.easy.installer.models.Command; +import java.util.ArrayList; + +/** + * + * @author vincent + */ +public class CustomExecutableStep extends BasicStep implements ICustomStep, IExecutableStep{ + + private Command command; + private String nextKoStepKey; + private String titleKey; + private String titleIconName; + private ArrayList textContentKeys; + + public CustomExecutableStep(String type, int stepNumber, + String nextKoStepKey, String titleKey, String titleIconName, + ArrayList contentKeys, Command command) { + super(type, stepNumber); + this.nextKoStepKey = nextKoStepKey; + this.titleKey = titleKey; + this.titleIconName = titleIconName; + this.command = command; + this.textContentKeys = contentKeys; + } + + @Override + public String getType(){ + return ICustomStep.super.getType(); + } + + @Override + public String getTitleKey() { return this.titleKey; } + + @Override + public String getTitleIconName() { return this.titleIconName; } + + @Override + public ArrayList getTextContentKeys() { return this.textContentKeys; } + + @Override + public Command getCommand() { return this.command; } + + @Override + public String getNextKoStepKey() { return this.nextKoStepKey; } +} -- GitLab From a4a56b6d5936e7b1bd17e8f18f07cab8a0e35a4b Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 20 Sep 2021 17:34:52 +0200 Subject: [PATCH 019/102] add LoadStep.java --- .../easy/installer/models/steps/LoadStep.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/ecorp/easy/installer/models/steps/LoadStep.java diff --git a/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java b/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java new file mode 100644 index 00000000..ec9e24dd --- /dev/null +++ b/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java @@ -0,0 +1,40 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.models.steps; + +import ecorp.easy.installer.models.Command; +import java.util.ArrayList; + +/** + * This encapsulate Step where user have to wait for + * a background job to be done, and where a ProgressIndicator + * is present + * @author vincent Bourgmayer + */ +public class LoadStep extends CustomExecutableStep{ + private int averageTime; //Used to fill the ProgressIndicator in UI + + public LoadStep(String type, int stepNumber, String nextKoStepKey, String titleKey, String titleIconName, ArrayList contentKeys, Command command) { + super(type, stepNumber, nextKoStepKey, titleKey, titleIconName, contentKeys, command); + } + + /** + * Get the average time of execution for the background task + * @return int amount in second + */ + public int getAverageTime() { + return averageTime; + } + + public void setAverageTime(int averageTime) { + this.averageTime = averageTime; + } + + @Override + public String getType(){ + return "load"; + } +} -- GitLab From 55d71c27208f61296d28cdfebd0356f01512f19c Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 20 Sep 2021 17:59:24 +0200 Subject: [PATCH 020/102] start to implement ConfigParse.java and update StepClass to add missing param in constructor --- .../installer/models/steps/BasicStep.java | 6 +- .../models/steps/CustomExecutableStep.java | 4 +- .../installer/models/steps/CustomStep.java | 9 +- .../models/steps/ExecutableStep.java | 4 +- .../easy/installer/models/steps/LoadStep.java | 5 +- .../easy/installer/utils/ConfigParser.java | 126 ++++++++++++++++++ 6 files changed, 139 insertions(+), 15 deletions(-) create mode 100644 src/main/java/ecorp/easy/installer/utils/ConfigParser.java diff --git a/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java b/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java index b96f4f4e..dbaf6768 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java @@ -15,18 +15,20 @@ public class BasicStep implements IStep{ public final static String LAST_STEP_KEY = "L"; //When a next step key has this value, it means that this is the last step of the process private final String type; private final int stepNumber; //This is the number of the step in the process - private String nextStepKey; //This is the key to the next Step + protected String nextStepKey; //This is the key to the next Step /** * Create an instance of Step * @param type the type of the step * @param stepNumber the number of the step in the whole process */ - public BasicStep(String type, int stepNumber) { + public BasicStep(String type, String nextStepKey, int stepNumber) { this.type = type; + this.nextStepKey = nextStepKey; this.stepNumber = stepNumber; } + @Override public String getType() { return type; diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java index d7bb3690..a3df005c 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java @@ -20,10 +20,10 @@ public class CustomExecutableStep extends BasicStep implements ICustomStep, IExe private String titleIconName; private ArrayList textContentKeys; - public CustomExecutableStep(String type, int stepNumber, + public CustomExecutableStep(String type, String nextStepKey, int stepNumber, String nextKoStepKey, String titleKey, String titleIconName, ArrayList contentKeys, Command command) { - super(type, stepNumber); + super(type, nextStepKey, stepNumber); this.nextKoStepKey = nextKoStepKey; this.titleKey = titleKey; this.titleIconName = titleIconName; diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java index d8d88edd..d6de5184 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java @@ -18,8 +18,8 @@ public class CustomStep extends BasicStep implements ICustomStep{ private String titleIconName; private ArrayList textContentKeys; - public CustomStep(String type, int stepNumber, String titleKey, String titleIconName, ArrayList contentKeys) { - super(type, stepNumber); + public CustomStep(String type, String nextStepKey, int stepNumber, String titleKey, String titleIconName, ArrayList contentKeys) { + super(type, nextStepKey, stepNumber); this.titleKey = titleKey; this.titleIconName = titleIconName; this.textContentKeys = contentKeys; @@ -39,9 +39,4 @@ public class CustomStep extends BasicStep implements ICustomStep{ public ArrayList getTextContentKeys() { return this.textContentKeys; } - - @Override - public String getType() { - return ICustomStep.super.getType(); //To change body of generated methods, choose Tools | Templates. - } } diff --git a/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java index 8fd493ea..dcf1134a 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java @@ -18,8 +18,8 @@ public class ExecutableStep extends BasicStep implements IExecutableStep{ private Command command; private String nextKoStepKey; - public ExecutableStep(String type, int stepNumber, String nextKoStepKey, Command command) { - super(type, stepNumber); + public ExecutableStep(String type, String nextStepKey, int stepNumber, String nextKoStepKey, Command command) { + super(type, nextStepKey, stepNumber); this.command = command; this.nextKoStepKey = nextKoStepKey; } diff --git a/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java b/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java index ec9e24dd..387e5858 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java @@ -17,8 +17,9 @@ import java.util.ArrayList; public class LoadStep extends CustomExecutableStep{ private int averageTime; //Used to fill the ProgressIndicator in UI - public LoadStep(String type, int stepNumber, String nextKoStepKey, String titleKey, String titleIconName, ArrayList contentKeys, Command command) { - super(type, stepNumber, nextKoStepKey, titleKey, titleIconName, contentKeys, command); + public LoadStep(String type, String nextStepKey, int stepNumber, String nextKoStepKey, String titleKey, String titleIconName, ArrayList contentKeys, Command command, int averageTime) { + super(type, nextStepKey, stepNumber, nextKoStepKey, titleKey, titleIconName, contentKeys, command); + this.averageTime = averageTime; } /** diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java new file mode 100644 index 00000000..05dd7ea7 --- /dev/null +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -0,0 +1,126 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.utils; + +import ecorp.easy.installer.models.Command; +import ecorp.easy.installer.models.steps.BasicStep; +import ecorp.easy.installer.models.steps.IStep; +import ecorp.easy.installer.models.steps.LoadStep; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Class in charge of parsing yaml config file + * into IStep's implementation + * @author vincent Bourgmayer + */ +public class ConfigParser { + private final static Logger logger = LoggerFactory.getLogger(ConfigParser.class); + + /** + * Create a single Step instance from a Map containing yaml content + * @param yaml + * @return + * @throws ParseException + * @throws NumberFormatException + */ + public static IStep parseStep(Map yaml) throws ParseException, NumberFormatException{ + logger.debug("parseStep(yaml)"); + IStep result = null; + + String type = (String) yaml.get("type"); + logger.debug("--step type:"+type); + switch(type){ + case "load": + result = parseLoadStep(yaml, type); + // example: twrp or /e/ installation + break; + case "custom": + result = parseCustomStep(yaml, type); + // Example: enable DevOption, enable ADB, enable MTP + // S9: OEM unlock + // FP3: update phone & oem unlock + // GS290 update stockrom + break; + case "custom-executable": + result = parseExecutableCustomStep(yaml, type); + //Example: reboot from download mode into twrp, etc. + break; + case "executable": + //Example: Device detection + break; + default: + result = parseBasicStep(yaml, type); + break; + } + return result; + } + + /** + * create a basic step from yaml. + * This is perfect to integrate fixed step like deviceDetection + * @param yaml the yaml input + * @param type type of the step + * @return Step object with nextStepKey, stepNumber and type + */ + private static BasicStep parseBasicStep(Map yaml, String type) throws ParseException, NumberFormatException{ + final int stepNumber = (Integer)yaml.get("stepNumber"); + final String nextStepKey = (String) yaml.get("nextStepKey"); + + return new BasicStep(type, nextStepKey, stepNumber); + } + + /** + * Parse yaml content into Command object + * @param yaml Map yaml content + * @return Command object + */ + private static Command parseCommand(Map yaml) throws ParseException, NumberFormatException{ + final String commandBase = (String) yaml.get("script"); + //@TODO: uncomment belows when Command and CommandExecution will be separated + + //final String outputKey = (String) yaml.get("outputKey"); + //final HashMap parameters = (HashMap) yaml.get("parameters"); + //final HashMap okCodes = (HashMap) yaml.get("okCodes"); + //final HashMap koCodes = (HashMap) yaml.get("koCodes"); + + final Command result = new Command(commandBase/*, parameters*/); + //result.setOkCodes(okCodes); + //result.setKoCodes(koCodes); + //if(outputKey != null) result.setOutputKey(outputKey); + + return result; + } + + + /** + * Parse yaml content into LoadStep + * example of this kind of step is /e/ or TWRP installation + * @param yaml yaml content + * @param type Type of step + * @return LoadStep the step + */ + private static LoadStep parseLoadStep(Map yaml, String type) throws ParseException, NumberFormatException{ + final int stepNumber = (Integer)yaml.get("stepNumber"); + final String nextStepKey = (String) yaml.get("succeed"); + final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); + final String titleKey = (String) yaml.get("title"); + final String titleIconName = (String) yaml.get("titleIcon"); + final ArrayList instructions = (ArrayList) yaml.get("instructions"); + final int averageTime = (Integer) yaml.get("averageTime"); + + final Command cmd = parseCommand(yaml); + LoadStep result = new LoadStep(type, nextStepKey, stepNumber , nextKoStepKey, + titleKey, titleIconName, instructions, cmd, averageTime); + return result; + } + + +} -- GitLab From e9fbdd53f362c1d858e7447ff810f62c80c78a75 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 09:52:55 +0200 Subject: [PATCH 021/102] add missing method in config parser --- .../easy/installer/utils/ConfigParser.java | 91 ++++++++++++++++--- 1 file changed, 78 insertions(+), 13 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index 05dd7ea7..cf2d8625 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -7,11 +7,15 @@ package ecorp.easy.installer.utils; import ecorp.easy.installer.models.Command; import ecorp.easy.installer.models.steps.BasicStep; +import ecorp.easy.installer.models.steps.CustomExecutableStep; +import ecorp.easy.installer.models.steps.CustomStep; +import ecorp.easy.installer.models.steps.ExecutableStep; import ecorp.easy.installer.models.steps.IStep; import ecorp.easy.installer.models.steps.LoadStep; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,6 +58,7 @@ public class ConfigParser { //Example: reboot from download mode into twrp, etc. break; case "executable": + result = parseExecutableStep(yaml, type); //Example: Device detection break; default: @@ -77,6 +82,68 @@ public class ConfigParser { return new BasicStep(type, nextStepKey, stepNumber); } + + /** + * Parse yaml content into LoadStep + * example of this kind of step is /e/ or TWRP installation + * @param yaml yaml content + * @param type Type of step + * @return LoadStep the step + */ + private static LoadStep parseLoadStep(Map yaml, String type) throws ParseException, NumberFormatException{ + final int stepNumber = (Integer)yaml.get("stepNumber"); + final String nextStepKey = (String) yaml.get("succeed"); + final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); + final String titleKey = (String) yaml.get("title"); + final String titleIconName = (String) yaml.get("titleIcon"); + final ArrayList instructions = (ArrayList) yaml.get("instructions"); + final int averageTime = (Integer) yaml.get("averageTime"); + + final Command cmd = parseCommand(yaml); + LoadStep result = new LoadStep(type, nextStepKey, stepNumber , nextKoStepKey, + titleKey, titleIconName, instructions, cmd, averageTime); + return result; + } + + /** + * Parse yaml content into CustomStep object + * Example of this kind of test is when you tell + * the user to enable developer mode. + * @param yaml Map yaml content + * @param type Type of step + * @return CustomStep object + */ + private static CustomStep parseCustomStep(Map yaml, String type) throws ParseException, NumberFormatException{ + logger.debug("parseCustomStep(yaml)"); + int stepNumber = (Integer)yaml.get("stepNumber"); + String nextStepKey = (String) yaml.get("nextStepKey"); + String titleKey = (String) yaml.get("title"); + String titleIconName = (String) yaml.get("titleIcon"); + ArrayList instructions = (ArrayList) yaml.get("instructions"); + + CustomStep result = new CustomStep(type, nextStepKey, stepNumber, titleKey, titleIconName, instructions); + return result; + } + + /** + * Parse yaml content into ExecutableStep + * example of this kind of step is the step + * to detect device + * @param yaml yaml content + * @param type Type of step + * @return ExecutableStep the step + */ + private static ExecutableStep parseExecutableStep(Map yaml, String type) throws ParseException, NumberFormatException{ + final int stepNumber = (Integer)yaml.get("stepNumber"); + final String nextStepKey = (String) yaml.get("succeed"); + final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); + + final Command cmd = parseCommand(yaml); + ExecutableStep result = new ExecutableStep(type, nextStepKey, stepNumber, + nextKoStepKey, cmd); + return result; + } + /** * Parse yaml content into Command object * @param yaml Map yaml content @@ -98,29 +165,27 @@ public class ConfigParser { return result; } - - /** - * Parse yaml content into LoadStep - * example of this kind of step is /e/ or TWRP installation + /** + * Parse yaml content into ExecutableCustomStep + * example of this kind of step is the step on + * Samsung galaxy device when user must leave + * download mode to start on TWRP * @param yaml yaml content * @param type Type of step - * @return LoadStep the step + * @return ExecutableCustomStep the step */ - private static LoadStep parseLoadStep(Map yaml, String type) throws ParseException, NumberFormatException{ + private static CustomExecutableStep parseExecutableCustomStep(Map yaml, String type) throws ParseException, NumberFormatException{ final int stepNumber = (Integer)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("succeed"); final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); final String titleKey = (String) yaml.get("title"); final String titleIconName = (String) yaml.get("titleIcon"); final ArrayList instructions = (ArrayList) yaml.get("instructions"); - final int averageTime = (Integer) yaml.get("averageTime"); - + final Command cmd = parseCommand(yaml); - LoadStep result = new LoadStep(type, nextStepKey, stepNumber , nextKoStepKey, - titleKey, titleIconName, instructions, cmd, averageTime); + CustomExecutableStep result = new CustomExecutableStep(type, nextStepKey, stepNumber, + nextKoStepKey, titleKey, titleIconName, instructions, cmd); return result; - } - - + } } -- GitLab From 528ac0ba6684f3df143ceb1f29265af79e74fb7b Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 10:32:50 +0200 Subject: [PATCH 022/102] add comment, set some fields final in steps class --- .../models/steps/CustomExecutableStep.java | 10 +++++----- .../easy/installer/models/steps/CustomStep.java | 6 +++--- .../installer/models/steps/ExecutableStep.java | 4 ++-- .../ecorp/easy/installer/models/steps/IStep.java | 14 ++++++++++++-- .../ecorp/easy/installer/utils/ConfigParser.java | 8 ++++---- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java index a3df005c..bac3a05e 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java @@ -14,11 +14,11 @@ import java.util.ArrayList; */ public class CustomExecutableStep extends BasicStep implements ICustomStep, IExecutableStep{ - private Command command; - private String nextKoStepKey; - private String titleKey; - private String titleIconName; - private ArrayList textContentKeys; + private final Command command; + private final String nextKoStepKey; + private final String titleKey; + private final String titleIconName; + private final ArrayList textContentKeys; public CustomExecutableStep(String type, String nextStepKey, int stepNumber, String nextKoStepKey, String titleKey, String titleIconName, diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java index d6de5184..d5d9631b 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java @@ -14,9 +14,9 @@ import java.util.ArrayList; */ public class CustomStep extends BasicStep implements ICustomStep{ - private String titleKey; - private String titleIconName; - private ArrayList textContentKeys; + private final String titleKey; + private final String titleIconName; + private final ArrayList textContentKeys; public CustomStep(String type, String nextStepKey, int stepNumber, String titleKey, String titleIconName, ArrayList contentKeys) { super(type, nextStepKey, stepNumber); diff --git a/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java index dcf1134a..71ed195b 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java @@ -15,8 +15,8 @@ import ecorp.easy.installer.models.Command; */ public class ExecutableStep extends BasicStep implements IExecutableStep{ - private Command command; - private String nextKoStepKey; + private final Command command; + private final String nextKoStepKey; public ExecutableStep(String type, String nextStepKey, int stepNumber, String nextKoStepKey, Command command) { super(type, nextStepKey, stepNumber); diff --git a/src/main/java/ecorp/easy/installer/models/steps/IStep.java b/src/main/java/ecorp/easy/installer/models/steps/IStep.java index 6214b9c5..0bb84a33 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/IStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/IStep.java @@ -6,8 +6,19 @@ package ecorp.easy.installer.models.steps; /** - * Just a trial * Represent a basic Step type + * + * Below comment also apply for child interface + * + * It doesn't include setter signature because + * without the only place where they could be used + * is in configParser and since we have constructor it's useless + * Moreover, it allow to set most of the implementation field "final" + * + * However, if class current implementation should evolve, it will be + * a pain to update constructor method to handle new field. + * So we could consider, if we feel the need to add those setters + * in interface definition in future. This isn't a closed Topic. * @author vincent */ public interface IStep { @@ -31,5 +42,4 @@ public interface IStep { * @return String */ public String getNextStepKey(); - } diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index cf2d8625..99a5b9c1 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -105,7 +105,7 @@ public class ConfigParser { return result; } - /** + /** * Parse yaml content into CustomStep object * Example of this kind of test is when you tell * the user to enable developer mode. @@ -125,7 +125,7 @@ public class ConfigParser { return result; } - /** + /** * Parse yaml content into ExecutableStep * example of this kind of step is the step * to detect device @@ -144,7 +144,7 @@ public class ConfigParser { return result; } - /** + /** * Parse yaml content into Command object * @param yaml Map yaml content * @return Command object @@ -166,7 +166,7 @@ public class ConfigParser { return result; } - /** + /** * Parse yaml content into ExecutableCustomStep * example of this kind of step is the step on * Samsung galaxy device when user must leave -- GitLab From 0688b068d08c4310742616c34b7abee9e9c95e32 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 10:56:45 +0200 Subject: [PATCH 023/102] add test resources for ConfigParser --- .../easy/installer/utils/ConfigParser.java | 11 +++- src/test/resources/yaml/parsingTest.yml | 64 +++++++++++++++++++ 2 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/yaml/parsingTest.yml diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index 99a5b9c1..6c86d255 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -23,6 +23,11 @@ import org.slf4j.LoggerFactory; /** * Class in charge of parsing yaml config file * into IStep's implementation + * + * I wonder, if I should make it a singleton... + * This class is perfect candidate for unit test + * however, since its methods are static it might + * cause a problem (I'm thinking of mocking) * @author vincent Bourgmayer */ public class ConfigParser { @@ -31,7 +36,7 @@ public class ConfigParser { /** * Create a single Step instance from a Map containing yaml content * @param yaml - * @return + * @return the IStep implementation's instance * @throws ParseException * @throws NumberFormatException */ @@ -54,7 +59,7 @@ public class ConfigParser { // GS290 update stockrom break; case "custom-executable": - result = parseExecutableCustomStep(yaml, type); + result = parseCustomExecutableStep(yaml, type); //Example: reboot from download mode into twrp, etc. break; case "executable": @@ -175,7 +180,7 @@ public class ConfigParser { * @param type Type of step * @return ExecutableCustomStep the step */ - private static CustomExecutableStep parseExecutableCustomStep(Map yaml, String type) throws ParseException, NumberFormatException{ + private static CustomExecutableStep parseCustomExecutableStep(Map yaml, String type) throws ParseException, NumberFormatException{ final int stepNumber = (Integer)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("succeed"); final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); diff --git a/src/test/resources/yaml/parsingTest.yml b/src/test/resources/yaml/parsingTest.yml new file mode 100644 index 00000000..93eb7f18 --- /dev/null +++ b/src/test/resources/yaml/parsingTest.yml @@ -0,0 +1,64 @@ +## YAML Template. +--- +stepsCount: 2 +steps: + f0: + type: basic + stepNumber: 1 + nextStepKey: f1 + f1: + type: custom + stepNumber: 2 + nextStepKey: f2 + titleKey: test_title_test1 + titleIconName: test.png + instructions: + - test_lbl_test1 + - test_lbl_test2 + - test_lbl_test3 + f3: + type: executable + stepNumber: 3 + nextStepKey: f4 + script: test + outputKey: myTestVar + nextKoStepKey: ~ + okCodes: + 0: test_lbl_cmdSuccess + koCodes: + 1: test_lbl_cmdFailure + f4: + type: custom-executable + stepNumber: 3 + nextStepKey: f4 + titleKey: test_title_test1 + titleIconName: test.png + instructions: + - test_lbl_test1 + - test_lbl_test2 + - test_lbl_test3 + script: test + outputKey: myTestVar + nextKoStepKey: ~ + okCodes: + 0: test_lbl_cmdSuccess + koCodes: + 1: test_lbl_cmdFailure + f5: + type: load + stepNumber: 3 + nextStepKey: f5 + titleKey: test_title_test1 + titleIconName: test.png + instructions: + - test_lbl_test1 + - test_lbl_test2 + - test_lbl_test3 + script: test + outputKey: myTestVar + nextKoStepKey: ~ + okCodes: + 0: test_lbl_cmdSuccess + koCodes: + 1: test_lbl_cmdFailure + averageTime: 25 \ No newline at end of file -- GitLab From 1c0557f7a767a90ec7d7328c60b00781877be1b3 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 12:02:57 +0200 Subject: [PATCH 024/102] add unit test for ConfigParser and fixed issue thanks to them --- .../easy/installer/utils/ConfigParser.java | 30 ++-- .../installer/utils/ConfigParserTest.java | 156 ++++++++++++++++++ 2 files changed, 171 insertions(+), 15 deletions(-) create mode 100644 src/test/java/ecorp/easy/installer/utils/ConfigParserTest.java diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index 6c86d255..0047f543 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -40,7 +40,7 @@ public class ConfigParser { * @throws ParseException * @throws NumberFormatException */ - public static IStep parseStep(Map yaml) throws ParseException, NumberFormatException{ + public static IStep parseStep(Map yaml) throws ParseException, NumberFormatException, NullPointerException{ logger.debug("parseStep(yaml)"); IStep result = null; @@ -80,8 +80,8 @@ public class ConfigParser { * @param type type of the step * @return Step object with nextStepKey, stepNumber and type */ - private static BasicStep parseBasicStep(Map yaml, String type) throws ParseException, NumberFormatException{ - final int stepNumber = (Integer)yaml.get("stepNumber"); + private static BasicStep parseBasicStep(Map yaml, String type) throws ParseException, ClassCastException{ + final int stepNumber = (int) yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("nextStepKey"); return new BasicStep(type, nextStepKey, stepNumber); @@ -95,14 +95,14 @@ public class ConfigParser { * @param type Type of step * @return LoadStep the step */ - private static LoadStep parseLoadStep(Map yaml, String type) throws ParseException, NumberFormatException{ - final int stepNumber = (Integer)yaml.get("stepNumber"); + private static LoadStep parseLoadStep(Map yaml, String type) throws ParseException, ClassCastException{ + final int stepNumber = (int)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("succeed"); final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); final String titleKey = (String) yaml.get("title"); final String titleIconName = (String) yaml.get("titleIcon"); final ArrayList instructions = (ArrayList) yaml.get("instructions"); - final int averageTime = (Integer) yaml.get("averageTime"); + final int averageTime = (int) yaml.get("averageTime"); final Command cmd = parseCommand(yaml); LoadStep result = new LoadStep(type, nextStepKey, stepNumber , nextKoStepKey, @@ -118,9 +118,9 @@ public class ConfigParser { * @param type Type of step * @return CustomStep object */ - private static CustomStep parseCustomStep(Map yaml, String type) throws ParseException, NumberFormatException{ + private static CustomStep parseCustomStep(Map yaml, String type) throws ParseException, ClassCastException{ logger.debug("parseCustomStep(yaml)"); - int stepNumber = (Integer)yaml.get("stepNumber"); + int stepNumber = (int)yaml.get("stepNumber"); String nextStepKey = (String) yaml.get("nextStepKey"); String titleKey = (String) yaml.get("title"); String titleIconName = (String) yaml.get("titleIcon"); @@ -138,8 +138,8 @@ public class ConfigParser { * @param type Type of step * @return ExecutableStep the step */ - private static ExecutableStep parseExecutableStep(Map yaml, String type) throws ParseException, NumberFormatException{ - final int stepNumber = (Integer)yaml.get("stepNumber"); + private static ExecutableStep parseExecutableStep(Map yaml, String type) throws ParseException, ClassCastException{ + final int stepNumber = (int)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("succeed"); final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); @@ -154,14 +154,14 @@ public class ConfigParser { * @param yaml Map yaml content * @return Command object */ - private static Command parseCommand(Map yaml) throws ParseException, NumberFormatException{ + private static Command parseCommand(Map yaml) throws ParseException, ClassCastException{ final String commandBase = (String) yaml.get("script"); //@TODO: uncomment belows when Command and CommandExecution will be separated //final String outputKey = (String) yaml.get("outputKey"); //final HashMap parameters = (HashMap) yaml.get("parameters"); - //final HashMap okCodes = (HashMap) yaml.get("okCodes"); - //final HashMap koCodes = (HashMap) yaml.get("koCodes"); + //final HashMap okCodes = (HashMap) yaml.get("okCodes"); + //final HashMap koCodes = (HashMap) yaml.get("koCodes"); final Command result = new Command(commandBase/*, parameters*/); //result.setOkCodes(okCodes); @@ -180,8 +180,8 @@ public class ConfigParser { * @param type Type of step * @return ExecutableCustomStep the step */ - private static CustomExecutableStep parseCustomExecutableStep(Map yaml, String type) throws ParseException, NumberFormatException{ - final int stepNumber = (Integer)yaml.get("stepNumber"); + private static CustomExecutableStep parseCustomExecutableStep(Map yaml, String type) throws ParseException, ClassCastException{ + final int stepNumber = (int)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("succeed"); final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); final String titleKey = (String) yaml.get("title"); diff --git a/src/test/java/ecorp/easy/installer/utils/ConfigParserTest.java b/src/test/java/ecorp/easy/installer/utils/ConfigParserTest.java new file mode 100644 index 00000000..13684ec8 --- /dev/null +++ b/src/test/java/ecorp/easy/installer/utils/ConfigParserTest.java @@ -0,0 +1,156 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ecorp.easy.installer.utils; + +import ecorp.easy.installer.models.steps.IStep; +import java.text.ParseException; +import java.util.HashMap; +import java.util.Map; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * What to test: Mainly parsing result + * Try to use invalid type. By example: + * Trying to parse data as String instead of int + * + * Question: Do I need to parse a real config file + * or can I just create Map instance with data ? + * @author vincent Bourgmayer + */ +public class ConfigParserTest { + + public ConfigParserTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of parseStep method, of class ConfigParser. + */ + @Test + public void testParseStepWithNullYaml() throws Exception { + System.out.println("testParseStepWithNullYaml"); + Map yaml = null; + IStep result = null; + try{ + result = ConfigParser.parseStep(yaml); + }catch(Exception e){ + assertEquals("Exception isn't the one expected", NullPointerException.class, e.getClass()); + } + assertNull("No Step should be returned", result); + } + + /** + * Assert that parsing fail and return expected Exception in case of invalid + * data type + */ + @Test + public void testParseStepWithInvalidDataType() throws Exception { + System.out.println("testParseStepWithInvalidDataType"); + IStep result = null; + + Map yaml = new HashMap<>(); + yaml.put("type", "basic"); + yaml.put("nextStepKey", "f1"); + yaml.put("stepNumber", "10"); + + try{ + result = ConfigParser.parseStep(yaml); + }catch(Exception e){ + assertEquals("#1 ClassCastException was expected but got "+e.getClass().getSimpleName(), ClassCastException.class, e.getClass()); + } + + assertNull("No Step should be returned", result); + + System.out.println("parseStep"); + yaml = new HashMap<>(); + yaml.put("type", "basic"); + yaml.put("nextStepKey", 5); + yaml.put("stepNumber", 1); + + try{ + result = ConfigParser.parseStep(yaml); + }catch(Exception e){ + assertEquals("#2 ClassCastException was expected but got "+e.getClass().getSimpleName(), ClassCastException.class, e.getClass()); + } + assertNull("No Step should be returned", result); + } + + @Test + public void testParseStepWithMissingIntData() throws Exception { + System.out.println("testParseStepWithMissingIntData"); + IStep result = null; + + Map yaml = new HashMap<>(); + yaml.put("type", "basic"); + yaml.put("nextStepKey", "f1"); + + try{ + result = ConfigParser.parseStep(yaml); + }catch(Exception e){ + assertEquals("NullPointerException was expected but got "+e.getClass().getSimpleName(), NullPointerException.class, e.getClass()); + } + + assertNull("No Step should be returned", result); + } + + @Test + public void testParseStepWithMissingStringData() throws Exception { + System.out.println("testParseStepWithMissingIntData"); + IStep result = null; + + Map yaml = new HashMap<>(); + yaml.put("type", "basic"); + yaml.put("stepNumber", 1); + + try{ + result = ConfigParser.parseStep(yaml); + }catch(Exception e){ + fail("No Exception expected"); + } + + assertNotNull(" Step should be returned", result); + assertNull("IStep.getNextStepKey() should return null", result.getNextStepKey()); + } + + @Test + public void testParseStepWithMissingStepType() throws Exception { + System.out.println("testParseStepWithMissingIntData"); + IStep result = null; + + Map yaml = new HashMap<>(); + yaml.put("stepNumber", 1); + yaml.put("nextStepKey", "f1"); + + try{ + result = ConfigParser.parseStep(yaml); + }catch(Exception e){ + assertEquals("NullPointerException was expected but got "+e.getClass().getSimpleName(), NullPointerException.class, e.getClass()); + } + + assertNull(" Step should be null", result); + } +} -- GitLab From 4dd586e9c0b3e3768fef2818b79b792a6be3dc38 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 15:23:09 +0200 Subject: [PATCH 025/102] add Teracube new config file. Remove 'nextKoStepKey' feature because useless at the moment --- .../models/steps/CustomExecutableStep.java | 6 +- .../models/steps/ExecutableStep.java | 9 +- .../models/steps/IExecutableStep.java | 7 -- .../easy/installer/models/steps/LoadStep.java | 4 +- .../easy/installer/utils/ConfigParser.java | 10 +- src/main/resources/yaml/Teracube_2e_new.yml | 114 ++++++++++++++++++ src/test/resources/yaml/parsingTest.yml | 3 - 7 files changed, 121 insertions(+), 32 deletions(-) create mode 100644 src/main/resources/yaml/Teracube_2e_new.yml diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java index bac3a05e..310e5a25 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java @@ -15,16 +15,14 @@ import java.util.ArrayList; public class CustomExecutableStep extends BasicStep implements ICustomStep, IExecutableStep{ private final Command command; - private final String nextKoStepKey; private final String titleKey; private final String titleIconName; private final ArrayList textContentKeys; public CustomExecutableStep(String type, String nextStepKey, int stepNumber, - String nextKoStepKey, String titleKey, String titleIconName, + String titleKey, String titleIconName, ArrayList contentKeys, Command command) { super(type, nextStepKey, stepNumber); - this.nextKoStepKey = nextKoStepKey; this.titleKey = titleKey; this.titleIconName = titleIconName; this.command = command; @@ -48,6 +46,4 @@ public class CustomExecutableStep extends BasicStep implements ICustomStep, IExe @Override public Command getCommand() { return this.command; } - @Override - public String getNextKoStepKey() { return this.nextKoStepKey; } } diff --git a/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java index 71ed195b..3af6ef71 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java @@ -16,21 +16,14 @@ import ecorp.easy.installer.models.Command; public class ExecutableStep extends BasicStep implements IExecutableStep{ private final Command command; - private final String nextKoStepKey; - public ExecutableStep(String type, String nextStepKey, int stepNumber, String nextKoStepKey, Command command) { + public ExecutableStep(String type, String nextStepKey, int stepNumber, Command command) { super(type, nextStepKey, stepNumber); this.command = command; - this.nextKoStepKey = nextKoStepKey; } @Override public Command getCommand() { return command; } - - @Override - public String getNextKoStepKey() { - return this.nextKoStepKey; - } } diff --git a/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java index 4644fcdb..6d026547 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java @@ -22,11 +22,4 @@ public interface IExecutableStep extends IStep{ * @return Command instance */ public Command getCommand(); - - /** - * Return the key of the next step to - * run in case of failure of the command - * @return - */ - public String getNextKoStepKey(); } diff --git a/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java b/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java index 387e5858..64f4ca6a 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java @@ -17,8 +17,8 @@ import java.util.ArrayList; public class LoadStep extends CustomExecutableStep{ private int averageTime; //Used to fill the ProgressIndicator in UI - public LoadStep(String type, String nextStepKey, int stepNumber, String nextKoStepKey, String titleKey, String titleIconName, ArrayList contentKeys, Command command, int averageTime) { - super(type, nextStepKey, stepNumber, nextKoStepKey, titleKey, titleIconName, contentKeys, command); + public LoadStep(String type, String nextStepKey, int stepNumber, String titleKey, String titleIconName, ArrayList contentKeys, Command command, int averageTime) { + super(type, nextStepKey, stepNumber, titleKey, titleIconName, contentKeys, command); this.averageTime = averageTime; } diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index 0047f543..915a9403 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -98,14 +98,13 @@ public class ConfigParser { private static LoadStep parseLoadStep(Map yaml, String type) throws ParseException, ClassCastException{ final int stepNumber = (int)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("succeed"); - final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); final String titleKey = (String) yaml.get("title"); final String titleIconName = (String) yaml.get("titleIcon"); final ArrayList instructions = (ArrayList) yaml.get("instructions"); final int averageTime = (int) yaml.get("averageTime"); final Command cmd = parseCommand(yaml); - LoadStep result = new LoadStep(type, nextStepKey, stepNumber , nextKoStepKey, + LoadStep result = new LoadStep(type, nextStepKey, stepNumber , titleKey, titleIconName, instructions, cmd, averageTime); return result; } @@ -141,11 +140,9 @@ public class ConfigParser { private static ExecutableStep parseExecutableStep(Map yaml, String type) throws ParseException, ClassCastException{ final int stepNumber = (int)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("succeed"); - final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); final Command cmd = parseCommand(yaml); - ExecutableStep result = new ExecutableStep(type, nextStepKey, stepNumber, - nextKoStepKey, cmd); + ExecutableStep result = new ExecutableStep(type, nextStepKey, stepNumber, cmd); return result; } @@ -183,14 +180,13 @@ public class ConfigParser { private static CustomExecutableStep parseCustomExecutableStep(Map yaml, String type) throws ParseException, ClassCastException{ final int stepNumber = (int)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("succeed"); - final String nextKoStepKey = (String) yaml.get("nextKoStepKey"); final String titleKey = (String) yaml.get("title"); final String titleIconName = (String) yaml.get("titleIcon"); final ArrayList instructions = (ArrayList) yaml.get("instructions"); final Command cmd = parseCommand(yaml); CustomExecutableStep result = new CustomExecutableStep(type, nextStepKey, stepNumber, - nextKoStepKey, titleKey, titleIconName, instructions, cmd); + titleKey, titleIconName, instructions, cmd); return result; } } diff --git a/src/main/resources/yaml/Teracube_2e_new.yml b/src/main/resources/yaml/Teracube_2e_new.yml new file mode 100644 index 00000000..5eabadff --- /dev/null +++ b/src/main/resources/yaml/Teracube_2e_new.yml @@ -0,0 +1,114 @@ +## YAML Template. +--- +stepsCount: 6 +steps: + f0: + type: custom + stepNumber: 1 + nextStepKey: f1 + titleKey: stepTitle_enableOemUnlock + titleIconName: icon-download.png + instructions: + - install_instr_openSettings + - install_instr_searchOEM + - install_instr_enableOEMUnlocking + - install_instr_acceptOEMUnlockWarning + - install_instr_onceDoneThenContinue + f1: + type: load + stepNumber: 2 + nextStepKey: f2 + titleKey: stepTitle_rebootBootloader + titleIconName: ~ + instructions: + - install_instr_rebootingOnBootloader + averageTime: 12 + script: reboot-fastboot + parameters: + device_id: ${DEVICE_ID} + fastboot_folder_path: ${ADB_FOLDER_PATH} + outputKey: ~ + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_cantRebootBootloader + 101: script_error_deviceID_missing + 102: script_error_fastbootPath_missing + f2: + type: custom-executable + stepNumber: 3 + nextStepKey: f3 + titleKey: stepTitle_oemUnlock + titleIconName: icon-download.png + instructions: + - install_instr_pressVolUpToAcceptOEMUnlocking + - install_instr_waitInstallStartAuto + script: gs290-flashingUnlock + parameters: + device_id: ${DEVICE_ID} + fastboot_folder_path: ${ADB_FOLDER_PATH} + outputKey: ~ + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 2: script_error_flashingUnlockFailed + 101: script_error_deviceID_missing + 102: script_error_fastbootPath_missing + f3: + type: load + stepNumber: 4 + nextStepKey: f4 + titleKey: stepTitle_installOS + titleIconName: ~ + instructions: + - install_instr_eosInstall + averageTime: 200 + script: Teracube_2e-install-from-bootloader + parameters: + device_id: ${DEVICE_ID} + archive_path: ${ARCHIVE_PATH} + fastboot_folder_path: ${ADB_FOLDER_PATH} + java_folder_path: ${JAVA_FOLDER_PATH} + outputKey: ~ + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_cantUnpackSources + 11: script_error_cantWipeData + 12: script_error_cantFlashBoot + 13: script_error_cantFlashRecovery + 14: script_error_cantFlashVbmeta + 15: script_error_cantFlashVbmeta_system + 16: script_error_cantFlashVBmeta_vendor + 17: script_error_cantRebootToFastboot + 18: script_error_cantFlashSystem + 19: script_error_cantFlashproduct + 20: script_error_cantFlashVendor + 101: script_error_deviceID_missing + 102: script_error_installFromFastboot_102 + 103: script_error_fastbootPath_missing + f4: + type: askAccount + stepNumber: 5 + nextStepKey: f5 + f5: + type: custom-executable + stepNumber: 6 + nextStepKey: ~ + titleKey: stepTitle_rebootDevice + titleIconName: icon-download.png + instructions: + - install_instr_onceDeviceRebootThenContinue + script: gs290-wait-reboot-from-fastboot + parameters: + fastboot_folder_path: ${ADB_FOLDER_PATH} + outputKey: ~ + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_cantrebootFromFasboot + 101: script_error_noDeviceFoundInFastboot \ No newline at end of file diff --git a/src/test/resources/yaml/parsingTest.yml b/src/test/resources/yaml/parsingTest.yml index 93eb7f18..f45c22a1 100644 --- a/src/test/resources/yaml/parsingTest.yml +++ b/src/test/resources/yaml/parsingTest.yml @@ -22,7 +22,6 @@ steps: nextStepKey: f4 script: test outputKey: myTestVar - nextKoStepKey: ~ okCodes: 0: test_lbl_cmdSuccess koCodes: @@ -39,7 +38,6 @@ steps: - test_lbl_test3 script: test outputKey: myTestVar - nextKoStepKey: ~ okCodes: 0: test_lbl_cmdSuccess koCodes: @@ -56,7 +54,6 @@ steps: - test_lbl_test3 script: test outputKey: myTestVar - nextKoStepKey: ~ okCodes: 0: test_lbl_cmdSuccess koCodes: -- GitLab From 14afafb9c35746002c4e1bc69dff7808d937c7e0 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 15:36:32 +0200 Subject: [PATCH 026/102] add licence header to new class and resources --- .../installer/models/steps/BasicStep.java | 17 +++++++-- .../models/steps/CustomExecutableStep.java | 19 +++++++--- .../installer/models/steps/CustomStep.java | 17 +++++++-- .../models/steps/ExecutableStep.java | 17 +++++++-- .../installer/models/steps/ICustomStep.java | 17 +++++++-- .../models/steps/IExecutableStep.java | 17 +++++++-- .../easy/installer/models/steps/IStep.java | 19 +++++++--- .../easy/installer/models/steps/LoadStep.java | 17 +++++++-- .../easy/installer/utils/ConfigParser.java | 35 ++++++++++++------- src/main/resources/yaml/Teracube_2e_new.yml | 16 ++++++++- .../installer/utils/ConfigParserTest.java | 17 +++++++-- src/test/resources/yaml/parsingTest.yml | 16 ++++++++- 12 files changed, 181 insertions(+), 43 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java b/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java index dbaf6768..8bb8f03a 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/BasicStep.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.models.steps; diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java index 310e5a25..896317b3 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.models.steps; @@ -10,7 +21,7 @@ import java.util.ArrayList; /** * - * @author vincent + * @author vincent Bourgmayer */ public class CustomExecutableStep extends BasicStep implements ICustomStep, IExecutableStep{ diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java index d5d9631b..ee9f0fcd 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomStep.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.models.steps; diff --git a/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java index 3af6ef71..b036f0ba 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/ExecutableStep.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.models.steps; diff --git a/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java b/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java index 69b53a48..acfc10df 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.models.steps; diff --git a/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java index 6d026547..aa50d188 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/IExecutableStep.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.models.steps; diff --git a/src/main/java/ecorp/easy/installer/models/steps/IStep.java b/src/main/java/ecorp/easy/installer/models/steps/IStep.java index 0bb84a33..61dc449f 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/IStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/IStep.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.models.steps; @@ -19,7 +30,7 @@ package ecorp.easy.installer.models.steps; * a pain to update constructor method to handle new field. * So we could consider, if we feel the need to add those setters * in interface definition in future. This isn't a closed Topic. - * @author vincent + * @author vincent Bourgmayer */ public interface IStep { public final static String LAST_STEP_KEY = "L"; //When a next step key has this value, it means that this is the last step of the process diff --git a/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java b/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java index 64f4ca6a..15cd3113 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/LoadStep.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.models.steps; diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index 915a9403..39e8c1b2 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.utils; @@ -97,9 +108,9 @@ public class ConfigParser { */ private static LoadStep parseLoadStep(Map yaml, String type) throws ParseException, ClassCastException{ final int stepNumber = (int)yaml.get("stepNumber"); - final String nextStepKey = (String) yaml.get("succeed"); - final String titleKey = (String) yaml.get("title"); - final String titleIconName = (String) yaml.get("titleIcon"); + final String nextStepKey = (String) yaml.get("nextStepKey"); + final String titleKey = (String) yaml.get("titleKey"); + final String titleIconName = (String) yaml.get("titleIconName"); final ArrayList instructions = (ArrayList) yaml.get("instructions"); final int averageTime = (int) yaml.get("averageTime"); @@ -121,8 +132,8 @@ public class ConfigParser { logger.debug("parseCustomStep(yaml)"); int stepNumber = (int)yaml.get("stepNumber"); String nextStepKey = (String) yaml.get("nextStepKey"); - String titleKey = (String) yaml.get("title"); - String titleIconName = (String) yaml.get("titleIcon"); + String titleKey = (String) yaml.get("titleKey"); + String titleIconName = (String) yaml.get("titleIconName"); ArrayList instructions = (ArrayList) yaml.get("instructions"); CustomStep result = new CustomStep(type, nextStepKey, stepNumber, titleKey, titleIconName, instructions); @@ -139,7 +150,7 @@ public class ConfigParser { */ private static ExecutableStep parseExecutableStep(Map yaml, String type) throws ParseException, ClassCastException{ final int stepNumber = (int)yaml.get("stepNumber"); - final String nextStepKey = (String) yaml.get("succeed"); + final String nextStepKey = (String) yaml.get("nextStepKey"); final Command cmd = parseCommand(yaml); ExecutableStep result = new ExecutableStep(type, nextStepKey, stepNumber, cmd); @@ -179,9 +190,9 @@ public class ConfigParser { */ private static CustomExecutableStep parseCustomExecutableStep(Map yaml, String type) throws ParseException, ClassCastException{ final int stepNumber = (int)yaml.get("stepNumber"); - final String nextStepKey = (String) yaml.get("succeed"); - final String titleKey = (String) yaml.get("title"); - final String titleIconName = (String) yaml.get("titleIcon"); + final String nextStepKey = (String) yaml.get("nextStepKey"); + final String titleKey = (String) yaml.get("titleKey"); + final String titleIconName = (String) yaml.get("titleIconName"); final ArrayList instructions = (ArrayList) yaml.get("instructions"); final Command cmd = parseCommand(yaml); diff --git a/src/main/resources/yaml/Teracube_2e_new.yml b/src/main/resources/yaml/Teracube_2e_new.yml index 5eabadff..a816489d 100644 --- a/src/main/resources/yaml/Teracube_2e_new.yml +++ b/src/main/resources/yaml/Teracube_2e_new.yml @@ -1,4 +1,18 @@ -## YAML Template. +## Copyright 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 . +## Author: Vincent Bourgmayer --- stepsCount: 6 steps: diff --git a/src/test/java/ecorp/easy/installer/utils/ConfigParserTest.java b/src/test/java/ecorp/easy/installer/utils/ConfigParserTest.java index 13684ec8..e7bc4000 100644 --- a/src/test/java/ecorp/easy/installer/utils/ConfigParserTest.java +++ b/src/test/java/ecorp/easy/installer/utils/ConfigParserTest.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 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 . */ package ecorp.easy.installer.utils; diff --git a/src/test/resources/yaml/parsingTest.yml b/src/test/resources/yaml/parsingTest.yml index f45c22a1..3990e614 100644 --- a/src/test/resources/yaml/parsingTest.yml +++ b/src/test/resources/yaml/parsingTest.yml @@ -1,4 +1,18 @@ -## YAML Template. +## Copyright 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 . +## Author: Vincent Bourgmayer --- stepsCount: 2 steps: -- GitLab From 47fa34af204aa99fda9af1e312d361062a9267e6 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 16:11:45 +0200 Subject: [PATCH 027/102] add te new config file for FP3 --- src/main/resources/yaml/FP3_new.yml | 126 ++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 src/main/resources/yaml/FP3_new.yml diff --git a/src/main/resources/yaml/FP3_new.yml b/src/main/resources/yaml/FP3_new.yml new file mode 100644 index 00000000..3d0ff7d4 --- /dev/null +++ b/src/main/resources/yaml/FP3_new.yml @@ -0,0 +1,126 @@ +## Copyright 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 . +## Author: Vincent Bourgmayer +--- +stepsCount: 7 +steps: + f0: + type: enableOemUnlock + stepNumber: 1 + nextStepKey: f1 + f1: + type: custom-executable + stepNumber: 2 + nextStepKey: f2 + titleKey: stepTitle_StartInFastbootFP3 + titleIcon: icon-download.png + instructions: + - install_instr_turnOff + - install_instr_startFastboot + - install_instr_waitFastbootmodeDetected + script: wait-fastboot + parameters: + fastboot_folder_path: ${ADB_FOLDER_PATH} + outputKey: ~ + codes: + ok: + 0: ~ + ko: + 1: script_error_waitFastboot_1 + f2: + type: load + stepNumber: 3 + nextStepKey: f3 + titleKey: stepTitle2On7 + instructions: + - install_instr_oemUnlock + averageTime: 12 + script: fp3_oem-unlock + parameters: + fastboot_folder_path: ${ADB_FOLDER_PATH} + outputKey: ~ + codes: + ok: + 0: ~ + ko: + 10: script_error_oemUnlock_10 + f3: + type: custom-executable + stepNumber: 4 + nextStepKey: f4 + titleKey: stepTitle3On7FP3 + titleIconName: icon-download.png + instructions: + - install_instr_readAllWarning + - install_instr_selectUnlockBootloader + - install_instr_unlockBootloader + - install_instr_bootWarning + - install_instr_startFastbootFromOptions + - install_instr_ifYouMissedTimeout + script: wait-fastboot-unlocked + parameters: + fastboot_folder_path: ${ADB_FOLDER_PATH} + outputKey: ~ + codes: + ok: + 0: ~ + ko: + 1: script_error_waitFastboot_1 + f4: + type: load + stepNumber: 5 + nextStepKey: f5 + titleKey: stepTitle6On7 + instructions: + - install_instr_eosInstall + averageTime: 200 + script: fp3_install-from-fastboot + parameters: + archive_path: ${ARCHIVE_PATH} + fastboot_folder_path: ${ADB_FOLDER_PATH} + java_folder_path: ${JAVA_FOLDER_PATH} + outputKey: ~ + codes: + ok: + 0: ~ + ko: + 1: script_error_installFromFastboot_1 + 2: script_error_installFromFastboot_2 + 3: script_error_installFromFastboot_3 + 101: script_error_installFromFastboot_101 + 102: script_error_installFromFastboot_102 + f5: + type: askAccount + stepNumber: 6 + nextStepKey: f6 + f6: + type: custom-executable + stepNumber: 7 + nextStepKey: ~ + titleKey: ~ + titleIconName: icon-download.png + instruction: + - install_instr_selectLockBootloader + - install_instr_lockBootloader + script: wait-reboot-from-fastboot + parameters: + fastboot_folder_path: ${ADB_FOLDER_PATH} + outputKey: ~ + codes: + ok: + 0: ~ + ko: + 1: script_error_unknown + 101: script_error_waitRebootFromFastboot_101 -- GitLab From 4efe6ca335570e044cf3fc83d4d57958d1a4eaef Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 16:21:37 +0200 Subject: [PATCH 028/102] add default values for some missing datas in config file --- .../ecorp/easy/installer/utils/ConfigParser.java | 13 +++++-------- src/main/resources/yaml/FP3_new.yml | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index 39e8c1b2..e383b792 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -25,8 +25,6 @@ import ecorp.easy.installer.models.steps.IStep; import ecorp.easy.installer.models.steps.LoadStep; import java.text.ParseException; import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -110,8 +108,8 @@ public class ConfigParser { final int stepNumber = (int)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("nextStepKey"); final String titleKey = (String) yaml.get("titleKey"); - final String titleIconName = (String) yaml.get("titleIconName"); - final ArrayList instructions = (ArrayList) yaml.get("instructions"); + final String titleIconName = (String) yaml.getOrDefault("titleIconName", ""); + final ArrayList instructions = (ArrayList) yaml.getOrDefault("instructions", new ArrayList()); final int averageTime = (int) yaml.get("averageTime"); final Command cmd = parseCommand(yaml); @@ -134,7 +132,7 @@ public class ConfigParser { String nextStepKey = (String) yaml.get("nextStepKey"); String titleKey = (String) yaml.get("titleKey"); String titleIconName = (String) yaml.get("titleIconName"); - ArrayList instructions = (ArrayList) yaml.get("instructions"); + ArrayList instructions = (ArrayList) yaml.getOrDefault("instructions", new ArrayList()); CustomStep result = new CustomStep(type, nextStepKey, stepNumber, titleKey, titleIconName, instructions); return result; @@ -151,7 +149,6 @@ public class ConfigParser { private static ExecutableStep parseExecutableStep(Map yaml, String type) throws ParseException, ClassCastException{ final int stepNumber = (int)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("nextStepKey"); - final Command cmd = parseCommand(yaml); ExecutableStep result = new ExecutableStep(type, nextStepKey, stepNumber, cmd); return result; @@ -192,8 +189,8 @@ public class ConfigParser { final int stepNumber = (int)yaml.get("stepNumber"); final String nextStepKey = (String) yaml.get("nextStepKey"); final String titleKey = (String) yaml.get("titleKey"); - final String titleIconName = (String) yaml.get("titleIconName"); - final ArrayList instructions = (ArrayList) yaml.get("instructions"); + final String titleIconName = (String) yaml.getOrDefault("titleIconName", ""); + final ArrayList instructions = (ArrayList) yaml.getOrDefault("instructions", new ArrayList()); final Command cmd = parseCommand(yaml); CustomExecutableStep result = new CustomExecutableStep(type, nextStepKey, stepNumber, diff --git a/src/main/resources/yaml/FP3_new.yml b/src/main/resources/yaml/FP3_new.yml index 3d0ff7d4..c4fe5270 100644 --- a/src/main/resources/yaml/FP3_new.yml +++ b/src/main/resources/yaml/FP3_new.yml @@ -123,4 +123,4 @@ steps: 0: ~ ko: 1: script_error_unknown - 101: script_error_waitRebootFromFastboot_101 + 101: script_error_waitRebootFromFastboot_101 \ No newline at end of file -- GitLab From 36c7ac1ae9ab63661d7f1c20cebefd1fbfb4559b Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 16:32:42 +0200 Subject: [PATCH 029/102] add comment, and add some getOrDdefault() in ConfigParser --- .../java/ecorp/easy/installer/models/steps/IStep.java | 2 +- .../java/ecorp/easy/installer/utils/ConfigParser.java | 10 ++++++++++ src/main/resources/yaml/FP3_new.yml | 2 +- src/main/resources/yaml/Teracube_2e_new.yml | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/models/steps/IStep.java b/src/main/java/ecorp/easy/installer/models/steps/IStep.java index 61dc449f..21bdd651 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/IStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/IStep.java @@ -33,7 +33,7 @@ package ecorp.easy.installer.models.steps; * @author vincent Bourgmayer */ public interface IStep { - public final static String LAST_STEP_KEY = "L"; //When a next step key has this value, it means that this is the last step of the process + public final static String LAST_STEP_KEY = "end"; //When a next step key has this value, it means that this is the last step of the process /** * Get the type of the step diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index e383b792..489c4a05 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -82,6 +82,16 @@ public class ConfigParser { return result; } + /* NOTE for BELOW METHODS: + * Using yaml.getOrDefault(key, defaultValue) + * does only protect from missing value in yaml + * it doesn't protect from a value willingly setted + * to null + */ + + + + /** * create a basic step from yaml. * This is perfect to integrate fixed step like deviceDetection diff --git a/src/main/resources/yaml/FP3_new.yml b/src/main/resources/yaml/FP3_new.yml index c4fe5270..63286d74 100644 --- a/src/main/resources/yaml/FP3_new.yml +++ b/src/main/resources/yaml/FP3_new.yml @@ -108,7 +108,7 @@ steps: f6: type: custom-executable stepNumber: 7 - nextStepKey: ~ + nextStepKey: end titleKey: ~ titleIconName: icon-download.png instruction: diff --git a/src/main/resources/yaml/Teracube_2e_new.yml b/src/main/resources/yaml/Teracube_2e_new.yml index a816489d..a0c599d3 100644 --- a/src/main/resources/yaml/Teracube_2e_new.yml +++ b/src/main/resources/yaml/Teracube_2e_new.yml @@ -111,7 +111,7 @@ steps: f5: type: custom-executable stepNumber: 6 - nextStepKey: ~ + nextStepKey: end titleKey: stepTitle_rebootDevice titleIconName: icon-download.png instructions: -- GitLab From 239fbf8287f016df58ada1fdd31baf623da8e5c7 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 16:57:24 +0200 Subject: [PATCH 030/102] update FlashThread to use the new steps package --- .../easy/installer/threads/FlashThread.java | 95 +++++++++++-------- 1 file changed, 57 insertions(+), 38 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/threads/FlashThread.java b/src/main/java/ecorp/easy/installer/threads/FlashThread.java index a736abd1..6b0053af 100644 --- a/src/main/java/ecorp/easy/installer/threads/FlashThread.java +++ b/src/main/java/ecorp/easy/installer/threads/FlashThread.java @@ -20,6 +20,10 @@ import ecorp.easy.installer.models.Phone; import ecorp.easy.installer.models.Command; import ecorp.easy.installer.models.DataBundle; import ecorp.easy.installer.models.StepUi; +import ecorp.easy.installer.models.steps.ICustomStep; +import ecorp.easy.installer.models.steps.IExecutableStep; +import ecorp.easy.installer.models.steps.IStep; +import ecorp.easy.installer.models.steps.LoadStep; import ecorp.easy.installer.utils.IFlashHandler; import javafx.application.Platform; import java.util.HashMap; @@ -43,7 +47,7 @@ public class FlashThread extends Thread { final Phone device; protected final Map commonParameters; // this is parameters that are define by a script output and that can be use as parameter by another script - protected final Map commands; + protected final Map steps; protected String currentStepCode = ""; protected final String firstCommandKey; @@ -55,7 +59,7 @@ public class FlashThread extends Thread { * @param device Object containing device info */ public FlashThread(IFlashHandler controller, String firstCommandKey, Object pauseLock, Phone device){ - this.commands = new HashMap<>(); + this.steps = new HashMap<>(); this.commonParameters = new HashMap<>(); this.firstCommandKey = firstCommandKey; //this is the key of the command's hashmap this.application = controller; @@ -77,11 +81,11 @@ public class FlashThread extends Thread { /** * Add a command associated to a specific key * @param key must unique or the value associated with will be replaced by new one - * @param command Command to add + * @param step IStep step to add */ - public void addCommand(String key, Command command){ - if(command != null && key!= null) - commands.put(key, command); + public void addCommand(String key, IStep step){ + if(step != null && key!= null) + steps.put(key, step); } /** @@ -140,33 +144,47 @@ public class FlashThread extends Thread { * Execute some code before to execute the current command * It is runned in the While loop which loops over commands * It's executed in a Try catch. - * @throws java.lang.Exception + * @throws java.lang.ClassCastException */ - protected void doBeforeToRunCommand() throws Exception{ + protected void doBeforeToRunCommand() throws ClassCastException{ //Update UI - final Command cmd = commands.get(currentStepCode); + final IStep step = steps.get(currentStepCode); final DataBundle bundle = new DataBundle(); //Prepare datas for UI - final String stepType = cmd.getNewUIValues().getType(); + final String stepType = step.getType(); bundle.putString("stepType", stepType); - - if( stepType.equals(AppConstants.USER_ACTION_KEY) || stepType.equals(AppConstants.LOAD_KEY)){ - //UpdateUI - final StepUi newUIValues = (StepUi) cmd.getNewUIValues(); - if(newUIValues != null) { - //@todo: Must define bundle key as a static String at a single place. - if(stepType.equals(AppConstants.USER_ACTION_KEY)){ - bundle.putString("titleIconName", newUIValues.getTitleIconName()); - }else{ - bundle.putInteger("averageTime", newUIValues.getAverageTime()); - } - bundle.putString("stepTitle", newUIValues.getTitle()); - bundle.putList("stepInstructions", String.class.getSimpleName(), newUIValues.getInstructions()); - bundle.putBoolean("hasScript", cmd.hasScript()); - } + final boolean hasScript; + switch(stepType){ + case "custom": + bundle.putString("titleIconName", ((ICustomStep) step).getTitleIconName()); + bundle.putString("stepTitle", ((ICustomStep) step).getTitleKey()); + bundle.putList("stepInstructions", String.class.getSimpleName(), ((ICustomStep) step).getTextContentKeys()); + hasScript = false; + + break; + case "custom-executable": + bundle.putString("titleIconName", ((ICustomStep) step).getTitleIconName()); + bundle.putString("stepTitle", ((ICustomStep) step).getTitleKey()); + bundle.putList("stepInstructions", String.class.getSimpleName(), ((ICustomStep) step).getTextContentKeys()); + hasScript= true; + break; + case "executable": + hasScript= true; + break; + case "load": + hasScript= true; + bundle.putString("stepTitle", ((ICustomStep) step).getTitleKey()); + bundle.putList("stepInstructions", String.class.getSimpleName(), ((ICustomStep) step).getTextContentKeys()); + bundle.putString("titleIconName", ((ICustomStep) step).getTitleIconName()); + bundle.putInteger("averageTime", ((LoadStep) step).getAverageTime()); + break; + default: + hasScript = false; + break; } + bundle.putBoolean("hasScript", hasScript); //Update UI Platform.runLater(()->{ application.onStepStart(bundle); @@ -190,25 +208,26 @@ public class FlashThread extends Thread { */ @Override public void run(){ - if(commands.isEmpty()) return; + if(steps.isEmpty()) return; try{ //execute scripts String nextCommandKey = firstCommandKey; - while(nextCommandKey != null ){ + while(nextCommandKey != null && nextCommandKey != IStep.LAST_STEP_KEY){ currentStepCode = nextCommandKey; - final Command cmd = commands.get(nextCommandKey); - final String stepType = cmd.getNewUIValues().getType(); + final IStep step = steps.get(nextCommandKey); + final String stepType = step.getType(); //UpdateUI doBeforeToRunCommand(); - if( cmd.hasScript() && - ( stepType.equals(AppConstants.USER_ACTION_KEY) || - stepType.equals(AppConstants.LOAD_KEY) ) ) + if(stepType.equals("executable") + || stepType.equals("load") + || stepType.equals("custom-executable")) { - - updateParameters(); + Command cmd = ((IExecutableStep) step).getCommand(); + updateParameters(cmd); + logger.debug("Run(), Command = "+cmd.getCommand()); cmd.execAndReadOutput(); handleResult(cmd); @@ -218,7 +237,7 @@ public class FlashThread extends Thread { synchronized(pauseLock){ pauseLock.wait(); } } - nextCommandKey = cmd.getNextCommandKey(); + nextCommandKey = step.getNextStepKey(); } }catch(Exception e){ @@ -233,16 +252,16 @@ public class FlashThread extends Thread { * @return */ public int getCommandsSize(){ - return this.commands.size(); + return this.steps.size(); } /** * Update parameters of the current command * It is called before to execute the command + * @param cmd */ - protected void updateParameters(){ - final Command cmd = commands.get(currentStepCode); + protected void updateParameters(final Command cmd){ //Update Parameters if(cmd.getParameters() != null){ //@TODO: remove functionnal and rewrite it as it was before with simple loop. cmd.getParameters().entrySet().stream().filter((param) -> (param.getValue().contains("$"))).forEachOrdered((param) -> { -- GitLab From f6ea092fe2d244c712991c6a41fde0334763d507 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 17:01:17 +0200 Subject: [PATCH 031/102] marl Step.java as depecrated and update ProcessMould.java to use IStep instead of Step --- .../java/ecorp/easy/installer/models/ProcessMould.java | 9 +++++---- src/main/java/ecorp/easy/installer/models/Step.java | 1 + .../java/ecorp/easy/installer/threads/ThreadFactory.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/models/ProcessMould.java b/src/main/java/ecorp/easy/installer/models/ProcessMould.java index 0ce98087..c6f76414 100644 --- a/src/main/java/ecorp/easy/installer/models/ProcessMould.java +++ b/src/main/java/ecorp/easy/installer/models/ProcessMould.java @@ -16,6 +16,7 @@ */ package ecorp.easy.installer.models; +import ecorp.easy.installer.models.steps.IStep; import java.util.HashMap; import java.util.Map; @@ -27,7 +28,7 @@ import java.util.Map; public class ProcessMould { String modelName; - Map steps; + Map steps; /** * Constructor of ProcessMould @@ -44,7 +45,7 @@ public class ProcessMould { * @param key * @param step */ - public void addStep(String key, Step step){ + public void addStep(String key, IStep step){ this.steps.put(key, step); } @@ -60,7 +61,7 @@ public class ProcessMould { * Get the list of steps in this processMould * @return */ - public Map getSteps() { + public Map getSteps() { return steps; } @@ -68,7 +69,7 @@ public class ProcessMould { * Replace current steps by the new one * @param steps the new steps */ - public void setSteps(Map steps) { + public void setSteps(Map steps) { this.steps = steps; } } diff --git a/src/main/java/ecorp/easy/installer/models/Step.java b/src/main/java/ecorp/easy/installer/models/Step.java index 2c798335..4014c0fe 100644 --- a/src/main/java/ecorp/easy/installer/models/Step.java +++ b/src/main/java/ecorp/easy/installer/models/Step.java @@ -20,6 +20,7 @@ import java.util.Map; /** * This class encapsulate data about a step in the flashing process * @author Vincent Bourgmayer + * @deprecated */ public class Step { private StepUi ui; //Datas about user interface diff --git a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java index fed051d9..af73d0b3 100644 --- a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java +++ b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java @@ -77,7 +77,7 @@ public class ThreadFactory { */ private boolean loadYAMLFile(){ logger.info("loadYAMLFile()"); - final String modelName = device.getAdbDevice(); //Do not use device.getModel as it doesn't return the expected value + final String modelName = device.getAdbDevice(); if(modelName == null || modelName.isEmpty()){ return false; } -- GitLab From d5cd3fc48e09ba8db09c361492a873468b585d55 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 17:59:30 +0200 Subject: [PATCH 032/102] fix FlashThread and ThreadFactory and ProcessMould to use IStep --- .../easy/installer/models/ProcessMould.java | 2 +- .../easy/installer/threads/FlashThread.java | 2 +- .../easy/installer/threads/ThreadFactory.java | 87 +++++-------------- 3 files changed, 24 insertions(+), 67 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/models/ProcessMould.java b/src/main/java/ecorp/easy/installer/models/ProcessMould.java index c6f76414..73d79316 100644 --- a/src/main/java/ecorp/easy/installer/models/ProcessMould.java +++ b/src/main/java/ecorp/easy/installer/models/ProcessMould.java @@ -46,7 +46,7 @@ public class ProcessMould { * @param step */ public void addStep(String key, IStep step){ - this.steps.put(key, step); + this.steps.put(key, step); } /** diff --git a/src/main/java/ecorp/easy/installer/threads/FlashThread.java b/src/main/java/ecorp/easy/installer/threads/FlashThread.java index 6b0053af..7e445457 100644 --- a/src/main/java/ecorp/easy/installer/threads/FlashThread.java +++ b/src/main/java/ecorp/easy/installer/threads/FlashThread.java @@ -83,7 +83,7 @@ public class FlashThread extends Thread { * @param key must unique or the value associated with will be replaced by new one * @param step IStep step to add */ - public void addCommand(String key, IStep step){ + public void addStep(String key, IStep step){ if(step != null && key!= null) steps.put(key, step); } diff --git a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java index af73d0b3..e681c555 100644 --- a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java +++ b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java @@ -21,10 +21,13 @@ import ecorp.easy.installer.models.Command; import ecorp.easy.installer.models.Phone; import ecorp.easy.installer.models.ProcessMould; import ecorp.easy.installer.models.Step; +import ecorp.easy.installer.models.steps.IStep; +import ecorp.easy.installer.utils.ConfigParser; import ecorp.easy.installer.utils.IFlashHandler; import java.io.IOException; import java.io.InputStream; import java.security.InvalidParameterException; +import java.text.ParseException; import java.util.LinkedHashMap; //used instead of HashMap to conserve order import java.util.List; import java.util.Map; @@ -86,7 +89,7 @@ public class ThreadFactory { Yaml yaml = new Yaml (); //load config file - InputStream is = getClass().getResourceAsStream(yamlFolderPath+modelName+".yml"); + InputStream is = getClass().getResourceAsStream(yamlFolderPath+modelName+"_new.yml"); Map yamlContent= (Map)yaml.load(is); is.close(); if(yamlContent == null || yamlContent.isEmpty() ) { @@ -96,7 +99,7 @@ public class ThreadFactory { flashMould = new ProcessMould(modelName); - loadFlashProcess((Map) yamlContent.get("flash")); + loadFlashProcess((Map) yamlContent.get("steps")); //Load config file specific to user interface //DO NOT USE classLoader() to load resource! @@ -109,8 +112,7 @@ public class ThreadFactory { logger.error("Parsed extra datas (UI, sources) from yaml file are empty or null"); return false; } - - loadFlashExtra((Map) yamlContent.get("flash")); + loadSourcesToDownload((Map) yamlContent.get("sources")); }catch(IOException e){ @@ -128,72 +130,26 @@ public class ThreadFactory { logger.info("loadFlashProcess( ... ) "); Set keys = steps.keySet(); - - for(String key: keys){ + try{ + + for(String key: keys){ logger.debug("Key = "+key); Map stepData = (Map) steps.get(key); //Content load from YAML file - Step step = new Step(); //Object to build - - //1. Does the step contain a script ? - if(stepData.get("script") != null){ - step.setScript(stepData.get("script")+( AppConstants.isWindowsOs() ? ".bat" : ".sh" ) ); - - //Fill the result codes fields - Map codes = (Map) stepData.get("codes"); - if(codes != null){ - step.setOkCode ( (Map) codes.get("ok") ); - step.setKoCode ( (Map) codes.get("ko") ); - } - - //Fill the parameters field - step.setParameters ((LinkedHashMap) stepData.get("parameters") ); - - //Fill the output to read - this is the name of a variable - //to create and store in CommonParams for use in another step - step.setOutput ((String) stepData.get("output") ); - }else{ //This is for step without script to run - step.setScript(null); - } - //Fill the step's key of the next step in case of success or failure - step.setAfterSuccess ((String) stepData.get("succeed") ); - step.setAfterFail ((String) stepData.get("failed") ); - + IStep step = ConfigParser.parseStep(stepData); //Object to build + //Integrate the step in the process flashMould.addStep(key, step); } - } - - /** - * Load extra element for Flash process (sources to dl and UI definition) - * @TODO: make entries's key a final static to be store only at one place - * @param steps Map Loaded from YAML - */ - protected void loadFlashExtra( Map steps){ - logger.info("loadFlashExtra(...)"); - - for(String key : (Set) steps.keySet() ){ - Map subObj = (Map) steps.get(key); - if(subObj == null) continue; - - StepUi stepUI = null; - - Map uiProperties = (Map) subObj.get("ui"); - if(uiProperties != null){ - String type = (String) uiProperties.get("type"); - List instructions = (List) uiProperties.get("instruction"); - String title = (String) uiProperties.get("title"); - String titleIconName= (String)uiProperties.get("titleIcon"); - String stepNumber = (String)uiProperties.get("stepNumber"); - Integer averageTime = (Integer) uiProperties.get("averageTime"); - stepUI = new StepUi(type, instructions, title, titleIconName, stepNumber, averageTime != null ? averageTime:-1); - } - - Step step = flashMould.getSteps().get(key); - if(step != null){ - step.setUI(stepUI ); - } + + }catch(ClassCastException e){ + logger.debug("ClassCast Exception <-> Invalid Yaml: {}", e.getMessage()); + e.printStackTrace(); + }catch(ParseException e){ + logger.debug("ParseException <-> Invalid Yaml: {}", e.getMessage()); + e.printStackTrace(); } } + /** * Load Preparation steps from yaml @@ -231,11 +187,12 @@ public class ThreadFactory { if(flashMould == null || flashMould.getSteps() == null || device == null) return null; - FlashThread result = new FlashThread(application, "f1", pauseLock, device); + FlashThread result = new FlashThread(application, "f0", pauseLock, device); flashMould.getSteps().entrySet().forEach((entry) -> { - result.addCommand(entry.getKey(), new Command(AppConstants.getScriptsFolderPath(), new Step( entry.getValue() ) ) ); + //@TODO replace the entry.getValue() by a copy by value + result.addStep(entry.getKey(), entry.getValue() ); }); return result; } -- GitLab From e683884ca0fbe942c166004e245584102a02355c Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 18:14:33 +0200 Subject: [PATCH 033/102] integrate steps usage for FlashSceneController --- .../subcontrollers/FlashSceneController.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java index ea4470ab..43142bbc 100644 --- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java +++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java @@ -173,11 +173,15 @@ public class FlashSceneController extends AbstractSubSteppedController implement logger.debug("Title: "+title); //Get Type of step ("action" or "load") - switch(db.getString("stepType")){ - case AppConstants.USER_ACTION_KEY: + final String stepType = db.getString("stepType"); + + switch (stepType) { + case AppConstants.USER_ACTION_KEY: //@deprecated + case "custom": + case "custom-executable": instructionsContainer.setOpacity(0.0); updateInstructions(title, db.getList("stepInstructions", "String") ); - displayActionStepType(db); + displayActionStepType(db); UiUtils.buildFadeTransition(instructionsContainer, false).play(); break; case AppConstants.LOAD_KEY: -- GitLab From 7f2836cc2a0b0f64a5e1726a31e76685b2d215e0 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 21 Sep 2021 18:22:57 +0200 Subject: [PATCH 034/102] remove old config file for FP3 & t2e and remove old datas in _fs.yml for those two devices --- src/main/resources/yaml/FP3.yml | 99 ------------------- src/main/resources/yaml/FP3_fs.yml | 57 +---------- src/main/resources/yaml/Teracube_2e.yml | 107 --------------------- src/main/resources/yaml/Teracube_2e_fs.yml | 49 ---------- 4 files changed, 1 insertion(+), 311 deletions(-) delete mode 100644 src/main/resources/yaml/FP3.yml delete mode 100644 src/main/resources/yaml/Teracube_2e.yml diff --git a/src/main/resources/yaml/FP3.yml b/src/main/resources/yaml/FP3.yml deleted file mode 100644 index 2a36c2ea..00000000 --- a/src/main/resources/yaml/FP3.yml +++ /dev/null @@ -1,99 +0,0 @@ -## Copyright 2019-2020 - 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 . -## Author: Vincent Bourgmayer ---- -name: FP3 -flash: - f1: - script: enableOemUnlock - parameters: ~ - codes: ~ - output: ~ - succeed: f2 - failed: ~ - f2: - script: wait-fastboot - parameters: - fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitFastboot_1 - output: ~ - succeed: f3 - failed: ~ - f3: - script: fp3_oem-unlock - parameters: - fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 10: script_error_oemUnlock_10 - output: ~ - succeed: f4 - failed: ~ - f4: - script: wait-fastboot-unlocked - parameters: - fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitFastboot_1 - output: ~ - succeed: f5 - failed: ~ - f5: - script: fp3_install-from-fastboot - parameters: - archive_path: ${ARCHIVE_PATH} - fastboot_folder_path: ${ADB_FOLDER_PATH} - java_folder_path: ${JAVA_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromFastboot_1 - 2: script_error_installFromFastboot_2 - 3: script_error_installFromFastboot_3 - 101: script_error_installFromFastboot_101 - 102: script_error_installFromFastboot_102 - output: ~ - succeed: f6 - failed: ~ - f6: - script: askAccount - parameters: ~ - codes: ~ - output: ~ - succeed: f7 - failed: ~ - f7: - script: wait-reboot-from-fastboot - parameters: - fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 101: script_error_waitRebootFromFastboot_101 - output: ~ - succeed: ~ - failed: ~ \ No newline at end of file diff --git a/src/main/resources/yaml/FP3_fs.yml b/src/main/resources/yaml/FP3_fs.yml index ba9890b6..88ca6731 100644 --- a/src/main/resources/yaml/FP3_fs.yml +++ b/src/main/resources/yaml/FP3_fs.yml @@ -17,59 +17,4 @@ sources: rom: url: https://images.ecloud.global/stable/FP3/IMG-e-latest-FP3.zip - filePath: IMG-e-latest-FP3.zip -flash: - f1: - ui: - type: enableOemUnlock - f2: - ui: - type: action - title: stepTitle_StartInFastbootFP3 - instruction: - - install_instr_turnOff - - install_instr_startFastboot - - install_instr_waitFastbootmodeDetected - stepNumber: 1/5 - titleIcon: icon-download.png - f3: - ui: - type: load - title: stepTitle2On7 - instruction: - - install_instr_oemUnlock - stepNumber: 2/5 - averageTime: 12 - f4: - ui: - type: action - title: stepTitle3On7FP3 - instruction: - - install_instr_readAllWarning - - install_instr_selectUnlockBootloader - - install_instr_unlockBootloader - - install_instr_bootWarning - - install_instr_startFastbootFromOptions - - install_instr_ifYouMissedTimeout - stepNumber: 3/5 - titleIcon: icon-download.png - f5: - ui: - type: load - title: stepTitle6On7 - instruction: - - install_instr_eosInstall - stepNumber: 4/5 - averageTime: 200 - f6: - ui: - type: askAccount - f7: - ui: - type: action - title: - instruction: - - install_instr_selectLockBootloader - - install_instr_lockBootloader - stepNumber: 5/5 - titleIcon: icon-download.png + filePath: IMG-e-latest-FP3.zip \ No newline at end of file diff --git a/src/main/resources/yaml/Teracube_2e.yml b/src/main/resources/yaml/Teracube_2e.yml deleted file mode 100644 index d5f71fa7..00000000 --- a/src/main/resources/yaml/Teracube_2e.yml +++ /dev/null @@ -1,107 +0,0 @@ -## Copyright 2019-2020 - 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 . -## Author: Vincent Bourgmayer ---- -name: Teracube_2e -flash: - f1: - script: ~ - parameters: ~ - codes: ~ - output: ~ - succeed: f2 - failed: ~ - f2: - script: reboot-fastboot - parameters: - device_id: ${DEVICE_ID} - fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_cantRebootBootloader - 101: script_error_deviceID_missing - 102: script_error_fastbootPath_missing - output: ~ - succeed: f3 - failed: ~ - f3: - script: gs290-flashingUnlock - parameters: - device_id: ${DEVICE_ID} - fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 2: script_error_flashingUnlockFailed - 101: script_error_deviceID_missing - 102: script_error_fastbootPath_missing - output: ~ - succeed: f4 - failed: ~ - f4: - script: Teracube_2e-install-from-bootloader - parameters: - device_id: ${DEVICE_ID} - archive_path: ${ARCHIVE_PATH} - fastboot_folder_path: ${ADB_FOLDER_PATH} - java_folder_path: ${JAVA_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_cantUnpackSources - 11: script_error_cantWipeData - 12: script_error_cantFlashBoot - 13: script_error_cantFlashRecovery - 14: script_error_cantFlashVbmeta - 15: script_error_cantFlashVbmeta_system - 16: script_error_cantFlashVBmeta_vendor - 17: script_error_cantRebootToFastboot - 18: script_error_cantFlashSystem - 19: script_error_cantFlashproduct - 20: script_error_cantFlashVendor - 101: script_error_deviceID_missing - 102: script_error_installFromFastboot_102 - 103: script_error_fastbootPath_missing - output: ~ - succeed: f5 - failed: ~ - f5: - script: askAccount - parameters: ~ - codes: ~ - output: ~ - succeed: f6 - failed: ~ - f6: - script: gs290-wait-reboot-from-fastboot - parameters: - fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_cantrebootFromFasboot - 101: script_error_noDeviceFoundInFastboot - output: ~ - succeed: ~ - failed: ~ \ No newline at end of file diff --git a/src/main/resources/yaml/Teracube_2e_fs.yml b/src/main/resources/yaml/Teracube_2e_fs.yml index b8c6ae3b..41f90507 100644 --- a/src/main/resources/yaml/Teracube_2e_fs.yml +++ b/src/main/resources/yaml/Teracube_2e_fs.yml @@ -18,52 +18,3 @@ sources: rom: url: https://images.ecloud.global/stable/2e/IMG-e-latest-2e.zip filePath: IMG-e-latest-2e.zip -flash: - f1: - ui: - type: action - title: stepTitle_enableOemUnlock - instruction: - - install_instr_openSettings - - install_instr_searchOEM - - install_instr_enableOEMUnlocking - - install_instr_acceptOEMUnlockWarning - - install_instr_onceDoneThenContinue - stepNumber: 1/5 - titleIcon: icon-download.png - f2: - ui: - type: load - title: stepTitle_rebootBootloader - instruction: - - install_instr_rebootingOnBootloader - stepNumber: 2/5 - averageTime: 12 - f3: - ui: - type: action - title: stepTitle_oemUnlock - instruction: - - install_instr_pressVolUpToAcceptOEMUnlocking - - install_instr_waitInstallStartAuto - stepNumber: 3/5 - titleIcon: icon-download.png - f4: - ui: - type: load - title: stepTitle_installOS - instruction: - - install_instr_eosInstall - stepNumber: 4/5 - averageTime: 200 - f5: - ui: - type: askAccount - f6: - ui: - type: action - title: stepTitle_rebootDevice - instruction: - - install_instr_onceDeviceRebootThenContinue - stepNumber: 5/5 - titleIcon: icon-download.png -- GitLab From 4dcc0e89ae8fcef3fabca7586d4c66fd8634f770 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 10:22:54 +0200 Subject: [PATCH 035/102] fix parseCommand() in configParser --- .../easy/installer/utils/ConfigParser.java | 30 +++++++----- src/main/resources/yaml/GS290_new.yml | 46 +++++++++++++++++++ 2 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 src/main/resources/yaml/GS290_new.yml diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index 489c4a05..20402833 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -16,7 +16,9 @@ */ package ecorp.easy.installer.utils; +import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.models.Command; +import ecorp.easy.installer.models.Step; import ecorp.easy.installer.models.steps.BasicStep; import ecorp.easy.installer.models.steps.CustomExecutableStep; import ecorp.easy.installer.models.steps.CustomStep; @@ -25,6 +27,8 @@ import ecorp.easy.installer.models.steps.IStep; import ecorp.easy.installer.models.steps.LoadStep; import java.text.ParseException; import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -166,23 +170,25 @@ public class ConfigParser { /** * Parse yaml content into Command object + * @TODO rewrite when splitting command between data and job * @param yaml Map yaml content * @return Command object */ private static Command parseCommand(Map yaml) throws ParseException, ClassCastException{ - final String commandBase = (String) yaml.get("script"); - //@TODO: uncomment belows when Command and CommandExecution will be separated - - //final String outputKey = (String) yaml.get("outputKey"); - //final HashMap parameters = (HashMap) yaml.get("parameters"); - //final HashMap okCodes = (HashMap) yaml.get("okCodes"); - //final HashMap koCodes = (HashMap) yaml.get("koCodes"); - - final Command result = new Command(commandBase/*, parameters*/); - //result.setOkCodes(okCodes); - //result.setKoCodes(koCodes); - //if(outputKey != null) result.setOutputKey(outputKey); + final String commandBase = (String) yaml.get("script")+( AppConstants.isWindowsOs() ? ".bat" : ".sh" ) ; + + final String outputKey = (String) yaml.getOrDefault("outputKey", null); + final LinkedHashMap parameters = (LinkedHashMap) yaml.get("parameters"); + final HashMap okCodes = (HashMap) yaml.getOrDefault("okCodes", null); + final HashMap koCodes = (HashMap) yaml.getOrDefault("koCodes", null); + final Step cmdStep = new Step(); + cmdStep.setOutput(outputKey); + cmdStep.setKoCode(koCodes); + cmdStep.setOkCode(okCodes); + cmdStep.setParameters(parameters); + cmdStep.setScript(commandBase); + final Command result = new Command(AppConstants.getScriptsFolderPath(), cmdStep); return result; } diff --git a/src/main/resources/yaml/GS290_new.yml b/src/main/resources/yaml/GS290_new.yml new file mode 100644 index 00000000..5012c680 --- /dev/null +++ b/src/main/resources/yaml/GS290_new.yml @@ -0,0 +1,46 @@ +## Copyright 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 . +## Author: Vincent Bourgmayer +--- +stepsCount: 7 +steps: + f0: + type: + stepNumber: 1 + nextStepKey: f1 + f1: + type: + stepNumber: 2 + nextStepKey: f2 + f2: + type: + stepNumber: 3 + nextStepKey: f3 + f3: + type: + stepNumber: 4 + nextStepKey: f4 + f4: + type: + stepNumber: 5 + nextStepKey: f5 + f5: + type: askAccount + stepNumber: 6 + nextStepKey: f6 + f6: + type: + stepNumber: 7 + nextStepKey: end \ No newline at end of file -- GitLab From ee9caf8ebf5cf400e5d35cb8ee83ed0cedabd166 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 10:43:12 +0200 Subject: [PATCH 036/102] fix device detection to use new config file --- .../controllers/subcontrollers/DeviceDetectedController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java index 44eb6a0a..e789a8f6 100644 --- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java +++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java @@ -110,7 +110,7 @@ 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()+".yml"); + URL resourceUrl = getClass().getResource("/yaml/"+phone.getAdbDevice()+"_new.yml"); if(resourceUrl == null){ //@TODO: this can be replaced or completed with a call to DeviceHelper displayIncompatibleDeviceFound(model); -- GitLab From a4b34be01e24fdce2e974e798f5fd151418e73c0 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 14:31:14 +0200 Subject: [PATCH 037/102] increase averageTime for t2e's load step --- src/main/resources/yaml/Teracube_2e_new.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/yaml/Teracube_2e_new.yml b/src/main/resources/yaml/Teracube_2e_new.yml index a0c599d3..e26e1b28 100644 --- a/src/main/resources/yaml/Teracube_2e_new.yml +++ b/src/main/resources/yaml/Teracube_2e_new.yml @@ -36,7 +36,7 @@ steps: titleIconName: ~ instructions: - install_instr_rebootingOnBootloader - averageTime: 12 + averageTime: 15 script: reboot-fastboot parameters: device_id: ${DEVICE_ID} @@ -78,7 +78,7 @@ steps: titleIconName: ~ instructions: - install_instr_eosInstall - averageTime: 200 + averageTime: 215 script: Teracube_2e-install-from-bootloader parameters: device_id: ${DEVICE_ID} -- GitLab From d69abaa117d7a20816782384c7731f3803ef2b20 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 14:32:07 +0200 Subject: [PATCH 038/102] change logged info in FlashThread and config parser --- src/main/java/ecorp/easy/installer/threads/FlashThread.java | 5 ++++- src/main/java/ecorp/easy/installer/utils/ConfigParser.java | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/threads/FlashThread.java b/src/main/java/ecorp/easy/installer/threads/FlashThread.java index 7e445457..e16b4ed6 100644 --- a/src/main/java/ecorp/easy/installer/threads/FlashThread.java +++ b/src/main/java/ecorp/easy/installer/threads/FlashThread.java @@ -84,6 +84,7 @@ public class FlashThread extends Thread { * @param step IStep step to add */ public void addStep(String key, IStep step){ + logger.debug("FlashThread.addStep({}, ...)", key); if(step != null && key!= null) steps.put(key, step); } @@ -150,10 +151,12 @@ public class FlashThread extends Thread { //Update UI final IStep step = steps.get(currentStepCode); final DataBundle bundle = new DataBundle(); - + logger.debug("doBeforeToRunCommand(), currentStepCode: {}", currentStepCode); //Prepare datas for UI final String stepType = step.getType(); bundle.putString("stepType", stepType); + logger.debug("--stepType: {}", stepType); + final boolean hasScript; switch(stepType){ case "custom": diff --git a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java index 20402833..9eecebbb 100644 --- a/src/main/java/ecorp/easy/installer/utils/ConfigParser.java +++ b/src/main/java/ecorp/easy/installer/utils/ConfigParser.java @@ -54,7 +54,6 @@ public class ConfigParser { * @throws NumberFormatException */ public static IStep parseStep(Map yaml) throws ParseException, NumberFormatException, NullPointerException{ - logger.debug("parseStep(yaml)"); IStep result = null; String type = (String) yaml.get("type"); @@ -207,7 +206,6 @@ public class ConfigParser { final String titleKey = (String) yaml.get("titleKey"); final String titleIconName = (String) yaml.getOrDefault("titleIconName", ""); final ArrayList instructions = (ArrayList) yaml.getOrDefault("instructions", new ArrayList()); - final Command cmd = parseCommand(yaml); CustomExecutableStep result = new CustomExecutableStep(type, nextStepKey, stepNumber, titleKey, titleIconName, instructions, cmd); -- GitLab From 616e3c9fa61241cb0982c0fb7e3ead8225c0f034 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 14:32:44 +0200 Subject: [PATCH 039/102] fix issue due to ICustomStep.getType() --- .../easy/installer/models/steps/CustomExecutableStep.java | 2 +- .../java/ecorp/easy/installer/models/steps/ICustomStep.java | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java index 896317b3..13692a2e 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/CustomExecutableStep.java @@ -42,7 +42,7 @@ public class CustomExecutableStep extends BasicStep implements ICustomStep, IExe @Override public String getType(){ - return ICustomStep.super.getType(); + return super.getType(); } @Override diff --git a/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java b/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java index acfc10df..05dbd41d 100644 --- a/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java +++ b/src/main/java/ecorp/easy/installer/models/steps/ICustomStep.java @@ -48,9 +48,5 @@ public interface ICustomStep extends IStep{ * @return ArrayList le list of keys */ public ArrayList getTextContentKeys(); - - @Override - default String getType(){ - return "action"; - } + } -- GitLab From 02ec2f6e85219001843148bf64d5ab7d94f1af9b Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 14:33:17 +0200 Subject: [PATCH 040/102] update logged info for FlashSceneController --- .../controllers/subcontrollers/FlashSceneController.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java index 43142bbc..0e855e1d 100644 --- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java +++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java @@ -156,7 +156,6 @@ public class FlashSceneController extends AbstractSubSteppedController implement @Override public void onStepStart(DataBundle db) { logger.info("onStepStart()"); - logger.debug(" DataBundle = {}", db.toString()); if(db == null)return; //close the timer of a loadStepType @@ -170,11 +169,11 @@ public class FlashSceneController extends AbstractSubSteppedController implement //Update instruction title final String title = db.getString("stepTitle"); - logger.debug("Title: "+title); + logger.debug("--Title {}", title); //Get Type of step ("action" or "load") final String stepType = db.getString("stepType"); - + logger.debug("--Type: {}", stepType); switch (stepType) { case AppConstants.USER_ACTION_KEY: //@deprecated case "custom": -- GitLab From b4e3a9a767003e76a2f0ff6bd73ab4a79b13b2a4 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 14:59:26 +0200 Subject: [PATCH 041/102] update config file for FP3 & 2e. Add GS290 new config file and template for dreamlte --- src/main/resources/yaml/FP3_new.yml | 5 - src/main/resources/yaml/GS290.yml | 84 +--------------- src/main/resources/yaml/GS290_fs.yml | 64 +------------ src/main/resources/yaml/GS290_new.yml | 100 ++++++++++++++++++-- src/main/resources/yaml/Teracube_2e_new.yml | 4 - src/main/resources/yaml/dreamlte_new.yml | 50 ++++++++++ 6 files changed, 147 insertions(+), 160 deletions(-) create mode 100644 src/main/resources/yaml/dreamlte_new.yml diff --git a/src/main/resources/yaml/FP3_new.yml b/src/main/resources/yaml/FP3_new.yml index 63286d74..db73a76e 100644 --- a/src/main/resources/yaml/FP3_new.yml +++ b/src/main/resources/yaml/FP3_new.yml @@ -33,7 +33,6 @@ steps: script: wait-fastboot parameters: fastboot_folder_path: ${ADB_FOLDER_PATH} - outputKey: ~ codes: ok: 0: ~ @@ -50,7 +49,6 @@ steps: script: fp3_oem-unlock parameters: fastboot_folder_path: ${ADB_FOLDER_PATH} - outputKey: ~ codes: ok: 0: ~ @@ -72,7 +70,6 @@ steps: script: wait-fastboot-unlocked parameters: fastboot_folder_path: ${ADB_FOLDER_PATH} - outputKey: ~ codes: ok: 0: ~ @@ -91,7 +88,6 @@ steps: archive_path: ${ARCHIVE_PATH} fastboot_folder_path: ${ADB_FOLDER_PATH} java_folder_path: ${JAVA_FOLDER_PATH} - outputKey: ~ codes: ok: 0: ~ @@ -117,7 +113,6 @@ steps: script: wait-reboot-from-fastboot parameters: fastboot_folder_path: ${ADB_FOLDER_PATH} - outputKey: ~ codes: ok: 0: ~ diff --git a/src/main/resources/yaml/GS290.yml b/src/main/resources/yaml/GS290.yml index 9817806a..2d7b8cd6 100644 --- a/src/main/resources/yaml/GS290.yml +++ b/src/main/resources/yaml/GS290.yml @@ -16,92 +16,14 @@ --- name: GS290 flash: - f1: - script: ~ - parameters: ~ - codes: ~ - output: ~ - succeed: f2 - failed: ~ - f2: - script: ~ - parameters: ~ - codes: ~ - output: ~ - succeed: f3 - failed: ~ - f3: - script: reboot-fastboot - parameters: - device_id: ${DEVICE_ID} - fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_cantRebootBootloader - 101: script_error_deviceID_missing - 102: script_error_fastbootPath_missing - output: ~ - succeed: f4 - failed: ~ - f4: - script: gs290-flashingUnlock - parameters: - device_id: ${DEVICE_ID} - fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 2: script_error_flashingUnlockFailed - 101: script_error_deviceID_missing - 102: script_error_fastbootPath_missing - output: ~ - succeed: f5 - failed: ~ - f5: - script: gs290-install-from-bootloader - parameters: - device_id: ${DEVICE_ID} - archive_path: ${ARCHIVE_PATH} - fastboot_folder_path: ${ADB_FOLDER_PATH} - java_folder_path: ${JAVA_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_cantUnpackSources - 11: script_error_cantWipeData - 12: script_error_cantFlashBoot - 13: script_error_cantFlashRecovery - 14: script_error_cantFlashsystem - 15: script_error_cantFlashLk - 16: script_error_cantFlashLogo - 101: script_error_deviceID_missing - 102: script_error_installFromFastboot_102 - 103: script_error_fastbootPath_missing - output: ~ - succeed: f6 - failed: ~ - f6: - script: askAccount - parameters: ~ - codes: ~ - output: ~ - succeed: f7 - failed: ~ + f7: script: gs290-wait-reboot-from-fastboot parameters: fastboot_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: + okCodes: 0: ~ - ko: + koCodes: 1: script_error_unknown 10: script_error_cantrebootFromFasboot 101: script_error_noDeviceFoundInFastboot diff --git a/src/main/resources/yaml/GS290_fs.yml b/src/main/resources/yaml/GS290_fs.yml index c0e2c7f9..ecb849f0 100644 --- a/src/main/resources/yaml/GS290_fs.yml +++ b/src/main/resources/yaml/GS290_fs.yml @@ -1,4 +1,4 @@ -## Copyright 2019-2020 - ECORP SAS +## 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 @@ -30,65 +30,3 @@ sources: recovery: url: https://images.ecloud.global/stable/GS290/recovery-e-latest-GS290.img filePath: recovery-e-latest-GS290.img -flash: - f1: - ui: - type: action - title: stepTitle_checkDeviceUptodate - instruction: - - install_instr_connectTowifi - - install_instr_GS290_accessSystemSettings - - install_instr_GS290_accessSystemUpdate - - install_instr_update_stockrom - - install_instr_continueIfDeviceUpToDate - stepNumber: 1/6 - titleIcon: icon-download.png - f2: - ui: - type: action - title: stepTitle_enableOemUnlock - instruction: - - install_instr_openSettings - - install_instr_searchOEM - - install_instr_enableOEMUnlocking - - install_instr_acceptOEMUnlockWarning - - install_instr_onceDoneThenContinue - stepNumber: 2/6 - titleIcon: icon-download.png - f3: - ui: - type: load - title: stepTitle_rebootBootloader - instruction: - - install_instr_rebootingOnBootloader - stepNumber: 3/6 - averageTime: 12 - f4: - ui: - type: action - title: stepTitle_oemUnlock - instruction: - - install_instr_pressVolUpToAcceptOEMUnlocking - - install_instr_unlockingOem - - install_instr_waitInstallStartAuto - stepNumber: 4/6 - titleIcon: icon-download.png - f5: - ui: - type: load - title: stepTitle_installOS - instruction: - - install_instr_eosInstall - stepNumber: 5/6 - averageTime: 200 - f6: - ui: - type: askAccount - f7: - ui: - type: action - title: stepTitle_rebootDevice - instruction: - - install_instr_onceDeviceRebootThenContinue - stepNumber: 6/6 - titleIcon: icon-download.png diff --git a/src/main/resources/yaml/GS290_new.yml b/src/main/resources/yaml/GS290_new.yml index 5012c680..112ff8d2 100644 --- a/src/main/resources/yaml/GS290_new.yml +++ b/src/main/resources/yaml/GS290_new.yml @@ -17,30 +17,116 @@ stepsCount: 7 steps: f0: - type: + type: custom stepNumber: 1 nextStepKey: f1 + titleKey: stepTitle_checkDeviceUptodate + titleIconName: icon-download.png + instructions: + - install_instr_connectTowifi + - install_instr_GS290_accessSystemSettings + - install_instr_GS290_accessSystemUpdate + - install_instr_update_stockrom + - install_instr_continueIfDeviceUpToDate f1: - type: + type: custom stepNumber: 2 nextStepKey: f2 + titleKey: stepTitle_enableOemUnlock + titleIconName: icon-download.png + instructions: + - install_instr_openSettings + - install_instr_searchOEM + - install_instr_enableOEMUnlocking + - install_instr_acceptOEMUnlockWarning + - install_instr_onceDoneThenContinue f2: - type: + type: load stepNumber: 3 nextStepKey: f3 + titleKey: stepTitle_rebootBootloader + instructions: + - install_instr_rebootingOnBootloader + averageTime: 12 + script: reboot-fastboot + parameters: + device_id: ${DEVICE_ID} + fastboot_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_cantRebootBootloader + 101: script_error_deviceID_missing + 102: script_error_fastbootPath_missing f3: - type: + type: custom-executable stepNumber: 4 nextStepKey: f4 + titleKey: stepTitle_oemUnlock + titleIconName: icon-download.png + instructions: + - install_instr_pressVolUpToAcceptOEMUnlocking + - install_instr_unlockingOem + - install_instr_waitInstallStartAuto + script: gs290-flashingUnlock + parameters: + device_id: ${DEVICE_ID} + fastboot_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 2: script_error_flashingUnlockFailed + 101: script_error_deviceID_missing + 102: script_error_fastbootPath_missing + f4: - type: + type: load stepNumber: 5 nextStepKey: f5 + titleKey: stepTitle_installOS + instructions: + - install_instr_eosInstall + averageTime: 200 + script: gs290-install-from-bootloader + parameters: + device_id: ${DEVICE_ID} + archive_path: ${ARCHIVE_PATH} + fastboot_folder_path: ${ADB_FOLDER_PATH} + java_folder_path: ${JAVA_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_cantUnpackSources + 11: script_error_cantWipeData + 12: script_error_cantFlashBoot + 13: script_error_cantFlashRecovery + 14: script_error_cantFlashsystem + 15: script_error_cantFlashLk + 16: script_error_cantFlashLogo + 101: script_error_deviceID_missing + 102: script_error_installFromFastboot_102 + 103: script_error_fastbootPath_missing f5: type: askAccount stepNumber: 6 nextStepKey: f6 f6: - type: + type: custom-executable stepNumber: 7 - nextStepKey: end \ No newline at end of file + nextStepKey: end + titleKey: stepTitle_rebootDevice + titleIconName: icon-download.png + instructions: + - install_instr_onceDeviceRebootThenContinue + script: gs290-wait-reboot-from-fastboot + parameters: + fastboot_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_cantrebootFromFasboot + 101: script_error_noDeviceFoundInFastboot \ No newline at end of file diff --git a/src/main/resources/yaml/Teracube_2e_new.yml b/src/main/resources/yaml/Teracube_2e_new.yml index e26e1b28..e244ae4e 100644 --- a/src/main/resources/yaml/Teracube_2e_new.yml +++ b/src/main/resources/yaml/Teracube_2e_new.yml @@ -41,7 +41,6 @@ steps: parameters: device_id: ${DEVICE_ID} fastboot_folder_path: ${ADB_FOLDER_PATH} - outputKey: ~ okCodes: 0: ~ koCodes: @@ -62,7 +61,6 @@ steps: parameters: device_id: ${DEVICE_ID} fastboot_folder_path: ${ADB_FOLDER_PATH} - outputKey: ~ okCodes: 0: ~ koCodes: @@ -85,7 +83,6 @@ steps: archive_path: ${ARCHIVE_PATH} fastboot_folder_path: ${ADB_FOLDER_PATH} java_folder_path: ${JAVA_FOLDER_PATH} - outputKey: ~ okCodes: 0: ~ koCodes: @@ -119,7 +116,6 @@ steps: script: gs290-wait-reboot-from-fastboot parameters: fastboot_folder_path: ${ADB_FOLDER_PATH} - outputKey: ~ okCodes: 0: ~ koCodes: diff --git a/src/main/resources/yaml/dreamlte_new.yml b/src/main/resources/yaml/dreamlte_new.yml new file mode 100644 index 00000000..4d90551b --- /dev/null +++ b/src/main/resources/yaml/dreamlte_new.yml @@ -0,0 +1,50 @@ +## Copyright 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 . +## Author: Vincent Bourgmayer +--- +stepsCount: 7 +steps: + f0: + type: + stepNumber: 1 + nextStepKey: f1 + f1: + type: + stepNumber: 2 + nextStepKey: f2 + f2: + type: + stepNumber: 3 + nextStepKey: f3 + f3: + type: + stepNumber: 4 + nextStepKey: f4 + f4: + type: + stepNumber: 5 + nextStepKey: f5 + f5: + type: + stepNumber: 6 + nextStepKey: f6 + f6: + type: askAccount + stepNumber: 7 + nextStepKey: f6 + f7: + type: + stepNumber: 8 + nextStepKey: end \ No newline at end of file -- GitLab From 190c7229cf2cb4131f1a2a1e5f00945ddd7d1919 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 15:18:22 +0200 Subject: [PATCH 042/102] add dreamlte new config file, and remove old one. --- src/main/resources/yaml/GS290.yml | 32 ---- src/main/resources/yaml/dream2lte.yml | 129 ---------------- src/main/resources/yaml/dream2lte_fs.yml | 86 +---------- src/main/resources/yaml/dream2lte_new.yml | 170 ++++++++++++++++++++++ src/main/resources/yaml/dreamlte.yml | 129 ---------------- src/main/resources/yaml/dreamlte_fs.yml | 84 +---------- src/main/resources/yaml/dreamlte_new.yml | 136 ++++++++++++++++- 7 files changed, 301 insertions(+), 465 deletions(-) delete mode 100644 src/main/resources/yaml/GS290.yml delete mode 100644 src/main/resources/yaml/dream2lte.yml create mode 100644 src/main/resources/yaml/dream2lte_new.yml delete mode 100644 src/main/resources/yaml/dreamlte.yml diff --git a/src/main/resources/yaml/GS290.yml b/src/main/resources/yaml/GS290.yml deleted file mode 100644 index 2d7b8cd6..00000000 --- a/src/main/resources/yaml/GS290.yml +++ /dev/null @@ -1,32 +0,0 @@ -## Copyright 2019-2020 - 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 . -## Author: Vincent Bourgmayer ---- -name: GS290 -flash: - - f7: - script: gs290-wait-reboot-from-fastboot - parameters: - fastboot_folder_path: ${ADB_FOLDER_PATH} - okCodes: - 0: ~ - koCodes: - 1: script_error_unknown - 10: script_error_cantrebootFromFasboot - 101: script_error_noDeviceFoundInFastboot - output: ~ - succeed: ~ - failed: ~ \ No newline at end of file diff --git a/src/main/resources/yaml/dream2lte.yml b/src/main/resources/yaml/dream2lte.yml deleted file mode 100644 index fac9e786..00000000 --- a/src/main/resources/yaml/dream2lte.yml +++ /dev/null @@ -1,129 +0,0 @@ -## Copyright 2019-2020 - 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 . -## Author: Vincent Bourgmayer ---- -name: dream2lte -flash: - f1: - script: wait-download - parameters: - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitDownload_1 - output: ~ - succeed: f2 - failed: ~ - f2: - script: install-recovery - parameters: - twrp_image_path: ${TWRP_IMAGE_PATH} - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 101: script_error_installRecovery_101 - output: ~ - succeed: f3 - failed: ~ - f3: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f4 - failed: ~ - f4: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: f5 - failed: ~ - f5: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f6 - failed: ~ - f6: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${ARCHIVE_PATH} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f7 - failed: ~ - f7: - script: askAccount - parameters: ~ - codes: ~ - output: ~ - succeed: f8 - failed: ~ - f8: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: ~ - failed: ~ \ No newline at end of file diff --git a/src/main/resources/yaml/dream2lte_fs.yml b/src/main/resources/yaml/dream2lte_fs.yml index 05c7833a..81cfb3fc 100644 --- a/src/main/resources/yaml/dream2lte_fs.yml +++ b/src/main/resources/yaml/dream2lte_fs.yml @@ -1,4 +1,4 @@ -## Copyright 2019-2020 - ECORP SAS +## 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 @@ -20,86 +20,4 @@ sources: filePath: e-latest-dream2lte.zip twrp: url: https://images.ecloud.global/stable/twrp/dream2lte/twrp-3.3.1-2-dream2lte.img - filePath: twrp-3.3.1-2-dream2lte.img -flash: - f1: - ui: - type: action - title: stepTitle_oemUnlock - instruction: - - install_instr_openSettings - - install_instr_openDevOptions - - install_instr_enableOEMUnlock - - install_instr_turnOff - - install_instr_startDl_pressPowerBixbyVolDown - - install_instr_acceptWarning - stepNumber: 1/7 - titleIcon: icon-download.png - f2: - ui: - type: load - title: stepTitle_installRecovery - instruction: - - install_instr_recoveryInstall - stepNumber: 2/7 - averageTime: 6 - f3: - ui: - type: action - title: stepTitle_startRecovery - instruction: - - install_instr_leaveDl_pressPowerBixbyVolDown - - install_instr_startRec_pressPowerBixbyVolUp - - install_instr_swipeTwrp - stepNumber: 3/7 - titleIcon: icon-download.png - f4: - ui: - type: action - title: stepTitle_formatDataTurnOff - instruction: - - install_instr_tapWipe - - install_instr_tapFormatData - - install_instr_writeYes - - install_instr_validate - - install_instr_backX3 - - install_instr_tapReboot - - install_instr_tapRebootPowerOff - - install_instr_doNotInstall - stepNumber: 4/7 - titleIcon: icon-search.png - f5: - ui: - type: action - title: stepTitle_restartRecovery - instruction: - - install_instr_startRec_pressPowerBixbyVolUp - - install_instr_swipeTwrp - stepNumber: 5/7 - titleIcon: icon-download.png - f6: - ui: - type: load - title: stepTitle_installOS - instruction: - - install_instr_eosInstall - stepNumber: 6/7 - averageTime: 475 - f7: - ui: - type: askAccount - f8: - ui: - type: action - title: stepTitle_resizeDataPartition - instruction: - - install_instr_tapWipe - - install_instr_tapAdvancedWipe - - install_instr_tickData - - install_instr_tapRepairChangeFs - - install_instr_resizeFs - - install_instr_swipeForOk - - install_instr_tapRebootSystem - - install_instr_doNotInstall - stepNumber: 7/7 - titleIcon: icon-search.png \ No newline at end of file + filePath: twrp-3.3.1-2-dream2lte.img \ No newline at end of file diff --git a/src/main/resources/yaml/dream2lte_new.yml b/src/main/resources/yaml/dream2lte_new.yml new file mode 100644 index 00000000..8d162221 --- /dev/null +++ b/src/main/resources/yaml/dream2lte_new.yml @@ -0,0 +1,170 @@ +## Copyright 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 . +## Author: Vincent Bourgmayer +--- +stepsCount: 8 +steps: + f0: + type: custom-executable + stepNumber: 1 + nextStepKey: f1 + titleKey: stepTitle_oemUnlock + instructions: + - install_instr_openSettings + - install_instr_openDevOptions + - install_instr_enableOEMUnlock + - install_instr_turnOff + - install_instr_startDl_pressPowerBixbyVolDown + - install_instr_acceptWarning + titleKeyIconName: icon-download.png + script: wait-download + parameters: + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitDownload_1 + f1: + type: load + stepNumber: 2 + nextStepKey: f2 + titleKey: stepTitle_installRecovery + instructions: + - install_instr_recoveryInstall + averageTime: 6 + script: install-recovery + parameters: + twrp_image_path: ${TWRP_IMAGE_PATH} + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 101: script_error_installRecovery_101 + f2: + type: custom-executable + stepNumber: 3 + nextStepKey: f3 + titleKey: stepTitle_startRecovery + instructions: + - install_instr_leaveDl_pressPowerBixbyVolDown + - install_instr_startRec_pressPowerBixbyVolUp + - install_instr_swipeTwrp + titleKeyIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 + f3: + type: custom-executable + stepNumber: 4 + nextStepKey: f4 + titleKey: stepTitle_formatDataTurnOff + instructions: + - install_instr_tapWipe + - install_instr_tapFormatData + - install_instr_writeYes + - install_instr_validate + - install_instr_backX3 + - install_instr_tapReboot + - install_instr_tapRebootPowerOff + - install_instr_doNotInstall + titleKeyIconName: icon-search.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 + f4: + type: + stepNumber: 5 + nextStepKey: f5 + type: action + titleKey: stepTitle_restartRecovery + instructions: + - install_instr_startRec_pressPowerBixbyVolUp + - install_instr_swipeTwrp + titleKeyIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 + f5: + type: load + stepNumber: 6 + nextStepKey: f6 + titleKey: stepTitle_installOS + instructions: + - install_instr_eosInstall + averageTime: 475 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${ARCHIVE_PATH} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 + f6: + type: askAccount + stepNumber: 7 + nextStepKey: f6 + f7: + type: custom-executable + stepNumber: 8 + nextStepKey: end + titleKey: stepTitle_resizeDataPartition + instructions: + - install_instr_tapWipe + - install_instr_tapAdvancedWipe + - install_instr_tickData + - install_instr_tapRepairChangeFs + - install_instr_resizeFs + - install_instr_swipeForOk + - install_instr_tapRebootSystem + - install_instr_doNotInstall + titleKeyIconName: icon-search.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 \ No newline at end of file diff --git a/src/main/resources/yaml/dreamlte.yml b/src/main/resources/yaml/dreamlte.yml deleted file mode 100644 index dfe13b10..00000000 --- a/src/main/resources/yaml/dreamlte.yml +++ /dev/null @@ -1,129 +0,0 @@ -## Copyright 2019-2020 - 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 . -## Author: Vincent Bourgmayer ---- -name: dreamlte -flash: - f1: - script: wait-download - parameters: - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitDownload_1 - output: ~ - succeed: f2 - failed: ~ - f2: - script: install-recovery - parameters: - twrp_image_path: ${TWRP_IMAGE_PATH} - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 101: script_error_installRecovery_101 - output: ~ - succeed: f3 - failed: ~ - f3: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f4 - failed: ~ - f4: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: f5 - failed: ~ - f5: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f6 - failed: ~ - f6: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${ARCHIVE_PATH} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f7 - failed: ~ - f7: - script: askAccount - parameters: ~ - codes: ~ - output: ~ - succeed: f8 - failed: ~ - f8: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: ~ - failed: ~ \ No newline at end of file diff --git a/src/main/resources/yaml/dreamlte_fs.yml b/src/main/resources/yaml/dreamlte_fs.yml index 8b108b5a..865c0d77 100644 --- a/src/main/resources/yaml/dreamlte_fs.yml +++ b/src/main/resources/yaml/dreamlte_fs.yml @@ -20,86 +20,4 @@ sources: filePath: e-latest-dreamlte.zip twrp: url: https://images.ecloud.global/stable/twrp/dreamlte/twrp-3.3.1-2-dreamlte.img - filePath: twrp-3.3.1-2-dreamlte.img -flash: - f1: - ui: - type: action - title: stepTitle_oemUnlock - instruction: - - install_instr_openSettings - - install_instr_openDevOptions - - install_instr_enableOEMUnlock - - install_instr_turnOff - - install_instr_startDl_pressPowerBixbyVolDown - - install_instr_acceptWarning - stepNumber: 1/7 - titleIcon: icon-download.png - f2: - ui: - type: load - title: stepTitle_installRecovery - instruction: - - install_instr_recoveryInstall - stepNumber: 2/7 - averageTime: 6 - f3: - ui: - type: action - title: stepTitle_startRecovery - instruction: - - install_instr_leaveDl_pressPowerBixbyVolDown - - install_instr_startRec_pressPowerBixbyVolUp - - install_instr_swipeTwrp - stepNumber: 3/7 - titleIcon: icon-download.png - f4: - ui: - type: action - title: stepTitle_formatDataTurnOff - instruction: - - install_instr_tapWipe - - install_instr_tapFormatData - - install_instr_writeYes - - install_instr_validate - - install_instr_backX3 - - install_instr_tapReboot - - install_instr_tapRebootPowerOff - - install_instr_doNotInstall - stepNumber: 4/7 - titleIcon: icon-search.png - f5: - ui: - type: action - title: stepTitle_restartRecovery - instruction: - - install_instr_startRec_pressPowerBixbyVolUp - - install_instr_swipeTwrp - stepNumber: 5/7 - titleIcon: icon-download.png - f6: - ui: - type: load - title: stepTitle_installOS - instruction: - - install_instr_eosInstall - stepNumber: 6/7 - averageTime: 475 - f7: - ui: - type: askAccount - f8: - ui: - type: action - title: stepTitle_resizeDataPartition - instruction: - - install_instr_tapWipe - - install_instr_tapAdvancedWipe - - install_instr_tickData - - install_instr_tapRepairChangeFs - - install_instr_resizeFs - - install_instr_swipeForOk - - install_instr_tapRebootSystem - - install_instr_doNotInstall - stepNumber: 7/7 - titleIcon: icon-search.png \ No newline at end of file + filePath: twrp-3.3.1-2-dreamlte.img \ No newline at end of file diff --git a/src/main/resources/yaml/dreamlte_new.yml b/src/main/resources/yaml/dreamlte_new.yml index 4d90551b..8d162221 100644 --- a/src/main/resources/yaml/dreamlte_new.yml +++ b/src/main/resources/yaml/dreamlte_new.yml @@ -14,37 +14,157 @@ ## along with this program. If not, see . ## Author: Vincent Bourgmayer --- -stepsCount: 7 +stepsCount: 8 steps: f0: - type: + type: custom-executable stepNumber: 1 nextStepKey: f1 + titleKey: stepTitle_oemUnlock + instructions: + - install_instr_openSettings + - install_instr_openDevOptions + - install_instr_enableOEMUnlock + - install_instr_turnOff + - install_instr_startDl_pressPowerBixbyVolDown + - install_instr_acceptWarning + titleKeyIconName: icon-download.png + script: wait-download + parameters: + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitDownload_1 f1: - type: + type: load stepNumber: 2 nextStepKey: f2 + titleKey: stepTitle_installRecovery + instructions: + - install_instr_recoveryInstall + averageTime: 6 + script: install-recovery + parameters: + twrp_image_path: ${TWRP_IMAGE_PATH} + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 101: script_error_installRecovery_101 f2: - type: + type: custom-executable stepNumber: 3 nextStepKey: f3 + titleKey: stepTitle_startRecovery + instructions: + - install_instr_leaveDl_pressPowerBixbyVolDown + - install_instr_startRec_pressPowerBixbyVolUp + - install_instr_swipeTwrp + titleKeyIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 f3: - type: + type: custom-executable stepNumber: 4 nextStepKey: f4 + titleKey: stepTitle_formatDataTurnOff + instructions: + - install_instr_tapWipe + - install_instr_tapFormatData + - install_instr_writeYes + - install_instr_validate + - install_instr_backX3 + - install_instr_tapReboot + - install_instr_tapRebootPowerOff + - install_instr_doNotInstall + titleKeyIconName: icon-search.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 f4: type: stepNumber: 5 nextStepKey: f5 + type: action + titleKey: stepTitle_restartRecovery + instructions: + - install_instr_startRec_pressPowerBixbyVolUp + - install_instr_swipeTwrp + titleKeyIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 f5: - type: + type: load stepNumber: 6 nextStepKey: f6 + titleKey: stepTitle_installOS + instructions: + - install_instr_eosInstall + averageTime: 475 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${ARCHIVE_PATH} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 f6: type: askAccount stepNumber: 7 nextStepKey: f6 f7: - type: + type: custom-executable stepNumber: 8 - nextStepKey: end \ No newline at end of file + nextStepKey: end + titleKey: stepTitle_resizeDataPartition + instructions: + - install_instr_tapWipe + - install_instr_tapAdvancedWipe + - install_instr_tickData + - install_instr_tapRepairChangeFs + - install_instr_resizeFs + - install_instr_swipeForOk + - install_instr_tapRebootSystem + - install_instr_doNotInstall + titleKeyIconName: icon-search.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 \ No newline at end of file -- GitLab From c52eb16554334d39febdd43a112c4797d3d9a2d4 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 15:32:15 +0200 Subject: [PATCH 043/102] add new config file for herolte & hero2lte --- src/main/resources/yaml/hero2lte.yml | 99 ------------------ src/main/resources/yaml/hero2lte_fs.yml | 61 +---------- src/main/resources/yaml/hero2lte_new.yml | 126 +++++++++++++++++++++++ src/main/resources/yaml/herolte.yml | 99 ------------------ src/main/resources/yaml/herolte_fs.yml | 61 +---------- src/main/resources/yaml/herolte_new.yml | 126 +++++++++++++++++++++++ 6 files changed, 254 insertions(+), 318 deletions(-) delete mode 100644 src/main/resources/yaml/hero2lte.yml create mode 100644 src/main/resources/yaml/hero2lte_new.yml delete mode 100644 src/main/resources/yaml/herolte.yml create mode 100644 src/main/resources/yaml/herolte_new.yml diff --git a/src/main/resources/yaml/hero2lte.yml b/src/main/resources/yaml/hero2lte.yml deleted file mode 100644 index 7a06b4c8..00000000 --- a/src/main/resources/yaml/hero2lte.yml +++ /dev/null @@ -1,99 +0,0 @@ -## Copyright 2019-2020 - 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 . -## Author: Vincent Bourgmayer ---- -name: hero2lte -flash: - f1: - script: wait-download - parameters: - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitDownload_1 - output: ~ - succeed: f2 - failed: ~ - f2: - script: install-recovery - parameters: - twrp_image_path: ${TWRP_IMAGE_PATH} - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 101: script_error_installRecovery_101 - output: ~ - succeed: f3 - failed: ~ - f3: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f4 - failed: ~ - f4: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${ARCHIVE_PATH} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f5 - failed: ~ - f5: - script: askAccount - parameters: ~ - codes: ~ - output: ~ - succeed: f6 - failed: ~ - f6: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: ~ - failed: ~ \ No newline at end of file diff --git a/src/main/resources/yaml/hero2lte_fs.yml b/src/main/resources/yaml/hero2lte_fs.yml index afa1c0c2..a5bf1bba 100644 --- a/src/main/resources/yaml/hero2lte_fs.yml +++ b/src/main/resources/yaml/hero2lte_fs.yml @@ -20,63 +20,4 @@ sources: filePath: e-latest-hero2lte.zip twrp: url: https://images.ecloud.global/stable/twrp/hero2lte/twrp-3.2.3-0-hero2lte.img - filePath: twrp-3.2.3-0-hero2lte.img -flash: - f1: - ui: - type: action - title: stepTitle1On7 - instruction: - - install_instr_turnOff - - install_instr_startDownload - - install_instr_acceptWarning - stepNumber: 1/5 - titleIcon: icon-download.png - f2: - ui: - type: load - title: stepTitle4On7 - instruction: - - install_instr_recoveryInstall - stepNumber: 2/5 - averageTime: 6 - f3: - ui: - type: action - title: stepTitle5On7 - instruction: - - install_instr_leaveDownload - - install_instr_startRecovery - - install_instr_swipeTwrp - stepNumber: 3/5 - titleIcon: icon-download.png - f4: - ui: - type: load - title: stepTitle6On7 - instruction: - - install_instr_eosInstall - stepNumber: 4/5 - averageTime: 475 - f5: - ui: - type: askAccount - f6: - ui: - type: action - title: stepTitle7On7 - instruction: - - install_instr_tapWipe - - install_instr_tapAdvancedWipe - - install_instr_tickData - - install_instr_tapRepairChangeFs - - install_instr_tapChangeFs - - install_instr_tapExt3 - - install_instr_swipeForOk - - install_instr_backX2 - - install_instr_resizeFs - - install_instr_swipeForOk - - install_instr_tapRebootSystem - - install_instr_doNotInstall - stepNumber: 5/5 - titleIcon: icon-search.png \ No newline at end of file + filePath: twrp-3.2.3-0-hero2lte.img \ No newline at end of file diff --git a/src/main/resources/yaml/hero2lte_new.yml b/src/main/resources/yaml/hero2lte_new.yml new file mode 100644 index 00000000..f9d5ace4 --- /dev/null +++ b/src/main/resources/yaml/hero2lte_new.yml @@ -0,0 +1,126 @@ +## Copyright 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 . +## Author: Vincent Bourgmayer +--- +stepsCount: 6 +steps: + f0: + type: custom-executable + stepNumber: 1 + nextStepKey: f1 + titleKey: stepTitle1On7 + instructions: + - install_instr_turnOff + - install_instr_startDownload + - install_instr_acceptWarning + titleIconName: icon-download.png + script: wait-download + parameters: + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitDownload_1 + f1: + type: load + stepNumber: 2 + nextStepKey: f2 + titleKey: stepTitle4On7 + instructions: + - install_instr_recoveryInstall + averageTime: 6 + script: install-recovery + parameters: + twrp_image_path: ${TWRP_IMAGE_PATH} + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 101: script_error_installRecovery_101 + f2: + type: custom-executable + stepNumber: 3 + nextStepKey: f3 + titleKey: stepTitle5On7 + instructions: + - install_instr_leaveDownload + - install_instr_startRecovery + - install_instr_swipeTwrp + titleIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 + f3: + type: load + stepNumber: 4 + nextStepKey: f4 + titleKey: stepTitle6On7 + instructions: + - install_instr_eosInstall + averageTime: 475 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${ARCHIVE_PATH} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 + f4: + type: askAccount + stepNumber: 5 + nextStepKey: f5 + f5: + type: custom-executable + stepNumber: 6 + nextStepKey: end + titleKey: stepTitle7On7 + instructions: + - install_instr_tapWipe + - install_instr_tapAdvancedWipe + - install_instr_tickData + - install_instr_tapRepairChangeFs + - install_instr_tapChangeFs + - install_instr_tapExt3 + - install_instr_swipeForOk + - install_instr_backX2 + - install_instr_resizeFs + - install_instr_swipeForOk + - install_instr_tapRebootSystem + - install_instr_doNotInstall + titleIconName: icon-search.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 diff --git a/src/main/resources/yaml/herolte.yml b/src/main/resources/yaml/herolte.yml deleted file mode 100644 index 8021fbca..00000000 --- a/src/main/resources/yaml/herolte.yml +++ /dev/null @@ -1,99 +0,0 @@ -## Copyright 2019-2020 - 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 . -## Author: Vincent Bourgmayer ---- -name: herolte -flash: - f1: - script: wait-download - parameters: - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitDownload_1 - output: ~ - succeed: f2 - failed: ~ - f2: - script: install-recovery - parameters: - twrp_image_path: ${TWRP_IMAGE_PATH} - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 101: script_error_installRecovery_101 - output: ~ - succeed: f3 - failed: ~ - f3: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f4 - failed: ~ - f4: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${ARCHIVE_PATH} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f5 - failed: ~ - f5: - script: askAccount - parameters: ~ - codes: ~ - output: ~ - succeed: f6 - failed: ~ - f6: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: ~ - failed: ~ \ No newline at end of file diff --git a/src/main/resources/yaml/herolte_fs.yml b/src/main/resources/yaml/herolte_fs.yml index 36bf18af..33f682b9 100644 --- a/src/main/resources/yaml/herolte_fs.yml +++ b/src/main/resources/yaml/herolte_fs.yml @@ -20,63 +20,4 @@ sources: filePath: e-latest-herolte.zip twrp: url: https://images.ecloud.global/stable/twrp/herolte/twrp-3.2.3-0-herolte.img - filePath: twrp-3.2.3-0-herolte.img -flash: - f1: - ui: - type: action - title: stepTitle1On7 - instruction: - - install_instr_turnOff - - install_instr_startDownload - - install_instr_acceptWarning - stepNumber: 1/5 - titleIcon: icon-download.png - f2: - ui: - type: load - title: stepTitle4On7 - instruction: - - install_instr_recoveryInstall - stepNumber: 2/5 - averageTime: 6 - f3: - ui: - type: action - title: stepTitle5On7 - instruction: - - install_instr_leaveDownload - - install_instr_startRecovery - - install_instr_swipeTwrp - stepNumber: 3/5 - titleIcon: icon-download.png - f4: - ui: - type: load - title: stepTitle6On7 - instruction: - - install_instr_eosInstall - stepNumber: 4/5 - averageTime: 475 - f5: - ui: - type: askAccount - f6: - ui: - type: action - title: stepTitle7On7 - instruction: - - install_instr_tapWipe - - install_instr_tapAdvancedWipe - - install_instr_tickData - - install_instr_tapRepairChangeFs - - install_instr_tapChangeFs - - install_instr_tapExt3 - - install_instr_swipeForOk - - install_instr_backX2 - - install_instr_resizeFs - - install_instr_swipeForOk - - install_instr_tapRebootSystem - - install_instr_doNotInstall - stepNumber: 5/5 - titleIcon: icon-search.png \ No newline at end of file + filePath: twrp-3.2.3-0-herolte.img \ No newline at end of file diff --git a/src/main/resources/yaml/herolte_new.yml b/src/main/resources/yaml/herolte_new.yml new file mode 100644 index 00000000..f9d5ace4 --- /dev/null +++ b/src/main/resources/yaml/herolte_new.yml @@ -0,0 +1,126 @@ +## Copyright 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 . +## Author: Vincent Bourgmayer +--- +stepsCount: 6 +steps: + f0: + type: custom-executable + stepNumber: 1 + nextStepKey: f1 + titleKey: stepTitle1On7 + instructions: + - install_instr_turnOff + - install_instr_startDownload + - install_instr_acceptWarning + titleIconName: icon-download.png + script: wait-download + parameters: + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitDownload_1 + f1: + type: load + stepNumber: 2 + nextStepKey: f2 + titleKey: stepTitle4On7 + instructions: + - install_instr_recoveryInstall + averageTime: 6 + script: install-recovery + parameters: + twrp_image_path: ${TWRP_IMAGE_PATH} + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 101: script_error_installRecovery_101 + f2: + type: custom-executable + stepNumber: 3 + nextStepKey: f3 + titleKey: stepTitle5On7 + instructions: + - install_instr_leaveDownload + - install_instr_startRecovery + - install_instr_swipeTwrp + titleIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 + f3: + type: load + stepNumber: 4 + nextStepKey: f4 + titleKey: stepTitle6On7 + instructions: + - install_instr_eosInstall + averageTime: 475 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${ARCHIVE_PATH} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 + f4: + type: askAccount + stepNumber: 5 + nextStepKey: f5 + f5: + type: custom-executable + stepNumber: 6 + nextStepKey: end + titleKey: stepTitle7On7 + instructions: + - install_instr_tapWipe + - install_instr_tapAdvancedWipe + - install_instr_tickData + - install_instr_tapRepairChangeFs + - install_instr_tapChangeFs + - install_instr_tapExt3 + - install_instr_swipeForOk + - install_instr_backX2 + - install_instr_resizeFs + - install_instr_swipeForOk + - install_instr_tapRebootSystem + - install_instr_doNotInstall + titleIconName: icon-search.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 -- GitLab From b0a82a20ef404342d8d7b065732061ec650821bf Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 15:56:53 +0200 Subject: [PATCH 044/102] add starlte & star2lte new config file --- src/main/resources/yaml/star2lte.yml | 172 ----------------- src/main/resources/yaml/star2lte_fs.yml | 114 +----------- src/main/resources/yaml/star2lte_new.yml | 223 +++++++++++++++++++++++ src/main/resources/yaml/starlte.yml | 173 ------------------ src/main/resources/yaml/starlte_fs.yml | 112 +----------- src/main/resources/yaml/starlte_new.yml | 223 +++++++++++++++++++++++ 6 files changed, 449 insertions(+), 568 deletions(-) delete mode 100644 src/main/resources/yaml/star2lte.yml create mode 100644 src/main/resources/yaml/star2lte_new.yml delete mode 100644 src/main/resources/yaml/starlte.yml create mode 100644 src/main/resources/yaml/starlte_new.yml diff --git a/src/main/resources/yaml/star2lte.yml b/src/main/resources/yaml/star2lte.yml deleted file mode 100644 index 2e9d41ef..00000000 --- a/src/main/resources/yaml/star2lte.yml +++ /dev/null @@ -1,172 +0,0 @@ -## Copyright 2019-2020 - 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 . -## Author: Vincent Bourgmayer ---- -name: star2lte -flash: - f1: - script: ~ - parameters: ~ - codes: ~ - output: ~ - succeed: f2 - failed: ~ - f2: - script: wait-download - parameters: - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitDownload_1 - output: ~ - succeed: f3 - failed: ~ - f3: - script: install-recovery - parameters: - twrp_image_path: ${TWRP_IMAGE_PATH} - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 101: script_error_installRecovery_101 - output: ~ - succeed: f4 - failed: ~ - f4: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f5 - failed: ~ - f5: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: f6 - failed: ~ - f6: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f7 - failed: ~ - f7: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${SOURCES_PATH}no-verity-opt-encrypt-samsung-1.0.zip - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f8 - failed: ~ - f8: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${SOURCES_PATH}VENDOR-27_ARI9.zip - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f9 - failed: ~ - f9: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${ARCHIVE_PATH} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f10 - failed: ~ - f10: - script: askAccount - parameters: ~ - codes: ~ - output: ~ - succeed: f11 - failed: ~ - f11: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: ~ - failed: ~ \ No newline at end of file diff --git a/src/main/resources/yaml/star2lte_fs.yml b/src/main/resources/yaml/star2lte_fs.yml index cdaddcfb..e036cd17 100644 --- a/src/main/resources/yaml/star2lte_fs.yml +++ b/src/main/resources/yaml/star2lte_fs.yml @@ -1,4 +1,4 @@ -## Copyright 2019-2020 - ECORP SAS +## 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 @@ -26,114 +26,4 @@ sources: filePath: VENDOR-27_ARI9.zip f3: url: https://images.ecloud.global/stable/patch/no-verity-opt-encrypt-samsung-1.0.zip - filePath: no-verity-opt-encrypt-samsung-1.0.zip -flash: - f1: - ui: - type: action - title: stepTitle_oemUnlock - instruction: - - install_instr_connectTowifi - - install_instr_openSettingsThenDevOptions - - install_instr_disableAutoUpdateSystem - - install_instr_openSoftwareUpdate - - install_instr_disableAutomaticDownload - - install_instr_clickDlAndInstall - - install_instr_rebootDeviceThenContinue - stepNumber: 1/10 - titleIcon: icon-download.png - f2: - ui: - type: action - title: stepTitle_oemUnlock - instruction: - - install_instr_openSettingsThenDevOptions - - install_instr_enableOEMUnlock - - install_instr_acceptFactoryReset - - install_instr_startDl_pressPowerBixbyVolDown - - install_instr_acceptWarning - stepNumber: 2/10 - titleIcon: icon-download.png - f3: - ui: - type: load - title: stepTitle4On7 - instruction: - - install_instr_recoveryInstall - stepNumber: 3/10 - averageTime: 6 - f4: - ui: - type: action - title: stepTitle5On7 - instruction: - - install_instr_leaveDl_pressPowerBixbyVolDown - - install_instr_startRec_pressPowerBixbyVolUp - - install_instr_keepReadOnly - stepNumber: 4/10 - titleIcon: icon-download.png - f5: - ui: - type: action - title: stepTitle5On7 - instruction: - - install_instr_tapWipe - - install_instr_tapFormatData - - install_instr_writeYes - - install_instr_validate - - install_instr_backX3 - - install_instr_tapReboot - - install_instr_tapRebootRecovery - - install_instr_doNotInstall - stepNumber: 5/10 - titleIcon: icon-download.png - f6: - ui: - type: action - title: stepTitle5On7 - instruction: - - install_instr_swipeTwrp - stepNumber: 6/10 - titleIcon: icon-download.png - f7: - ui: - type: load - title: install_instr_patchInstall - instruction: - - install_instr_patchInstall - stepNumber: 7/10 - averageTime: 55 - f8: - ui: - type: load - title: install_instr_vendorInstall - instruction: - - install_instr_vendorInstall - stepNumber: 8/10 - averageTime: 65 - f9: - ui: - type: load - title: install_instr_eosInstall - instruction: - - install_instr_eosInstall - stepNumber: 9/10 - averageTime: 440 - f10: - ui: - type: askAccount - f11: - ui: - type: action - title: stepTitle7On7 - instruction: - - install_instr_tapWipe - - install_instr_tapAdvancedWipe - - install_instr_tickData - - install_instr_tapRepairChangeFs - - install_instr_resizeFs - - install_instr_swipeForOk - - install_instr_tapRebootSystem - - install_instr_doNotInstall - stepNumber: 10/10 - titleIcon: icon-download.png \ No newline at end of file + filePath: no-verity-opt-encrypt-samsung-1.0.zip \ No newline at end of file diff --git a/src/main/resources/yaml/star2lte_new.yml b/src/main/resources/yaml/star2lte_new.yml new file mode 100644 index 00000000..291360e1 --- /dev/null +++ b/src/main/resources/yaml/star2lte_new.yml @@ -0,0 +1,223 @@ +## Copyright 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 . +## Author: Vincent Bourgmayer +--- +stepsCount: 11 +steps: + f0: + type: custom + stepNumber: 1 + nextStepKey: f1 + titleKey: stepTitle_oemUnlock + instructions: + - install_instr_connectTowifi + - install_instr_openSettingsThenDevOptions + - install_instr_disableAutoUpdateSystem + - install_instr_openSoftwareUpdate + - install_instr_disableAutomaticDownload + - install_instr_clickDlAndInstall + - install_instr_rebootDeviceThenContinue + titleKeyIconName: icon-download.png + f1: + type: custom-executable + stepNumber: 2 + nextStepKey: f2 + titleKey: stepTitle_oemUnlock + instructions: + - install_instr_openSettingsThenDevOptions + - install_instr_enableOEMUnlock + - install_instr_acceptFactoryReset + - install_instr_startDl_pressPowerBixbyVolDown + - install_instr_acceptWarning + titleKeyIconName: icon-download.png + script: wait-download + parameters: + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitDownload_1 + f2: + type: load + stepNumber: 3 + nextStepKey: f3 + titleKey: stepTitle4On7 + instructions: + - install_instr_recoveryInstall + averageTime: 6 + script: install-recovery + parameters: + twrp_image_path: ${TWRP_IMAGE_PATH} + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 101: script_error_installRecovery_101 + f3: + type: + stepNumber: 4 + nextStepKey: f4 + titleKey: stepTitle5On7 + instructions: + - install_instr_leaveDl_pressPowerBixbyVolDown + - install_instr_startRec_pressPowerBixbyVolUp + - install_instr_keepReadOnly + titleKeyIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 + f4: + type: + stepNumber: 5 + nextStepKey: f5 + titleKey: stepTitle5On7 + instructions: + - install_instr_tapWipe + - install_instr_tapFormatData + - install_instr_writeYes + - install_instr_validate + - install_instr_backX3 + - install_instr_tapReboot + - install_instr_tapRebootRecovery + - install_instr_doNotInstall + titleKeyIconName: icon-download.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 + f5: + type: + stepNumber: 6 + nextStepKey: f6 + titleKey: stepTitle5On7 + instructions: + - install_instr_swipeTwrp + titleKeyIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 + f6: + type: load + stepNumber: 7 + nextStepKey: f7 + titleKey: install_instr_patchInstall + instructions: + - install_instr_patchInstall + averageTime: 55 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${SOURCES_PATH}no-verity-opt-encrypt-samsung-1.0.zip + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 + f7: + type: load + stepNumber: 8 + nextStepKey: f8 + titleKey: install_instr_vendorInstall + instructions: + - install_instr_vendorInstall + averageTime: 65 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${SOURCES_PATH}VENDOR-27_ARI9.zip + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 + f8: + type: load + stepNumber: 9 + nextStepKey: f9 + titleKey: install_instr_eosInstall + instructions: + - install_instr_eosInstall + averageTime: 440 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${ARCHIVE_PATH} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 + f9: + type: askAccount + stepNumber: 10 + nextStepKey: f10 + f10: + type: + stepNumber: 11 + nextStepKey: end + titleKey: stepTitle7On7 + instructions: + - install_instr_tapWipe + - install_instr_tapAdvancedWipe + - install_instr_tickData + - install_instr_tapRepairChangeFs + - install_instr_resizeFs + - install_instr_swipeForOk + - install_instr_tapRebootSystem + - install_instr_doNotInstall + titleKeyIconName: icon-download.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 diff --git a/src/main/resources/yaml/starlte.yml b/src/main/resources/yaml/starlte.yml deleted file mode 100644 index 3f9af81c..00000000 --- a/src/main/resources/yaml/starlte.yml +++ /dev/null @@ -1,173 +0,0 @@ -## Copyright 2019-2020 - 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 . -## Author: Vincent Bourgmayer ---- -name: starlte -flash: - f1: - script: ~ - parameters: ~ - codes: ~ - output: ~ - succeed: f2 - failed: ~ - f2: - script: wait-download - parameters: - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitDownload_1 - output: ~ - succeed: f3 - failed: ~ - f3: - script: install-recovery - parameters: - twrp_image_path: ${TWRP_IMAGE_PATH} - heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 101: script_error_installRecovery_101 - output: ~ - succeed: f4 - failed: ~ - f4: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f5 - failed: ~ - f5: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: f6 - failed: ~ - f6: - script: wait-recovery - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_waitRecovery_1 - 101: script_error_waitRecovery_101 - 102: script_error_waitRecovery_102 - output: ~ - succeed: f7 - failed: ~ - f7: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${SOURCES_PATH}no-verity-opt-encrypt-samsung-1.0.zip - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f8 - failed: ~ - f8: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${SOURCES_PATH}VENDOR-27_ARI9.zip - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f9 - failed: ~ - f9: - script: install-from-recovery - parameters: - device_id: ${DEVICE_ID} - archive_path: ${ARCHIVE_PATH} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_installFromRecovery_1 - 2: script_error_installFromRecovery_2 - 3: script_error_installFromRecovery_3 - 101: script_error_installFromRecovery_101 - 102: script_error_installFromRecovery_102 - output: ~ - succeed: f10 - failed: ~ - f10: - script: askAccount - parameters: ~ - codes: ~ - output: ~ - succeed: f11 - failed: ~ - f11: - script: wait-reboot - parameters: - device_id: ${DEVICE_ID} - adb_folder_path: ${ADB_FOLDER_PATH} - codes: - ok: - 0: ~ - ko: - 1: script_error_unknown - 10: script_error_waitReboot_10 - 101: script_error_waitReboot_101 - output: ~ - succeed: ~ - failed: ~ \ No newline at end of file diff --git a/src/main/resources/yaml/starlte_fs.yml b/src/main/resources/yaml/starlte_fs.yml index e766da83..d9a906d9 100644 --- a/src/main/resources/yaml/starlte_fs.yml +++ b/src/main/resources/yaml/starlte_fs.yml @@ -1,4 +1,4 @@ -## Copyright 2019-2020 - ECORP SAS +## 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 @@ -27,113 +27,3 @@ sources: f3: url: https://images.ecloud.global/stable/patch/no-verity-opt-encrypt-samsung-1.0.zip filePath: no-verity-opt-encrypt-samsung-1.0.zip -flash: - f1: - ui: - type: action - title: stepTitle_oemUnlock - instruction: - - install_instr_connectTowifi - - install_instr_openSettingsThenDevOptions - - install_instr_disableAutoUpdateSystem - - install_instr_openSoftwareUpdate - - install_instr_disableAutomaticDownload - - install_instr_clickDlAndInstall - - install_instr_rebootDeviceThenContinue - stepNumber: 1/10 - titleIcon: icon-download.png - f2: - ui: - type: action - title: stepTitle_oemUnlock - instruction: - - install_instr_openSettingsThenDevOptions - - install_instr_enableOEMUnlock - - install_instr_acceptFactoryReset - - install_instr_startDl_pressPowerBixbyVolDown - - install_instr_acceptWarning - stepNumber: 2/10 - titleIcon: icon-download.png - f3: - ui: - type: load - title: stepTitle4On7 - instruction: - - install_instr_recoveryInstall - stepNumber: 3/10 - averageTime: 6 - f4: - ui: - type: action - title: stepTitle5On7 - instruction: - - install_instr_leaveDl_pressPowerBixbyVolDown - - install_instr_startRec_pressPowerBixbyVolUp - - install_instr_keepReadOnly - stepNumber: 4/10 - titleIcon: icon-download.png - f5: - ui: - type: action - title: stepTitle5On7 - instruction: - - install_instr_tapWipe - - install_instr_tapFormatData - - install_instr_writeYes - - install_instr_validate - - install_instr_backX3 - - install_instr_tapReboot - - install_instr_tapRebootRecovery - - install_instr_doNotInstall - stepNumber: 5/10 - titleIcon: icon-download.png - f6: - ui: - type: action - title: stepTitle5On7 - instruction: - - install_instr_swipeTwrp - stepNumber: 6/10 - titleIcon: icon-download.png - f7: - ui: - type: load - title: install_instr_patchInstall - instruction: - - install_instr_patchInstall - stepNumber: 7/10 - averageTime: 55 - f8: - ui: - type: load - title: install_instr_vendorInstall - instruction: - - install_instr_vendorInstall - stepNumber: 8/10 - averageTime: 65 - f9: - ui: - type: load - title: install_instr_eosInstall - instruction: - - install_instr_eosInstall - stepNumber: 9/10 - averageTime: 440 - f10: - ui: - type: askAccount - f11: - ui: - type: action - title: stepTitle7On7 - instruction: - - install_instr_tapWipe - - install_instr_tapAdvancedWipe - - install_instr_tickData - - install_instr_tapRepairChangeFs - - install_instr_resizeFs - - install_instr_swipeForOk - - install_instr_tapRebootSystem - - install_instr_doNotInstall - stepNumber: 10/10 - titleIcon: icon-download.png \ No newline at end of file diff --git a/src/main/resources/yaml/starlte_new.yml b/src/main/resources/yaml/starlte_new.yml new file mode 100644 index 00000000..291360e1 --- /dev/null +++ b/src/main/resources/yaml/starlte_new.yml @@ -0,0 +1,223 @@ +## Copyright 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 . +## Author: Vincent Bourgmayer +--- +stepsCount: 11 +steps: + f0: + type: custom + stepNumber: 1 + nextStepKey: f1 + titleKey: stepTitle_oemUnlock + instructions: + - install_instr_connectTowifi + - install_instr_openSettingsThenDevOptions + - install_instr_disableAutoUpdateSystem + - install_instr_openSoftwareUpdate + - install_instr_disableAutomaticDownload + - install_instr_clickDlAndInstall + - install_instr_rebootDeviceThenContinue + titleKeyIconName: icon-download.png + f1: + type: custom-executable + stepNumber: 2 + nextStepKey: f2 + titleKey: stepTitle_oemUnlock + instructions: + - install_instr_openSettingsThenDevOptions + - install_instr_enableOEMUnlock + - install_instr_acceptFactoryReset + - install_instr_startDl_pressPowerBixbyVolDown + - install_instr_acceptWarning + titleKeyIconName: icon-download.png + script: wait-download + parameters: + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitDownload_1 + f2: + type: load + stepNumber: 3 + nextStepKey: f3 + titleKey: stepTitle4On7 + instructions: + - install_instr_recoveryInstall + averageTime: 6 + script: install-recovery + parameters: + twrp_image_path: ${TWRP_IMAGE_PATH} + heimdall_folder_path: ${HEIMDALL_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 101: script_error_installRecovery_101 + f3: + type: + stepNumber: 4 + nextStepKey: f4 + titleKey: stepTitle5On7 + instructions: + - install_instr_leaveDl_pressPowerBixbyVolDown + - install_instr_startRec_pressPowerBixbyVolUp + - install_instr_keepReadOnly + titleKeyIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 + f4: + type: + stepNumber: 5 + nextStepKey: f5 + titleKey: stepTitle5On7 + instructions: + - install_instr_tapWipe + - install_instr_tapFormatData + - install_instr_writeYes + - install_instr_validate + - install_instr_backX3 + - install_instr_tapReboot + - install_instr_tapRebootRecovery + - install_instr_doNotInstall + titleKeyIconName: icon-download.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 + f5: + type: + stepNumber: 6 + nextStepKey: f6 + titleKey: stepTitle5On7 + instructions: + - install_instr_swipeTwrp + titleKeyIconName: icon-download.png + script: wait-recovery + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_waitRecovery_1 + 101: script_error_waitRecovery_101 + 102: script_error_waitRecovery_102 + f6: + type: load + stepNumber: 7 + nextStepKey: f7 + titleKey: install_instr_patchInstall + instructions: + - install_instr_patchInstall + averageTime: 55 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${SOURCES_PATH}no-verity-opt-encrypt-samsung-1.0.zip + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 + f7: + type: load + stepNumber: 8 + nextStepKey: f8 + titleKey: install_instr_vendorInstall + instructions: + - install_instr_vendorInstall + averageTime: 65 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${SOURCES_PATH}VENDOR-27_ARI9.zip + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 + f8: + type: load + stepNumber: 9 + nextStepKey: f9 + titleKey: install_instr_eosInstall + instructions: + - install_instr_eosInstall + averageTime: 440 + script: install-from-recovery + parameters: + device_id: ${DEVICE_ID} + archive_path: ${ARCHIVE_PATH} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_installFromRecovery_1 + 2: script_error_installFromRecovery_2 + 3: script_error_installFromRecovery_3 + 101: script_error_installFromRecovery_101 + 102: script_error_installFromRecovery_102 + f9: + type: askAccount + stepNumber: 10 + nextStepKey: f10 + f10: + type: + stepNumber: 11 + nextStepKey: end + titleKey: stepTitle7On7 + instructions: + - install_instr_tapWipe + - install_instr_tapAdvancedWipe + - install_instr_tickData + - install_instr_tapRepairChangeFs + - install_instr_resizeFs + - install_instr_swipeForOk + - install_instr_tapRebootSystem + - install_instr_doNotInstall + titleKeyIconName: icon-download.png + script: wait-reboot + parameters: + device_id: ${DEVICE_ID} + adb_folder_path: ${ADB_FOLDER_PATH} + okCodes: + 0: ~ + koCodes: + 1: script_error_unknown + 10: script_error_waitReboot_10 + 101: script_error_waitReboot_101 -- GitLab From 7d024c2503268f94c652acc91158b1988e6cc280 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 15:59:51 +0200 Subject: [PATCH 045/102] rename all _new config file to _flash --- src/main/resources/yaml/{FP3_new.yml => FP3_flash.yml} | 0 src/main/resources/yaml/{GS290_new.yml => GS290_flash.yml} | 0 .../resources/yaml/{Teracube_2e_new.yml => Teracube_2e_flash.yml} | 0 .../resources/yaml/{dream2lte_new.yml => dream2lte_flash.yml} | 0 src/main/resources/yaml/{dreamlte_new.yml => dreamlte_flash.yml} | 0 src/main/resources/yaml/{hero2lte_new.yml => hero2lte_flash.yml} | 0 src/main/resources/yaml/{herolte_new.yml => herolte_flash.yml} | 0 src/main/resources/yaml/{star2lte_new.yml => star2lte_flash.yml} | 0 src/main/resources/yaml/{starlte_new.yml => starlte_flash.yml} | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/yaml/{FP3_new.yml => FP3_flash.yml} (100%) rename src/main/resources/yaml/{GS290_new.yml => GS290_flash.yml} (100%) rename src/main/resources/yaml/{Teracube_2e_new.yml => Teracube_2e_flash.yml} (100%) rename src/main/resources/yaml/{dream2lte_new.yml => dream2lte_flash.yml} (100%) rename src/main/resources/yaml/{dreamlte_new.yml => dreamlte_flash.yml} (100%) rename src/main/resources/yaml/{hero2lte_new.yml => hero2lte_flash.yml} (100%) rename src/main/resources/yaml/{herolte_new.yml => herolte_flash.yml} (100%) rename src/main/resources/yaml/{star2lte_new.yml => star2lte_flash.yml} (100%) rename src/main/resources/yaml/{starlte_new.yml => starlte_flash.yml} (100%) diff --git a/src/main/resources/yaml/FP3_new.yml b/src/main/resources/yaml/FP3_flash.yml similarity index 100% rename from src/main/resources/yaml/FP3_new.yml rename to src/main/resources/yaml/FP3_flash.yml diff --git a/src/main/resources/yaml/GS290_new.yml b/src/main/resources/yaml/GS290_flash.yml similarity index 100% rename from src/main/resources/yaml/GS290_new.yml rename to src/main/resources/yaml/GS290_flash.yml diff --git a/src/main/resources/yaml/Teracube_2e_new.yml b/src/main/resources/yaml/Teracube_2e_flash.yml similarity index 100% rename from src/main/resources/yaml/Teracube_2e_new.yml rename to src/main/resources/yaml/Teracube_2e_flash.yml diff --git a/src/main/resources/yaml/dream2lte_new.yml b/src/main/resources/yaml/dream2lte_flash.yml similarity index 100% rename from src/main/resources/yaml/dream2lte_new.yml rename to src/main/resources/yaml/dream2lte_flash.yml diff --git a/src/main/resources/yaml/dreamlte_new.yml b/src/main/resources/yaml/dreamlte_flash.yml similarity index 100% rename from src/main/resources/yaml/dreamlte_new.yml rename to src/main/resources/yaml/dreamlte_flash.yml diff --git a/src/main/resources/yaml/hero2lte_new.yml b/src/main/resources/yaml/hero2lte_flash.yml similarity index 100% rename from src/main/resources/yaml/hero2lte_new.yml rename to src/main/resources/yaml/hero2lte_flash.yml diff --git a/src/main/resources/yaml/herolte_new.yml b/src/main/resources/yaml/herolte_flash.yml similarity index 100% rename from src/main/resources/yaml/herolte_new.yml rename to src/main/resources/yaml/herolte_flash.yml diff --git a/src/main/resources/yaml/star2lte_new.yml b/src/main/resources/yaml/star2lte_flash.yml similarity index 100% rename from src/main/resources/yaml/star2lte_new.yml rename to src/main/resources/yaml/star2lte_flash.yml diff --git a/src/main/resources/yaml/starlte_new.yml b/src/main/resources/yaml/starlte_flash.yml similarity index 100% rename from src/main/resources/yaml/starlte_new.yml rename to src/main/resources/yaml/starlte_flash.yml -- GitLab From 154cef8972949827c7e078fb752fff006b68fd21 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 22 Sep 2021 16:01:00 +0200 Subject: [PATCH 046/102] load config file with correct name --- .../controllers/subcontrollers/DeviceDetectedController.java | 2 +- src/main/java/ecorp/easy/installer/threads/ThreadFactory.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java index e789a8f6..04314110 100644 --- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java +++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java @@ -110,7 +110,7 @@ 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()+"_new.yml"); + 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); diff --git a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java index e681c555..493f2064 100644 --- a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java +++ b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java @@ -89,7 +89,7 @@ public class ThreadFactory { Yaml yaml = new Yaml (); //load config file - InputStream is = getClass().getResourceAsStream(yamlFolderPath+modelName+"_new.yml"); + InputStream is = getClass().getResourceAsStream(yamlFolderPath+modelName+"_flash.yml"); Map yamlContent= (Map)yaml.load(is); is.close(); if(yamlContent == null || yamlContent.isEmpty() ) { -- GitLab From 4a570c44ed8bcc912689bdf2ef06653445caee6b Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 23 Sep 2021 17:59:49 +0200 Subject: [PATCH 047/102] add base for StepController class --- .../installer/controllers/StepController.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/ecorp/easy/installer/controllers/StepController.java diff --git a/src/main/java/ecorp/easy/installer/controllers/StepController.java b/src/main/java/ecorp/easy/installer/controllers/StepController.java new file mode 100644 index 00000000..44cd611f --- /dev/null +++ b/src/main/java/ecorp/easy/installer/controllers/StepController.java @@ -0,0 +1,59 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package ecorp.easy.installer.controllers; +//import ecorp.easy.installer.models.steps.IStep; + +import java.net.URL; +import java.util.ResourceBundle; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.Node; +import javafx.scene.input.MouseEvent; + + +/** + * + * @author vincent + */ +public class StepController implements Initializable{ + + protected static MainWindowController parentController; + + @FXML Node stepUIRoot; + protected ResourceBundle i18n; + protected S step; + + @Override + public void initialize(URL url, ResourceBundle rb) { + i18n = rb; + //@TODO find a solution for this + final String stepKey = parentController.getCurrentStepKey(); + System.out.println("stepKey = "+stepKey); + //@TODO find a solution for this + step = (S) parentController.getCurrentProcess().getStep(stepKey); + + parentController.setNextButtonOnClickListener( ( MouseEvent event) -> { + if(event.getEventType().equals(MouseEvent.MOUSE_CLICKED)){ + onStepEnd(); + } + }); + } + + public static void setParentController(MainWindowController parentController) { + StepController.parentController = parentController; + } + + + /** + * Code executed when the step is over + * Mainly load the next step + * apply UI effect like fade in/out + */ + protected void onStepEnd(){ + System.out.println("onStepEnd() load: "+step.getNextStepCode()); + parentController.removeNodeFromRoot(stepUIRoot.getId()); + parentController.loadNextStep(step.getNextStepCode()); + } +} -- GitLab From 710a95d8940d1071b6a355f77d7a05debbe19848 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 27 Sep 2021 10:51:30 +0200 Subject: [PATCH 048/102] update StepController and add CustomStepController --- .../stepControllers/CustomStepController.java | 110 ++++++++++++++++++ .../{ => stepControllers}/StepController.java | 17 ++- 2 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java rename src/main/java/ecorp/easy/installer/controllers/{ => stepControllers}/StepController.java (77%) diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java new file mode 100644 index 00000000..fd1a0927 --- /dev/null +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java @@ -0,0 +1,110 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package ecorp.easy.installer.controllers.stepControllers; + +import ecorp.easy.installer.graphics.Instruction; +import ecorp.easy.installer.utils.UiUtils; +import java.net.URL; +import java.util.ArrayList; +import java.util.Locale; +import java.util.ResourceBundle; +import javafx.fxml.FXML; +import javafx.scene.control.ContentDisplay; +import javafx.scene.control.Label; +import javafx.scene.image.ImageView; +import javafx.scene.layout.VBox; + +/** + * + * @author vincent + */ +public class CustomStepController extends StepController{ + protected final static ResourceBundle IMG_BUNDLE = ResourceBundle.getBundle("instructions.imageName", + new Locale.Builder() + .setRegion("en") + .setLanguage("EN") + .setVariant(parentController.getDevice().getInternalCode()) + .build()); + + private int currentEmphasizedInstruction = 0; + private int instructionsCount; + + + @FXML private VBox instructionsContainer; + @FXML private Label titleLbl; + @FXML private ImageView imgView; + + + @Override + public void initialize(URL url, ResourceBundle rb) { + super.initialize(url, rb); + + titleLbl.setText(i18n.getString(step.getTitleKey() )); + if(step.getTitleIconName() != null){ + titleLbl.setGraphic(new ImageView(UiUtils.loadImage(step.getTitleIconName()))); + titleLbl.setGraphicTextGap(18); //set spacing between icon and text + titleLbl.setContentDisplay(ContentDisplay.LEFT); //set Icon to be displayed on left + } + + final ArrayList instructions = loadInstructions(); + instructions.get(currentEmphasizedInstruction).emphasize(); + instructionsContainer.getChildren().addAll(instructions); + displayInstructionImage(instructions.get(currentEmphasizedInstruction)); + + instructionsCount = instructions.size(); + + } + + + @Override + protected void onContinueClicked(){ + if(currentEmphasizedInstruction+1 == instructionsCount){ + UiUtils.buildFadeTransition(uiRoot, false); + super.onStepEnd(); + }else{ + final Instruction currentInstruction = (Instruction) instructionsContainer + .getChildren().get(currentEmphasizedInstruction++); + currentInstruction.trivialize(); + + final Instruction nextInstruction = (Instruction) instructionsContainer + .getChildren().get(currentEmphasizedInstruction); + nextInstruction.emphasize(); + + displayInstructionImage(nextInstruction); + } + } + + /** + * Create Instruction nodes with text key from step + */ + private ArrayList loadInstructions(){ + final ArrayList result = new ArrayList<>(); + + for(String key : step.getTextContentkeys()){ + String contentKey = "all_lbl_notImplemented"; //set default key + System.out.println("translation key: "+key); + if(i18n.containsKey(key)){ + contentKey = key; + } + result.add(new Instruction(key, i18n.getString(contentKey))); + } + return result; + } + + + /** + * Display Image corresponding to the current Instruction + * if there is one. In other way, it remove current image + * @param instruction + */ + private void displayInstructionImage(Instruction instruction){ + if(IMG_BUNDLE.containsKey(instruction.getKey())){ + imgView.setImage( + UiUtils.loadImage( IMG_BUNDLE.getString( instruction.getKey() ) ) ); + }else{ + imgView.setImage(null); + } + } +} diff --git a/src/main/java/ecorp/easy/installer/controllers/StepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java similarity index 77% rename from src/main/java/ecorp/easy/installer/controllers/StepController.java rename to src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java index 44cd611f..9a6f5705 100644 --- a/src/main/java/ecorp/easy/installer/controllers/StepController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java @@ -2,9 +2,11 @@ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ -package ecorp.easy.installer.controllers; +package ecorp.easy.installer.controllers.stepControllers; //import ecorp.easy.installer.models.steps.IStep; +import ecorp.easy.installer.controllers.MainWindowController; +import ecorp.easy.installer.models.steps.IStep; import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.FXML; @@ -21,7 +23,7 @@ public class StepController implements Initializable{ protected static MainWindowController parentController; - @FXML Node stepUIRoot; + @FXML Node uiRoot; protected ResourceBundle i18n; protected S step; @@ -36,7 +38,7 @@ public class StepController implements Initializable{ parentController.setNextButtonOnClickListener( ( MouseEvent event) -> { if(event.getEventType().equals(MouseEvent.MOUSE_CLICKED)){ - onStepEnd(); + onContinueClicked(); } }); } @@ -45,6 +47,13 @@ public class StepController implements Initializable{ StepController.parentController = parentController; } + /** + * Behaviour for when user click on "continue button" + * defined mostly for subclass overriding + */ + protected void onContinueClicked(){ + onStepEnd(); + } /** * Code executed when the step is over @@ -53,7 +62,7 @@ public class StepController implements Initializable{ */ protected void onStepEnd(){ System.out.println("onStepEnd() load: "+step.getNextStepCode()); - parentController.removeNodeFromRoot(stepUIRoot.getId()); + parentController.removeNodeFromRoot(uiRoot.getId()); parentController.loadNextStep(step.getNextStepCode()); } } -- GitLab From a092ea421b14ac72b71a2e5b09e3f78fe347987f Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 27 Sep 2021 15:10:18 +0200 Subject: [PATCH 049/102] fix CustomStepController, StepController and add new ExecutableStepController --- .../stepControllers/CustomStepController.java | 6 +- .../ExecutableStepController.java | 121 ++++++++++++++++++ .../stepControllers/StepController.java | 4 +- 3 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java index fd1a0927..425ff5e0 100644 --- a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java @@ -5,6 +5,7 @@ package ecorp.easy.installer.controllers.stepControllers; import ecorp.easy.installer.graphics.Instruction; +import ecorp.easy.installer.models.steps.ICustomStep; import ecorp.easy.installer.utils.UiUtils; import java.net.URL; import java.util.ArrayList; @@ -15,12 +16,15 @@ import javafx.scene.control.ContentDisplay; import javafx.scene.control.Label; import javafx.scene.image.ImageView; import javafx.scene.layout.VBox; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * - * @author vincent + * @author vincent Bourgmayer */ public class CustomStepController extends StepController{ + protected final static ResourceBundle IMG_BUNDLE = ResourceBundle.getBundle("instructions.imageName", new Locale.Builder() .setRegion("en") diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java new file mode 100644 index 00000000..29b9f527 --- /dev/null +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java @@ -0,0 +1,121 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package ecorp.easy.installer.controllers.stepControllers; + +import ecorp.easy.installer.models.Command; +import ecorp.easy.installer.models.steps.IExecutableStep; +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; +import javafx.concurrent.Service; +import javafx.concurrent.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @blocked: I don't know how to do it at the moment.. + * Should I use a service ? a Thread ? .. + * @TODO - add a error and cancellation listener on the Service + * @author vincent Bourgmayer + */ +public class ExecutableStepController extends StepController{ + + Task task; + CommandService backgroundService; + + @Override + public void initialize(URL arg0, ResourceBundle resources) { + super.initialize(arg0, resources); //To change body of generated methods, choose Tools | Templates. + + backgroundService = new CommandService(step.getCommand()); + + backgroundService.start(); + } + + + protected void displayError(String errorMsgKey){ + //Show error UI and hide everything that should be hidden + //like restart btn, etc. + if(i18n.containsKey(errorMsgKey)){ + //Set text to a label + } + } + + + /** + * Class in charge to run the background command + */ + protected class CommandService extends Service{ + final Command cmd; + + public CommandService(Command cmd){ + this.cmd = cmd; + } + + + @Override + protected Task createTask() { + + Task task = new Task() { + @Override + protected Boolean call() throws Exception { + logger.info("Command Task call()"); + try{ + cmd.execAndReadOutput(); + }catch( IOException | InterruptedException e){ + logger.error("cmd.execAndReadOutput(), error = {}", e.toString() ); + return false; + } + + //read result from command object + final int exitValue = cmd.getExitValue(); + final String shellOutput = cmd.getShellOutput(); + + logger.debug("command output= {}\nexit value = {}\n", shellOutput, exitValue); + + + if(cmd.isSuccess()){ + String outputKey = cmd.getOutputKey(); + //If an output is expected from succeed script + + //@TODO: uncomment and fix COMMON_PARAM_IDENTIFIER ref + /*if( outputKey != null && outputKey.charAt(0) == COMMON_PARAM_IDENTIFIER){ + final int lastIndex = shellOutput.lastIndexOf("\n"); + final int length = shellOutput.length(); + final String shellOutputCleaned = shellOutput.substring(lastIndex+1, length); + logger.debug("shell output cleaned : "+shellOutputCleaned); + this.commonParameters.put(outputKey.replace("${","").replace("}", ""), shellOutputCleaned); + }*/ + + return true; + }else{ //fails case + return false; + } + + } + }; + + return task; + } + + + @Override + protected void succeeded() { + super.succeeded(); + + if(this.getValue()){ //if true + onStepEnd(); + }else{ + String errorMsgKey = cmd.getErrorMsg(); + if (errorMsgKey == null || errorMsgKey.isEmpty()){ + errorMsgKey = "script_error_unknown"; + } + displayError(errorMsgKey); + } + } + } + +} diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java index 9a6f5705..42474183 100644 --- a/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java @@ -13,6 +13,8 @@ import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.Node; import javafx.scene.input.MouseEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -20,7 +22,7 @@ import javafx.scene.input.MouseEvent; * @author vincent */ public class StepController implements Initializable{ - + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected static MainWindowController parentController; @FXML Node uiRoot; -- GitLab From 6e4c4ff977e232ad09c73e71fca842d2f9d32aed Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 27 Sep 2021 15:31:39 +0200 Subject: [PATCH 050/102] add new CustomExecutableController --- .../CustomExecutableController.java | 209 ++++++++++++++++++ .../stepControllers/CustomStepController.java | 2 +- .../ExecutableStepController.java | 5 + 3 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java new file mode 100644 index 00000000..53540171 --- /dev/null +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java @@ -0,0 +1,209 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package ecorp.easy.installer.controllers.stepControllers; + +import ecorp.easy.installer.graphics.Instruction; +import ecorp.easy.installer.models.Command; +import ecorp.easy.installer.models.steps.CustomExecutableStep; +import ecorp.easy.installer.utils.UiUtils; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Locale; +import java.util.ResourceBundle; +import javafx.concurrent.Service; +import javafx.concurrent.Task; +import javafx.fxml.FXML; +import javafx.scene.control.ContentDisplay; +import javafx.scene.control.Label; +import javafx.scene.image.ImageView; +import javafx.scene.layout.VBox; + +/** + * This is clearly a mix of CustomStepController & ExecutableStepController + * It means that it's code duplication. I don't like it but I didn't find a way to reuse + * both class because multiple extension isn't possible and any design pattern fit + * my need. But If you find a way please implement it! + * @author vincent Bourgmayer + */ +public class CustomExecutableController extends StepController{ + + protected final ResourceBundle IMG_BUNDLE = ResourceBundle.getBundle("instructions.imageName", + new Locale.Builder() + .setRegion("en") + .setLanguage("EN") + .setVariant(parentController.getDevice().getInternalCode()) + .build()); + + private int currentEmphasizedInstruction = 0; + private int instructionsCount; + private Task task; + private CommandService backgroundService; + + @FXML private VBox instructionsContainer; + @FXML private Label titleLbl; + @FXML private ImageView imgView; + + + @Override + public void initialize(URL url, ResourceBundle rb) { + super.initialize(url, rb); + + titleLbl.setText(i18n.getString(step.getTitleKey() )); + if(step.getTitleIconName() != null){ + titleLbl.setGraphic(new ImageView(UiUtils.loadImage(step.getTitleIconName()))); + titleLbl.setGraphicTextGap(18); //set spacing between icon and text + titleLbl.setContentDisplay(ContentDisplay.LEFT); //set Icon to be displayed on left + } + + final ArrayList instructions = loadInstructions(); + instructions.get(currentEmphasizedInstruction).emphasize(); + instructionsContainer.getChildren().addAll(instructions); + displayInstructionImage(instructions.get(currentEmphasizedInstruction)); + + instructionsCount = instructions.size(); + + backgroundService = new CommandService(step.getCommand()); + + backgroundService.start(); + + } + + @Override + protected void onContinueClicked(){ + if(currentEmphasizedInstruction+1 == instructionsCount){ + UiUtils.buildFadeTransition(uiRoot, false); + super.onStepEnd(); + }else{ + final Instruction currentInstruction = (Instruction) instructionsContainer + .getChildren().get(currentEmphasizedInstruction++); + currentInstruction.trivialize(); + + final Instruction nextInstruction = (Instruction) instructionsContainer + .getChildren().get(currentEmphasizedInstruction); + nextInstruction.emphasize(); + + displayInstructionImage(nextInstruction); + } + } + + + /** + * Create Instruction nodes with text key from step + */ + private ArrayList loadInstructions(){ + final ArrayList result = new ArrayList<>(); + + for(String key : step.getTextContentkeys()){ + String contentKey = "all_lbl_notImplemented"; //set default key + System.out.println("translation key: "+key); + if(i18n.containsKey(key)){ + contentKey = key; + } + result.add(new Instruction(key, i18n.getString(contentKey))); + } + return result; + } + + + /** + * Display Image corresponding to the current Instruction + * if there is one. In other way, it remove current image + * @param instruction + */ + private void displayInstructionImage(Instruction instruction){ + if(IMG_BUNDLE.containsKey(instruction.getKey())){ + imgView.setImage( + UiUtils.loadImage( IMG_BUNDLE.getString( instruction.getKey() ) ) ); + }else{ + imgView.setImage(null); + } + } + + /** + * Display an error due to background task + * @param errorMsgKey + */ + protected void displayError(String errorMsgKey){ + //Show error UI and hide everything that should be hidden + //like restart btn, etc. + if(i18n.containsKey(errorMsgKey)){ + //Set text to a label + } + } + + /** + * Duplication of ExecutableStepController.CommandService + */ + protected class CommandService extends Service{ + final Command cmd; + + public CommandService(Command cmd){ + this.cmd = cmd; + } + + + @Override + protected Task createTask() { + + Task task = new Task() { + @Override + protected Boolean call() throws Exception { + logger.info("Command Task call()"); + try{ + cmd.execAndReadOutput(); + }catch( IOException | InterruptedException e){ + logger.error("cmd.execAndReadOutput(), error = {}", e.toString() ); + return false; + } + + //read result from command object + final int exitValue = cmd.getExitValue(); + final String shellOutput = cmd.getShellOutput(); + + logger.debug("command output= {}\nexit value = {}\n", shellOutput, exitValue); + + + if(cmd.isSuccess()){ + String outputKey = cmd.getOutputKey(); + //If an output is expected from succeed script + + //@TODO: uncomment and fix COMMON_PARAM_IDENTIFIER ref + /*if( outputKey != null && outputKey.charAt(0) == COMMON_PARAM_IDENTIFIER){ + final int lastIndex = shellOutput.lastIndexOf("\n"); + final int length = shellOutput.length(); + final String shellOutputCleaned = shellOutput.substring(lastIndex+1, length); + logger.debug("shell output cleaned : "+shellOutputCleaned); + this.commonParameters.put(outputKey.replace("${","").replace("}", ""), shellOutputCleaned); + }*/ + + return true; + }else{ //fails case + return false; + } + + } + }; + + return task; + } + + + @Override + protected void succeeded() { + super.succeeded(); + + if(this.getValue()){ //if true + onStepEnd(); + }else{ + String errorMsgKey = cmd.getErrorMsg(); + if (errorMsgKey == null || errorMsgKey.isEmpty()){ + errorMsgKey = "script_error_unknown"; + } + displayError(errorMsgKey); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java index 425ff5e0..0dc3c394 100644 --- a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomStepController.java @@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory; */ public class CustomStepController extends StepController{ - protected final static ResourceBundle IMG_BUNDLE = ResourceBundle.getBundle("instructions.imageName", + protected final ResourceBundle IMG_BUNDLE = ResourceBundle.getBundle("instructions.imageName", new Locale.Builder() .setRegion("en") .setLanguage("EN") diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java index 29b9f527..e41ba683 100644 --- a/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java @@ -47,6 +47,11 @@ public class ExecutableStepController extends StepController{ /** * Class in charge to run the background command + * @Suggestion for the end of the refactoring: + * if it's still usefull. Make it public as a standalone class + * in tasks package. Then define an interface with 'DisplayError(String errKey)' + * and 'onStepEnd()' method then use it to bind the controller to this service + * it will allow to use it for more controller with background task */ protected class CommandService extends Service{ final Command cmd; -- GitLab From 021a2b7aec936b99f2a703cc4cad2f460fc29131 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 27 Sep 2021 18:51:00 +0200 Subject: [PATCH 051/102] add CommandRunnerService and update StepController's subclass to use it --- .../CustomExecutableController.java | 97 +++------------- .../ExecutableStepController.java | 106 +++--------------- .../stepControllers/LoadStepController.java | 82 ++++++++++++++ .../installer/tasks/CommandRunnerService.java | 70 ++++++++++++ 4 files changed, 188 insertions(+), 167 deletions(-) create mode 100644 src/main/java/ecorp/easy/installer/controllers/stepControllers/LoadStepController.java create mode 100644 src/main/java/ecorp/easy/installer/tasks/CommandRunnerService.java diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java index 53540171..62fdf255 100644 --- a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java @@ -7,13 +7,12 @@ package ecorp.easy.installer.controllers.stepControllers; import ecorp.easy.installer.graphics.Instruction; import ecorp.easy.installer.models.Command; import ecorp.easy.installer.models.steps.CustomExecutableStep; +import ecorp.easy.installer.tasks.CommandRunnerService; import ecorp.easy.installer.utils.UiUtils; -import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.Locale; import java.util.ResourceBundle; -import javafx.concurrent.Service; import javafx.concurrent.Task; import javafx.fxml.FXML; import javafx.scene.control.ContentDisplay; @@ -40,7 +39,7 @@ public class CustomExecutableController extends StepController{ + boolean result = backgroundService.getValue(); + if(result) + onStepEnd(); + else{ + String errorMsgKey = cmd.getErrorMsg(); + if (errorMsgKey == null || errorMsgKey.isEmpty()){ + errorMsgKey = "script_error_unknown"; + } + displayError(errorMsgKey); + } + }); backgroundService.start(); } @@ -133,77 +145,4 @@ public class CustomExecutableController extends StepController{ - final Command cmd; - - public CommandService(Command cmd){ - this.cmd = cmd; - } - - - @Override - protected Task createTask() { - - Task task = new Task() { - @Override - protected Boolean call() throws Exception { - logger.info("Command Task call()"); - try{ - cmd.execAndReadOutput(); - }catch( IOException | InterruptedException e){ - logger.error("cmd.execAndReadOutput(), error = {}", e.toString() ); - return false; - } - - //read result from command object - final int exitValue = cmd.getExitValue(); - final String shellOutput = cmd.getShellOutput(); - - logger.debug("command output= {}\nexit value = {}\n", shellOutput, exitValue); - - - if(cmd.isSuccess()){ - String outputKey = cmd.getOutputKey(); - //If an output is expected from succeed script - - //@TODO: uncomment and fix COMMON_PARAM_IDENTIFIER ref - /*if( outputKey != null && outputKey.charAt(0) == COMMON_PARAM_IDENTIFIER){ - final int lastIndex = shellOutput.lastIndexOf("\n"); - final int length = shellOutput.length(); - final String shellOutputCleaned = shellOutput.substring(lastIndex+1, length); - logger.debug("shell output cleaned : "+shellOutputCleaned); - this.commonParameters.put(outputKey.replace("${","").replace("}", ""), shellOutputCleaned); - }*/ - - return true; - }else{ //fails case - return false; - } - - } - }; - - return task; - } - - - @Override - protected void succeeded() { - super.succeeded(); - - if(this.getValue()){ //if true - onStepEnd(); - }else{ - String errorMsgKey = cmd.getErrorMsg(); - if (errorMsgKey == null || errorMsgKey.isEmpty()){ - errorMsgKey = "script_error_unknown"; - } - displayError(errorMsgKey); - } - } - } } \ No newline at end of file diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java index e41ba683..f3894a18 100644 --- a/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/ExecutableStepController.java @@ -6,32 +6,41 @@ package ecorp.easy.installer.controllers.stepControllers; import ecorp.easy.installer.models.Command; import ecorp.easy.installer.models.steps.IExecutableStep; -import java.io.IOException; +import ecorp.easy.installer.tasks.CommandRunnerService; import java.net.URL; import java.util.ResourceBundle; -import javafx.concurrent.Service; import javafx.concurrent.Task; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** - * @blocked: I don't know how to do it at the moment.. - * Should I use a service ? a Thread ? .. * @TODO - add a error and cancellation listener on the Service * @author vincent Bourgmayer */ public class ExecutableStepController extends StepController{ Task task; - CommandService backgroundService; + CommandRunnerService backgroundService; @Override public void initialize(URL arg0, ResourceBundle resources) { super.initialize(arg0, resources); //To change body of generated methods, choose Tools | Templates. - backgroundService = new CommandService(step.getCommand()); + final Command cmd = step.getCommand(); + backgroundService = new CommandRunnerService(cmd); + + backgroundService.setOnSucceeded(eh->{ + boolean result = backgroundService.getValue(); + if(result) + onStepEnd(); + else{ + String errorMsgKey = cmd.getErrorMsg(); + if (errorMsgKey == null || errorMsgKey.isEmpty()){ + errorMsgKey = "script_error_unknown"; + } + displayError(errorMsgKey); + } + }); + backgroundService.start(); } @@ -44,83 +53,4 @@ public class ExecutableStepController extends StepController{ } } - - /** - * Class in charge to run the background command - * @Suggestion for the end of the refactoring: - * if it's still usefull. Make it public as a standalone class - * in tasks package. Then define an interface with 'DisplayError(String errKey)' - * and 'onStepEnd()' method then use it to bind the controller to this service - * it will allow to use it for more controller with background task - */ - protected class CommandService extends Service{ - final Command cmd; - - public CommandService(Command cmd){ - this.cmd = cmd; - } - - - @Override - protected Task createTask() { - - Task task = new Task() { - @Override - protected Boolean call() throws Exception { - logger.info("Command Task call()"); - try{ - cmd.execAndReadOutput(); - }catch( IOException | InterruptedException e){ - logger.error("cmd.execAndReadOutput(), error = {}", e.toString() ); - return false; - } - - //read result from command object - final int exitValue = cmd.getExitValue(); - final String shellOutput = cmd.getShellOutput(); - - logger.debug("command output= {}\nexit value = {}\n", shellOutput, exitValue); - - - if(cmd.isSuccess()){ - String outputKey = cmd.getOutputKey(); - //If an output is expected from succeed script - - //@TODO: uncomment and fix COMMON_PARAM_IDENTIFIER ref - /*if( outputKey != null && outputKey.charAt(0) == COMMON_PARAM_IDENTIFIER){ - final int lastIndex = shellOutput.lastIndexOf("\n"); - final int length = shellOutput.length(); - final String shellOutputCleaned = shellOutput.substring(lastIndex+1, length); - logger.debug("shell output cleaned : "+shellOutputCleaned); - this.commonParameters.put(outputKey.replace("${","").replace("}", ""), shellOutputCleaned); - }*/ - - return true; - }else{ //fails case - return false; - } - - } - }; - - return task; - } - - - @Override - protected void succeeded() { - super.succeeded(); - - if(this.getValue()){ //if true - onStepEnd(); - }else{ - String errorMsgKey = cmd.getErrorMsg(); - if (errorMsgKey == null || errorMsgKey.isEmpty()){ - errorMsgKey = "script_error_unknown"; - } - displayError(errorMsgKey); - } - } - } - } diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/LoadStepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/LoadStepController.java new file mode 100644 index 00000000..876a710e --- /dev/null +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/LoadStepController.java @@ -0,0 +1,82 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package ecorp.easy.installer.controllers.stepControllers; + +import ecorp.easy.installer.models.Command; +import ecorp.easy.installer.models.steps.LoadStep; +import ecorp.easy.installer.tasks.CommandRunnerService; +import java.net.URL; +import java.util.ResourceBundle; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.control.ProgressBar; +import javafx.util.Duration; + +/** + * + * @author vincent + */ +public class LoadStepController extends StepController{ + + @FXML private ProgressBar progressBar; + @FXML private Label titleLbl; + + private Timeline pbTimeline; //progressBar Timeline + private CommandRunnerService backgroundService; + + @Override + public void initialize(URL url, ResourceBundle rb) { + + if(i18n.containsKey(step.getTitleKey())){ + titleLbl.setText(step.getTitleKey()); + } + + /** Prepare ProgressBar animation **/ + final int averageTime = step.getAverageTime(); + if(averageTime > 0){ + pbTimeline = new Timeline( + new KeyFrame(Duration.millis(0), new KeyValue(progressBar.progressProperty(), 0.0) ), + new KeyFrame(Duration.millis(averageTime*1000.0), new KeyValue(progressBar.progressProperty(), 1.0)) + ); + } + + /** Prepare Command execution **/ + final Command cmd = step.getCommand(); + backgroundService = new CommandRunnerService(cmd); + + backgroundService.setOnSucceeded(eh->{ + pbTimeline.stop(); + boolean result = backgroundService.getValue(); + + if(result) + onStepEnd(); + else{ + String errorMsgKey = cmd.getErrorMsg(); + if (errorMsgKey == null || errorMsgKey.isEmpty()){ + errorMsgKey = "script_error_unknown"; + } + displayError(errorMsgKey); + } + + }); + + backgroundService.setOnRunning(eh->{ + progressBar.setProgress(0.0); //Reset to prevent showing last value + pbTimeline.playFromStart(); + }); + + backgroundService.start(); + } + + + protected void displayError(String errorMsgKey){ + //@TODO Make ProgressBar red + //@TODO display text of error + //@TODO show send log btn, etc. + } +} diff --git a/src/main/java/ecorp/easy/installer/tasks/CommandRunnerService.java b/src/main/java/ecorp/easy/installer/tasks/CommandRunnerService.java new file mode 100644 index 00000000..006c8a39 --- /dev/null +++ b/src/main/java/ecorp/easy/installer/tasks/CommandRunnerService.java @@ -0,0 +1,70 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package ecorp.easy.installer.tasks; + +import ecorp.easy.installer.models.Command; +import java.io.IOException; +import javafx.concurrent.Service; +import javafx.concurrent.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Service in charge to run Command task + * @author vincent Bourgmayer + */ +public class CommandRunnerService extends Service{ + private final static Logger logger = LoggerFactory.getLogger(CommandRunnerService.class); + private final Command cmd; + + public CommandRunnerService( Command cmd){ + this.cmd = cmd; + } + + @Override + protected Task createTask() { + + Task task = new Task() { + @Override + protected Boolean call() throws Exception { + logger.info("Command Task call()"); + try{ + cmd.execAndReadOutput(); + }catch( IOException | InterruptedException e){ + logger.error("cmd.execAndReadOutput(), error = {}", e.toString() ); + return false; + } + + //read result from command object + final int exitValue = cmd.getExitValue(); + final String shellOutput = cmd.getShellOutput(); + + logger.debug("command output= {}\nexit value = {}\n", shellOutput, exitValue); + + + if(cmd.isSuccess()){ + String outputKey = cmd.getOutputKey(); + //If an output is expected from succeed script + + //@TODO: uncomment and fix COMMON_PARAM_IDENTIFIER ref + /*if( outputKey != null && outputKey.charAt(0) == COMMON_PARAM_IDENTIFIER){ + final int lastIndex = shellOutput.lastIndexOf("\n"); + final int length = shellOutput.length(); + final String shellOutputCleaned = shellOutput.substring(lastIndex+1, length); + logger.debug("shell output cleaned : "+shellOutputCleaned); + this.commonParameters.put(outputKey.replace("${","").replace("}", ""), shellOutputCleaned); + }*/ + + return true; + }else{ //fails case + return false; + } + + } + }; + + return task; + } +} -- GitLab From 9a042badae3f6e956bfbc2500aa373de246c08b8 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 27 Sep 2021 19:16:59 +0200 Subject: [PATCH 052/102] update ThreadFactory and MainSceneController to provide method required by StepController --- .../controllers/MainWindowController.java | 15 ++++++++++++++- .../stepControllers/LoadStepController.java | 19 ++++++++++++------- .../stepControllers/StepController.java | 15 ++++++++++----- .../easy/installer/threads/ThreadFactory.java | 5 +++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/main/java/ecorp/easy/installer/controllers/MainWindowController.java b/src/main/java/ecorp/easy/installer/controllers/MainWindowController.java index 6259a342..4dd936b8 100644 --- a/src/main/java/ecorp/easy/installer/controllers/MainWindowController.java +++ b/src/main/java/ecorp/easy/installer/controllers/MainWindowController.java @@ -19,6 +19,7 @@ package ecorp.easy.installer.controllers; import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.controllers.subcontrollers.AbstractSubController; import ecorp.easy.installer.EasyInstaller; +import ecorp.easy.installer.controllers.stepControllers.StepController; import ecorp.easy.installer.models.Phone; import ecorp.easy.installer.threads.ThreadFactory; import ecorp.easy.installer.utils.UiUtils; @@ -61,7 +62,7 @@ public class MainWindowController implements Initializable { ThreadFactory factory = new ThreadFactory("/yaml/"); Phone device; //Object encapsulating data about the device to flash private boolean isFlashed = false; // True when /e/ OS installed on device - + private String currentStepKey = "f1"; /** * Initializes the controller class. @@ -81,6 +82,8 @@ public class MainWindowController implements Initializable { Bindings.concat("-fx-font-size: ", fontSize.asString("%.0f")).concat("px;") ); + StepController.setParentController(this); + } /** @@ -370,5 +373,15 @@ public class MainWindowController implements Initializable { public Phone getDevice() { return device; } + + + public String getCurrentStepKey() { + return currentStepKey; + } + + + public void setCurrentStepKey(String currentStepKey) { + this.currentStepKey = currentStepKey; + } } diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/LoadStepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/LoadStepController.java index 876a710e..e703f83e 100644 --- a/src/main/java/ecorp/easy/installer/controllers/stepControllers/LoadStepController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/LoadStepController.java @@ -19,7 +19,7 @@ import javafx.util.Duration; /** * - * @author vincent + * @author vincent Bourgmayer */ public class LoadStepController extends StepController{ @@ -27,7 +27,7 @@ public class LoadStepController extends StepController{ @FXML private Label titleLbl; private Timeline pbTimeline; //progressBar Timeline - private CommandRunnerService backgroundService; + private CommandRunnerService service; @Override public void initialize(URL url, ResourceBundle rb) { @@ -47,11 +47,11 @@ public class LoadStepController extends StepController{ /** Prepare Command execution **/ final Command cmd = step.getCommand(); - backgroundService = new CommandRunnerService(cmd); + service = new CommandRunnerService(cmd); - backgroundService.setOnSucceeded(eh->{ + service.setOnSucceeded(eh->{ pbTimeline.stop(); - boolean result = backgroundService.getValue(); + boolean result = service.getValue(); if(result) onStepEnd(); @@ -65,12 +65,17 @@ public class LoadStepController extends StepController{ }); - backgroundService.setOnRunning(eh->{ + service.setOnRunning(eh->{ progressBar.setProgress(0.0); //Reset to prevent showing last value pbTimeline.playFromStart(); }); - backgroundService.start(); + + service.setOnCancelled(eh->{ + pbTimeline.stop(); + }); + + service.start(); } diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java index 42474183..2494ac41 100644 --- a/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/StepController.java @@ -19,7 +19,8 @@ import org.slf4j.LoggerFactory; /** * - * @author vincent + * @author vincent Bourgmayer + * @param implementation of IStep interface */ public class StepController implements Initializable{ protected final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -32,12 +33,12 @@ public class StepController implements Initializable{ @Override public void initialize(URL url, ResourceBundle rb) { i18n = rb; - //@TODO find a solution for this + final String stepKey = parentController.getCurrentStepKey(); System.out.println("stepKey = "+stepKey); - //@TODO find a solution for this - step = (S) parentController.getCurrentProcess().getStep(stepKey); - + + step = (S) parentController.getThreadFactory().getFlashMould().getSteps().get(stepKey); + parentController.setNextButtonOnClickListener( ( MouseEvent event) -> { if(event.getEventType().equals(MouseEvent.MOUSE_CLICKED)){ onContinueClicked(); @@ -45,6 +46,10 @@ public class StepController implements Initializable{ }); } + /** + * /!\ it must be called Before the Initialize() method!! + * @param parentController + */ public static void setParentController(MainWindowController parentController) { StepController.parentController = parentController; } diff --git a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java index fed051d9..7af86809 100644 --- a/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java +++ b/src/main/java/ecorp/easy/installer/threads/ThreadFactory.java @@ -248,4 +248,9 @@ public class ThreadFactory { if(flashMould == null) return 0; return flashMould.getSteps().size(); } + + + public ProcessMould getFlashMould() { + return flashMould; + } } \ No newline at end of file -- GitLab From d9929f671132f5db8477bc721ee766341cc876bb Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 28 Sep 2021 10:43:00 +0200 Subject: [PATCH 053/102] add fxml for customStep & loadStep and update controllers --- .../CustomExecutableController.java | 8 ++-- .../stepControllers/CustomStepController.java | 2 - .../stepControllers/LoadStepController.java | 21 +++++++-- src/main/resources/fxml/customStep.fxml | 46 ++++++++++++++++++ src/main/resources/fxml/loadStep.fxml | 47 +++++++++++++++++++ 5 files changed, 114 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/fxml/customStep.fxml create mode 100644 src/main/resources/fxml/loadStep.fxml diff --git a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java index 62fdf255..46702d62 100644 --- a/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java +++ b/src/main/java/ecorp/easy/installer/controllers/stepControllers/CustomExecutableController.java @@ -13,7 +13,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Locale; import java.util.ResourceBundle; -import javafx.concurrent.Task; import javafx.fxml.FXML; import javafx.scene.control.ContentDisplay; import javafx.scene.control.Label; @@ -38,7 +37,6 @@ public class CustomExecutableController extends StepController