diff --git a/.gitignore b/.gitignore index fe1d19fe02ee1bc9d905c680e4e52d90c54512be..97765057a85d5018b67badad90b7b684faf29d0b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ sources/ .waiting.lock .cables/ .devices/ - +.bin/ diff --git a/README.md b/README.md index f40483b8da51d70adda52a0fb068d1dd576b2036..f2139b7a4ad938a6842e8ef1bfa2ae70f7236d5c 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,10 @@ developer: ## Changelogs -### v0.15.0 (candidate) +### v0.16.0 (candidate) +- Display ROM version number + +### v0.15.0 - No shortcut created when installing from a non-admin account on Windows - e-recovery assets - Update German translation - by F. Wildermuth diff --git a/src/main/java/ecorp/easy/installer/AppConstants.java b/src/main/java/ecorp/easy/installer/AppConstants.java index 62497b775cb49bb17327486301b551dde42f2a78..14cb30cac448b5c0c7b96a2e3fb930cda45c6ff7 100644 --- a/src/main/java/ecorp/easy/installer/AppConstants.java +++ b/src/main/java/ecorp/easy/installer/AppConstants.java @@ -27,7 +27,7 @@ import java.nio.file.Paths; */ public abstract class AppConstants { - public final static String APP_VERSION = "v0.15.0"; + public final static String APP_VERSION = "v0.16.0"; public final static String Separator = FileSystems.getDefault().getSeparator(); public final static String OsName = System.getProperty("os.name"); public final static String JavaHome = System.getProperty("java.home"); 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 bdff37e347db14713a0b9eea1b6afd17469cd804..ae3186132eeb9070f8ec758818a6dfeb3ba136d3 100644 --- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java +++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java @@ -23,10 +23,18 @@ import ecorp.easy.installer.exceptions.TooManyDevicesException; import ecorp.easy.installer.models.Phone; import ecorp.easy.installer.tasks.DeviceDetectionTask; import ecorp.easy.installer.utils.UiUtils; + +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; import java.net.URL; import java.text.ParseException; +import java.util.HashMap; +import java.util.Map; import java.util.ResourceBundle; + import javafx.concurrent.WorkerStateEvent; import javafx.fxml.FXML; import javafx.geometry.Pos; @@ -47,7 +55,7 @@ public class DeviceDetectedController extends AbstractSubController{ @FXML private Button startDetectionButton; @FXML private Label detectionMsg; @FXML private VBox deviceDetectedRoot; - + @FXML private Label murenaVersion; @Override public void initialize(URL location, ResourceBundle resources){ @@ -55,6 +63,7 @@ public class DeviceDetectedController extends AbstractSubController{ UiUtils.hideNode(buyNewDevice); UiUtils.hideNode(startDetectionButton); detectionMsg.setText(i18n.getString("detect_lbl_detecting")); + murenaVersion.setText(i18n.getString("detect_lbl_murena_version")); startDetection(); } @@ -69,6 +78,7 @@ public class DeviceDetectedController extends AbstractSubController{ UiUtils.showNode(detectionMsg); } + UiUtils.hideNode(murenaVersion); UiUtils.hideNode(buyNewDevice); UiUtils.hideNode(startDetectionButton); @@ -142,11 +152,69 @@ public class DeviceDetectedController extends AbstractSubController{ return; } + // Display Murena version + BufferedReader reader = null; + try { + // key is sources/rom/url | value is sources/rom/filePath @see, model_fs.yml file + // https://images.ecloud.global/stable/emerald/IMG-e-latest-emerald.zip IMG-e-latest-emerald.zip + + final HashMap map = DeviceHelper.getSourcesToDownload(phone.getAdbDevice()); + for (Map.Entry pair : map.entrySet()) { + + final boolean has_pattern = pair.getValue().startsWith("e-latest-") || + pair.getValue().startsWith("IMG-e-latest-"); + + if ( has_pattern && pair.getValue().endsWith(".zip")) { + // It is assumed that the URL of the property file can be deduced from that of the ROM. + // This is to avoid specifying in each specification file. + // We use this technique because the prop url is perfectly predictable. + //eg: https://images.ecloud.global/stable/starlte/e-latest-q-starlte.zip + // https://images.ecloud.global/stable/starlte/e-latest-q-starlte.zip.prop + // + //eg: https://images.ecloud.global/stable/emerald/IMG-e-latest-emerald.zip + // https://images.ecloud.global/stable/emerald/e-latest-emerald.zip.prop + + URL url = null; + if (pair.getValue().startsWith("IMG-e-latest-")){ + url = new URL(pair.getKey().replaceAll("IMG-e-latest-","e-latest-")+".prop"); + } else { + url = new URL(pair.getKey()+".prop"); + } + + + final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + final InputStream responseStream = connection.getInputStream(); + + reader = new BufferedReader(new InputStreamReader(responseStream)); + String line = null; + while ((line = reader.readLine()) != null) { + if (line.startsWith("ro.lineage.build.version=")) { + String version = line.substring("ro.lineage.build.version=".length()); + logger.debug("Found Murena version : {}", version); + UiUtils.showNode(murenaVersion); + murenaVersion.setText(String.format(i18n.getString("detect_lbl_murena_version"), version)); + break; + } + } + } + } + } catch(IOException | ParseException | ClassCastException e) { + // Cannot read version. Do not display anything in that case. + logger.debug("Can't get version from Yaml : {}", e.getMessage()); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException ioe) {} + } + } + AppConstants.setDeviceModel(phone.getAdbDevice()); //this line must be before the "parentController.setDevice(phone). If it's not the case, //the AppConstants.getSourceFolder() won't include the device model's name parentController.setPhone(phone); parentController.disableNextButton(false); + } } } diff --git a/src/main/resources/fxml/4-deviceDetected.fxml b/src/main/resources/fxml/4-deviceDetected.fxml index a0944c6984a4374881858b217b414f9040b2ff1b..d4601da2459f05dbdd118bebb5c9ed7d5f9868b2 100644 --- a/src/main/resources/fxml/4-deviceDetected.fxml +++ b/src/main/resources/fxml/4-deviceDetected.fxml @@ -34,6 +34,7 @@ xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">