use of com.android.documentsui.model.RootInfo in project platform_frameworks_base by android.
the class RootsCache method isIconUniqueBlocking.
public boolean isIconUniqueBlocking(RootInfo root) {
waitForFirstLoad();
loadStoppedAuthorities();
synchronized (mLock) {
final int rootIcon = root.derivedIcon != 0 ? root.derivedIcon : root.icon;
for (RootInfo test : mRoots.get(root.authority)) {
if (Objects.equals(test.rootId, root.rootId)) {
continue;
}
final int testIcon = test.derivedIcon != 0 ? test.derivedIcon : test.icon;
if (testIcon == rootIcon) {
return false;
}
}
return true;
}
}
use of com.android.documentsui.model.RootInfo in project platform_frameworks_base by android.
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 com.android.documentsui.model.RootInfo in project platform_frameworks_base by android.
the class RootsFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final Context context = getActivity();
final RootsCache roots = DocumentsApplication.getRootsCache(context);
final State state = ((BaseActivity) context).getDisplayState();
mCallbacks = new LoaderCallbacks<Collection<RootInfo>>() {
@Override
public Loader<Collection<RootInfo>> onCreateLoader(int id, Bundle args) {
return new RootsLoader(context, roots, state);
}
@Override
public void onLoadFinished(Loader<Collection<RootInfo>> loader, Collection<RootInfo> result) {
if (!isAdded()) {
return;
}
Intent handlerAppIntent = getArguments().getParcelable(EXTRA_INCLUDE_APPS);
mAdapter = new RootsAdapter(context, result, handlerAppIntent, state);
mList.setAdapter(mAdapter);
onCurrentRootChanged();
}
@Override
public void onLoaderReset(Loader<Collection<RootInfo>> loader) {
mAdapter = null;
mList.setAdapter(null);
}
};
}
use of com.android.documentsui.model.RootInfo in project platform_frameworks_base by android.
the class BaseActivity method reloadSearch.
private void reloadSearch(String query) {
FragmentManager fm = getFragmentManager();
RootInfo root = getCurrentRoot();
DocumentInfo cwd = getCurrentDirectory();
DirectoryFragment.reloadSearch(fm, root, cwd, query);
}
use of com.android.documentsui.model.RootInfo in project platform_frameworks_base by android.
the class RootsCacheTest method testExcludedAuthorities.
public void testExcludedAuthorities() throws Exception {
final List<RootInfo> roots = newArrayList();
// Set up some roots
for (int i = 0; i < 5; ++i) {
RootInfo root = new RootInfo();
root.authority = "authority" + i;
roots.add(root);
}
// Make some allowed authorities
List<RootInfo> allowedRoots = newArrayList(roots.get(0), roots.get(2), roots.get(4));
// Set up the excluded authority list
for (RootInfo root : roots) {
if (!allowedRoots.contains(root)) {
mState.excludedAuthorities.add(root.authority);
}
}
mState.acceptMimes = new String[] { "*/*" };
assertContainsExactly(allowedRoots, getMatchingRoots(roots, mState));
}
Aggregations