Support option to show file sizes in Runtime APEX test scripts' list output.

Support option `--size` in `build/apex/art_apex_test.py` for list
output (`--list`).

Adjust `build/apex/runtests.sh` to honor option `-s`/`--print-sizes`
when using `--list-files`.

Test: art/build/apex/runtests.sh --list-files --print-sizes
Change-Id: Icbe102f1ff1469f1d988c46ac1839ff62478c6f2
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 1d85ef5..3bcf7c6 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -643,8 +643,9 @@
 
 
 class List:
-  def __init__(self, provider):
+  def __init__(self, provider, print_size):
     self._provider = provider
+    self._print_size = print_size
 
   def print_list(self):
 
@@ -659,7 +660,13 @@
         del apex_map['..']
       for (_, val) in sorted(apex_map.items()):
         val_path = os.path.join(path, val.name)
-        print(val_path)
+        if self._print_size:
+          if val.size < 0:
+            print('[    n/a    ]  %s' % val_path)
+          else:
+            print('[%11d]  %s' % (val.size, val_path))
+        else:
+          print(val_path)
         if val.is_dir:
           print_list_rec(val_path)
 
@@ -730,8 +737,8 @@
   if test_args.list and test_args.tree:
     logging.error("Both of --list and --tree set")
     return 1
-  if test_args.size and not test_args.tree:
-    logging.error("--size set but --tree not set")
+  if test_args.size and not (test_args.list or test_args.tree):
+    logging.error("--size set but neither --list nor --tree set")
     return 1
   if not test_args.tmpdir:
     logging.error("Need a tmpdir.")
@@ -758,7 +765,7 @@
     Tree(apex_provider, test_args.apex, test_args.size).print_tree()
     return 0
   if test_args.list:
-    List(apex_provider).print_list()
+    List(apex_provider, test_args.size).print_list()
     return 0
 
   checkers = []
@@ -877,7 +884,7 @@
 
   parser.add_argument('--list', help='List all files', action='store_true')
   parser.add_argument('--tree', help='Print directory tree', action='store_true')
-  parser.add_argument('--size', help='Print file sizes in tree output', action='store_true')
+  parser.add_argument('--size', help='Print file sizes', action='store_true')
 
   parser.add_argument('--tmpdir', help='Directory for temp files')
   parser.add_argument('--debugfs', help='Path to debugfs')