From 5c7d9079b4b688a9f95459dc6edbd80372771e16 Mon Sep 17 00:00:00 2001 From: Frank Preel Date: Thu, 22 Sep 2022 10:10:40 +0200 Subject: [PATCH 1/8] Context --- README.md | 5 ++++- src/main/java/ecorp/easy/installer/AppConstants.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f40483b8..ddc4fce8 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,10 @@ developer: ## Changelogs -### v0.15.0 (candidate) +### v0.16.0 (candidate) +- Display OS 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 62497b77..800be52c 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 Version"; 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"); -- GitLab From c044a5836b5a98a8ff65711e5cf6945581e28a1e Mon Sep 17 00:00:00 2001 From: Frank Preel Date: Thu, 22 Sep 2022 10:23:48 +0200 Subject: [PATCH 2/8] Display ROM version number --- .../DeviceDetectedController.java | 69 ++++++++++++++++++- src/main/resources/fxml/4-deviceDetected.fxml | 1 + .../resources/lang/translation.properties | 1 + .../lang/translation_fr_FR.properties | 1 + 4 files changed, 71 insertions(+), 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 bdff37e3..dd0b7605 100644 --- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java +++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java @@ -23,9 +23,16 @@ 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; @@ -47,7 +54,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 +62,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 +77,7 @@ public class DeviceDetectedController extends AbstractSubController{ UiUtils.showNode(detectionMsg); } + UiUtils.hideNode(murenaVersion); UiUtils.hideNode(buyNewDevice); UiUtils.hideNode(startDetectionButton); @@ -142,11 +151,69 @@ public class DeviceDetectedController extends AbstractSubController{ return; } + // Display Murena version + BufferedReader reader = null; + try{ + // Get the prop + HashMap map = DeviceHelper.getSourcesToDownload(phone.getAdbDevice()); + for (Map.Entry pair : map.entrySet()) { + if (pair.getValue().startsWith("e-latest-") && 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 the URL of the latter. + //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 + + // Create a neat value object to hold the URL + URL url = new URL(pair.getKey()+".prop"); + + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + //connection.setRequestProperty("accept", "application/json"); + 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){ + logger.debug("Can't load Flashing Process from Yaml : {}", e.getMessage()); + displayIncompatibleDeviceFound(model); + return; + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException ioe) {} + } + } + + + + /* + * final S stepsCount = (Integer) yamlContent.get("stepsCount"); + final Process flashingProcess = new Process(stepsCount); + HashMap steps = parseSteps( (HashMap) yamlContent.get("steps") ); + */ + + + 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 a0944c69..d4601da2 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">