Search in sources :

Example 31 with VolumeInfo

use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.

the class MountService method mount.

@Override
public void mount(String volId) {
    enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
    waitForReady();
    final VolumeInfo vol = findVolumeByIdOrThrow(volId);
    if (isMountDisallowed(vol)) {
        throw new SecurityException("Mounting " + volId + " restricted by policy");
    }
    try {
        mConnector.execute("volume", "mount", vol.id, vol.mountFlags, vol.mountUserId);
    } catch (NativeDaemonConnectorException e) {
        throw e.rethrowAsParcelableException();
    }
}
Also used : VolumeInfo(android.os.storage.VolumeInfo)

Example 32 with VolumeInfo

use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.

the class StorageNotification method updateMissingPrivateVolumes.

private void updateMissingPrivateVolumes() {
    final List<VolumeRecord> recs = mStorageManager.getVolumeRecords();
    for (VolumeRecord rec : recs) {
        if (rec.getType() != VolumeInfo.TYPE_PRIVATE)
            continue;
        final String fsUuid = rec.getFsUuid();
        final VolumeInfo info = mStorageManager.findVolumeByUuid(fsUuid);
        if ((info != null && info.isMountedWritable()) || rec.isSnoozed()) {
            // Yay, private volume is here, or user snoozed
            mNotificationManager.cancelAsUser(fsUuid, PRIVATE_ID, UserHandle.ALL);
        } else {
            // Boo, annoy the user to reinsert the private volume
            final CharSequence title = mContext.getString(R.string.ext_media_missing_title, rec.getNickname());
            final CharSequence text = mContext.getString(R.string.ext_media_missing_message);
            Notification.Builder builder = new Notification.Builder(mContext).setSmallIcon(R.drawable.ic_sd_card_48dp).setColor(mContext.getColor(R.color.system_notification_accent_color)).setContentTitle(title).setContentText(text).setContentIntent(buildForgetPendingIntent(rec)).setStyle(new Notification.BigTextStyle().bigText(text)).setVisibility(Notification.VISIBILITY_PUBLIC).setLocalOnly(true).setCategory(Notification.CATEGORY_SYSTEM).setDeleteIntent(buildSnoozeIntent(fsUuid));
            SystemUI.overrideNotificationAppName(mContext, builder);
            mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, builder.build(), UserHandle.ALL);
        }
    }
}
Also used : VolumeRecord(android.os.storage.VolumeRecord) VolumeInfo(android.os.storage.VolumeInfo) Notification(android.app.Notification)

Example 33 with VolumeInfo

use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.

the class StorageNotification method onMoveFinished.

private void onMoveFinished(MoveInfo move, int status) {
    if (move.packageName != null) {
        // We currently ignore finished app moves; just clear the last
        // published progress
        mNotificationManager.cancelAsUser(move.packageName, MOVE_ID, UserHandle.ALL);
        return;
    }
    final VolumeInfo privateVol = mContext.getPackageManager().getPrimaryStorageCurrentVolume();
    final String descrip = mStorageManager.getBestVolumeDescription(privateVol);
    final CharSequence title;
    final CharSequence text;
    if (status == PackageManager.MOVE_SUCCEEDED) {
        title = mContext.getString(R.string.ext_media_move_success_title);
        text = mContext.getString(R.string.ext_media_move_success_message, descrip);
    } else {
        title = mContext.getString(R.string.ext_media_move_failure_title);
        text = mContext.getString(R.string.ext_media_move_failure_message);
    }
    // Jump back into the wizard flow if we moved to a real disk
    final PendingIntent intent;
    if (privateVol != null && privateVol.getDisk() != null) {
        intent = buildWizardReadyPendingIntent(privateVol.getDisk());
    } else if (privateVol != null) {
        intent = buildVolumeSettingsPendingIntent(privateVol);
    } else {
        intent = null;
    }
    Notification.Builder builder = new Notification.Builder(mContext).setSmallIcon(R.drawable.ic_sd_card_48dp).setColor(mContext.getColor(R.color.system_notification_accent_color)).setContentTitle(title).setContentText(text).setContentIntent(intent).setStyle(new Notification.BigTextStyle().bigText(text)).setVisibility(Notification.VISIBILITY_PUBLIC).setLocalOnly(true).setCategory(Notification.CATEGORY_SYSTEM).setPriority(Notification.PRIORITY_LOW).setAutoCancel(true);
    SystemUI.overrideNotificationAppName(mContext, builder);
    mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, builder.build(), UserHandle.ALL);
}
Also used : VolumeInfo(android.os.storage.VolumeInfo) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 34 with VolumeInfo

use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.

the class StorageNotification method start.

@Override
public void start() {
    mNotificationManager = mContext.getSystemService(NotificationManager.class);
    mStorageManager = mContext.getSystemService(StorageManager.class);
    mStorageManager.registerListener(mListener);
    mContext.registerReceiver(mSnoozeReceiver, new IntentFilter(ACTION_SNOOZE_VOLUME), android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, null);
    mContext.registerReceiver(mFinishReceiver, new IntentFilter(ACTION_FINISH_WIZARD), android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, null);
    // Kick current state into place
    final List<DiskInfo> disks = mStorageManager.getDisks();
    for (DiskInfo disk : disks) {
        onDiskScannedInternal(disk, disk.volumeCount);
    }
    final List<VolumeInfo> vols = mStorageManager.getVolumes();
    for (VolumeInfo vol : vols) {
        onVolumeStateChangedInternal(vol);
    }
    mContext.getPackageManager().registerMoveCallback(mMoveCallback, new Handler());
    updateMissingPrivateVolumes();
}
Also used : IntentFilter(android.content.IntentFilter) NotificationManager(android.app.NotificationManager) StorageManager(android.os.storage.StorageManager) DiskInfo(android.os.storage.DiskInfo) Handler(android.os.Handler) VolumeInfo(android.os.storage.VolumeInfo)

Example 35 with VolumeInfo

use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.

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)

Aggregations

VolumeInfo (android.os.storage.VolumeInfo)290 StorageManager (android.os.storage.StorageManager)81 File (java.io.File)49 Test (org.junit.Test)42 Intent (android.content.Intent)39 DiskInfo (android.os.storage.DiskInfo)29 Bundle (android.os.Bundle)28 ArrayList (java.util.ArrayList)26 VolumeRecord (android.os.storage.VolumeRecord)22 Context (android.content.Context)21 Before (org.junit.Before)21 UserHandle (android.os.UserHandle)19 LayoutInflater (android.view.LayoutInflater)19 CountDownLatch (java.util.concurrent.CountDownLatch)18 IOException (java.io.IOException)17 StorageStatsManager (android.app.usage.StorageStatsManager)14 MenuItem (android.view.MenuItem)14 StorageVolumeProvider (com.android.settingslib.deviceinfo.StorageVolumeProvider)14 NonNull (android.annotation.NonNull)10 Notification (android.app.Notification)10