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 bd11c459d3c10c29a308f1d0d807f49a8ba44c3b..3558066692824e9fe1cbc9daacf236e838fc3424 100644
--- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java
+++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/DeviceDetectedController.java
@@ -22,6 +22,7 @@ import ecorp.easy.installer.helpers.DeviceHelper;
import ecorp.easy.installer.exceptions.TooManyDevicesException;
import ecorp.easy.installer.models.Phone;
import ecorp.easy.installer.tasks.DeviceDetectionTask;
+import ecorp.easy.installer.tasks.DeviceInformationTask;
import ecorp.easy.installer.utils.UiUtils;
import java.io.IOException;
import java.net.URL;
@@ -78,6 +79,32 @@ public class DeviceDetectedController extends AbstractSubController{
DeviceDetectionTask detectorTask = new DeviceDetectionTask();
detectorTask.setOnSucceeded((WorkerStateEvent t) -> {
Phone result = detectorTask.getValue();
+
+ final DeviceInformationTask android_version = new DeviceInformationTask("ro.build.version.release");
+ final Thread tav = new Thread(android_version);
+ tav.setDaemon(true);
+ tav.start();
+ android_version.setOnSucceeded((WorkerStateEvent wav) -> {
+ result.setAndroidVersion(android_version.getValue());
+ logger.debug("android_version : {}", result.getAndroidVersion());
+ });
+ android_version.setOnFailed((WorkerStateEvent wav) -> {});
+
+ try {
+ tav.join();
+ } catch(Exception e) {
+ System.out.println(e);
+ }
+ final DeviceInformationTask manufacturer = new DeviceInformationTask("ro.product.manufacturer");
+ final Thread tm = new Thread(manufacturer);
+ tm.setDaemon(true);
+ tm.start();
+ manufacturer.setOnSucceeded((WorkerStateEvent m) -> {
+ result.setManufacturer(manufacturer.getValue());
+ logger.debug("Manufacturer : {}", result.getManufacturer());
+ });
+ manufacturer.setOnFailed((WorkerStateEvent m) -> {});
+
handleDetectionResult(result);
});
@@ -117,6 +144,10 @@ public class DeviceDetectedController extends AbstractSubController{
return;
}
+ if (isIncompatibleVersion(phone)) {
+ displayIncompatibleDeviceFound(phone.getAdbModel());
+ return;
+ }
final String model = phone.getAdbModel();
if(model == null || model.isEmpty()) displayUnknowDeviceFound();
@@ -145,6 +176,18 @@ public class DeviceDetectedController extends AbstractSubController{
}
}
+ // Temporary Fix see https://gitlab.e.foundation/e/devices/easy-installer/-/issues/461
+ // Allow only Android 11 flash for the OnePlus
+ private boolean isIncompatibleVersion(Phone phone) {
+ try {
+ if (phone.getManufacturer().toLowerCase().equals("oneplus") &&
+ phone.getAndroidVersion() != 11) {
+ return true;
+ }
+ } catch (Exception e) {}
+ return false;
+ }
+
//Note: Two below function could be merged and use a parameter to define detectionMsg.setText..
/**
diff --git a/src/main/java/ecorp/easy/installer/models/Phone.java b/src/main/java/ecorp/easy/installer/models/Phone.java
index 955957422a856fcdb4f58b043fa342be600dfe95..e6630073f035f4392f4c582c58aa5fa4fc9d8d70 100644
--- a/src/main/java/ecorp/easy/installer/models/Phone.java
+++ b/src/main/java/ecorp/easy/installer/models/Phone.java
@@ -33,6 +33,8 @@ public class Phone {
private boolean flashed = false;
private boolean adbAuthorized = false;
//private boolean isReady = false; //tell if preparation process succeed
+ private int androidVersion = 0;
+ private String manufacturer = null;
private Process flashingProcess;
@@ -154,7 +156,6 @@ public class Phone {
public Process getFlashingProcess() {
return flashingProcess;
}
-
/**
* Set the flashing process of the phone
@@ -163,4 +164,41 @@ public class Phone {
public void setFlashingProcess(Process flashingProcess) {
this.flashingProcess = flashingProcess;
}
+
+ /**
+ * Get the android version
+ * Can return 0 if not setted
+ * @return
+ */
+ public int getAndroidVersion() {
+ return androidVersion;
+ }
+
+ /**
+ * Set the Android version
+ * @param version
+ */
+ public void setAndroidVersion(String version) {
+ try {
+ this.androidVersion = Integer.parseInt(version.replaceAll("\\s", ""));
+ } catch (Exception e) {}
+ }
+
+ /**
+ * Get the Manufacturer
+ * Can return null if not setted
+ * @return
+ */
+ public String getManufacturer() {
+ return manufacturer;
+ }
+
+ /**
+ * Set the manufacturer
+ * @param manufacturer
+ */
+ public void setManufacturer(String manufacturer) {
+ System.out.println(manufacturer);
+ this.manufacturer = manufacturer.replaceAll("\\s", "");
+ }
}
diff --git a/src/main/java/ecorp/easy/installer/tasks/DeviceInformationTask.java b/src/main/java/ecorp/easy/installer/tasks/DeviceInformationTask.java
new file mode 100644
index 0000000000000000000000000000000000000000..53b1c85a249d3e8b6b32ad47934c5443e0a59f71
--- /dev/null
+++ b/src/main/java/ecorp/easy/installer/tasks/DeviceInformationTask.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2023 - 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.tasks;
+
+import ecorp.easy.installer.AppConstants;
+import ecorp.easy.installer.exceptions.TooManyDevicesException;
+import ecorp.easy.installer.models.Command;
+import ecorp.easy.installer.models.Phone;
+import ecorp.easy.installer.models.steps.CommandExecutionResult;
+
+import javafx.concurrent.Task;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class provides information about devices through adb getprop command
+ *
+ * @author Frank PREEL
+ */
+public class DeviceInformationTask extends Task{
+ private final static Logger logger = LoggerFactory.getLogger(DeviceInformationTask.class);
+ private final Command command;
+
+ // "ro.build.version.release"
+ public DeviceInformationTask(String key){
+ command = new Command(AppConstants.getADBFolderPath()+"adb");
+ command.addParameter("1", "shell");
+ command.addParameter("2", "getprop");
+ command.addParameter("3", key);
+ }
+
+ /**
+ * @return
+ * @throws java.lang.Exception
+ * @inheritDoc
+ */
+ @Override
+ protected String call() throws Exception{
+ logger.info("runADBDevicesCmd(): ", command.getCommandBase());
+ CommandExecutionTask task = new CommandExecutionTask(command);
+ task.run(); //I feel like it lacks something... but it work in test
+
+ CommandExecutionResult result = task.get();
+ logger.debug(" raw shell outputs = {} ", result.getShellOutput());
+
+ return result.getShellOutput();
+ }
+
+}
\ No newline at end of file