Search in sources :

Example 6 with VolumeRecord

use of android.os.storage.VolumeRecord in project android_frameworks_base by ResurrectionRemix.

the class MountService method forgetAllVolumes.

@Override
public void forgetAllVolumes() {
    enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
    waitForReady();
    synchronized (mLock) {
        for (int i = 0; i < mRecords.size(); i++) {
            final String fsUuid = mRecords.keyAt(i);
            final VolumeRecord rec = mRecords.valueAt(i);
            if (!TextUtils.isEmpty(rec.partGuid)) {
                mHandler.obtainMessage(H_PARTITION_FORGET, rec.partGuid).sendToTarget();
            }
            mCallbacks.notifyVolumeForgotten(fsUuid);
        }
        mRecords.clear();
        if (!Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL, mPrimaryStorageUuid)) {
            mPrimaryStorageUuid = getDefaultPrimaryStorageUuid();
        }
        writeSettingsLocked();
        mHandler.obtainMessage(H_RESET).sendToTarget();
    }
}
Also used : VolumeRecord(android.os.storage.VolumeRecord)

Example 7 with VolumeRecord

use of android.os.storage.VolumeRecord in project android_frameworks_base by ResurrectionRemix.

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);
        final Pair<String, Long> pair = StorageManager.getPrimaryStoragePathAndSize();
        if (pair == null) {
            pw.println("Internal storage total size: N/A");
        } else {
            pw.print("Internal storage (");
            pw.print(pair.first);
            pw.print(") total size: ");
            pw.print(pair.second);
            pw.print(" (");
            pw.print((float) pair.second / TrafficStats.GB_IN_BYTES);
            pw.println(" GB)");
        }
        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 8 with VolumeRecord

use of android.os.storage.VolumeRecord in project android_frameworks_base by ResurrectionRemix.

the class MountService method readSettingsLocked.

private void readSettingsLocked() {
    mRecords.clear();
    mPrimaryStorageUuid = getDefaultPrimaryStorageUuid();
    mForceAdoptable = false;
    FileInputStream fis = null;
    try {
        fis = mSettingsFile.openRead();
        final XmlPullParser in = Xml.newPullParser();
        in.setInput(fis, StandardCharsets.UTF_8.name());
        int type;
        while ((type = in.next()) != END_DOCUMENT) {
            if (type == START_TAG) {
                final String tag = in.getName();
                if (TAG_VOLUMES.equals(tag)) {
                    final int version = readIntAttribute(in, ATTR_VERSION, VERSION_INIT);
                    final boolean primaryPhysical = SystemProperties.getBoolean(StorageManager.PROP_PRIMARY_PHYSICAL, false);
                    final boolean validAttr = (version >= VERSION_FIX_PRIMARY) || (version >= VERSION_ADD_PRIMARY && !primaryPhysical);
                    if (validAttr) {
                        mPrimaryStorageUuid = readStringAttribute(in, ATTR_PRIMARY_STORAGE_UUID);
                    }
                    mForceAdoptable = readBooleanAttribute(in, ATTR_FORCE_ADOPTABLE, false);
                } else if (TAG_VOLUME.equals(tag)) {
                    final VolumeRecord rec = readVolumeRecord(in);
                    mRecords.put(rec.fsUuid, rec);
                }
            }
        }
    } catch (FileNotFoundException e) {
    // Missing metadata is okay, probably first boot
    } catch (IOException e) {
        Slog.wtf(TAG, "Failed reading metadata", e);
    } catch (XmlPullParserException e) {
        Slog.wtf(TAG, "Failed reading metadata", e);
    } finally {
        IoUtils.closeQuietly(fis);
    }
}
Also used : VolumeRecord(android.os.storage.VolumeRecord) XmlPullParser(org.xmlpull.v1.XmlPullParser) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Example 9 with VolumeRecord

use of android.os.storage.VolumeRecord in project android_frameworks_base by ResurrectionRemix.

the class MountService method shouldBenchmark.

private boolean shouldBenchmark() {
    final long benchInterval = Settings.Global.getLong(mContext.getContentResolver(), Settings.Global.STORAGE_BENCHMARK_INTERVAL, -1);
    if (benchInterval == -1) {
        return false;
    } else if (benchInterval == 0) {
        return true;
    }
    synchronized (mLock) {
        for (int i = 0; i < mVolumes.size(); i++) {
            final VolumeInfo vol = mVolumes.valueAt(i);
            final VolumeRecord rec = mRecords.get(vol.fsUuid);
            if (vol.isMountedWritable() && rec != null) {
                final long benchAge = System.currentTimeMillis() - rec.lastBenchMillis;
                if (benchAge >= benchInterval) {
                    return true;
                }
            }
        }
        return false;
    }
}
Also used : VolumeRecord(android.os.storage.VolumeRecord) VolumeInfo(android.os.storage.VolumeInfo)

Example 10 with VolumeRecord

use of android.os.storage.VolumeRecord in project android_frameworks_base by ResurrectionRemix.

the class MountService method setVolumeNickname.

@Override
public void setVolumeNickname(String fsUuid, String nickname) {
    enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
    waitForReady();
    Preconditions.checkNotNull(fsUuid);
    synchronized (mLock) {
        final VolumeRecord rec = mRecords.get(fsUuid);
        if (rec == null)
            return;
        rec.nickname = nickname;
        mCallbacks.notifyVolumeRecordChanged(rec);
        writeSettingsLocked();
    }
}
Also used : VolumeRecord(android.os.storage.VolumeRecord)

Aggregations

VolumeRecord (android.os.storage.VolumeRecord)61 VolumeInfo (android.os.storage.VolumeInfo)16 DiskInfo (android.os.storage.DiskInfo)11 Notification (android.app.Notification)10 IOException (java.io.IOException)10 Intent (android.content.Intent)6 Action (android.app.Notification.Action)5 PendingIntent (android.app.PendingIntent)5 IBinder (android.os.IBinder)5 RemoteCallbackList (android.os.RemoteCallbackList)5 StorageVolume (android.os.storage.StorageVolume)5 FastXmlSerializer (com.android.internal.util.FastXmlSerializer)5 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)5 FileInputStream (java.io.FileInputStream)5 FileNotFoundException (java.io.FileNotFoundException)5 FileOutputStream (java.io.FileOutputStream)5 ArrayList (java.util.ArrayList)5 LinkedList (java.util.LinkedList)5 List (java.util.List)5 Entry (java.util.Map.Entry)5