Merge cherrypicks of ['android-review.googlesource.com/3262291', 'android-review.googlesource.com/3264011', 'android-review.googlesource.com/3264095', 'android-review.googlesource.com/3274351', 'android-review.googlesource.com/3282114'] into androidx-graphics-release.

Change-Id: I3ebd566c9b6e0f3214bb8e2b56815841b0352484
diff --git a/busytown/androidx_host_tests_docker_2004.sh b/busytown/androidx_host_tests_docker_2004.sh
new file mode 100755
index 0000000..4c0b17b
--- /dev/null
+++ b/busytown/androidx_host_tests_docker_2004.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -e
+
+echo "Starting $0 at $(date)"
+
+cd "$(dirname $0)"
+
+impl/build.sh test allHostTests zipOwnersFiles createModuleInfo \
+    -Pandroidx.ignoreTestFailures \
+    -Pandroidx.displayTestOutput=false \
+    "$@"
+
+echo "Completing $0 at $(date)"
diff --git a/busytown/impl/build.sh b/busytown/impl/build.sh
index e1ffc07..3269137 100755
--- a/busytown/impl/build.sh
+++ b/busytown/impl/build.sh
@@ -65,9 +65,6 @@
   fi
 }
 
-# export some variables
-ANDROID_HOME=../../prebuilts/fullsdk-linux
-
 BUILD_STATUS=0
 # enable remote build cache unless explicitly disabled
 if [ "$USE_ANDROIDX_REMOTE_BUILD_CACHE" == "" ]; then
@@ -78,15 +75,23 @@
 # If our existing native libraries are newer, then we don't downgrade them because
 # something else (like Bash) might be requiring the newer version.
 function areNativeLibsNewEnoughForKonan() {
-  host=`uname`
-  if [[ "$host" == Darwin* ]]; then
+  if [[ "$(uname)" == Darwin* ]]; then
     # we don't have any Macs having native dependencies too old to build KMP/konan
     true
+  elif [[ -f /etc/os-release ]]; then
+    . /etc/os-release
+    version=${VERSION_ID//./}  # Remove dots for comparison
+    if (( version >= 2004 )); then
+      true
+    else
+      # on Ubuntu < 20.04 we check whether we have a sufficiently new GLIBCXX
+      gcc --print-file-name=libstdc++.so.6 | xargs readelf -a -W | grep GLIBCXX_3.4.21 >/dev/null
+    fi
   else
-    # on Linux we check whether we have a sufficiently new GLIBCXX
-    gcc --print-file-name=libstdc++.so.6 | xargs readelf -a -W | grep GLIBCXX_3.4.21 >/dev/null
+    true
   fi
 }
+
 if ! areNativeLibsNewEnoughForKonan; then
   KONAN_HOST_LIBS="$OUT_DIR/konan-host-libs"
   LOG="$KONAN_HOST_LIBS.log"
diff --git a/busytown/impl/parse_profile_html.py b/busytown/impl/parse_profile_html.py
index 0ce5cae..436db9f 100755
--- a/busytown/impl/parse_profile_html.py
+++ b/busytown/impl/parse_profile_html.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
  #
  # Copyright (C) 2016 The Android Open Source Project
  #
diff --git a/development/JetpadClient.py b/development/JetpadClient.py
index 19b74bc..88eb445 100644
--- a/development/JetpadClient.py
+++ b/development/JetpadClient.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 #
 # Copyright (C) 2020 The Android Open Source Project
 #
diff --git a/development/build_log_simplifier/build_log_simplifier.py b/development/build_log_simplifier/build_log_simplifier.py
index 974acd6..09e28b6 100755
--- a/development/build_log_simplifier/build_log_simplifier.py
+++ b/development/build_log_simplifier/build_log_simplifier.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 #
 # Copyright (C) 2016 The Android Open Source Project
 #
diff --git a/development/build_log_simplifier/test.py b/development/build_log_simplifier/test.py
index 40ab24b..5c7bb3d 100755
--- a/development/build_log_simplifier/test.py
+++ b/development/build_log_simplifier/test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 #
 # Copyright (C) 2020 The Android Open Source Project
 #
diff --git a/development/copy_screenshots_to_golden_repo.py b/development/copy_screenshots_to_golden_repo.py
index 5f80cbb..1d16446 100755
--- a/development/copy_screenshots_to_golden_repo.py
+++ b/development/copy_screenshots_to_golden_repo.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 # This script helps to rename and copy the golden images required to run the screenshot tests to the golden directory.
 # To generate new golden images for a test, run the test on the emulator with the required device type, and download the screenshots from the device using adb
diff --git a/development/file-utils/diff-filterer.py b/development/file-utils/diff-filterer.py
index 3a9bb5c..dc34ca7 100755
--- a/development/file-utils/diff-filterer.py
+++ b/development/file-utils/diff-filterer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 #
 #  Copyright (C) 2018 The Android Open Source Project
 #
diff --git a/development/importMaven/import_maven_artifacts.py b/development/importMaven/import_maven_artifacts.py
index c3f6947..66f02fe 100755
--- a/development/importMaven/import_maven_artifacts.py
+++ b/development/importMaven/import_maven_artifacts.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 """
 Copyright 2018 The Android Open Source Project
diff --git a/development/offlinifyDocs/offlinify_dackka_docs.py b/development/offlinifyDocs/offlinify_dackka_docs.py
index 932d03c..2c16bfa 100644
--- a/development/offlinifyDocs/offlinify_dackka_docs.py
+++ b/development/offlinifyDocs/offlinify_dackka_docs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 from argparse import ArgumentParser
 import os
diff --git a/development/offlinifyDocs/test_offlinify_dackka_docs.py b/development/offlinifyDocs/test_offlinify_dackka_docs.py
index c6695dd..116481c 100644
--- a/development/offlinifyDocs/test_offlinify_dackka_docs.py
+++ b/development/offlinifyDocs/test_offlinify_dackka_docs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 from filecmp import cmp, dircmp
 from offlinify_dackka_docs import check_library, process_input, STYLE_FILENAME
diff --git a/development/project-creator/create_project.py b/development/project-creator/create_project.py
index 7b0ddc4..ce27130 100755
--- a/development/project-creator/create_project.py
+++ b/development/project-creator/create_project.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 #
 # Copyright (C) 2020 The Android Open Source Project
 #
diff --git a/development/project-creator/test_project_creator.py b/development/project-creator/test_project_creator.py
index 9d3c2c8..cdf4d06 100755
--- a/development/project-creator/test_project_creator.py
+++ b/development/project-creator/test_project_creator.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 #
 # Copyright (C) 2020 The Android Open Source Project
 #
diff --git a/development/simplify-build-failure/impl/explode.py b/development/simplify-build-failure/impl/explode.py
index 3ade65a..5ea515f1 100755
--- a/development/simplify-build-failure/impl/explode.py
+++ b/development/simplify-build-failure/impl/explode.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 #
 #  Copyright (C) 2020 The Android Open Source Project
 #
diff --git a/development/suppressFailingTests.py b/development/suppressFailingTests.py
index d9c71af..e39cf95 100755
--- a/development/suppressFailingTests.py
+++ b/development/suppressFailingTests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 """
 Parses information about failing tests, and then generates a change to disable them.
diff --git a/development/ts.py b/development/ts.py
index f4c54d9..95e8faf 100755
--- a/development/ts.py
+++ b/development/ts.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 # This program reads stdin, prepends the current time to each line, and prints the result
 
 from datetime import datetime