use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class AppsProvider method queryChildDocuments.
@Override
public Cursor queryChildDocuments(String docId, String[] projection, String sortOrder) throws FileNotFoundException {
final MatrixCursor result = new DocumentCursor(resolveDocumentProjection(projection), docId);
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
try {
if (docId.startsWith(ROOT_ID_USER_APP)) {
List<PackageInfo> allAppList = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
for (PackageInfo packageInfo : allAppList) {
includeAppFromPackage(result, docId, packageInfo, false, null);
}
} else if (docId.startsWith(ROOT_ID_SYSTEM_APP)) {
List<PackageInfo> allAppList = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
for (PackageInfo packageInfo : allAppList) {
includeAppFromPackage(result, docId, packageInfo, true, null);
}
} else if (docId.startsWith(ROOT_ID_PROCESS)) {
if (Utils.hasNougat()) {
List<RunningServiceInfo> runningServices = activityManager.getRunningServices(1000);
for (RunningServiceInfo process : runningServices) {
includeAppFromService(result, docId, process, null);
}
} else if (Utils.hasLollipopMR1()) {
List<AndroidAppProcess> runningAppProcesses = AndroidProcesses.getRunningAppProcesses();
for (AndroidAppProcess process : runningAppProcesses) {
includeAppFromProcess(result, docId, process, null);
}
} else {
List<RunningAppProcessInfo> runningProcessesList = activityManager.getRunningAppProcesses();
for (RunningAppProcessInfo processInfo : runningProcessesList) {
includeAppFromProcess(result, docId, processInfo, null);
}
}
}
} finally {
Binder.restoreCallingIdentity(token);
}
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class DownloadStorageProvider method queryChildDocuments.
@Override
public Cursor queryChildDocuments(String docId, String[] projection, String sortOrder) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
Query query = new Query();
DownloadManagerUtils.setOnlyIncludeVisibleInDownloadsUi(query);
// query.setOnlyIncludeVisibleInDownloadsUi(true);
query.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL);
// query.setFilterByStatus(DownloadManager.STATUS_PENDING | DownloadManager.STATUS_PAUSED | DownloadManager.STATUS_RUNNING | DownloadManager.STATUS_FAILED);
// .setOnlyIncludeVisibleInDownloadsUi(true)
cursor = mDm.query(query);
// copyNotificationUri(result, cursor);
while (cursor.moveToNext()) {
includeDownloadFromCursor(result, cursor);
}
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class DownloadStorageProvider method queryChildDocumentsForManage.
@Override
public Cursor queryChildDocumentsForManage(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
cursor = mDm.query(// .setOnlyIncludeVisibleInDownloadsUi(true));
new DownloadManager.Query());
// copyNotificationUri(result, cursor);
while (cursor.moveToNext()) {
includeDownloadFromCursor(result, cursor);
}
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class DownloadStorageProvider method queryRoots.
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
final RowBuilder row = result.newRow();
row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT);
row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_CREATE);
row.add(Root.COLUMN_ICON, R.drawable.ic_root_download);
row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_downloads));
row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class ExternalStorageProvider method queryRoots.
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
synchronized (mRootsLock) {
for (RootInfo root : mRoots.values()) {
final RowBuilder row = result.newRow();
row.add(Root.COLUMN_ROOT_ID, root.rootId);
row.add(Root.COLUMN_FLAGS, root.flags);
row.add(Root.COLUMN_TITLE, root.title);
row.add(Root.COLUMN_DOCUMENT_ID, root.docId);
row.add(Root.COLUMN_PATH, root.path);
if (ROOT_ID_PRIMARY_EMULATED.equals(root.rootId) || root.rootId.startsWith(ROOT_ID_SECONDARY) || root.rootId.startsWith(ROOT_ID_PHONE)) {
final File file = root.rootId.startsWith(ROOT_ID_PHONE) ? Environment.getRootDirectory() : root.path;
row.add(Root.COLUMN_AVAILABLE_BYTES, file.getFreeSpace());
row.add(Root.COLUMN_CAPACITY_BYTES, file.getTotalSpace());
}
}
}
return result;
}
Aggregations