Search in sources :

Example 76 with VolumeInfo

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

the class PackageManagerService method prepareUserData.

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

Example 77 with VolumeInfo

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

the class StorageNotification method buildWizardMigratePendingIntent.

private PendingIntent buildWizardMigratePendingIntent(MoveInfo move) {
    final Intent intent = new Intent();
    intent.setClassName("com.android.settings", "com.android.settings.deviceinfo.StorageWizardMigrateProgress");
    intent.putExtra(PackageManager.EXTRA_MOVE_ID, move.moveId);
    final VolumeInfo vol = mStorageManager.findVolumeByQualifiedUuid(move.volumeUuid);
    if (vol != null) {
        intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, vol.getId());
    }
    return PendingIntent.getActivityAsUser(mContext, move.moveId, intent, PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) VolumeInfo(android.os.storage.VolumeInfo)

Example 78 with VolumeInfo

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

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, SystemMessage.NOTE_STORAGE_MOVE, 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, SystemMessage.NOTE_STORAGE_MOVE, builder.build(), UserHandle.ALL);
}
Also used : VolumeInfo(android.os.storage.VolumeInfo) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 79 with VolumeInfo

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

the class MountService method onVolumeCreatedLocked.

private void onVolumeCreatedLocked(VolumeInfo vol) {
    if (mPms.isOnlyCoreApps()) {
        Slog.d(TAG, "System booted in core-only mode; ignoring volume " + vol.getId());
        return;
    }
    if (vol.type == VolumeInfo.TYPE_EMULATED) {
        final StorageManager storage = mContext.getSystemService(StorageManager.class);
        final VolumeInfo privateVol = storage.findPrivateForEmulated(vol);
        if (Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL, mPrimaryStorageUuid) && VolumeInfo.ID_PRIVATE_INTERNAL.equals(privateVol.id)) {
            Slog.v(TAG, "Found primary storage at " + vol);
            vol.mountFlags |= VolumeInfo.MOUNT_FLAG_PRIMARY;
            vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
            mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget();
        } else if (Objects.equals(privateVol.fsUuid, mPrimaryStorageUuid)) {
            Slog.v(TAG, "Found primary storage at " + vol);
            vol.mountFlags |= VolumeInfo.MOUNT_FLAG_PRIMARY;
            vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
            mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget();
        }
    } else if (vol.type == VolumeInfo.TYPE_PUBLIC) {
        // TODO: only look at first public partition
        if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, mPrimaryStorageUuid) && vol.disk.isDefaultPrimary()) {
            Slog.v(TAG, "Found primary storage at " + vol);
            vol.mountFlags |= VolumeInfo.MOUNT_FLAG_PRIMARY;
            vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
        }
        // public API requirement of being in a stable location.
        if (vol.disk.isAdoptable()) {
            vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
        }
        vol.mountUserId = mCurrentUserId;
        mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget();
    } else if (vol.type == VolumeInfo.TYPE_PRIVATE) {
        mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget();
    } else {
        Slog.d(TAG, "Skipping automatic mounting of " + vol);
    }
}
Also used : StorageManager(android.os.storage.StorageManager) VolumeInfo(android.os.storage.VolumeInfo)

Example 80 with VolumeInfo

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

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)

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