use of android.support.annotation.VisibleForTesting in project android_frameworks_base by ResurrectionRemix.
the class FileOperations method cancel.
@VisibleForTesting
public static void cancel(Activity activity, String jobId) {
if (DEBUG)
Log.d(TAG, "Attempting to canceling operation: " + jobId);
Intent intent = new Intent(activity, FileOperationService.class);
intent.putExtra(EXTRA_CANCEL, true);
intent.putExtra(EXTRA_JOB_ID, jobId);
activity.startService(intent);
}
use of android.support.annotation.VisibleForTesting in project android_frameworks_base by ResurrectionRemix.
the class StubProvider method createVirtualFile.
@VisibleForTesting
public Uri createVirtualFile(String rootId, String path, String mimeType, List<String> streamTypes, byte[] content) throws FileNotFoundException, IOException {
final File file = createFile(rootId, path, mimeType, content);
final StubDocument parent = mStorage.get(getDocumentIdForFile(file.getParentFile()));
if (parent == null) {
throw new FileNotFoundException("Parent not found.");
}
final StubDocument document = StubDocument.createVirtualDocument(file, mimeType, streamTypes, parent);
mStorage.put(document.documentId, document);
return DocumentsContract.buildDocumentUri(mAuthority, document.documentId);
}
use of android.support.annotation.VisibleForTesting in project android_frameworks_base by ResurrectionRemix.
the class StubProvider method createRegularFile.
@VisibleForTesting
public Uri createRegularFile(String rootId, String path, String mimeType, byte[] content) throws FileNotFoundException, IOException {
final File file = createFile(rootId, path, mimeType, content);
final StubDocument parent = mStorage.get(getDocumentIdForFile(file.getParentFile()));
if (parent == null) {
throw new FileNotFoundException("Parent not found.");
}
final StubDocument document = StubDocument.createRegularDocument(file, mimeType, parent);
mStorage.put(document.documentId, document);
return DocumentsContract.buildDocumentUri(mAuthority, document.documentId);
}
use of android.support.annotation.VisibleForTesting in project android_frameworks_base by ResurrectionRemix.
the class StubProvider method getFile.
@VisibleForTesting
public File getFile(String rootId, String path) throws FileNotFoundException {
StubDocument root = mRoots.get(rootId).document;
if (root == null) {
throw new FileNotFoundException("No roots with the ID " + rootId + " were found");
}
// Convert the path string into a path that's relative to the root.
File needle = new File(root.file, path.substring(1));
StubDocument found = mStorage.get(getDocumentIdForFile(needle));
if (found == null) {
return null;
}
return found.file;
}
use of android.support.annotation.VisibleForTesting in project android_frameworks_base by DirtyUnicorns.
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;
}
Aggregations