Home | History | Annotate | Download | only in live

Lines Matching refs:ad

84     def _add_google_account(self, ad, retries=3):
86 ad.ensure_screen_on()
87 output = ad.adb.shell(
91 (ad.user_account, ad.user_password))
93 ad.log.info("google account is added successfully")
95 ad.log.error("Fail to add google account due to %s", output)
98 def _remove_google_account(self, ad, retries=3):
99 if not ad.is_apk_installed("com.google.android.tradefed.account"
104 ad.log.info("Install account_util %s", account_util)
105 ad.ensure_screen_on()
106 ad.adb.install("-r %s" % account_util, timeout=180)
107 if not ad.is_apk_installed("com.google.android.tradefed.account"):
108 ad.log.error(
112 ad.ensure_screen_on()
113 output = ad.adb.shell(
117 ad.log.info("google account is removed successfully")
119 ad.log.error("Fail to remove google account due to %s", output)
122 def _install_account_util(self, ad):
126 ad.log.info("Install account_util %s", account_util)
127 ad.ensure_screen_on()
128 ad.adb.install("-r %s" % account_util, timeout=180)
130 if not ad.is_apk_installed("com.google.android.tradefed.account"):
131 ad.log.info("com.google.android.tradefed.account is not installed")
135 def _account_registration(self, ad):
136 if hasattr(ad, "user_account"):
137 ad.exit_setup_wizard()
138 if not ad.is_apk_installed("com.google.android.tradefed.account"
142 if self._install_account_util(ad):
145 ad.log.error(
148 ad.force_stop_apk(_TYCHO_PKG)
149 if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid,
151 ad.log.error("Failed to connect to wifi")
153 ad.log.info("Add google account")
154 if not self._add_google_account(ad):
155 ad.log.error("Failed to add google account")
157 ad.adb.shell(
161 (ad.user_account, ad.user_password))
162 ad.log.info("Enable and activate tycho apk")
163 ad.adb.shell('pm enable %s' % _TYCHO_PKG)
164 self.activate_fi_account(ad)
165 if not self.check_project_fi_activated(ad):
166 ad.log.error("Fail to activate Fi account")
168 elif "Fi Network" in ad.adb.getprop("gsm.sim.operator.alpha"):
169 ad.log.error("Google account is not provided for Fi Network")
171 if not ensure_phone_subscription(self.log, ad):
172 ad.log.error("Unable to find a valid subscription!")
174 refresh_droid_config(self.log, ad)
177 def start_service(self, ad, package, service_id, extras, action_type):
181 ad: (android_device.AndroidDevice) device to start activity on
187 ad.log.info('Starting service %s/.%s.', package, service_id)
188 intent = ad.droid.makeIntent(action_type, None, None, extras, [
191 ad.droid.startServiceIntent(intent)
193 def start_activity(self, ad, package, activity_id, extras=None):
197 ad: (android_device.AndroidDevice) device to start activity on
202 ad.log.info('Starting activity %s/.%s.', package, activity_id)
203 intent = ad.droid.makeIntent(ActionTypeId.MAIN, None, None, extras, [
206 ad.droid.startActivityIntent(intent, False)
208 def activate_fi_account(self, ad):
218 ad: Android device need to start Tycho InitActivity.
221 self.start_activity(ad, _TYCHO_PKG, TychoClassId.INIT_ACTIVITY, extra)
223 ad.send_keycode("WAKEUP")
225 current_window = ad.get_my_current_focus_window()
226 log_screen_shot(ad, self.test_name)
228 ad.log.info("In Switch Confirmation Dialog")
229 if ad.adb.getprop("ro.build.version.release")[0] not in ("8", "O"):
230 ad.send_keycode("TAB")
231 ad.send_keycode("TAB")
232 ad.send_keycode("ENTER")
235 ad.log.info("In Tycho InitActivity")
236 ad.send_keycode("TAB")
237 ad.send_keycode("TAB")
238 ad.send_keycode("ENTER")
242 ad.send_keycode("ENTER")
244 ad.log.info("Finished activation process")
247 def check_project_fi_activated(self, ad):
249 if is_sim_ready(self.log, ad) and (
250 ad.droid.telephonyGetSimOperatorName() == "Fi Network"):
251 ad.log.info("SIM state is READY, SIM operator is Fi")
255 def start_tycho_activation(self, ad):
268 ad: Android device need to start Tycho activation.
271 self.start_activity(ad, _TYCHO_PKG, TychoClassId.CARRIER_SETUP, extra)
273 def start_super_network_activation(self, ad):
282 ad: Android device need to start Tycho super network activation.
285 self.start_service(ad, _TYCHO_PKG,
289 def get_active_carrier(self, ad):
293 ad: An AndroidDevice Object.
303 mcc_mnc = ad.droid.telephonyGetSimOperator()
309 ad.log.error('Unknown Mobile Country Code/Mobile Network Code %s',
313 def switch_sim(self, ad):
317 ad: An AndroidDevice Object.
325 old_sim_operator = ad.droid.telephonyGetSimOperatorName()
326 ad.log.info("Before SIM switch, SIM operator = %s", old_sim_operator)
327 send_dialer_secret_code(ad, "794824746")
329 new_sim_operator = ad.droid.telephonyGetSimOperatorName()
330 ad.log.info("After SIM switch, SIM operator = %s", new_sim_operator)
331 refresh_droid_config(self.log, ad)
335 ad,
345 ad: An AndroidDevice Object.
357 if self.is_ready_to_make_carrier_switch(ad):
362 ad.log.error("Device stays in carrier switch lock state")
365 send_dialer_secret_code(ad, _CARRIER_DIALER_CODE_LOOKUP[carrier])
367 old_carrier = self.get_active_carrier(ad)
369 ad.log.info('Already on %s, so no need to switch', carrier)
373 ad.log.info('Initiating unsolicited switch from %s to %s.',
375 send_dialer_secret_code(ad, _CARRIER_DIALER_CODE_LOOKUP[carrier])
377 ad, carrier, timeout=timeout, check_interval=check_interval)
379 def is_switching_silent(self, ad):
384 Args: ad: An AndroidDevice Object.
389 return "isInSilentMode\" value=\"true" in ad.adb.shell(
393 def is_switching_locked(self, ad):
396 Args: ad: An AndroidDevice Object.
402 return "switchingInProgress\" value=\"true" in ad.adb.shell(
405 def is_ready_to_make_carrier_switch(self, ad):
409 ad: An AndroidDevice Object.
415 if self.is_switching_silent(ad):
416 ad.log.info(
420 if self.is_switching_locked(ad):
421 ad.log.info(
424 if self.is_carrier_switch_in_progress(ad):
425 ad.log.info("Cannot make carrier switch: Switch in progress!")
429 def is_carrier_switch_in_progress(self, ad):
433 ad: An AndroidDevice Object.
438 switching_preferences = ad.adb.shell("cat %s" % _SWITCHING_PREF_FILE)
441 def check_network_carrier(self, ad, carrier):
442 current_carrier = self.get_active_carrier(ad)
443 ad.log.info("Current network carrier is %s", current_carrier)
444 is_in_switch = self.is_carrier_switch_in_progress(ad)
445 ad.log.info("Device in carrier switch progress mode")
449 ad,
459 ad: An Android device object.
466 check_args = [ad, carrier]
469 ad.log.info("Switched to %s successfully", carrier)
470 ad.send_keycode("ENTER")
473 ad.log.error("Carrier is %s. Fail to switch to %s",
474 self.get_active_carrier(ad), carrier)
477 def operator_network_switch(self, ad, carrier):
478 if ad.droid.telephonyGetSimOperatorName() == "Fi Network":
480 if self.set_active_carrier(ad, carrier):
483 ad.log.error("Failed to switch to %s", carrier)
485 if not ensure_phone_subscription(self.log, ad):
486 ad.log.error("Unable to find a valid subscription!")
488 refresh_droid_config(self.log, ad)
492 tasks = [(self.operator_network_switch, [ad, carrier])
493 for ad in self.android_devices]
510 tasks = [(self._account_registration, [ad])
511 for ad in self.android_devices]
569 for ad in self.android_devices:
570 self.switch_sim(ad)
575 for ad in self.android_devices:
576 self._remove_google_account(ad)