use of android.support.annotation.VisibleForTesting in project android_frameworks_base by crdroidandroid.
the class RootsCache method getMatchingRoots.
@VisibleForTesting
static List<RootInfo> getMatchingRoots(Collection<RootInfo> roots, State state) {
final List<RootInfo> matching = new ArrayList<>();
for (RootInfo root : roots) {
if (DEBUG)
Log.d(TAG, "Evaluating " + root);
if (state.action == State.ACTION_CREATE && !root.supportsCreate()) {
if (DEBUG)
Log.d(TAG, "Excluding read-only root because: ACTION_CREATE.");
continue;
}
if (state.action == State.ACTION_PICK_COPY_DESTINATION && !root.supportsCreate()) {
if (DEBUG)
Log.d(TAG, "Excluding read-only root because: ACTION_PICK_COPY_DESTINATION.");
continue;
}
if (state.action == State.ACTION_OPEN_TREE && !root.supportsChildren()) {
if (DEBUG)
Log.d(TAG, "Excluding root !supportsChildren because: ACTION_OPEN_TREE.");
continue;
}
if (!state.showAdvanced && root.isAdvanced()) {
if (DEBUG)
Log.d(TAG, "Excluding root because: unwanted advanced device.");
continue;
}
if (state.localOnly && !root.isLocalOnly()) {
if (DEBUG)
Log.d(TAG, "Excluding root because: unwanted non-local device.");
continue;
}
if (state.directoryCopy && root.isDownloads()) {
if (DEBUG)
Log.d(TAG, "Excluding downloads root because: unsupported directory copy.");
continue;
}
if (state.action == State.ACTION_OPEN && root.isEmpty()) {
if (DEBUG)
Log.d(TAG, "Excluding empty root because: ACTION_OPEN.");
continue;
}
if (state.action == State.ACTION_GET_CONTENT && root.isEmpty()) {
if (DEBUG)
Log.d(TAG, "Excluding empty root because: ACTION_GET_CONTENT.");
continue;
}
final boolean overlap = MimePredicate.mimeMatches(root.derivedMimeTypes, state.acceptMimes) || MimePredicate.mimeMatches(state.acceptMimes, root.derivedMimeTypes);
if (!overlap) {
if (DEBUG)
Log.d(TAG, "Excluding root because: unsupported content types > " + state.acceptMimes);
continue;
}
if (state.excludedAuthorities.contains(root.authority)) {
if (DEBUG)
Log.d(TAG, "Excluding root because: owned by calling package.");
continue;
}
if (DEBUG)
Log.d(TAG, "Including " + root);
matching.add(root);
}
return matching;
}
use of android.support.annotation.VisibleForTesting in project mobile-center-sdk-android by Microsoft.
the class HashUtils method sha256.
@NonNull
@VisibleForTesting
static String sha256(@NonNull String data, String charsetName) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
digest.update(data.getBytes(charsetName));
return encodeHex(digest.digest());
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
/*
* Never happens as every device has UTF-8 support and SHA-256,
* but if it ever happens make sure we propagate exception as unchecked.
*/
throw new RuntimeException(e);
}
}
use of android.support.annotation.VisibleForTesting in project CleanAndroidProject_MVP by wangjiegulu.
the class ProviderSchedulers method setAllSchedulers.
@VisibleForTesting
public static void setAllSchedulers(Scheduler scheduler) {
SchedulerSelector schedulerSelector = SchedulerSelector.get();
schedulerSelector.putScheduler(ProviderSchedulers.NET, () -> scheduler);
schedulerSelector.putScheduler(ProviderSchedulers.DB, () -> scheduler);
}
Aggregations