autoupdate_EndToEnd: Better reverse port forwarding management.

* Renamed methods to _{add,remove,install}_rev_forwarding(): `add' and
  `remove' mirror the underlying ADBHost methods; `_rev' signifies that
  we're managing reverse forwarding.

* _add_rev_forwarding() now installs the configured port. There's no
  need to call _install_rev_forwarding() separately, so we remove the
  two existing calls to it. Instead, we now call it as part of
  reboot_device(), strengthening the postcondition and reducing the
  chances for test breakage.

* _remove_rev_forwarding() now removes the corresponding port, so no
  need to call the underlying ADBHost method directly. Furthermore, if
  no URL is provided, it removes all previously configured ports. It
  only removes ports that were previously configured.

* _install_rev_forwarding() is also used by _add_rev_forwarding() for
  installing a specific rule, improving code reuse.

* The default port value (80) becomes a class constant. This value
  doesn't change in general, and allowing it to change between calls
  might lead to inconsistencies.

* The DUT localhost value becomes a class constant (one less inline
  string literal).

* Better handling of forwarding removal in _install_source_version().

Note that, due to b/24771474, actual removal of forwarding rules is
commented out. In one case where we need to remove all rules, we simply
reboot the device. These should be undone once that bug is fixed.

BUG=b:24158510
TEST=Test runs on Moblab, rules installed as expected.

Change-Id: I8a928a39def748d71fcbe235726fb92ad9bf4e81
Reviewed-on: https://chromium-review.googlesource.com/305250
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
1 file changed