Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* - <a href="http://developer.android.com/guide/topics/providers/document-provider.html#43">...</a>
*/
public class FolderProvider extends DocumentsProvider {
private static final List<String> BLOCKED_PACKAGES = List.of("com.dnamobile.modlymodmanager");

private static final String ALL_MIME_TYPES = "*/*";

Expand Down Expand Up @@ -101,6 +102,8 @@ public Cursor queryRoots(String[] projection) {

@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
if(BLOCKED_PACKAGES.contains(getCallingPackage()))
throw new RuntimeException("Unsupported package caller!");
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
// Future-proofing in case if we implement realtime file watching
result.setNotificationUri(mContentResolver, createUriForDocId(documentId));
Expand All @@ -110,6 +113,8 @@ public Cursor queryDocument(String documentId, String[] projection) throws FileN

@Override
public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException {
if(BLOCKED_PACKAGES.contains(getCallingPackage()))
throw new RuntimeException("Unsupported package caller!");
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
final File parent = getFileForDocId(parentDocumentId);
final File[] children = parent.listFiles();
Expand Down Expand Up @@ -138,9 +143,9 @@ public AssetFileDescriptor openDocumentThumbnail(String documentId, Point sizeHi

@Override
public boolean onCreate() {
if(Tools.checkStorageRoot(getContext())) {
if (Tools.checkStorageRoot(getContext())) {
Tools.initStorageConstants(getContext());
}else {
} else {
return false;
}
BASE_DIR = new File(Tools.DIR_GAME_HOME);
Expand All @@ -151,6 +156,8 @@ public boolean onCreate() {

@Override
public String createDocument(String parentDocumentId, String mimeType, String displayName) throws FileNotFoundException {
if(BLOCKED_PACKAGES.contains(getCallingPackage()))
throw new RuntimeException("Unsupported package caller!");
File newFile = new File(parentDocumentId, displayName);
int noConflictId = 2;
while (newFile.exists()) {
Expand Down