import com.android.sdklib.internal.repository.SdkSources;\r
import com.android.sdklib.internal.repository.ToolPackage;\r
import com.android.sdklib.internal.repository.AddonsListFetcher.Site;\r
+import com.android.sdklib.repository.SdkAddonConstants;\r
import com.android.sdklib.repository.SdkAddonsListConstants;\r
import com.android.sdklib.repository.SdkRepoConstants;\r
import com.android.sdkuilib.internal.repository.icons.ImageFactory;\r
// Load user sources\r
sources.loadUserAddons(getSdkLog());\r
\r
- // SDK_UPDATER_URLS is a semicolon-separated list of URLs that can be used to\r
- // seed the SDK Updater list for full repositories.\r
- String str = System.getenv("SDK_UPDATER_URLS");\r
+ // SDK_TEST_URLS is a semicolon-separated list of URLs that can be used to\r
+ // seed the SDK Updater list for full repos and addon repositories. This is\r
+ // only meant as a debugging and QA testing tool and not for user usage.\r
+ //\r
+ // To be used, the URLs must either end with the / or end with the canonical\r
+ // filename expected for either a full repo or an add-on repo. This lets QA\r
+ // use URLs ending with / to cover all cases.\r
+ String str = System.getenv("SDK_TEST_URLS");\r
if (str != null) {\r
String[] urls = str.split(";");\r
for (String url : urls) {\r
- if (url != null && url.length() > 0) {\r
- SdkSource s = new SdkRepoSource(url, null/*uiName*/);\r
- if (!sources.hasSourceUrl(s)) {\r
- sources.add(SdkSourceCategory.GETENV_REPOS, s);\r
+ if (url != null) {\r
+ url = url.trim();\r
+ if (url.endsWith("/") || url.endsWith(SdkRepoConstants.URL_DEFAULT_FILENAME)) {\r
+ String fullUrl = url;\r
+ if (fullUrl.endsWith("/")) {\r
+ fullUrl += SdkRepoConstants.URL_DEFAULT_FILENAME;\r
+ }\r
+\r
+ SdkSource s = new SdkRepoSource(fullUrl, null/*uiName*/);\r
+ if (!sources.hasSourceUrl(s)) {\r
+ sources.add(SdkSourceCategory.GETENV_REPOS, s);\r
+ }\r
}\r
- }\r
- }\r
- }\r
\r
- // SDK_UPDATER_USER_URLS is a semicolon-separated list of URLs that can be used to\r
- // seed the SDK Updater list for user-only repositories. User sources can only provide\r
- // add-ons and extra packages.\r
- str = System.getenv("SDK_UPDATER_USER_URLS");\r
- if (str != null) {\r
- String[] urls = str.split(";");\r
- for (String url : urls) {\r
- if (url != null && url.length() > 0) {\r
- SdkSource s = new SdkAddonSource(url, null/*uiName*/);\r
- if (!sources.hasSourceUrl(s)) {\r
- sources.add(SdkSourceCategory.GETENV_ADDONS, s);\r
+ if (url.endsWith("/") || url.endsWith(SdkAddonConstants.URL_DEFAULT_FILENAME)) {\r
+ String fullUrl = url;\r
+ if (fullUrl.endsWith("/")) {\r
+ fullUrl += SdkAddonConstants.URL_DEFAULT_FILENAME;\r
+ }\r
+\r
+ SdkSource s = new SdkAddonSource(fullUrl, null/*uiName*/);\r
+ if (!sources.hasSourceUrl(s)) {\r
+ sources.add(SdkSourceCategory.GETENV_ADDONS, s);\r
+ }\r
}\r
}\r
}\r
private void loadRemoteAddonsListInTask(ITaskMonitor monitor) {\r
mStateFetchRemoteAddonsList = -1;\r
\r
- /*\r
- * This env var can be defined to override the default addons_list.xml\r
- * location, useful for debugging.\r
- */\r
- String url = System.getenv("SDK_UPDATER_ADDONS_LIST");\r
+ // SDK_TEST_URLS is a semicolon-separated list of URLs that can be used to\r
+ // seed the SDK Updater list. This is only meant as a debugging and QA testing\r
+ // tool and not for user usage.\r
+ //\r
+ // To be used, the URLs must either end with the / or end with the canonical\r
+ // filename expected for an addon list. This lets QA use URLs ending with /\r
+ // to cover all cases.\r
+ //\r
+ // Since SDK_TEST_URLS can contain many such URLs, we take the first one that\r
+ // matches our criteria.\r
+ String url = System.getenv("SDK_TEST_URLS");\r
\r
if (url == null) {\r
+ // No override, use the canonical URL.\r
url = SdkAddonsListConstants.URL_ADDON_LIST;\r
- }\r
- if (getSettingsController().getForceHttp()) {\r
- url = url.replaceAll("https://", "http://"); //$NON-NLS-1$ //$NON-NLS-2$\r
+ } else {\r
+ String[] urls = url.split(";");\r
+ url = null;\r
+ for (String u : urls) {\r
+ u = u.trim();\r
+ // This is an URL that comes from the env var. We expect it to either\r
+ // end with a / or the canonical name, otherwise we don't use it.\r
+ if (u.endsWith("/")) {\r
+ url = u + SdkAddonsListConstants.URL_DEFAULT_FILENAME;\r
+ break;\r
+ } else if (u.endsWith(SdkAddonsListConstants.URL_DEFAULT_FILENAME)) {\r
+ url = u;\r
+ break;\r
+ }\r
+ }\r
}\r
\r
- AddonsListFetcher fetcher = new AddonsListFetcher();\r
- Site[] sites = fetcher.fetch(monitor, url);\r
- if (sites != null) {\r
- mSources.removeAll(SdkSourceCategory.ADDONS_3RD_PARTY);\r
-\r
- for (Site s : sites) {\r
- mSources.add(SdkSourceCategory.ADDONS_3RD_PARTY,\r
- new SdkAddonSource(s.getUrl(), s.getUiName()));\r
+ if (url != null) {\r
+ if (getSettingsController().getForceHttp()) {\r
+ url = url.replaceAll("https://", "http://"); //$NON-NLS-1$ //$NON-NLS-2$\r
}\r
\r
- mStateFetchRemoteAddonsList = 1;\r
+ AddonsListFetcher fetcher = new AddonsListFetcher();\r
+ Site[] sites = fetcher.fetch(monitor, url);\r
+ if (sites != null) {\r
+ mSources.removeAll(SdkSourceCategory.ADDONS_3RD_PARTY);\r
+\r
+ for (Site s : sites) {\r
+ mSources.add(SdkSourceCategory.ADDONS_3RD_PARTY,\r
+ new SdkAddonSource(s.getUrl(), s.getUiName()));\r
+ }\r
+\r
+ mStateFetchRemoteAddonsList = 1;\r
+ }\r
}\r
}\r
\r