Skip to content

Commit 1b1de85

Browse files
author
Greger Stolt Nilsen
committed
Add override of download location.
Add ability to override download location by setting environment variable ANDROID_REPOSITORY.
1 parent e4cdba1 commit 1b1de85

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

emu/emu_downloads_menu.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@
2727
from emu.utils import download
2828
from emu.docker_config import DockerConfig
2929

30+
ANDROID_REPOSITORY = os.environ.get("ANDROID_REPOSITORY", "https://dl.google.com/")
31+
3032
SYSIMG_REPOS = [
31-
"https://dl.google.com/android/repository/sys-img/android/sys-img2-1.xml",
32-
"https://dl.google.com/android/repository/sys-img/google_apis/sys-img2-1.xml",
33-
"https://dl.google.com/android/repository/sys-img/google_apis_playstore/sys-img2-1.xml",
34-
"https://dl.google.com/android/repository/sys-img/google_atd/sys-img2-1.xml",
35-
"https://dl.google.com/android/repository/sys-img/android-tv/sys-img2-1.xml",
33+
f"{ANDROID_REPOSITORY}/android/repository/sys-img/android/sys-img2-1.xml",
34+
f"{ANDROID_REPOSITORY}/android/repository/sys-img/google_apis/sys-img2-1.xml",
35+
f"{ANDROID_REPOSITORY}/android/repository/sys-img/google_apis_playstore/sys-img2-1.xml",
36+
f"{ANDROID_REPOSITORY}/android/repository/sys-img/google_atd/sys-img2-1.xml",
37+
f"{ANDROID_REPOSITORY}/android/repository/sys-img/android-tv/sys-img2-1.xml",
3638
]
3739

38-
EMU_REPOS = ["https://dl.google.com/android/repository/repository2-1.xml"]
40+
EMU_REPOS = [f"{ANDROID_REPOSITORY}/android/repository/repository2-1.xml"]
3941

4042
CHANNEL_MAPPING = {
4143
"channel-0": "stable",
@@ -161,10 +163,7 @@ def __init__(self, pkg, licenses):
161163
url_element = pkg.find(".//url")
162164
self.zip = url_element.text
163165

164-
self.url = "https://dl.google.com/android/repository/sys-img/%s/%s" % (
165-
self.tag,
166-
self.zip,
167-
)
166+
self.url = f"{ANDROID_REPOSITORY}/android/repository/sys-img/%s/%s" % (self.tag, self.zip)
168167

169168
def short_tag(self):
170169
return self.SHORT_TAG[self.tag]
@@ -214,7 +213,7 @@ def __init__(self, pkg, licenses):
214213
for archive in archives:
215214
url = archive.find(".//url").text
216215
hostos = archive.find("host-os").text
217-
self.urls[hostos] = "https://dl.google.com/android/repository/%s" % url
216+
self.urls[hostos] = f"{ANDROID_REPOSITORY}/android/repository/{url}"
218217

219218
def download_name(self):
220219
return "emulator-{}.zip".format(self.version)

emu/platform_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import os
1415
import zipfile
1516
from pathlib import Path
1617

1718
from emu.utils import download
1819

19-
2020
class PlatformTools(object):
2121
"""The platform tools zip file. It will be downloaded on demand."""
2222

2323
# Platform tools, needed to get adb.
2424
PLATFORM_TOOLS_URL = (
25-
"https://dl.google.com/android/repository/platform-tools_r29.0.5-linux.zip"
25+
f'{os.environ.get("ANDROID_REPOSITORY", "https://dl.google.com")}/android/repository/platform-tools_r29.0.5-linux.zip'
2626
)
2727
PLATFORM_TOOLS_ZIP = "platform-tools-latest-linux.zip"
2828

0 commit comments

Comments
 (0)