use of android.os.storage.StorageManager in project cw-omnibus by commonsguy.
the class VolumeHelper method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference pref, Object o) {
StorageManager storage = pref.getContext().getSystemService(StorageManager.class);
List<StorageVolume> volumes = storage.getStorageVolumes();
String uuid = o.toString();
for (StorageVolume volume : volumes) {
if ((volume.getUuid() == null && uuid.equals(SettingsFragment.STORAGE_FAKE_UUID)) || (uuid.equals(volume.getUuid()))) {
Intent i = volume.createAccessIntent(dirName);
host.startActivityForHelper(i, this);
break;
}
}
return (true);
}
use of android.os.storage.StorageManager in project android_frameworks_base by ParanoidAndroid.
the class MountServiceTests method testMountAndUnmountObbNormal.
@LargeTest
public void testMountAndUnmountObbNormal() {
StorageManager sm = getStorageManager();
final File outFile = getFilePath("test1.obb");
mountObb(sm, R.raw.test1, outFile, OnObbStateChangeListener.MOUNTED);
mountObb(sm, R.raw.test1, outFile, OnObbStateChangeListener.ERROR_ALREADY_MOUNTED);
final String mountPath = checkMountedPath(sm, outFile);
final File mountDir = new File(mountPath);
assertTrue("OBB mounted path should be a directory", mountDir.isDirectory());
unmountObb(sm, outFile, OnObbStateChangeListener.UNMOUNTED);
}
use of android.os.storage.StorageManager in project platform_frameworks_base by android.
the class MtpDocumentsProviderTest method setupProvider.
private void setupProvider(int flag) {
mDatabase = new MtpDatabase(getContext(), flag);
mProvider = new MtpDocumentsProvider();
final StorageManager storageManager = getContext().getSystemService(StorageManager.class);
assertTrue(mProvider.onCreateForTesting(getContext(), mResources, mMtpManager, mResolver, mDatabase, storageManager, new TestServiceIntentSender()));
}
use of android.os.storage.StorageManager in project platform_frameworks_base by android.
the class AppFuseTest method testOpenFile.
public void testOpenFile() throws IOException {
final StorageManager storageManager = getContext().getSystemService(StorageManager.class);
final int INODE = 10;
final AppFuse appFuse = new AppFuse("test", new TestCallback() {
@Override
public long getFileSize(int inode) throws FileNotFoundException {
if (INODE == inode) {
return 1024;
}
throw new FileNotFoundException();
}
});
appFuse.mount(storageManager);
final ParcelFileDescriptor fd = appFuse.openFile(INODE, ParcelFileDescriptor.MODE_READ_ONLY);
fd.close();
appFuse.close();
}
use of android.os.storage.StorageManager in project platform_frameworks_base by android.
the class AppFuseTest method testReadFile.
public void testReadFile() throws IOException {
final StorageManager storageManager = getContext().getSystemService(StorageManager.class);
final int fileInode = 10;
final byte[] fileBytes = new byte[] { 'a', 'b', 'c', 'd', 'e' };
final AppFuse appFuse = new AppFuse("test", new TestCallback() {
@Override
public long getFileSize(int inode) throws FileNotFoundException {
if (inode == fileInode) {
return fileBytes.length;
}
return super.getFileSize(inode);
}
@Override
public long readObjectBytes(int inode, long offset, long size, byte[] bytes) throws IOException {
if (inode == fileInode) {
int i = 0;
while (i < size && i + offset < fileBytes.length) {
bytes[i] = fileBytes[(int) (i + offset)];
i++;
}
return i;
}
return super.readObjectBytes(inode, offset, size, bytes);
}
});
appFuse.mount(storageManager);
final ParcelFileDescriptor fd = appFuse.openFile(fileInode, ParcelFileDescriptor.MODE_READ_ONLY);
try (final ParcelFileDescriptor.AutoCloseInputStream stream = new ParcelFileDescriptor.AutoCloseInputStream(fd)) {
final byte[] buffer = new byte[1024];
final int size = stream.read(buffer, 0, buffer.length);
assertEquals(5, size);
}
appFuse.close();
}
Aggregations