Search in sources :

Example 16 with VolumeInfo

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

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

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

the class MountService method onUnlockUser.

private void onUnlockUser(int userId) {
    Slog.d(TAG, "onUnlockUser " + userId);
    // bind mount against.
    try {
        mConnector.execute("volume", "user_started", userId);
    } catch (NativeDaemonConnectorException ignored) {
    }
    // correctly, then synthesize events for any already-mounted volumes.
    synchronized (mVolumes) {
        for (int i = 0; i < mVolumes.size(); i++) {
            final VolumeInfo vol = mVolumes.valueAt(i);
            if (vol.isVisibleForRead(userId) && vol.isMountedReadable()) {
                final StorageVolume userVol = vol.buildStorageVolume(mContext, userId, false);
                mHandler.obtainMessage(H_VOLUME_BROADCAST, userVol).sendToTarget();
                final String envState = VolumeInfo.getEnvironmentForState(vol.getState());
                mCallbacks.notifyStorageStateChanged(userVol.getPath(), envState, envState);
            }
        }
        mSystemUnlockedUsers = ArrayUtils.appendInt(mSystemUnlockedUsers, userId);
    }
}
Also used : StorageVolume(android.os.storage.StorageVolume) VolumeInfo(android.os.storage.VolumeInfo)

Example 18 with VolumeInfo

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

the class MountService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ", 160);
    synchronized (mLock) {
        pw.println("Disks:");
        pw.increaseIndent();
        for (int i = 0; i < mDisks.size(); i++) {
            final DiskInfo disk = mDisks.valueAt(i);
            disk.dump(pw);
        }
        pw.decreaseIndent();
        pw.println();
        pw.println("Volumes:");
        pw.increaseIndent();
        for (int i = 0; i < mVolumes.size(); i++) {
            final VolumeInfo vol = mVolumes.valueAt(i);
            if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.id))
                continue;
            vol.dump(pw);
        }
        pw.decreaseIndent();
        pw.println();
        pw.println("Records:");
        pw.increaseIndent();
        for (int i = 0; i < mRecords.size(); i++) {
            final VolumeRecord note = mRecords.valueAt(i);
            note.dump(pw);
        }
        pw.decreaseIndent();
        pw.println();
        pw.println("Primary storage UUID: " + mPrimaryStorageUuid);
        pw.println("Force adoptable: " + mForceAdoptable);
        pw.println();
        pw.println("Local unlocked users: " + Arrays.toString(mLocalUnlockedUsers));
        pw.println("System unlocked users: " + Arrays.toString(mSystemUnlockedUsers));
    }
    synchronized (mObbMounts) {
        pw.println();
        pw.println("mObbMounts:");
        pw.increaseIndent();
        final Iterator<Entry<IBinder, List<ObbState>>> binders = mObbMounts.entrySet().iterator();
        while (binders.hasNext()) {
            Entry<IBinder, List<ObbState>> e = binders.next();
            pw.println(e.getKey() + ":");
            pw.increaseIndent();
            final List<ObbState> obbStates = e.getValue();
            for (final ObbState obbState : obbStates) {
                pw.println(obbState);
            }
            pw.decreaseIndent();
        }
        pw.decreaseIndent();
        pw.println();
        pw.println("mObbPathToStateMap:");
        pw.increaseIndent();
        final Iterator<Entry<String, ObbState>> maps = mObbPathToStateMap.entrySet().iterator();
        while (maps.hasNext()) {
            final Entry<String, ObbState> e = maps.next();
            pw.print(e.getKey());
            pw.print(" -> ");
            pw.println(e.getValue());
        }
        pw.decreaseIndent();
    }
    pw.println();
    pw.println("mConnector:");
    pw.increaseIndent();
    mConnector.dump(fd, pw, args);
    pw.decreaseIndent();
    pw.println();
    pw.println("mCryptConnector:");
    pw.increaseIndent();
    mCryptConnector.dump(fd, pw, args);
    pw.decreaseIndent();
    pw.println();
    pw.print("Last maintenance: ");
    pw.println(TimeUtils.formatForLogging(mLastMaintenance));
}
Also used : DiskInfo(android.os.storage.DiskInfo) VolumeInfo(android.os.storage.VolumeInfo) VolumeRecord(android.os.storage.VolumeRecord) Entry(java.util.Map.Entry) IBinder(android.os.IBinder) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) RemoteCallbackList(android.os.RemoteCallbackList) List(java.util.List) LinkedList(java.util.LinkedList) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 19 with VolumeInfo

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

the class MountService method setPrimaryStorageUuid.

@Override
public void setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback) {
    enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
    waitForReady();
    final VolumeInfo from;
    final VolumeInfo to;
    synchronized (mLock) {
        if (Objects.equals(mPrimaryStorageUuid, volumeUuid)) {
            throw new IllegalArgumentException("Primary storage already at " + volumeUuid);
        }
        if (mMoveCallback != null) {
            throw new IllegalStateException("Move already in progress");
        }
        mMoveCallback = callback;
        mMoveTargetUuid = volumeUuid;
        // the current storage location, so we have nothing to move.
        if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, mPrimaryStorageUuid) || Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, volumeUuid)) {
            Slog.d(TAG, "Skipping move to/from primary physical");
            onMoveStatusLocked(MOVE_STATUS_COPY_FINISHED);
            onMoveStatusLocked(PackageManager.MOVE_SUCCEEDED);
            mHandler.obtainMessage(H_RESET).sendToTarget();
            return;
        } else {
            from = findStorageForUuid(mPrimaryStorageUuid);
            to = findStorageForUuid(volumeUuid);
            if (from == null) {
                Slog.w(TAG, "Failing move due to missing from volume " + mPrimaryStorageUuid);
                onMoveStatusLocked(PackageManager.MOVE_FAILED_INTERNAL_ERROR);
                return;
            } else if (to == null) {
                Slog.w(TAG, "Failing move due to missing to volume " + volumeUuid);
                onMoveStatusLocked(PackageManager.MOVE_FAILED_INTERNAL_ERROR);
                return;
            }
        }
    }
    try {
        mConnector.execute("volume", "move_storage", from.id, to.id);
    } catch (NativeDaemonConnectorException e) {
        throw e.rethrowAsParcelableException();
    }
}
Also used : VolumeInfo(android.os.storage.VolumeInfo)

Example 20 with VolumeInfo

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

the class MountService method addInternalVolumeLocked.

private void addInternalVolumeLocked() {
    // Create a stub volume that represents internal storage
    final VolumeInfo internal = new VolumeInfo(VolumeInfo.ID_PRIVATE_INTERNAL, VolumeInfo.TYPE_PRIVATE, null, null);
    internal.state = VolumeInfo.STATE_MOUNTED;
    internal.path = Environment.getDataDirectory().getAbsolutePath();
    mVolumes.put(internal.id, internal);
}
Also used : 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