def wrap_do(self):
        # Go to Settings - Wi-Fi menu and turn on Wi-Fi
        wifi_steps.set_wifi(serial=self.serial, state="ON")()
        wifi_steps.open_wifi_settings(serial=self.serial)()

        # TODO: Implement steps in ui_steps for using spinners and check boxes?

        # Click "More"
        # if self.device_info.dessert in ["L", "M"]:
        #     ui_steps.click_button(serial=self.serial,
        #                           view_to_find={"descriptionContains": "More"},
        #                           view_to_check={"textContains": "Add network"})()
        # if self.device_info.dessert in ["N"]:
        #     ui_steps.wait_for_view_with_scroll(serial=self.serial, timeout=10000,
        #                                        view_to_find={"resourceId": "android:id/icon_frame"},
        #                                        iterations=5)()

        # Click "Add network"
        ui_steps.click_button(serial=self.serial,
                              view_to_find={
                                  "textContains": "Add network"},
                              view_to_check={"textContains": "Network name"})()

        # Complete the SSID text field
        ui_steps.edit_text(serial=self.serial,
                           view_to_find={
                               "resourceId": "com.android.settings:id/ssid"},
                           value=self.ssid,
                           is_password=False)()
    def do(self):
        if self.open_wifi_settings:
            # Turn on Wi-Fi and go to Settings - Wi-Fi menu and Turn
            wifi_steps.set_wifi(
                serial=self.serial,
                state="ON",
                use_adb=self.use_adb)()
            wifi_steps.open_wifi_settings(serial=self.serial, use_adb=False)()

        # Click the More button
        # if not ui_steps.click_button_if_exists(serial=self.serial,
        #            view_to_find = self.device_info.wifi_more_options_id)():
        if self.uidevice(scrollable=True):
            self.uidevice(scrollable=True).scroll.toEnd()

        # Look for the 'Saved Networks' button.
        # If it exists, click it. If not, it means there are no saved Wi-Fi
        # networks.
        if self.uidevice(text="Saved networks").wait.exists(timeout=1000):
            ui_steps.click_button(serial=self.serial,
                                  view_to_find={"text": "Saved networks"},
                                  view_to_check={"text": "Saved networks"})()

            # Get the top saved network from the ListView
            i = self.uidevice(resourceId="android:id/title").count
            number_of_saved_networks = i - 1
            for x in xrange(number_of_saved_networks):
                ui_steps.click_button(serial=self.serial,
                                      view_to_find={
                                          "resourceId": "android:id/title"},
                                      view_to_check={"textContains": "CANCEL"})()
                ui_steps.click_button(serial=self.serial,
                                      view_to_find={
                                          "textContains": "FORGET"},
                                      view_to_check={"textContains": "Add network"})()

            # If we still have an entry in the list, the step is failed.
            if self.max_entries == 0:
                self.step_data = False
                self.set_errorm("", "Network still in 'Saved Networks' list.")
            else:
                self.step_data = True
        else:
            self.step_data = True
##### test start #####
adb_steps.connect_device(serial = serial,
                         port = adb_server_port)()

# configure ap
ap_steps.setup(mode, security,
               encryption = encryption,
               wifi_password = ddwrt_ap_pass,
               new_ssid = ddwrt_ap_name,
               serial = serial)()

# ensure the device is unlocked
ui_steps.unlock_device(serial = serial)()

if adb_utils.get_product_name(serial=serial) == "r2_s3gr10m6s_trusty":
    wifi_steps.open_wifi_settings(serial=serial)()

# rotate screen
# get the device rotation type
ui_steps.set_orientation(serial = serial,
                     orientation = "landscape",
                     target = "tablet")()
device_type = adb_utils.get_device_orientation_type(serial = serial)

# rotate to portrait
ui_steps.set_orientation(serial = serial,
                     orientation = "portrait",
                     target = device_type)()


# make sure there are no saved networks