-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebloat.py
73 lines (59 loc) · 2.29 KB
/
Debloat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import sys
import subprocess
import os
import platform
import res.rc_res as rc_res
from pathlib import Path
from PySide6.QtCore import QObject, Slot, Signal
from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine, QmlElement
QML_IMPORT_NAME = "io.qt.textproperties"
QML_IMPORT_MAJOR_VERSION = 1
@QmlElement
class Debloater(QObject):
@Slot(result=str)
def check_device(self):
if platform.system() == "Windows":
os.chdir("adb")
result = subprocess.run(["adb", "devices"], capture_output=True, text=True)
lines = result.stdout.splitlines()
for line in lines[1:]:
parts = line.split("\t")
if len(parts) > 1 and parts[1] == "device":
return parts[0]
return "No devices connected."
@Slot(str,result=str)
def app_name(self,s):
self.Application_name = s.strip().lower()
@Slot(str,result=list)
def load_pkgs(self,s):
package_list = subprocess.run(['adb', 'shell', 'pm', 'list', 'packages'], stdout=subprocess.PIPE, text=True).stdout.splitlines()
cleaned_package_list = []
for pkg in package_list:
clean = pkg.replace("package:","")
cleaned_package_list.append(clean)
if cleaned_package_list:
if not s:
return cleaned_package_list
self.filtered = []
if cleaned_package_list :
for pkg in cleaned_package_list:
if self.Application_name in pkg.lower():
self.filtered.append(pkg)
if self.filtered:
return self.filtered
@Slot(str,result=str)
def uninstall(self,s):
process = subprocess.run(['adb', 'shell', 'pm', 'uninstall', '--user', '0', s],stdout=subprocess.PIPE, text=True).stdout.splitlines()
if "Success" in process:
return "Uninstalled Successfully"
else:
return "Failed"
if __name__ == "__main__":
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
qml_file = Path(__file__).resolve().parent / "qml/Main.qml"
engine.load(qml_file)
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec())