Windows, aar_resources_extractor: longpath bugfix

Fix a bug in the Android tool
aar_resources_extractor: open the compressed data
and the target file as file descriptores, rather
than using aar.extract.

This way we can shorten the directories in the
relative path of the extracted file, because we
can open the target file via a junction and thus
work around long path limitations.

//tools/android:aar_resources_extractor_test now
passes on Windows.

Change-Id: I9f5c7de2279ad8769e53e015b8334a58a76cd989
PiperOrigin-RevId: 170181143
diff --git a/tools/android/aar_resources_extractor_test.py b/tools/android/aar_resources_extractor_test.py
index b59e416..d5f630b 100644
--- a/tools/android/aar_resources_extractor_test.py
+++ b/tools/android/aar_resources_extractor_test.py
@@ -23,6 +23,10 @@
 from tools.android import aar_resources_extractor
 
 
+def _HostPath(path):
+  return os.path.normpath(path)
+
+
 class AarResourcesExtractorTest(unittest.TestCase):
   """Unit tests for aar_resources_extractor.py."""
 
@@ -33,14 +37,16 @@
     shutil.rmtree("out_dir")
 
   def DirContents(self, d):
-    return [path + "/" + f for (path, _, files) in os.walk(d)
-            for f in files]
+    return [
+        _HostPath(path + "/" + f)
+        for (path, _, files) in os.walk(d) for f in files
+    ]
 
   def testNoResources(self):
     aar = zipfile.ZipFile(StringIO.StringIO(), "w")
     os.makedirs("out_dir")
     aar_resources_extractor.ExtractResources(aar, "out_dir")
-    self.assertEqual(["out_dir/res/values/empty.xml"],
+    self.assertEqual([_HostPath("out_dir/res/values/empty.xml")],
                      self.DirContents("out_dir"))
     with open("out_dir/res/values/empty.xml", "r") as empty_xml:
       self.assertEqual("<resources/>", empty_xml.read())
@@ -51,8 +57,10 @@
     aar.writestr("res/layouts/layout.xml", "some layout")
     os.makedirs("out_dir")
     aar_resources_extractor.ExtractResources(aar, "out_dir")
-    expected_resources = ["out_dir/res/values/values.xml",
-                          "out_dir/res/layouts/layout.xml"]
+    expected_resources = [
+        _HostPath("out_dir/res/values/values.xml"),
+        _HostPath("out_dir/res/layouts/layout.xml")
+    ]
     self.assertItemsEqual(expected_resources, self.DirContents("out_dir"))
     with open("out_dir/res/values/values.xml", "r") as values_xml:
       self.assertEqual("some values", values_xml.read())