Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions MiUnlockToolGUI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
from PySide6.QtWidgets import (QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
QPushButton, QLineEdit, QLabel, QTextEdit,
QMessageBox, QApplication, QProgressBar)
from PySide6.QtCore import Qt, QThread, Signal
import sys
import os
import requests
import subprocess
import time

class UnlockThread(QThread):
progress_signal = Signal(str)
finished_signal = Signal(bool, str)

def __init__(self, user, pwd):
super().__init__()
self.user = user
self.pwd = pwd

def run(self):
try:
# Here you would integrate the actual unlock logic from MiUnlockTool
# For each step, emit progress:
self.progress_signal.emit("Checking device connection...")
time.sleep(1) # Simulate work

self.progress_signal.emit("Authenticating with Xiaomi servers...")
time.sleep(1) # Simulate work

self.progress_signal.emit("Requesting unlock permission...")
time.sleep(1) # Simulate work

# On success:
self.finished_signal.emit(True, "Device unlocked successfully!")
except Exception as e:
self.finished_signal.emit(False, f"Error: {str(e)}")

class MiUnlockToolGUI(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Mi Unlock Tool GUI")
self.setMinimumSize(600, 400)

# Central widget and main layout
central_widget = QWidget()
self.setCentralWidget(central_widget)
layout = QVBoxLayout(central_widget)

# Title
title_label = QLabel("Mi Unlock Tool")
title_label.setStyleSheet("font-size: 24px; font-weight: bold;")
title_label.setAlignment(Qt.AlignCenter)
layout.addWidget(title_label)

# Account credentials section
creds_group = QWidget()
creds_layout = QVBoxLayout(creds_group)

# Username/Email field
user_layout = QHBoxLayout()
self.user_input = QLineEdit()
self.user_input.setPlaceholderText("Xiaomi Account ID/Email/Phone")
user_layout.addWidget(QLabel("Account:"))
user_layout.addWidget(self.user_input)
creds_layout.addLayout(user_layout)

# Password field
pass_layout = QHBoxLayout()
self.pass_input = QLineEdit()
self.pass_input.setPlaceholderText("Password")
self.pass_input.setEchoMode(QLineEdit.Password)
pass_layout.addWidget(QLabel("Password:"))
pass_layout.addWidget(self.pass_input)
creds_layout.addLayout(pass_layout)

layout.addWidget(creds_group)

# Device info section
self.device_info = QTextEdit()
self.device_info.setReadOnly(True)
self.device_info.setPlaceholderText("Device information will appear here...")
layout.addWidget(self.device_info)

# Progress bar
self.progress_bar = QProgressBar()
self.progress_bar.setTextVisible(True)
self.progress_bar.setAlignment(Qt.AlignCenter)
layout.addWidget(self.progress_bar)

# Status label
self.status_label = QLabel()
self.status_label.setAlignment(Qt.AlignCenter)
layout.addWidget(self.status_label)

# Buttons
buttons_layout = QHBoxLayout()

self.check_device_btn = QPushButton("Check Device")
self.check_device_btn.clicked.connect(self.check_device)
buttons_layout.addWidget(self.check_device_btn)

self.unlock_btn = QPushButton("Unlock Device")
self.unlock_btn.clicked.connect(self.unlock_device)
buttons_layout.addWidget(self.unlock_btn)

layout.addLayout(buttons_layout)

# Initialize unlock thread
self.unlock_thread = None

def check_device(self):
try:
# Here implement the device checking logic from MiUnlockTool
# For example:
device_info = self.get_device_info()
self.device_info.setText(device_info)
self.status_label.setText("Device detected successfully")
self.status_label.setStyleSheet("color: green")
except Exception as e:
self.status_label.setText(f"Error: {str(e)}")
self.status_label.setStyleSheet("color: red")

def get_device_info(self):
# This would implement the actual device info gathering from MiUnlockTool
# For now, returning dummy data
return """Device Information:
Product: beryllium
SoC: Qualcomm
Bootloader Status: Locked
Token: 0x1234567890ABCDEF"""

def unlock_device(self):
if not self.user_input.text() or not self.pass_input.text():
QMessageBox.warning(self, "Error", "Please enter both username and password!")
return

self.unlock_btn.setEnabled(False)
self.check_device_btn.setEnabled(False)
self.progress_bar.setRange(0, 0) # Indeterminate progress

self.unlock_thread = UnlockThread(self.user_input.text(), self.pass_input.text())
self.unlock_thread.progress_signal.connect(self.update_progress)
self.unlock_thread.finished_signal.connect(self.unlock_finished)
self.unlock_thread.start()

def update_progress(self, message):
self.status_label.setText(message)

def unlock_finished(self, success, message):
self.unlock_btn.setEnabled(True)
self.check_device_btn.setEnabled(True)
self.progress_bar.setRange(0, 100)

if success:
self.progress_bar.setValue(100)
self.status_label.setStyleSheet("color: green")
else:
self.progress_bar.setValue(0)
self.status_label.setStyleSheet("color: red")

self.status_label.setText(message)

if __name__ == '__main__':
app = QApplication(sys.argv)
window = MiUnlockToolGUI()
window.show()
sys.exit(app.exec())