The initial version of the automation script fulfilled basic functionality but lacked a user interface, required manual coordinate adjustments for taps, and was not adaptable across devices with different screen resolutions. To address these limitations, the following enhancements are implemented:
- Introduce a graphical user interface (GUI) to monitor device connectivity via ADB.
- Enable automatic generation of input data based on user-defined ranges.
- Ensure compatibility across devices with varying screen sizes without code modification.
- Automatically verify successful data insertion after execution.
The GUI is built using Python’s tkinter library. Below is the core structure:
from tkinter import *
from tkinter import ttk
class AndroidAutomationUI:
def __init__(self, root):
self.root = root
self.setup_ui()
def setup_ui(self):
self.root.title('Android Automation Helper v1.1')
self.root.geometry('700x650')
self.root.resizable(width=False, height=False)
# Connection instructions
instructions = [
"1. Settings > About Phone > Tap Build Number 7 times",
"2. Settings > System > Developer Options > Enable USB Debugging",
"3. Allow ADB debugging in charging-only mode",
"4. Select USB debugging when prompted",
"5. If connection fails, set USB configuration to RNDIS (USB Ethernet)"
]
for i, text in enumerate(instructions):
Label(self.root, width=70, anchor="w", text=text).place(x=10, y=5 + i*20)
# Connection test button and output log
Button(self.root, width=10, text="Test ADB", bg="yellow", command=self.test_adb_connection).place(x=600, y=25)
self.log_text = Text(self.root, width=30, height=5)
self.log_text.place(x=380, y=10)
# Time range selectors
Label(self.root, text="Start Time").place(x=410, y=190)
Label(self.root, text="End Time").place(x=410, y=220)
Label(self.root, text="Hour").place(x=470, y=170)
Label(self.root, text="Minute").place(x=570, y=170)
self.start_hour = ttk.Combobox(self.root, width=5, values=[f"{i:02d}" for i in range(24)])
self.start_hour.current(9)
self.start_hour.place(x=500, y=190)
self.start_min = ttk.Combobox(self.root, width=5, values=[f"{i:02d}" for i in range(0, 60, 5)])
self.start_min.current(0)
self.start_min.place(x=600, y=190)
self.end_hour = ttk.Combobox(self.root, width=5, values=[f"{i:02d}" for i in range(24)])
self.end_hour.current(10)
self.end_hour.place(x=500, y=220)
self.end_min = ttk.Combobox(self.root, width=5, values=[f"{i:02d}" for i in range(0, 60, 5)])
self.end_min.current(0)
self.end_min.place(x=600, y=220)
# Data range inputs
Label(self.root, text="Temp Range").place(x=410, y=250)
Label(self.root, text="Humidity Range").place(x=410, y=280)
Label(self.root, text="<").place(x=540, y=250)
Label(self.root, text="<").place(x=540, y=280)
temp_vals = [f"{v:.1f}" for v in [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]]
self.temp_min = ttk.Combobox(self.root, width=5, values=temp_vals)
self.temp_min.current(0)
self.temp_min.place(x=500, y=250)
self.temp_max = ttk.Combobox(self.root, width=5, values=temp_vals)
self.temp_max.current(6)
self.temp_max.place(x=600, y=250)
hum_vals = [str(v) for v in [35, 40, 45, 50, 55, 60, 65, 70, 75]]
self.hum_min = ttk.Combobox(self.root, width=5, values=hum_vals)
self.hum_min.current(0)
self.hum_min.place(x=500, y=280)
self.hum_max = ttk.Combobox(self.root, width=5, values=hum_vals)
self.hum_max.current(8)
self.hum_max.place(x=600, y=280)
# Action buttons
Button(self.root, width=15, text="Generate Data", bg="yellow", command=self.generate_random_data).place(x=480, y=390)
Label(self.root, text="Data Source:").place(x=430, y=450)
Label(self.root, text="Entry Type:").place(x=430, y=480)
Button(self.root, width=12, text="Preview", bg="yellow", command=self.preview_data).place(x=440, y=520)
Button(self.root, width=12, text="Execute", bg="yellow", command=self.execute_insertion).place(x=550, y=520)
if __name__ == '__main__':
app = Tk()
AndroidAutomationUI(app)
app.mainloop()