diff --git a/README.rst b/README.rst
index e0925d4..f141a29 100644
--- a/README.rst
+++ b/README.rst
@@ -37,6 +37,7 @@ Contents
* `Check Debian Linux official packages <#check-debian-linux-official-packages>`_
* `Check Ubuntu Linux official packages <#check-ubuntu-linux-official-packages>`_
* `Check Anitya (release-monitoring.org) <#check-anitya>`_
+ * `Check Android SDK <#check-android-sdk>`_
* `Manually updating <#manually-updating>`_
* `Version Control System (VCS) (git, hg, svn, bzr) <#version-control-system-vcs-git-hg-svn-bzr>`_
* `Other <#other>`_
@@ -380,6 +381,16 @@ This enables you to track updates from `Anitya
anitya
``distro/package``, where ``distro`` can be a lot of things like "fedora", "arch linux", "gentoo", etc. ``package`` is the package name of the chosen distribution.
+Check Android SDK
+-----------------
+This enables you to track updates of Android SDK packages listed in ``sdkmanager --list``.
+
+android_sdk
+ The package path prefix. This value is matched against the ``path`` attribute in all nodes in an SDK manifest XML. The first match is used for version comparisions.
+
+repo
+ Should be one of ``addon`` or ``package``. Packages in ``addon2-1.xml`` use ``addon`` and packages in ``repository2-1.xml`` use ``package``.
+
Manually updating
-----------------
This enables you to manually specify the version (maybe because you want to approve each release before it gets to the script).
diff --git a/nvchecker/source/android_sdk.py b/nvchecker/source/android_sdk.py
index d90e754..386b596 100644
--- a/nvchecker/source/android_sdk.py
+++ b/nvchecker/source/android_sdk.py
@@ -1,5 +1,5 @@
# MIT licensed
-# Copyright (c) 2013-2017 lilydjwg , et al.
+# Copyright (c) 2017 Yen Chi Hsuan
import os
import re
@@ -7,19 +7,33 @@ from xml.etree import ElementTree
from . import session
-ANDROID_REPO_MANIFESTS = {
+_ANDROID_REPO_MANIFESTS = {
'addon': 'https://dl.google.com/android/repository/addon2-1.xml',
'package': 'https://dl.google.com/android/repository/repository2-1.xml',
}
-async def get_version(name, conf):
- repo_xml_url = ANDROID_REPO_MANIFESTS[conf['repo']]
- pkg_path_prefix = conf['android_sdk']
+_repo_manifests_cache = {}
+
+async def _get_repo_manifest(repo):
+ if repo in _repo_manifests_cache:
+ return _repo_manifests_cache[repo]
+
+ repo_xml_url = _ANDROID_REPO_MANIFESTS[repo]
async with session.get(repo_xml_url) as res:
data = (await res.read()).decode('utf-8')
repo_manifest = ElementTree.fromstring(data)
+ _repo_manifests_cache[repo] = repo_manifest
+
+ return repo_manifest
+
+async def get_version(name, conf):
+ repo = conf['repo']
+ pkg_path_prefix = conf['android_sdk']
+
+ repo_manifest = await _get_repo_manifest(repo)
+
for pkg in repo_manifest.findall('.//remotePackage'):
if not pkg.attrib['path'].startswith(pkg_path_prefix):
continue
diff --git a/tests/test_android.py b/tests/test_android.py
index 48d3160..36f5260 100644
--- a/tests/test_android.py
+++ b/tests/test_android.py
@@ -1,5 +1,5 @@
# MIT licensed
-# Copyright (c) 2013-2017 lilydjwg , et al.
+# Copyright (c) 2017 Yen Chi Hsuan
import pytest
pytestmark = pytest.mark.asyncio