Search in sources :

Example 16 with StorageManager

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);
}
Also used : StorageManager(android.os.storage.StorageManager) File(java.io.File) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 17 with StorageManager

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);
}
Also used : StorageManager(android.os.storage.StorageManager) File(java.io.File) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 18 with StorageManager

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;
}
Also used : StorageManager(android.os.storage.StorageManager) ArrayList(java.util.ArrayList) VolumeInfo(android.os.storage.VolumeInfo) NonNull(android.annotation.NonNull)

Example 19 with StorageManager

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);
}
Also used : StorageManager(android.os.storage.StorageManager) Nullable(android.annotation.Nullable)

Example 20 with StorageManager

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);
    }
}
Also used : StorageManager(android.os.storage.StorageManager) IOException(java.io.IOException)

Aggregations

StorageManager (android.os.storage.StorageManager)161 File (java.io.File)43 IOException (java.io.IOException)42 VolumeInfo (android.os.storage.VolumeInfo)38 FileNotFoundException (java.io.FileNotFoundException)32 ParcelFileDescriptor (android.os.ParcelFileDescriptor)25 LargeTest (android.test.suitebuilder.annotation.LargeTest)20 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)17 RemoteException (android.os.RemoteException)14 ArrayList (java.util.ArrayList)14 Intent (android.content.Intent)13 Bundle (android.os.Bundle)13 StorageVolume (android.os.storage.StorageVolume)13 PackageParserException (android.content.pm.PackageParser.PackageParserException)12 NotFoundException (android.content.res.Resources.NotFoundException)12 StorageListener (android.os.storage.StorageListener)12 SettingNotFoundException (android.provider.Settings.SettingNotFoundException)12 ErrnoException (android.system.ErrnoException)12 NonNull (android.annotation.NonNull)10 ZipFile (java.util.zip.ZipFile)10