You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
273 lines
9.1 KiB
273 lines
9.1 KiB
import subprocess |
|
import tkinter |
|
import tkinter.messagebox |
|
from datetime import datetime |
|
from tkinter import * |
|
def set_time(): |
|
root() |
|
year = datetime.now().strftime('%Y') |
|
month = datetime.now().strftime('%m') |
|
day = datetime.now().strftime('%d') |
|
hour = datetime.now().strftime('%H') |
|
minute = datetime.now().strftime('%M') |
|
subprocess.Popen(["adb", "shell", f"'date' `date +{month}{day}{hour}{minute}{year}.00`"]) |
|
time_string = day + "." + month + "." + year + " " + hour + ":" + minute |
|
labelTime.config(text=time_string, font=("arial", "9", "bold")) |
|
|
|
|
|
def Layout(self, Zeile, Spalte, Typ, Zeilen=1, Spalten=1, framefactor=1): |
|
offsetX = 70 |
|
stepX = 280 |
|
offsetY = 25 |
|
stepY = 40 |
|
|
|
background_edge = 10 * framefactor |
|
|
|
x_pos = offsetX + (Spalte-1) * stepX |
|
y_pos = offsetY + (Zeile-1) * stepY |
|
|
|
elements = { |
|
"Button": [100, 40], |
|
"Label": [240, 40], |
|
"Entry": [50, 40], |
|
"Background": [240, 40] |
|
} |
|
|
|
masse = elements[Typ] |
|
width = masse[0] |
|
height = masse[1] |
|
|
|
if Typ == "Background": |
|
x_pos = (Spalte-1)*stepX - background_edge + offsetX |
|
y_pos = (Zeile-1)*stepY - background_edge + offsetY |
|
width = masse[0]*Spalten + 2*background_edge |
|
height = masse[1]*Zeilen + 2*background_edge |
|
|
|
Label.place(self, x=x_pos, y=y_pos, width=width, height=height) |
|
|
|
|
|
""" --- layout Methoden --- """ |
|
Orte_list = { |
|
"saved \n Places": ["Lat", "Long"], |
|
"Ingolstadt": ["48.76219", "11.42543"], |
|
"Weissach": ["48.852187", "8.901738"], |
|
"Spa": ["50.447845", "5.960178"] |
|
} |
|
|
|
def saveIP(): |
|
newIP = entryIP.get() |
|
# print(IPs) |
|
if not newIP in IPs: |
|
IPs.append(newIP) |
|
dropDownIP = OptionMenu(Fenster, variable, *IPs, command=overwriteIPEntry) |
|
Layout(dropDownIP, 3, 1, "Button") |
|
else: |
|
tkinter.messagebox.showinfo("Fehler", "IP-Adresse bereits in Liste gespeichert") |
|
|
|
def saveCoor(): |
|
newCoor = [0, 0] |
|
newCoor[0] = entryLat.get() |
|
newCoor[1] = entryLong.get() |
|
Orte_list[f"{newCoor[0]}, {newCoor[1]}"] = newCoor # Adding new coordinates to dic |
|
Coordinates.append(f"{newCoor[0]}, {newCoor[1]}") # Adding new coordinates to List of Keys |
|
dropDownCoor = OptionMenu(Fenster, Orte, *Coordinates, command=overwriteLatLong) |
|
Layout(dropDownCoor, 7.5, 1, "Button") |
|
|
|
def overwriteIPEntry(IP): |
|
entryIP.delete(0, END) |
|
entryIP.insert(0, IP) |
|
|
|
def overwriteLatLong(Place): |
|
selected = Orte_list[Place] |
|
entryLat.delete(0, END) |
|
entryLat.insert(0, selected[0]) |
|
entryLong.delete(0, END) |
|
entryLong.insert(0, selected[1]) |
|
|
|
def delete_text(event): |
|
event.widget.delete(0, "end") |
|
|
|
|
|
""" --- adb methoden --- """ |
|
def connect(): |
|
ip = str(entryIP.get()) |
|
# subprocess.call(["adb", "connect", ip], shell=True) |
|
# output = subprocess.check_output(["adb", "connect", ip], shell=True) |
|
subprocess.Popen(["adb", "connect", ip]) # Öffnen ohne zu beachten |
|
# output = subprocess.run(["adb", "connect", ip], capture_output=True) # Check Return Code |
|
# print(output) |
|
# print(output.returncode) |
|
print('test connect') |
|
subprocess.Popen(["adb", "devices"]) # Öffnen ohne zu beachten |
|
|
|
def disconnect(): |
|
subprocess.call(["adb", "disconnect"]) |
|
|
|
def root(): |
|
subprocess.call(["adb", "root"]) |
|
|
|
def forceStop(): |
|
subprocess.call(["adb", "shell", "am", "force-stop", "de.eso.audi.navi"]) |
|
|
|
def clearCache(): |
|
root() |
|
subprocess.call(["adb", "shell", "rm", "-r", "/data/user/10/de.eso.audi.navi/files"]) |
|
subprocess.call(["adb", "shell", "rm", "-r", "/data/user/10/de.eso.audi.navi/cache"]) |
|
|
|
def reboot(): |
|
subprocess.call(["adb", "reboot"]) |
|
|
|
def VStart(): |
|
print("Starte Screenvideo") |
|
|
|
def VStop(): |
|
print("Stoppe Screenvideo") |
|
|
|
def VPull(): |
|
print("Pull Video to Desktop") |
|
|
|
|
|
""" --- Sonstiges --- """ |
|
|
|
def start_screencopy(): |
|
path_scrcpy = r"C:\Users\EOGDJZO\Desktop\Projekt\Basics\Screencopy" |
|
subprocess.Popen([path_scrcpy + r"\scrcpy.exe"]) |
|
#subprocess.call("C:\\Users\EOGDJZO\\Desktop\\Projekt\\Basics\\Screencopy\\scrcpy.exe") |
|
|
|
def set_CCP(): |
|
lat = str(entryLat.get()) |
|
long = str(entryLong.get()) |
|
# subprocess.call(["adb", "connect", ip], shell=True) |
|
# output = subprocess.check_output(["adb", "connect", ip], shell=True) |
|
output = subprocess.run(["adb", "shell", "am", "broadcast", "-a", "de.esolutions.navigation.SET_POSITION", "--ef", "latitude", lat, "--ef", "longitude", long], shell=True) # Check Return Code |
|
print(output) |
|
def startUp(): |
|
disconnect() |
|
connect() |
|
root() |
|
start_screencopy() |
|
set_time() |
|
set_CCP() |
|
|
|
# labelOutput.config(text=Result) |
|
|
|
|
|
Fenster = Tk() |
|
Fenster.title("HCP3 Interface") |
|
Fenster.geometry("960x1080") # Breite x Höhe |
|
|
|
labelTime = Label(master=Fenster, bg="grey") |
|
labelTime.place(x=830, y=10, width=120, height=30) |
|
buttonTime = Button(master=Fenster, bg="grey", text="Set Time", command=set_time, font=("arial", "12", "bold")) |
|
buttonTime.place(x=830, y=40, width=100, height=40) |
|
|
|
|
|
"""--- Background ---""" |
|
labelBGStartUp = Label(master=Fenster, bg="grey") |
|
Layout(labelBGStartUp, 1, 1, "Background", 10, 1, 2) |
|
|
|
labelBGIP = Label(master=Fenster, bg="white") |
|
Layout(labelBGIP, 1, 1, "Background", 4) |
|
|
|
labelBGCCP = Label(master=Fenster, bg="white") |
|
Layout(labelBGCCP, 5.5, 1, "Background", 4) |
|
|
|
labelBGApp_ = Label(master=Fenster, bg="grey") |
|
Layout(labelBGApp_, 12, 1, "Background", 4, 1, 2) |
|
|
|
labelBGApp = Label(master=Fenster, bg="white") |
|
Layout(labelBGApp, 12, 1, "Background", 4) |
|
|
|
labelBGVideo_ = Label(master=Fenster, bg="grey") |
|
Layout(labelBGVideo_, 16.5, 1, "Background", 4, 1, 2) |
|
|
|
labelBGVideo = Label(master=Fenster, bg="white") |
|
Layout(labelBGVideo, 16.5, 1, "Background", 4) |
|
|
|
"""--- IP ---""" |
|
labelEnterIP = Label(master=Fenster, text="Verbindung zum HCP3", font=("arial", 16, "bold")) |
|
Layout(labelEnterIP, 1, 1, "Label") |
|
# labelZahl1.place(x=70, y=25, width=120, height=50) |
|
|
|
entryIP = Entry(master=Fenster, justify="center", bg="white", font=("arial", 14)) |
|
entryIP.insert(0, "Hier IP Adresse eingeben") |
|
entryIP.bind('<Button-1>', delete_text) |
|
Layout(entryIP, 2, 1, "Label") |
|
|
|
buttonConnect = Button(master=Fenster, bg="green", text="Connect", command=connect, font=("arial", "12", "bold")) |
|
Layout(buttonConnect, 4, 1, "Button") |
|
|
|
buttonDisconnect = Button(master=Fenster, bg="red", text="Disconnect", command=disconnect, font=("arial", "12", "bold")) |
|
Layout(buttonDisconnect, 4, 1.5, "Button") |
|
|
|
IPs = ["saved \n IPs", "172.16.250.40", "172.16.250.41", "172.16.250.101"] |
|
variable = StringVar(Fenster) |
|
variable.set(IPs[0]) # Default für IP-Adresse |
|
dropDownIP = OptionMenu(Fenster, variable, *IPs, command=overwriteIPEntry) |
|
# dropDownIP.config(font=("arial", "12")) |
|
Layout(dropDownIP, 3, 1, "Button") |
|
|
|
buttonSaveIP = Button(master=Fenster, bg="yellow", text="Save IP \n to List", command=saveIP, font=("arial", "11", "bold")) |
|
Layout(buttonSaveIP, 3, 1.5, "Button") |
|
|
|
""" --- Koordinaten --- """ |
|
labelEnterKoo = Label(master=Fenster, text="CCP platzieren", font=("arial", 16, "bold")) |
|
Layout(labelEnterKoo, 5.5, 1, "Label") |
|
# labelZahl1.place(x=70, y=25, width=120, height=50) |
|
|
|
entryLat = Entry(master=Fenster, justify="center", bg="white", font=("arial", 16)) |
|
entryLat.insert(0, "Lat") |
|
entryLat.bind('<Button-1>', delete_text) |
|
Layout(entryLat, 6.5, 1, "Button") |
|
|
|
entryLong = Entry(master=Fenster, justify="center", bg="white", font=("arial", 16)) |
|
entryLong.insert(0, "Long") |
|
entryLong.bind('<Button-1>', delete_text) |
|
Layout(entryLong, 6.5, 1.5, "Button") |
|
|
|
Coordinates = ["saved \n Places", "Ingolstadt", "Weissach", "Spa"] |
|
Orte = StringVar(Fenster) |
|
Orte.set(Coordinates[0]) # Default für Koordinaten |
|
dropDownCoor = OptionMenu(Fenster, Orte, *Coordinates, command=overwriteLatLong) |
|
Layout(dropDownCoor, 7.5, 1, "Button") |
|
|
|
buttonSaveCoor = Button(master=Fenster, bg="yellow", text="Save \n Coordinates", command=saveCoor, font=("arial", "11", "bold")) |
|
Layout(buttonSaveCoor, 7.5, 1.5, "Button") |
|
|
|
buttonSetCCP = Button(master=Fenster, bg="green", text="Set Position", command=set_CCP, font=("arial", "12", "bold")) |
|
Layout(buttonSetCCP, 8.5, 1, "Label") |
|
|
|
buttonStartUp = Button(master=Fenster, bg="lightgrey", text="Execute StartUp Routine", command=startUp, font=("arial", "14", "bold")) |
|
Layout(buttonStartUp, 10, 1, "Label") |
|
|
|
"""--- App ---""" |
|
labelEnterKoo = Label(master=Fenster, text="Navigation App", font=("arial", 16, "bold")) |
|
Layout(labelEnterKoo, 12, 1, "Label") |
|
|
|
buttonFStop = Button(master=Fenster, bg="grey", text="Force Stop\nNavApp", command=forceStop, font=("arial", "11", "bold")) |
|
Layout(buttonFStop, 13.25, 1, "Button") |
|
|
|
buttonCCache = Button(master=Fenster, bg="grey", text="Clear Cache\n& Storage", command=clearCache, font=("arial", "11", "bold")) |
|
Layout(buttonCCache, 13.25, 1.5, "Button") |
|
|
|
buttonroot = Button(master=Fenster, bg="grey", text="adb root", command=root, font=("arial", "11", "bold")) |
|
Layout(buttonroot, 14.5, 1, "Button") |
|
|
|
buttonreboot = Button(master=Fenster, bg="grey", text="Reboot\nHCP3", command=reboot, font=("arial", "11", "bold")) |
|
Layout(buttonreboot, 14.5, 1.5, "Button") |
|
|
|
"""--- System ---""" |
|
labelSys = Label(master=Fenster, text="android Screenvideo", font=("arial", 16, "bold")) |
|
Layout(labelSys, 16.5, 1, "Label") |
|
|
|
buttonVStart = Button(master=Fenster, bg="green", text="Start", command=VStart, font=("arial", "12", "bold")) |
|
Layout(buttonVStart, 17.75, 1, "Button") |
|
|
|
buttonVStop = Button(master=Fenster, bg="red", text="Stop", command=VStop, font=("arial", "12", "bold")) |
|
Layout(buttonVStop, 17.75, 1.5, "Button") |
|
|
|
buttonVpull = Button(master=Fenster, bg="grey", text="pull Video to PC", command=VPull, font=("arial", "12", "bold")) |
|
Layout(buttonVpull, 19, 1, "Label") |
|
|
|
|
|
Fenster.mainloop()
|
|
|