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

Commit 1cdfde75 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Merge branch '359-issue-refactoring' into 'master'

Refactor  Device.java into Phone.java

Closes #359

See merge request e/tools/easy-installer!121
parents 14034f79 73aba196
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -19,7 +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.models.Device;
import ecorp.easy.installer.models.Phone;
import ecorp.easy.installer.threads.ThreadFactory;
import ecorp.easy.installer.utils.UiUtils;

@@ -59,7 +59,7 @@ public class MainWindowController implements Initializable {
    ResourceBundle i18n ;//internationalization
    String currentSubRootId =null;
    ThreadFactory factory = new ThreadFactory("/yaml/");
    Device device; //Object encapsulating data about the device to flash
    Phone device; //Object encapsulating data about the device to flash
    private boolean isFlashed = false; // True when /e/ OS installed on device


@@ -228,7 +228,7 @@ public class MainWindowController implements Initializable {
     * Put device object inside the factory
     * @param device the device object
     */
    public void setDevice(Device device){
    public void setDevice(Phone device){
        this.factory.changeMould(device);
        this.device = device;
    }
@@ -367,7 +367,7 @@ public class MainWindowController implements Initializable {
     * Allow subController to access to the device's information
     * @return 
     */
    public Device getDevice() {
    public Phone getDevice() {
        return device;
    }

+11 −11
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package ecorp.easy.installer.controllers.subcontrollers;


import ecorp.easy.installer.AppConstants;
import ecorp.easy.installer.models.Device;
import ecorp.easy.installer.models.Phone;
import ecorp.easy.installer.tasks.DeviceDetectionTask;
import ecorp.easy.installer.utils.UiUtils;
import java.net.URL;
@@ -74,7 +74,7 @@ public class DeviceDetectedController extends AbstractSubController{
        detectionMsg.setText(labelMsg);
        DeviceDetectionTask detectorTask = new DeviceDetectionTask();
        detectorTask.setOnSucceeded((WorkerStateEvent t) -> {
            Device result = detectorTask.getValue();
            Phone result = detectorTask.getValue();
            handleDetectionResult(result);
        });
        try{
@@ -90,35 +90,35 @@ public class DeviceDetectedController extends AbstractSubController{

    /**
     * Handle result of the DeviceDetectionTask
     * @param device 
     * @param phone 
     */
    private void handleDetectionResult(Device device){
    private void handleDetectionResult(Phone phone){

        //If result is null, then retry
        if (device == null ){ 
        if (phone == null ){ 
            startDetection();
            return; 
        }

        //If device is unauthorized
        if(!device.isAuthorized()){
        if(!phone.isAdbAuthorized()){
            displayUnauthorizedDeviceFound();
            return;
        }
        
        final String model = device.getModel();
        final String model = phone.getAdbModel();
        if(model == null || model.isEmpty()) displayUnknowDeviceFound();
        else{
            //check that there is config file for this device
            URL resourceUrl = getClass().getResource("/yaml/"+device.getDevice()+".yml");
            URL resourceUrl = getClass().getResource("/yaml/"+phone.getAdbDevice()+".yml");
            if(resourceUrl == null){
                //@TODO: this can be replaced or completed with a call to DeviceHelper
                displayIncompatibleDeviceFound(model);
            }else{
                detectionMsg.setText(String.format(i18n.getString("detect_lbl_compatibleDeviceFound"), model));
                if(parentController != null){
                    parentController.setDevice(device);
                    AppConstants.setDeviceModel(device.getDevice()); //@TODO remove this line ?
                    parentController.setDevice(phone);
                    AppConstants.setDeviceModel(phone.getAdbDevice()); //@TODO remove this line ?
                    parentController.disableNextButton(false);
                }
            }
+3 −3
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package ecorp.easy.installer.controllers.subcontrollers;

import ecorp.easy.installer.AppConstants;
import ecorp.easy.installer.controllers.MainWindowController;
import ecorp.easy.installer.models.Device;
import ecorp.easy.installer.models.Phone;
import ecorp.easy.installer.tasks.UploadToEcloudTask;
import ecorp.easy.installer.utils.UiUtils;
import java.io.BufferedWriter;
@@ -61,10 +61,10 @@ public class FeedbackController extends AbstractSubController {
    public void setParentController(MainWindowController parentController) {
        super.setParentController(parentController); //To change body of generated methods, choose Tools | Templates.
        parentController.setNextButtonText("feedback_btn_leave");
        Device device = parentController.getDevice();
        Phone device = parentController.getDevice();
        if(device != null){
            logger.debug("setParentController(), ParentController.getDevice() != null");
            deviceModel = device.getModel()+", "+device.getDevice();
            deviceModel = device.getAdbModel()+", "+device.getAdbDevice();
        }else{
            logger.warn("setParentController(), parentController.getDevice() == null");
        }
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ public class FlashSceneController extends AbstractSubSteppedController implement
                                                              new Locale.Builder()
                                                             .setRegion("en")
                                                             .setLanguage("EN")
                                                             .setVariant(DeviceHelper.getDeviceInternalcode(parentController.getDevice().getDevice()))
                                                             .setVariant(DeviceHelper.getDeviceInternalcode(parentController.getDevice().getAdbDevice()))
                                                             .build());
        pauseLock = new Object(); //This is object used to unpause a thread

+0 −137
Original line number Diff line number Diff line
/*
 * 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 <https://www.gnu.org/licenses/>.
 */
package ecorp.easy.installer.models;

/**
 * Encapsulate data about the device
 * @author Vincent Bourgmayer
 * @author Ingo
 */
public class Device {
    private String model;
    private String name;
    private String manufacturer;
    private String device;
    private String os;
    private String osApi;
    private String IMEI;
    private String adbId;
    private boolean authorized; //Tell if the device is authorized

    public boolean isAuthorized() {
        return authorized;
    }

    public void setAuthorized(boolean authorized) {
        this.authorized = authorized;
    }
    /**
     * Constructor of device object
     * @param adbId the serial number (used by adb) of the device
     */
    public Device(String adbId){
        this.adbId = adbId;
    }
    
    /**
     * Get the model of the device
     * @return can return null if not set before
     */
    public String getModel() {
        return model;
    }

    /**
     * Set the model of the devices
     * @param model 
     */
    public void setModel(String model) {
        this.model = model;
    }

    /**
     * Get the name of the devices
     * @return can return null if not setted
     */
    public String getName() {
        return name;
    }

    /**
     * Set the name of the device
     * @param name 
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Get Manufacturer name of device
     * @return can return null if not set
     */
    public String getManufacturer() {
        return manufacturer;
    }

    /**
     * Set the manufacturer name of the device
     * @param manufacturer 
     */
    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    /**
     * Get the device name
     * @return can be null if not setted
     */
    public String getDevice() {
        return device;
    }

    /**
     * Set the device name of the phone
     * @param device 
     */
    public void setDevice(String device) {
        this.device = device;
    }

    /**
     * Get the IMEI of the device
     * @return can return null if not set
     */
    public String getIMEI() {
        return IMEI;
    }

    /**
     * Set the IMEI of the device
     * @param IMEI 
     */
    public void setIMEI(String IMEI) {
        this.IMEI = IMEI;
    }

    /**
     * Get adb ID (aka serial number) of the device
     * @return String instance
     */
    public String getAdbId() {
        return adbId;
    }
}
Loading