5353
5454# Toggle to True for development purposes
5555DEVELOPMENT = False
56- DEVELOPMENT_CONFIG = "Samsung Galaxy A3 2017 " # "Pixel 3a "
56+ DEVELOPMENT_CONFIG = "a3y17lte " # "sargo "
5757
5858
5959PLATFORM = sys .platform
@@ -178,22 +178,20 @@ def close_developer_options_dlg(self, e):
178178 self .page .update ()
179179
180180 def search_devices (self , e ):
181+ """Search the device when the button is clicked."""
182+ logger .info ("Search devices..." )
181183 try :
182184 # read device properties
183185 # TODO: This is not windows ready...
184- if PLATFORM in ("linux" , "MacOS " ):
186+ if PLATFORM in ("linux" , "darwin " ):
185187 output = check_output (
186188 [
187189 str (BIN_PATH .joinpath (Path ("adb" ))),
188190 "shell" ,
189- "dumpsys" ,
190- "bluetooth_manager" ,
191+ "getprop" ,
191192 "|" ,
192193 "grep" ,
193- "'name:'" ,
194- "|" ,
195- "cut" ,
196- "-c9-" ,
194+ "ro.product.device"
197195 ],
198196 stderr = STDOUT ,
199197 ).decode ()
@@ -202,27 +200,29 @@ def search_devices(self, e):
202200 [
203201 str (BIN_PATH .joinpath (Path ("adb" ))),
204202 "shell" ,
205- "dumpsys" ,
206- "bluetooth_manager" ,
203+ "getprop" ,
207204 "|" ,
208205 "findstr" ,
209- "'name:'" ,
210- "|" ,
211- "-split" ,
212- "-c9-" ,
206+ "ro.product.device"
213207 ],
214208 stderr = STDOUT ,
215209 ).decode ()
216210 else :
217211 raise Exception (f"Unknown platform { PLATFORM } ." )
218212
213+ output = output .split ("[" )[- 1 ][:- 2 ]
214+ logger .info (f"Detected { output } " )
215+ # write the device code to the text shown in the box
219216 self .device_name .value = output .strip ()
220217 # load config from file
221218 path = CONFIG_PATH .joinpath (Path (f"{ output .strip ()} .yaml" ))
222219 load_config_success = self .load_config (path )
220+ # display success in the application
223221 if load_config_success :
224222 self .config_found_box .value = True
225223 self .continue_button .disabled = False
224+ # overwrite the text field with the real name from the config
225+ self .device_name .value = f"{ load_config_success } (code: { output .strip ()} )"
226226 else :
227227 # show alternative configs here
228228 # select a new path and load again
@@ -427,7 +427,7 @@ def load_config(self, path: str):
427427 try :
428428 self .config = InstallerConfig .from_file (path )
429429 self .num_total_steps = len (self .config .steps )
430- return True
430+ return self . config . metadata . get ( "devicename" , "No device name in config." )
431431 except FileNotFoundError :
432432 return False
433433
0 commit comments