Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7888dfd5 authored by Aleksandr Lukin's avatar Aleksandr Lukin Committed by Automerger Merge Worker
Browse files

Merge "Update the API usage to get total size of devices" into udc-d1-dev am: d1373d4a

parents 7ca1b2fe d1373d4a
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ import android.os.BatteryManager;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.os.INetworkManagementService;
import android.os.RemoteException;
@@ -1296,14 +1295,4 @@ public final class Utils extends com.android.settingslib.Utils {
        return dreamsSupported && (!dreamsOnlyEnabledForDockUser || canCurrentUserDream(context));
    }

    /**
     * Get private total size directly.
     * Referred from StorageManager
     */
    public static long getPrimaryStorageSize() {
        // TODO(b/288103116): remove this method once support by StorageManager.
        return Environment.getDataDirectory().getTotalSpace()
                + Environment.getRootDirectory().getTotalSpace();
    }

}
+1 −3
Original line number Diff line number Diff line
@@ -211,9 +211,7 @@ public class StorageCategoryFragment extends DashboardFragment

        setLoading(false /* loading */, false /* animate */);

        // TODO(b/288103116): replace with  new API to get TotalBytes before rounding
        //  once support by StorageManager.
        final long privateUsedBytes = Utils.getPrimaryStorageSize() - mStorageInfo.freeBytes;
        final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
        mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
        mPreferenceController.setUsedSize(privateUsedBytes);
        mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
+1 −3
Original line number Diff line number Diff line
@@ -387,9 +387,7 @@ public class StorageDashboardFragment extends DashboardFragment

        setLoading(false /* loading */, false /* animate */);

        // TODO(b/288103116): replace with  new API to get TotalBytes before rounding
        //  once support by StorageManager.
        final long privateUsedBytes = Utils.getPrimaryStorageSize() - mStorageInfo.freeBytes;
        final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
        mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
        mPreferenceController.setUsedSize(privateUsedBytes);
        mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
+1 −3
Original line number Diff line number Diff line
@@ -75,9 +75,7 @@ public class TopLevelStoragePreferenceController extends BasePreferenceControlle
            final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(
                    getStorageManagerVolumeProvider());

            // TODO(b/288103116): replace with  new API to get TotalBytes before rounding
            //  once support by StorageManager.
            long usedBytes = Utils.getPrimaryStorageSize() - info.freeBytes;
            long usedBytes = info.totalBytes - info.freeBytes;
            storageCacheHelper.cacheUsedSize(usedBytes);
            ThreadUtils.postOnMainThread(() -> {
                preference.setSummary(
+1 −4
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.utils.ThreadUtils;
import com.android.settingslib.widget.UsageProgressBarPreference;
@@ -93,9 +92,7 @@ public class StorageUsageProgressBarPreferenceController extends BasePreferenceC
                if (mStorageEntry.isPrivate()) {
                    // StorageStatsManager can only query private storages.
                    mTotalBytes = mStorageStatsManager.getTotalBytes(mStorageEntry.getFsUuid());
                    // TODO(b/288103116): replace with  new API to get TotalBytes before rounding
                    //  once support by StorageManager.
                    mUsedBytes = Utils.getPrimaryStorageSize()
                    mUsedBytes = mTotalBytes
                            - mStorageStatsManager.getFreeBytes(mStorageEntry.getFsUuid());
                } else {
                    final File rootFile = mStorageEntry.getPath();