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

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

Merge branch '360-issue-v2' into 'master'

Refactor Command.java class

Closes #360

See merge request e/tools/easy-installer!137
parents e7446da1 a08a2eed
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import ecorp.easy.installer.controllers.stepControllers.StepController;
import ecorp.easy.installer.controllers.stepControllers.Stoppable;
import ecorp.easy.installer.models.Phone;
import ecorp.easy.installer.models.steps.IStep;
import ecorp.easy.installer.tasks.CommandExecutionTask;
import ecorp.easy.installer.tasks.CommandRunnerService;
import ecorp.easy.installer.threads.ThreadFactory;
import ecorp.easy.installer.utils.UiUtils;
@@ -288,8 +289,8 @@ public class MainWindowController implements Initializable {
    public void setDevice(Phone device){
        this.factory.changeMould(device);
        this.device = device;
        CommandRunnerService.updateCommonParam("DEVICE_ID", device.getSerialNo());
        CommandRunnerService.updateCommonParam("DEVICE_DEVICE", device.getAdbDevice());
        CommandExecutionTask.updateCommonParam("DEVICE_ID", device.getSerialNo());
        CommandExecutionTask.updateCommonParam("DEVICE_DEVICE", device.getAdbDevice());
    }
    
    /**
+8 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import ecorp.easy.installer.models.steps.CustomExecutableStep;
import ecorp.easy.installer.tasks.CommandRunnerService;
import ecorp.easy.installer.utils.UiUtils;
import ecorp.easy.installer.graphics.FlashGlobalProgressManager;
import ecorp.easy.installer.models.steps.CommandExecutionResult;
import ecorp.easy.installer.models.steps.IStep;
import java.net.URL;
import java.util.ArrayList;
@@ -98,12 +99,16 @@ public class CustomExecutableController extends StepController<CustomExecutableS
        /** Initialization relatives to Executable **/
        final Command cmd = step.getCommand();
        backgroundService = new CommandRunnerService(cmd);
        

        
        backgroundService.setOnSucceeded(eh->{
            boolean result = backgroundService.getValue();
            if(result)
            CommandExecutionResult result = backgroundService.getValue();
            
            if(result.isSuccess())
                onStepEnd();
            else{
                String errorMsgKey = cmd.getErrorMsg();
                String errorMsgKey = cmd.getErrorMsg(result.getExitCode());
                if (errorMsgKey == null || errorMsgKey.isEmpty()){
                    errorMsgKey = "script_error_unknown";
                }
+4 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package ecorp.easy.installer.controllers.stepControllers;

import ecorp.easy.installer.models.Command;
import ecorp.easy.installer.models.steps.CommandExecutionResult;
import ecorp.easy.installer.models.steps.IExecutableStep;
import ecorp.easy.installer.tasks.CommandRunnerService;
import java.net.URL;
@@ -40,11 +41,11 @@ public class ExecutableStepController extends StepController<IExecutableStep>{
        backgroundService = new CommandRunnerService(cmd);

        backgroundService.setOnSucceeded(eh->{
            boolean result = backgroundService.getValue();
            if(result)
            CommandExecutionResult result = backgroundService.getValue();
            if(result.isSuccess())
                onStepEnd();
            else{
                String errorMsgKey = cmd.getErrorMsg();
                String errorMsgKey = cmd.getErrorMsg(result.getExitCode());
                if (errorMsgKey == null || errorMsgKey.isEmpty()){
                    errorMsgKey = "script_error_unknown";
                }
+4 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import ecorp.easy.installer.models.Command;
import ecorp.easy.installer.models.steps.LoadStep;
import ecorp.easy.installer.tasks.CommandRunnerService;
import ecorp.easy.installer.graphics.FlashGlobalProgressManager;
import ecorp.easy.installer.models.steps.CommandExecutionResult;
import ecorp.easy.installer.models.steps.IStep;
import java.net.URL;
import java.util.ResourceBundle;
@@ -97,12 +98,12 @@ public class LoadStepController extends StepController<LoadStep> implements Stop

        service.setOnSucceeded(eh->{
            pbTimeline.stop();
            boolean result = service.getValue();
            CommandExecutionResult result = service.getValue();
            
            if(result){
            if(result.isSuccess()){
                onStepEnd();
            }else{
                String errorMsgKey = cmd.getErrorMsg();
                String errorMsgKey = cmd.getErrorMsg(result.getExitCode());
                if (errorMsgKey == null || errorMsgKey.isEmpty()){
                    errorMsgKey = "script_error_unknown";
                }
+10 −0
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
package ecorp.easy.installer.controllers.subcontrollers;


import ecorp.easy.installer.AppConstants;
import ecorp.easy.installer.controllers.MainWindowController;
import ecorp.easy.installer.tasks.CommandExecutionTask;
import ecorp.easy.installer.tasks.DownloadTask;
import ecorp.easy.installer.utils.UiUtils;
import java.net.URL;
@@ -120,6 +122,14 @@ public class DownloadSrcController extends AbstractSubController {
        preparationProgressBar.setProgress(1.0); //BUG! apparement pas accessible par le service. J'ai un "A bound value cannot be set"
        progressLabel.setText(i18n.getString("download_lbl_complete"));
        progressTitle.setVisible(false);
        
        //need to update/add CommandExecutionTask.CommonParameters at this time..
        //But I'm not sure it's the best place to do that.
        //I don't like to add dependency to CommandExecutionTask just for that
        String sourcesFolderPath = AppConstants.getSourcesFolderPath();
        CommandExecutionTask.updateCommonParam("TWRP_IMAGE_PATH", sourcesFolderPath+AppConstants.getTwrpImgPath());
        CommandExecutionTask.updateCommonParam("ARCHIVE_PATH", sourcesFolderPath+AppConstants.getEArchivePath());
        
        parentController.disableNextButton(false);
    }
    
Loading