Skip to content

Commit

Permalink
Merge original repo to forked repo (#1)
Browse files Browse the repository at this point in the history
* Added more apps

* Order fix

* Removed guardprovider

* Added Mi Calendar

* Added information about failures

* Fixing README formatting

* add warning when OEM locking

* add QQ Browser and Mi Financial (#181)

* add QQ Browser and Mi Financial 

* alphabetical reorder 

😊

* Added warning to OEM unlocking

* Updated libs

* Specified error messages

* Added keylistener to app manager tables

* Updated version and external URLs

* Optimising imports

* Renamed camera2 panel

* Reverted repo link

* Updated JDK instructions

* Added Sogou keyboard

* Release 7.0.2

* Update build.gradle

* Formatting

* Added YT Music

* Added Google One

* UI fixes by Koalskiy

Fixed panels and tabs, unified font sizes, fixed scaling and other stuff

* Fixed self-clearing codename field in ROM downloader
Added more UI fixes

* Version bump and code cleanup

* Minor fixes

* Added MIUI Notifications

* Removed notifications

* Fix grammatical errors (#225)

* Lossless optimization of image assets (#228)

* Lossless optimization of image assets

* Lossless optimization of screenshot

* Removed homebrew

Co-authored-by: Szaki <[email protected]>
Co-authored-by: Szaki <[email protected]>
Co-authored-by: Elisei Roca <[email protected]>
Co-authored-by: Pavle <[email protected]>
Co-authored-by: Szaki <[email protected]>
Co-authored-by: Evgeniy Koalskiy <[email protected]>
Co-authored-by: Android Dev Notes <[email protected]>
Co-authored-by: Tiago Filipe Silva <[email protected]>
  • Loading branch information
9 people authored Jan 14, 2021
1 parent 5aa6c6b commit 77cf144
Show file tree
Hide file tree
Showing 18 changed files with 467 additions and 348 deletions.
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,50 +55,62 @@

## FAQ & Troubleshooting

**The application doesn't work. Is there anything I should have installed?**
### The application doesn't work. Is there anything I should have installed?

Yes, the Xiaomi ADB/Fastboot Tools was developed in Kotlin for the Java Virtual Machine so it needs the JRE to run, version 11 or later.
Yes, the Xiaomi ADB/Fastboot Tools was developed in Kotlin for the Java Virtual Machine so it needs the JRE to run, **version 11 or later**.

On Windows/MacOS, install Oracle Java from [here](https://www.oracle.com/technetwork/java/javase/downloads/index.html) or OpenJDK from [here](https://adoptopenjdk.net/).
#### Windows

On Linux distributions, install `openjdk-11-jdk`, `openjdk-11-jre` or later versions of OpenJDK.
Install Oracle Java from [here](https://www.oracle.com/java/technologies/javase-downloads.html) or OpenJDK from [here](https://adoptopenjdk.net/). [Ninite](https://www.ninite.com/) also includes AdoptOpenJDK.

**The app on Windows doesn't detect my device even though it's connected and USB debugging is enabled. What could be the issue?**
#### MacOS

Install Oracle Java from [here](https://www.oracle.com/java/technologies/javase-downloads.html).

#### Linux

Install Oracle Java from [here](https://www.oracle.com/java/technologies/javase-downloads.html) or OpenJDK from your preferred package manager (`openjdk-11-jre`).

### The app on Windows doesn't detect my device even though it's connected and USB debugging is enabled. What could be the issue?

Windows most likely doesn't recognise your device in ADB mode. Install the universal ADB drivers from [here](http://dl.adbdriver.com/upload/adbdriver.zip), reboot your PC and try again.

**Do I need an unlocked bootloader or root access to use the app?**
### Do I need an unlocked bootloader or root access to use the app?

The Flasher, Wiper and Camera2 modules in Fastboot mode require an unlocked bootloader but everything else works without rooting or unlocking.

**What apps are safe to uninstall?**
### What apps are safe to uninstall?

All applications in the list are safe to uninstall. You might lose access to some services but the device will keep working just fine. Some other apps, like Gallery or Security, aren't listed because uninstalling them would soft brick your device.

**What's the difference between uninstalling and disabling?**
### What's the difference between uninstalling and disabling?

The OS sees which apps have been disabled and it can re-enable them whenever it pleases but it cannot do the same with uninstalled apps. Apps you disable may come back anytime and you can also re-enable them in the Settings, while uninstalled apps will only return if you reinstall them (using ADB or an APK) or factory reset the device. There's no difference when it comes to their impact on the system, however, functionality or performance wise, so I recommend uninstalling apps which you believe pose a security/privacy risk and disabling everything else.

**Do uninstalled system apps affect OTA updates?**
### Do uninstalled system apps affect OTA updates?

No, you are free to install updates without the fear of bricking your device or losing data.

**Do uninstalled system apps come back with updates?**
### Do uninstalled system apps come back with updates?

No, uninstalled apps should only come back when you reinstall them or factory reset your device.

**Why does the Uninstaller hang on some apps?**
### Why does the Uninstaller hang on some apps?

There are some apps Global MIUI doesn't let you uninstall but Chinese MIUI does. If you try to uninstall an app like that, the tool might hang. If that happens, close the tools, disconnect your device, uninstall the app manually, then launch the tools again and reconnect your device to proceed.

**How do I regain uninstalled system apps?**
### Why does the Uninstaller fail to uninstall some apps?

If the attempted uninstallation of an application results in a failure or anything other than success, that isn't a bug or an issue within the program. It means that ADB was not able to uninstall the application and there is nothing we can do about it. Similary, if an uninstallation has no result at all (neither success nor failure), that means that ADB didn't report anything, therefore the program cannot derive any information about the successfulness of the uninstallation.

### How do I regain uninstalled system apps?

Simply reinstall them using the Reinstaller module when connected in ADB mode. In case the Reinstaller module is disabled because your device doesn't support it, you must perform a factory reset.

**The app is called Xiaomi ADB/Fastboot Tools. Does that mean that it only works with Xiaomi devices?**
### The app is called Xiaomi ADB/Fastboot Tools. Does that mean that it only works with Xiaomi devices?

ADB and Fastboot are universal interfaces on Android but some of the algorithms and methods of the app are specific to Xiaomi devices, so mostly yes.

**Does this replace MiFlash or MiUnlock?**
### Does this replace MiFlash or MiUnlock?

No. Fastboot ROM flashing is available so MiFlash can mostly be replaced but implementing EDL flashing or bootloader unlocking on MIUI would only make the program unnecessarily complex.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'application'
id 'org.jetbrains.kotlin.jvm' version '1.3.71'
id 'org.jetbrains.kotlin.jvm' version '1.4.0'
id 'org.openjfx.javafxplugin' version '0.0.5'
}

Expand All @@ -9,8 +9,7 @@ repositories {
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-javafx:1.3.5"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-javafx:1.3.9"
compile "org.openjfx:javafx-graphics:11.0.2:linux"
compile "org.openjfx:javafx-graphics:11.0.2:mac"
compile "org.openjfx:javafx-graphics:11.0.2:win"
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/main/kotlin/AppManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ object AppManager {
var output = sb.toString()
output = if ("installed for user" in output)
"Success\n"
else "Failure [${output.substringAfter(pkg).trim()}]\n"
else "Failure [ADB error ${output.substringAfter(pkg).trim()}]\n"
withContext(Dispatchers.Main) {
outputTextArea.apply {
appendText("App: ${it.appnameProperty().get()}\n")
Expand Down Expand Up @@ -220,7 +220,7 @@ object AppManager {
}
val output = if ("disabled-user" in sb.toString())
"Success\n"
else "Failure\n"
else "Failure [ADB error]\n"
withContext(Dispatchers.Main) {
outputTextArea.apply {
appendText("App: ${it.appnameProperty().get()}\n")
Expand Down Expand Up @@ -259,7 +259,7 @@ object AppManager {
}
val output = if ("enabled" in sb.toString())
"Success\n"
else "Failure\n"
else "Failure [ADB error]\n"
withContext(Dispatchers.Main) {
outputTextArea.apply {
appendText("App: ${it.appnameProperty().get()}\n")
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/Device.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object Device {
val propString = Command.exec(mutableListOf("adb", "shell", "getprop"))
when {
"unauthorized" in propString -> mode = Mode.AUTH
"no permissions" in propString -> mode = Mode.ADB_ERROR
"no permission" in propString -> mode = Mode.ADB_ERROR
"no devices" !in propString -> {
props.clear()
propString.trim().lines().forEach {
Expand Down Expand Up @@ -86,7 +86,7 @@ object Device {
suspend fun readFastboot() {
val devices = Command.exec(mutableListOf("fastboot", "devices"), redirectErrorStream = false)
when {
"no permissions" in devices -> mode = Mode.FASTBOOT_ERROR
"no permission" in devices -> mode = Mode.FASTBOOT_ERROR
devices.isNotEmpty() -> {
props.clear()
Command.exec(mutableListOf("fastboot", "getvar", "all")).trim().lines().forEach {
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/Downloader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import java.io.FileOutputStream
import java.net.URL
import java.nio.channels.Channels

class Downloader(val link: String, val target: File, val progressLabel: Label) {
class Downloader(link: String, private val target: File, private val progressLabel: Label) {

private val url = URL(link)
private val size = url.openConnection().contentLengthLong.toFloat()
private var startTime = 0L
val progress: Float
private val progress: Float
get() = (target.length() / size) * 100f
val speed: Float
private val speed: Float
get() = target.length() / ((System.currentTimeMillis() - startTime) / 1000.0f)

suspend fun start(scope: CoroutineScope = GlobalScope) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/FileExplorer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlinx.coroutines.withContext
import java.io.File
import java.util.*

class FileExplorer(val statusTextField: TextField, val statusProgressBar: ProgressBar) {
class FileExplorer(private val statusTextField: TextField, private val statusProgressBar: ProgressBar) {

var path = "/"

Expand Down
60 changes: 42 additions & 18 deletions src/main/kotlin/MainController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import javafx.scene.control.Alert.AlertType
import javafx.scene.control.cell.CheckBoxTableCell
import javafx.scene.control.cell.PropertyValueFactory
import javafx.scene.image.ImageView
import javafx.scene.input.KeyCode
import javafx.scene.layout.HBox
import javafx.scene.layout.VBox
import javafx.scene.text.Font
Expand Down Expand Up @@ -299,7 +300,6 @@ class MainController : Initializable {
}
else -> {
infoTextArea.clear()
codenameTextField.clear()
dpiTextField.clear()
widthTextField.clear()
heightTextField.clear()
Expand Down Expand Up @@ -344,11 +344,12 @@ class MainController : Initializable {
Mode.ADB_ERROR -> {
if ("loaded" !in outputTextArea.text)
outputTextArea.text =
"ERROR: The device cannot be loaded!\nTry setting the USB configuration to data transfer!\n\n"
"ERROR: The device cannot be loaded!\nTry setting the USB configuration to data transfer or launching the application with root/admin privileges!\n\n"
}
Mode.FASTBOOT_ERROR -> {
if ("loaded" !in outputTextArea.text)
outputTextArea.text = "ERROR: The device cannot be loaded!\n\n"
outputTextArea.text =
"ERROR: The device cannot be loaded!\nTry launching the application with root/admin privileges!\n\n"
}
else -> {
}
Expand All @@ -359,6 +360,17 @@ class MainController : Initializable {
} while (!(Device.mode == Mode.ADB || Device.mode == Mode.FASTBOOT || Device.mode == Mode.RECOVERY))
}

private fun TableView<App>.setKeyListener() {
this.setOnKeyPressed {
if (it.code == KeyCode.ENTER || it.code == KeyCode.SPACE)
this.selectionModel.selectedItems.forEach { app ->
app.apply {
selectedProperty().set(!selectedProperty().get())
}
}
}
}

override fun initialize(url: URL, rb: ResourceBundle?) {
uncheckTableColumn.cellValueFactory = PropertyValueFactory("selected")
uncheckTableColumn.setCellFactory { CheckBoxTableCell() }
Expand Down Expand Up @@ -400,6 +412,11 @@ class MainController : Initializable {
disablerTableView.columns.setAll(discheckTableColumn, disappTableColumn, dispackageTableColumn)
enablerTableView.columns.setAll(encheckTableColumn, enappTableColumn, enpackageTableColumn)

uninstallerTableView.setKeyListener()
reinstallerTableView.setKeyListener()
disablerTableView.setKeyListener()
enablerTableView.setKeyListener()

Command.outputTextArea = outputTextArea
Command.progressIndicator = progressIndicator
ROMFlasher.outputTextArea = outputTextArea
Expand Down Expand Up @@ -921,7 +938,9 @@ class MainController : Initializable {
GlobalScope.launch {
if (Device.checkFastboot()) {
if (confirm("Your partitions must be intact in order to successfully lock the bootloader.")) {
Command.execDisplayed(mutableListOf("fastboot", "oem", "lock"))
if (confirm("All your data will be gone.")) {
Command.execDisplayed(mutableListOf("fastboot", "oem", "lock"))
}
}
} else checkDevice()
}
Expand All @@ -930,8 +949,11 @@ class MainController : Initializable {
@FXML
private fun unlockButtonPressed(event: ActionEvent) {
GlobalScope.launch {
if (Device.checkFastboot())
Command.execDisplayed(mutableListOf("fastboot", "oem", "unlock")) else checkDevice()
if (Device.checkFastboot()) {
if (confirm("All your data will be gone.")) {
Command.execDisplayed(mutableListOf("fastboot", "oem", "unlock"))
}
} else checkDevice()
}
}

Expand Down Expand Up @@ -1204,28 +1226,30 @@ class MainController : Initializable {
graphic = ImageView("icon.png")
headerText =
"Xiaomi ADB/Fastboot Tools\nVersion ${XiaomiADBFastbootTools.version}\nCreated by Szaki\n\n" +
"SDK Platform Tools\n${runBlocking {
Command.exec(
mutableListOf(
"adb",
"--version"
)
).lines()[1]
}}"
"SDK Platform Tools\n${
runBlocking {
Command.exec(
mutableListOf(
"adb",
"--version"
)
).lines()[1]
}
}"
val vb = VBox()
vb.alignment = Pos.CENTER
val discord = Hyperlink("Xiaomi Community on Discord")
discord.onAction = EventHandler {
if (XiaomiADBFastbootTools.linux)
Runtime.getRuntime().exec("xdg-open https://discord.gg/xiaomi")
else Desktop.getDesktop().browse(URI("https://discord.gg/xiaomi"))
Runtime.getRuntime().exec("xdg-open http://discord.szaki.io/")
else Desktop.getDesktop().browse(URI("http://discord.szaki.io/"))
}
discord.font = Font(15.0)
val twitter = Hyperlink("Szaki on Twitter")
twitter.onAction = EventHandler {
if (XiaomiADBFastbootTools.linux)
Runtime.getRuntime().exec("xdg-open https://twitter.com/Szaki_EU")
else Desktop.getDesktop().browse(URI("https://twitter.com/Szaki_EU"))
Runtime.getRuntime().exec("xdg-open http://twitter.szaki.io/")
else Desktop.getDesktop().browse(URI("http://twitter.szaki.io/"))
}
twitter.font = Font(15.0)
val github = Hyperlink("Repository on GitHub")
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ fun MutableMap<String, MutableList<String>>.add(key: String, value: String) {
} else this[key]!!.add(value)
}

fun startProcess(vararg command: String, redirectErrorStream: Boolean = false) =
fun startProcess(vararg command: String, redirectErrorStream: Boolean = false): Process =
ProcessBuilder(*command).directory(XiaomiADBFastbootTools.dir).redirectErrorStream(redirectErrorStream).start()

fun startProcess(command: List<String?>, redirectErrorStream: Boolean = false) =
fun startProcess(command: List<String?>, redirectErrorStream: Boolean = false): Process =
ProcessBuilder(command).directory(XiaomiADBFastbootTools.dir).redirectErrorStream(redirectErrorStream).start()

fun runScript(file: File, redirectErrorStream: Boolean = false) = if (XiaomiADBFastbootTools.win)
fun runScript(file: File, redirectErrorStream: Boolean = false): Process = if (XiaomiADBFastbootTools.win)
ProcessBuilder("cmd.exe", "/c", file.absolutePath).directory(XiaomiADBFastbootTools.dir)
.redirectErrorStream(redirectErrorStream).start()
else ProcessBuilder("sh", "-c", file.absolutePath).directory(XiaomiADBFastbootTools.dir)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/XiaomiADBFastbootTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.io.File
class XiaomiADBFastbootTools : Application() {

companion object {
val version = "7.0"
const val version = "7.0.3"
val dir = File(System.getProperty("user.home"), "XiaomiADBFastbootTools")
val win = "win" in System.getProperty("os.name").toLowerCase()
val linux = "linux" in System.getProperty("os.name").toLowerCase()
Expand Down
Loading

0 comments on commit 77cf144

Please sign in to comment.