Java源码示例:com.android.annotations.VisibleForTesting.Visibility
示例1
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected SourcePackage(
SdkSource source,
AndroidVersion platformVersion,
int revision,
Properties props,
String localOsPath) {
super( source, //source
props, //properties
revision, //revision
null, //license
null, //description
null, //descUrl
localOsPath //archiveOsPath
);
mVersion = platformVersion;
mPkgDesc = PkgDesc.Builder
.newSource(mVersion,
(MajorRevision) getRevision())
.setDescriptions(this)
.create();
}
示例2
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected BuildToolPackage(
SdkSource source,
Properties props,
int revision,
String license,
String description,
String descUrl,
String archiveOsPath) {
super(source,
props,
revision,
license,
description,
descUrl,
archiveOsPath);
mPkgDesc = PkgDesc.Builder
.newBuildTool(getRevision())
.setDescriptions(this)
.create();
}
示例3
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected PlatformPackage(@Nullable SdkSource source,
@NonNull IAndroidTarget target,
@Nullable Properties props) {
super( source, //source
props, //properties
target.getRevision(), //revision
null, //license
target.getDescription(), //description
null, //descUrl
target.getLocation() //archiveOsPath
);
mVersion = target.getVersion();
mVersionName = target.getVersionName();
mLayoutlibVersion = new LayoutlibVersionMixin(props);
mIncludedAbi = props == null ? null : props.getProperty(PkgProps.PLATFORM_INCLUDED_ABI);
mPkgDesc = PkgDesc.Builder
.newPlatform(mVersion,
(MajorRevision) getRevision(),
getMinToolsRevision())
.setDescriptions(this)
.create();
}
示例4
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected PlatformToolPackage(
SdkSource source,
Properties props,
int revision,
String license,
String description,
String descUrl,
String archiveOsPath) {
super(source,
props,
revision,
license,
description,
descUrl,
archiveOsPath);
mPkgDesc = PkgDesc.Builder
.newPlatformTool(getRevision())
.setDescriptions(this)
.create();
}
示例5
/**
* Initializes the {@link SdkManager} and the {@link AvdManager}.
* Extracted so that we can override this in unit tests.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected void initSdk() {
setSdkManager(SdkManager.createManager(mOsSdkRoot, mSdkLog));
try {
mAvdManager = null;
mAvdManager = AvdManager.getInstance(mSdkManager.getLocalSdk(), mSdkLog);
} catch (AndroidLocationException e) {
mSdkLog.error(e, "Unable to read AVDs: " + e.getMessage()); //$NON-NLS-1$
// Note: we used to continue here, but the thing is that
// mAvdManager==null so nothing is really going to work as
// expected. Let's just display an error later in checkIfInitFailed()
// and abort right there. This step is just too early in the SWT
// setup process to display a message box yet.
mAvdManagerInitError = e;
}
// notify listeners.
broadcastOnSdkReload();
}
示例6
/**
* Initializes the {@link SettingsController}
* Extracted so that we can override this in unit tests.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected SettingsController initSettingsController() {
SettingsController settingsController = new SettingsController(mSdkLog);
settingsController.registerOnChangedListener(new OnChangedListener() {
@Override
public void onSettingsChanged(
SettingsController controller,
SettingsController.Settings oldSettings) {
// Reset the download cache if it doesn't match the right strategy.
// The cache instance gets lazily recreated later in getDownloadCache().
if (mDownloadCache != null) {
if (controller.getSettings().getUseDownloadCache() &&
mDownloadCache.getStrategy() != DownloadCache.Strategy.FRESH_CACHE) {
mDownloadCache = null;
} else if (!controller.getSettings().getUseDownloadCache() &&
mDownloadCache.getStrategy() != DownloadCache.Strategy.DIRECT) {
mDownloadCache = null;
}
}
}
});
return settingsController;
}
示例7
/**
* Takes an XML document as a string as parameter and returns a DOM for it.
*
* On error, returns null and prints a (hopefully) useful message on the monitor.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected Document getDocument(InputStream xml, ITaskMonitor monitor) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringComments(true);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
assert xml.markSupported();
xml.reset();
Document doc = builder.parse(new InputSource(xml));
return doc;
} catch (ParserConfigurationException e) {
monitor.logError("Failed to create XML document builder");
} catch (SAXException e) {
monitor.logError("Failed to parse XML document");
} catch (IOException e) {
monitor.logError("Failed to read XML document");
}
return null;
}
示例8
/**
* Takes an XML document as a string as parameter and returns a DOM for it.
*
* On error, returns null and prints a (hopefully) useful message on the monitor.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected Document getDocument(InputStream xml, ITaskMonitor monitor) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringComments(true);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
assert xml.markSupported();
xml.reset();
Document doc = builder.parse(new InputSource(xml));
return doc;
} catch (ParserConfigurationException e) {
monitor.logError("Failed to create XML document builder");
} catch (SAXException e) {
monitor.logError("Failed to parse XML document");
} catch (IOException e) {
monitor.logError("Failed to read XML document");
}
return null;
}
示例9
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected SourcePackage(
SdkSource source,
AndroidVersion platformVersion,
int revision,
Properties props,
String localOsPath) {
super( source, //source
props, //properties
revision, //revision
null, //license
null, //description
null, //descUrl
localOsPath //archiveOsPath
);
mVersion = platformVersion;
mPkgDesc = setDescriptions(PkgDesc.Builder.newSource(mVersion, (MajorRevision) getRevision())).create();
}
示例10
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected BuildToolPackage(
SdkSource source,
Properties props,
int revision,
String license,
String description,
String descUrl,
String archiveOsPath) {
super(source,
props,
revision,
license,
description,
descUrl,
archiveOsPath);
mPkgDesc = setDescriptions(PkgDesc.Builder.newBuildTool(getRevision())).create();
}
示例11
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected PlatformPackage(@Nullable SdkSource source,
@NonNull IAndroidTarget target,
@Nullable Properties props) {
super( source, //source
props, //properties
target.getRevision(), //revision
null, //license
target.getDescription(), //description
null, //descUrl
target.getLocation() //archiveOsPath
);
mVersion = target.getVersion();
mVersionName = target.getVersionName();
mLayoutlibVersion = new LayoutlibVersionMixin(props);
mIncludedAbi = props == null ? null : props.getProperty(PkgProps.PLATFORM_INCLUDED_ABI);
mPkgDesc = setDescriptions(PkgDesc.Builder
.newPlatform(mVersion, (MajorRevision) getRevision(), getMinToolsRevision()))
.create();
}
示例12
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected PlatformToolPackage(
SdkSource source,
Properties props,
int revision,
String license,
String description,
String descUrl,
String archiveOsPath) {
super(source,
props,
revision,
license,
description,
descUrl,
archiveOsPath);
mPkgDesc = setDescriptions(PkgDesc.Builder.newPlatformTool(getRevision())).create();
}
示例13
/**
* Initializes the {@link SettingsController}
* Extracted so that we can override this in unit tests.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected SettingsController initSettingsController() {
SettingsController settingsController = new SettingsController(mSdkLog);
settingsController.registerOnChangedListener(new OnChangedListener() {
@Override
public void onSettingsChanged(
SettingsController controller,
SettingsController.Settings oldSettings) {
// Reset the download cache if it doesn't match the right strategy.
// The cache instance gets lazily recreated later in getDownloadCache().
if (mDownloadCache != null) {
if (controller.getSettings().getUseDownloadCache() &&
mDownloadCache.getStrategy() != DownloadCache.Strategy.FRESH_CACHE) {
mDownloadCache = null;
} else if (!controller.getSettings().getUseDownloadCache() &&
mDownloadCache.getStrategy() != DownloadCache.Strategy.DIRECT) {
mDownloadCache = null;
}
}
}
});
return settingsController;
}
示例14
/**
* Takes an XML document as a string as parameter and returns a DOM for it.
*
* On error, returns null and prints a (hopefully) useful message on the monitor.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected Document getDocument(InputStream xml, ITaskMonitor monitor) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringComments(true);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
assert xml.markSupported();
xml.reset();
Document doc = builder.parse(new InputSource(xml));
return doc;
} catch (ParserConfigurationException e) {
monitor.logError("Failed to create XML document builder");
} catch (SAXException e) {
monitor.logError("Failed to parse XML document");
} catch (IOException e) {
monitor.logError("Failed to read XML document");
}
return null;
}
示例15
/**
* Takes an XML document as a string as parameter and returns a DOM for it.
*
* On error, returns null and prints a (hopefully) useful message on the monitor.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected Document getDocument(InputStream xml, ITaskMonitor monitor) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringComments(true);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
assert xml.markSupported();
xml.reset();
Document doc = builder.parse(new InputSource(xml));
return doc;
} catch (ParserConfigurationException e) {
monitor.logError("Failed to create XML document builder");
} catch (SAXException e) {
monitor.logError("Failed to parse XML document");
} catch (IOException e) {
monitor.logError("Failed to read XML document");
}
return null;
}
示例16
/**
* Returns the {@link DownloadCache}
* Extracted so that we can override this in unit tests.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected DownloadCache getDownloadCache() {
if (mDownloadCache == null) {
mDownloadCache = new DownloadCache(
mSettingsController.getSettings().getUseDownloadCache() ?
DownloadCache.Strategy.FRESH_CACHE :
DownloadCache.Strategy.DIRECT);
}
return mDownloadCache;
}
示例17
/**
* Creates a new local archive.
* This is typically called when inflating a local-package info by reading a local
* source.properties file. In this case a few properties like the URL, checksum and
* size are not defined.
*
* @param pkg The package that contains this archive. Cannot be null.
* @param props A set of properties. Can be null.
* @param localOsPath The OS path where the archive is installed if this represents a
* local package. Null for a remote package.
*/
@VisibleForTesting(visibility=Visibility.PACKAGE)
public Archive(@NonNull Package pkg,
@Nullable Properties props,
@Nullable String localOsPath) {
mPackage = pkg;
mArchFilter = new ArchFilter(props);
mUrl = null;
mLocalOsPath = localOsPath;
mSize = 0;
mChecksum = "";
mIsLocal = localOsPath != null;
}
示例18
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected SourcePackage(
AndroidVersion platformVersion,
int revision,
Properties props,
String localOsPath) {
this(null /*source*/, platformVersion, revision, props, localOsPath);
}
示例19
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected ToolPackage(
SdkSource source,
Properties props,
int revision,
String license,
String description,
String descUrl,
String archiveOsPath) {
super(source,
props,
revision,
license,
description,
descUrl,
archiveOsPath);
// Setup min-platform-tool
String revStr = getProperty(props, PkgProps.MIN_PLATFORM_TOOLS_REV, null);
FullRevision rev = MIN_PLATFORM_TOOLS_REV_INVALID;
if (revStr != null) {
try {
rev = FullRevision.parseRevision(revStr);
} catch (NumberFormatException ignore) {}
}
mMinPlatformToolsRevision = rev;
mPkgDesc = PkgDesc.Builder
.newTool(getRevision(),
mMinPlatformToolsRevision)
.setDescriptions(this)
.create();
}
示例20
@VisibleForTesting(visibility=Visibility.PRIVATE)
public SystemImagePackage(
AndroidVersion platformVersion,
int revision,
String abi,
Properties props,
String localOsPath) {
this(null /*source*/, platformVersion, revision, abi, props, localOsPath);
}
示例21
/**
* Calls {@link UrlOpener#openUrl(String, boolean, ITaskMonitor, Header[])}
* to actually perform a download.
* <p/>
* Isolated so that it can be overridden by unit tests.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
@NonNull
protected Pair<InputStream, HttpResponse> openUrl(
@NonNull String url,
boolean needsMarkResetSupport,
@NonNull ITaskMonitor monitor,
@Nullable Header[] headers) throws IOException, CanceledByUserException {
return UrlOpener.openUrl(url, needsMarkResetSupport, monitor, headers);
}
示例22
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected void setPackages(Package[] packages) {
mPackages = packages;
if (mPackages != null) {
// Order the packages.
Arrays.sort(mPackages, null);
}
}
示例23
/** Empty current property list. Made accessible for testing purposes. */
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected void clear() {
synchronized (sSourcesProperties) {
sSourcesProperties.clear();
sModified = false;
}
}
示例24
@VisibleForTesting(visibility=Visibility.PRIVATE)
@Nullable
protected NoPreviewRevision getCurrentJvmVersion() throws NumberFormatException {
String javav = System.getProperty("java.version"); //$NON-NLS-1$
// java Version is typically in the form "1.2.3_45" and we just need to keep up to "1.2.3"
// since our revision numbers are in 3-parts form (1.2.3).
Pattern p = Pattern.compile("((\\d+)(\\.\\d+)?(\\.\\d+)?).*"); //$NON-NLS-1$
Matcher m = p.matcher(javav);
if (m.matches()) {
return NoPreviewRevision.parseRevision(m.group(1));
}
return null;
}
示例25
/**
* Creates a new local archive.
* This is typically called when inflating a local-package info by reading a local
* source.properties file. In this case a few properties like the URL, checksum and
* size are not defined.
*
* @param pkg The package that contains this archive. Cannot be null.
* @param props A set of properties. Can be null.
* @param localOsPath The OS path where the archive is installed if this represents a
* local package. Null for a remote package.
*/
@VisibleForTesting(visibility=Visibility.PACKAGE)
public Archive(@NonNull Package pkg,
@Nullable Properties props,
@Nullable String localOsPath) {
mPackage = pkg;
mArchFilter = new ArchFilter(props);
mUrl = null;
mLocalOsPath = localOsPath;
mSize = 0;
mChecksum = "";
mIsLocal = localOsPath != null;
}
示例26
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected SourcePackage(
AndroidVersion platformVersion,
int revision,
Properties props,
String localOsPath) {
this(null /*source*/, platformVersion, revision, props, localOsPath);
}
示例27
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected ToolPackage(
SdkSource source,
Properties props,
int revision,
String license,
String description,
String descUrl,
String archiveOsPath) {
super(source,
props,
revision,
license,
description,
descUrl,
archiveOsPath);
// Setup min-platform-tool
String revStr = getProperty(props, PkgProps.MIN_PLATFORM_TOOLS_REV, null);
FullRevision rev = MIN_PLATFORM_TOOLS_REV_INVALID;
if (revStr != null) {
try {
rev = FullRevision.parseRevision(revStr);
} catch (NumberFormatException ignore) {}
}
mMinPlatformToolsRevision = rev;
mPkgDesc = setDescriptions(PkgDesc.Builder
.newTool(getRevision(), mMinPlatformToolsRevision))
.create();
}
示例28
@VisibleForTesting(visibility=Visibility.PRIVATE)
public SystemImagePackage(
AndroidVersion platformVersion,
int revision,
String abi,
Properties props,
String localOsPath) {
this(null /*source*/, platformVersion, revision, abi, props, localOsPath);
}
示例29
/**
* Initializes the {@link SdkManager} .
* Extracted so that we can override this in unit tests.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected void initSdk() {
setSdkManager(SdkManager.createManager(mOsSdkRoot, mSdkLog));
// notify listeners.
broadcastOnSdkReload();
}
示例30
/**
* Calls {@link UrlOpener#openUrl(String, boolean, ITaskMonitor, Header[])}
* to actually perform a download.
* <p/>
* Isolated so that it can be overridden by unit tests.
*/
@VisibleForTesting(visibility=Visibility.PRIVATE)
@NonNull
protected Pair<InputStream, HttpResponse> openUrl(
@NonNull String url,
boolean needsMarkResetSupport,
@NonNull ITaskMonitor monitor,
@Nullable Header[] headers) throws IOException, CanceledByUserException {
return UrlOpener.openUrl(url, needsMarkResetSupport, monitor, headers);
}