Search in sources :

Example 86 with VolumeInfo

use of android.os.storage.VolumeInfo in project android_frameworks_base by DirtyUnicorns.

the class MountService method onDiskScannedLocked.

private void onDiskScannedLocked(DiskInfo disk) {
    int volumeCount = 0;
    for (int i = 0; i < mVolumes.size(); i++) {
        final VolumeInfo vol = mVolumes.valueAt(i);
        if (Objects.equals(disk.id, vol.getDiskId())) {
            volumeCount++;
        }
    }
    final Intent intent = new Intent(DiskInfo.ACTION_DISK_SCANNED);
    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
    intent.putExtra(DiskInfo.EXTRA_DISK_ID, disk.id);
    intent.putExtra(DiskInfo.EXTRA_VOLUME_COUNT, volumeCount);
    mHandler.obtainMessage(H_INTERNAL_BROADCAST, intent).sendToTarget();
    final CountDownLatch latch = mDiskScanLatches.remove(disk.id);
    if (latch != null) {
        latch.countDown();
    }
    disk.volumeCount = volumeCount;
    mCallbacks.notifyDiskScanned(disk, volumeCount);
}
Also used : VolumeInfo(android.os.storage.VolumeInfo) Intent(android.content.Intent) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 87 with VolumeInfo

use of android.os.storage.VolumeInfo in project android_frameworks_base by DirtyUnicorns.

the class PackageManagerService method destroyUserData.

/**
     * Destroy storage areas for given user on all mounted devices.
     */
void destroyUserData(int userId, int flags) {
    synchronized (mInstallLock) {
        final StorageManager storage = mContext.getSystemService(StorageManager.class);
        for (VolumeInfo vol : storage.getWritablePrivateVolumes()) {
            final String volumeUuid = vol.getFsUuid();
            destroyUserDataLI(volumeUuid, userId, flags);
        }
    }
}
Also used : StorageManager(android.os.storage.StorageManager) VolumeInfo(android.os.storage.VolumeInfo)

Example 88 with VolumeInfo

use of android.os.storage.VolumeInfo in project android_frameworks_base by DirtyUnicorns.

the class DiskStatsLoggingService method onStartJob.

@Override
public boolean onStartJob(JobParameters params) {
    // subsequent runs.
    if (!isCharging(this) || !isDumpsysTaskEnabled(getContentResolver())) {
        jobFinished(params, true);
        return false;
    }
    VolumeInfo volume = getPackageManager().getPrimaryStorageCurrentVolume();
    // volume is null if the primary storage is not yet mounted.
    if (volume == null) {
        return false;
    }
    AppCollector collector = new AppCollector(this, volume);
    final int userId = UserHandle.myUserId();
    UserEnvironment environment = new UserEnvironment(userId);
    LogRunnable task = new LogRunnable();
    task.setRootDirectory(environment.getExternalStorageDirectory());
    task.setDownloadsDirectory(environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
    task.setSystemSize(FileCollector.getSystemSize(this));
    task.setLogOutputFile(new File(DUMPSYS_CACHE_PATH));
    task.setAppCollector(collector);
    task.setJobService(this, params);
    AsyncTask.execute(task);
    return true;
}
Also used : VolumeInfo(android.os.storage.VolumeInfo) UserEnvironment(android.os.Environment.UserEnvironment) File(java.io.File)

Example 89 with VolumeInfo

use of android.os.storage.VolumeInfo in project android_frameworks_base by DirtyUnicorns.

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 90 with VolumeInfo

use of android.os.storage.VolumeInfo in project android_frameworks_base by DirtyUnicorns.

the class ApplicationPackageManager method getPackageCandidateVolumes.

@Override
@NonNull
public List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app) {
    final StorageManager storage = mContext.getSystemService(StorageManager.class);
    final VolumeInfo currentVol = getPackageCurrentVolume(app);
    final List<VolumeInfo> vols = storage.getVolumes();
    final List<VolumeInfo> candidates = new ArrayList<>();
    for (VolumeInfo vol : vols) {
        if (Objects.equals(vol, currentVol) || isPackageCandidateVolume(mContext, app, 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)

Aggregations

VolumeInfo (android.os.storage.VolumeInfo)145 StorageManager (android.os.storage.StorageManager)43 File (java.io.File)31 ArrayList (java.util.ArrayList)26 Intent (android.content.Intent)21 CountDownLatch (java.util.concurrent.CountDownLatch)18 DiskInfo (android.os.storage.DiskInfo)16 VolumeRecord (android.os.storage.VolumeRecord)16 Test (org.junit.Test)12 NonNull (android.annotation.NonNull)10 Notification (android.app.Notification)10 PendingIntent (android.app.PendingIntent)10 StorageVolume (android.os.storage.StorageVolume)10 IOException (java.io.IOException)10 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)10 Bundle (android.os.Bundle)9 ApplicationInfo (android.content.pm.ApplicationInfo)8 PackageStats (android.content.pm.PackageStats)8 FragmentManager (android.app.FragmentManager)5 FragmentTransaction (android.app.FragmentTransaction)5