use of android.os.ParcelFileDescriptor.OnCloseListener in project platform_frameworks_base by android.
the class ExternalStorageProvider method openDocument.
@Override
public ParcelFileDescriptor openDocument(String documentId, String mode, CancellationSignal signal) throws FileNotFoundException {
if (mArchiveHelper.isArchivedDocument(documentId)) {
return mArchiveHelper.openDocument(documentId, mode, signal);
}
final File file = getFileForDocId(documentId);
final File visibleFile = getFileForDocId(documentId, true);
final int pfdMode = ParcelFileDescriptor.parseMode(mode);
if (pfdMode == ParcelFileDescriptor.MODE_READ_ONLY || visibleFile == null) {
return ParcelFileDescriptor.open(file, pfdMode);
} else {
try {
// When finished writing, kick off media scanner
return ParcelFileDescriptor.open(file, pfdMode, mHandler, new OnCloseListener() {
@Override
public void onClose(IOException e) {
final Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(visibleFile));
getContext().sendBroadcast(intent);
}
});
} catch (IOException e) {
throw new FileNotFoundException("Failed to open for writing: " + e);
}
}
}
use of android.os.ParcelFileDescriptor.OnCloseListener in project android_frameworks_base by ResurrectionRemix.
the class ExternalStorageProvider method openDocument.
@Override
public ParcelFileDescriptor openDocument(String documentId, String mode, CancellationSignal signal) throws FileNotFoundException {
if (mArchiveHelper.isArchivedDocument(documentId)) {
return mArchiveHelper.openDocument(documentId, mode, signal);
}
final File file = getFileForDocId(documentId);
final File visibleFile = getFileForDocId(documentId, true);
final int pfdMode = ParcelFileDescriptor.parseMode(mode);
if (pfdMode == ParcelFileDescriptor.MODE_READ_ONLY || visibleFile == null) {
return ParcelFileDescriptor.open(file, pfdMode);
} else {
try {
// When finished writing, kick off media scanner
return ParcelFileDescriptor.open(file, pfdMode, mHandler, new OnCloseListener() {
@Override
public void onClose(IOException e) {
final Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(visibleFile));
getContext().sendBroadcast(intent);
}
});
} catch (IOException e) {
throw new FileNotFoundException("Failed to open for writing: " + e);
}
}
}
use of android.os.ParcelFileDescriptor.OnCloseListener in project android_frameworks_base by crdroidandroid.
the class ExternalStorageProvider method openDocument.
@Override
public ParcelFileDescriptor openDocument(String documentId, String mode, CancellationSignal signal) throws FileNotFoundException {
if (mArchiveHelper.isArchivedDocument(documentId)) {
return mArchiveHelper.openDocument(documentId, mode, signal);
}
final File file = getFileForDocId(documentId);
final File visibleFile = getFileForDocId(documentId, true);
final int pfdMode = ParcelFileDescriptor.parseMode(mode);
if (pfdMode == ParcelFileDescriptor.MODE_READ_ONLY || visibleFile == null) {
return ParcelFileDescriptor.open(file, pfdMode);
} else {
try {
// When finished writing, kick off media scanner
return ParcelFileDescriptor.open(file, pfdMode, mHandler, new OnCloseListener() {
@Override
public void onClose(IOException e) {
final Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(visibleFile));
getContext().sendBroadcast(intent);
}
});
} catch (IOException e) {
throw new FileNotFoundException("Failed to open for writing: " + e);
}
}
}
use of android.os.ParcelFileDescriptor.OnCloseListener in project android_frameworks_base by AOSPA.
the class ExternalStorageProvider method openDocument.
@Override
public ParcelFileDescriptor openDocument(String documentId, String mode, CancellationSignal signal) throws FileNotFoundException {
if (mArchiveHelper.isArchivedDocument(documentId)) {
return mArchiveHelper.openDocument(documentId, mode, signal);
}
final File file = getFileForDocId(documentId);
final File visibleFile = getFileForDocId(documentId, true);
final int pfdMode = ParcelFileDescriptor.parseMode(mode);
if (pfdMode == ParcelFileDescriptor.MODE_READ_ONLY || visibleFile == null) {
return ParcelFileDescriptor.open(file, pfdMode);
} else {
try {
// When finished writing, kick off media scanner
return ParcelFileDescriptor.open(file, pfdMode, mHandler, new OnCloseListener() {
@Override
public void onClose(IOException e) {
final Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(visibleFile));
getContext().sendBroadcast(intent);
}
});
} catch (IOException e) {
throw new FileNotFoundException("Failed to open for writing: " + e);
}
}
}
use of android.os.ParcelFileDescriptor.OnCloseListener in project android_frameworks_base by DirtyUnicorns.
the class ExternalStorageProvider method openDocument.
@Override
public ParcelFileDescriptor openDocument(String documentId, String mode, CancellationSignal signal) throws FileNotFoundException {
if (mArchiveHelper.isArchivedDocument(documentId)) {
return mArchiveHelper.openDocument(documentId, mode, signal);
}
final File file = getFileForDocId(documentId);
final File visibleFile = getFileForDocId(documentId, true);
final int pfdMode = ParcelFileDescriptor.parseMode(mode);
if (pfdMode == ParcelFileDescriptor.MODE_READ_ONLY || visibleFile == null) {
return ParcelFileDescriptor.open(file, pfdMode);
} else {
try {
// When finished writing, kick off media scanner
return ParcelFileDescriptor.open(file, pfdMode, mHandler, new OnCloseListener() {
@Override
public void onClose(IOException e) {
final Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(visibleFile));
getContext().sendBroadcast(intent);
}
});
} catch (IOException e) {
throw new FileNotFoundException("Failed to open for writing: " + e);
}
}
}
Aggregations