Search in sources :

Example 6 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class StorageSlice method getPrivateStorageInfo.

@VisibleForTesting
PrivateStorageInfo getPrivateStorageInfo() {
    final StorageManager storageManager = mContext.getSystemService(StorageManager.class);
    final StorageManagerVolumeProvider smvp = new StorageManagerVolumeProvider(storageManager);
    return PrivateStorageInfo.getPrivateStorageInfo(smvp);
}
Also used : StorageManager(android.os.storage.StorageManager) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 7 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class StorageDashboardFragment method createPreferenceControllers.

@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    mSummaryController = new StorageSummaryDonutPreferenceController(context);
    controllers.add(mSummaryController);
    StorageManager sm = context.getSystemService(StorageManager.class);
    mPreferenceController = new StorageItemPreferenceController(context, this, mVolume, new StorageManagerVolumeProvider(sm));
    controllers.add(mPreferenceController);
    final UserManager userManager = context.getSystemService(UserManager.class);
    mSecondaryUsers = SecondaryUserController.getSecondaryUserControllers(context, userManager);
    controllers.addAll(mSecondaryUsers);
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) StorageItemPreferenceController(com.android.settings.deviceinfo.storage.StorageItemPreferenceController) UserManager(android.os.UserManager) ArrayList(java.util.ArrayList) StorageManager(android.os.storage.StorageManager) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider) StorageSummaryDonutPreferenceController(com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController)

Example 8 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class StorageProfileFragment method createPreferenceControllers.

@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final StorageManager sm = context.getSystemService(StorageManager.class);
    mPreferenceController = new StorageItemPreferenceController(context, this, mVolume, new StorageManagerVolumeProvider(sm), /* isWorkProfile */
    true);
    controllers.add(mPreferenceController);
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) StorageItemPreferenceController(com.android.settings.deviceinfo.storage.StorageItemPreferenceController) ArrayList(java.util.ArrayList) StorageManager(android.os.storage.StorageManager) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)

Example 9 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class StorageSettings method refresh.

private synchronized void refresh() {
    final Context context = getPrefContext();
    getPreferenceScreen().removeAll();
    mInternalCategory.removeAll();
    mExternalCategory.removeAll();
    mInternalCategory.addPreference(mInternalSummary);
    final StorageManagerVolumeProvider smvp = new StorageManagerVolumeProvider(mStorageManager);
    final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(smvp);
    final long privateTotalBytes = info.totalBytes;
    final long privateUsedBytes = info.totalBytes - info.freeBytes;
    final List<VolumeInfo> volumes = mStorageManager.getVolumes();
    Collections.sort(volumes, VolumeInfo.getDescriptionComparator());
    for (VolumeInfo vol : volumes) {
        if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
            if (vol.getState() == VolumeInfo.STATE_UNMOUNTABLE) {
                mInternalCategory.addPreference(new StorageVolumePreference(context, vol, 0));
            } else {
                final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol, sTotalInternalStorage);
                mInternalCategory.addPreference(new StorageVolumePreference(context, vol, volumeTotalBytes));
            }
        } else if (vol.getType() == VolumeInfo.TYPE_PUBLIC || vol.getType() == VolumeInfo.TYPE_STUB) {
            mExternalCategory.addPreference(new StorageVolumePreference(context, vol, 0));
        }
    }
    // Show missing private volumes
    final List<VolumeRecord> recs = mStorageManager.getVolumeRecords();
    for (VolumeRecord rec : recs) {
        if (rec.getType() == VolumeInfo.TYPE_PRIVATE && mStorageManager.findVolumeByUuid(rec.getFsUuid()) == null) {
            // TODO: add actual storage type to record
            final Preference pref = new Preference(context);
            pref.setKey(rec.getFsUuid());
            pref.setTitle(rec.getNickname());
            pref.setSummary(com.android.internal.R.string.ext_media_status_missing);
            pref.setIcon(R.drawable.ic_sim_sd);
            mInternalCategory.addPreference(pref);
        }
    }
    // Show unsupported disks to give a chance to init
    final List<DiskInfo> disks = mStorageManager.getDisks();
    for (DiskInfo disk : disks) {
        if (disk.volumeCount == 0 && disk.size > 0) {
            final Preference pref = new Preference(context);
            pref.setKey(disk.getId());
            pref.setTitle(disk.getDescription());
            pref.setSummary(com.android.internal.R.string.ext_media_status_unsupported);
            pref.setIcon(R.drawable.ic_sim_sd);
            mExternalCategory.addPreference(pref);
        }
    }
    final BytesResult result = Formatter.formatBytes(getResources(), privateUsedBytes, 0);
    mInternalSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large), result.value, result.units));
    mInternalSummary.setSummary(getString(R.string.storage_volume_used_total, Formatter.formatFileSize(context, privateTotalBytes)));
    if (mInternalCategory.getPreferenceCount() > 0) {
        getPreferenceScreen().addPreference(mInternalCategory);
    }
    if (mExternalCategory.getPreferenceCount() > 0) {
        getPreferenceScreen().addPreference(mExternalCategory);
    }
    if (mInternalCategory.getPreferenceCount() == 2 && mExternalCategory.getPreferenceCount() == 0) {
        // Only showing primary internal storage, so just shortcut
        if (!mHasLaunchedPrivateVolumeSettings) {
            mHasLaunchedPrivateVolumeSettings = true;
            final Bundle args = new Bundle();
            args.putString(VolumeInfo.EXTRA_VOLUME_ID, VolumeInfo.ID_PRIVATE_INTERNAL);
            new SubSettingLauncher(getActivity()).setDestination(StorageDashboardFragment.class.getName()).setArguments(args).setTitleRes(R.string.storage_settings).setSourceMetricsCategory(getMetricsCategory()).launch();
            finish();
        }
    }
}
Also used : Context(android.content.Context) PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) Bundle(android.os.Bundle) DiskInfo(android.os.storage.DiskInfo) VolumeInfo(android.os.storage.VolumeInfo) BytesResult(android.text.format.Formatter.BytesResult) VolumeRecord(android.os.storage.VolumeRecord) Preference(androidx.preference.Preference) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)

Example 10 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project android_packages_apps_Settings by omnirom.

the class StorageCategoryFragment method createPreferenceControllers.

@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final StorageManager sm = context.getSystemService(StorageManager.class);
    mPreferenceController = new StorageItemPreferenceController(context, this, null, /* volume */
    new StorageManagerVolumeProvider(sm), mIsWorkProfile);
    controllers.add(mPreferenceController);
    mSecondaryUsers = SecondaryUserController.getSecondaryUserControllers(context, mUserManager, mIsWorkProfile);
    controllers.addAll(mSecondaryUsers);
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) StorageItemPreferenceController(com.android.settings.deviceinfo.storage.StorageItemPreferenceController) ArrayList(java.util.ArrayList) StorageManager(android.os.storage.StorageManager) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)

Aggregations

StorageManagerVolumeProvider (com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)20 StorageManager (android.os.storage.StorageManager)17 StorageItemPreferenceController (com.android.settings.deviceinfo.storage.StorageItemPreferenceController)16 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)16 ArrayList (java.util.ArrayList)16 UserManager (android.os.UserManager)7 StorageSummaryDonutPreferenceController (com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController)7 UserManagerWrapper (com.android.settings.applications.UserManagerWrapper)6 UserManagerWrapperImpl (com.android.settings.applications.UserManagerWrapperImpl)6 AutomaticStorageManagementSwitchPreferenceController (com.android.settings.deviceinfo.storage.AutomaticStorageManagementSwitchPreferenceController)6 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)3 IconCompat (androidx.core.graphics.drawable.IconCompat)2 ListBuilder (androidx.slice.builders.ListBuilder)2 Context (android.content.Context)1 Bundle (android.os.Bundle)1 DiskInfo (android.os.storage.DiskInfo)1 VolumeInfo (android.os.storage.VolumeInfo)1 VolumeRecord (android.os.storage.VolumeRecord)1 BytesResult (android.text.format.Formatter.BytesResult)1 Preference (androidx.preference.Preference)1