use of android.os.storage.StorageManager in project platform_frameworks_base by android.
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 MountServiceTests method testMountAndUnmountTwoObbs.
@LargeTest
public void testMountAndUnmountTwoObbs() {
StorageManager sm = getStorageManager();
final File file1 = getFilePath("test1.obb");
final File file2 = getFilePath("test2.obb");
ObbObserver oo1 = mountObbWithoutWait(sm, R.raw.test1, file1);
ObbObserver oo2 = mountObbWithoutWait(sm, R.raw.test1, file2);
Log.d(TAG, "Waiting for OBB #1 to complete mount");
waitForObbActionCompletion(sm, file1, oo1, OnObbStateChangeListener.MOUNTED, false);
Log.d(TAG, "Waiting for OBB #2 to complete mount");
waitForObbActionCompletion(sm, file2, oo2, OnObbStateChangeListener.MOUNTED, false);
final String mountPath1 = checkMountedPath(sm, file1);
final File mountDir1 = new File(mountPath1);
assertTrue("OBB mounted path should be a directory", mountDir1.isDirectory());
final String mountPath2 = checkMountedPath(sm, file2);
final File mountDir2 = new File(mountPath2);
assertTrue("OBB mounted path should be a directory", mountDir2.isDirectory());
unmountObb(sm, file1, OnObbStateChangeListener.UNMOUNTED);
unmountObb(sm, file2, OnObbStateChangeListener.UNMOUNTED);
}
use of android.os.storage.StorageManager in project platform_frameworks_base by android.
the class ApplicationPackageManager method getPrimaryStorageCandidateVolumes.
@Override
@NonNull
public List<VolumeInfo> getPrimaryStorageCandidateVolumes() {
final StorageManager storage = mContext.getSystemService(StorageManager.class);
final VolumeInfo currentVol = getPrimaryStorageCurrentVolume();
final List<VolumeInfo> vols = storage.getVolumes();
final List<VolumeInfo> candidates = new ArrayList<>();
if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, storage.getPrimaryStorageUuid()) && currentVol != null) {
// TODO: support moving primary physical to emulated volume
candidates.add(currentVol);
} else {
for (VolumeInfo vol : vols) {
if (Objects.equals(vol, currentVol) || isPrimaryStorageCandidateVolume(vol)) {
candidates.add(vol);
}
}
}
return candidates;
}
use of android.os.storage.StorageManager in project platform_frameworks_base by android.
the class ApplicationPackageManager method getPrimaryStorageCurrentVolume.
@Override
@Nullable
public VolumeInfo getPrimaryStorageCurrentVolume() {
final StorageManager storage = mContext.getSystemService(StorageManager.class);
final String volumeUuid = storage.getPrimaryStorageUuid();
return storage.findVolumeByQualifiedUuid(volumeUuid);
}
use of android.os.storage.StorageManager in project android_frameworks_base by DirtyUnicorns.
the class DevicePolicyManagerService method wipeDataNoLock.
private void wipeDataNoLock(boolean wipeExtRequested, String reason) {
if (wipeExtRequested) {
StorageManager sm = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE);
sm.wipeAdoptableDisks();
}
try {
RecoverySystem.rebootWipeUserData(mContext, reason);
} catch (IOException | SecurityException e) {
Slog.w(LOG_TAG, "Failed requesting data wipe", e);
}
}
Aggregations