Loading src/com/android/settings/Utils.java +12 −1 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ 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; Loading Loading @@ -97,7 +98,6 @@ import android.widget.TabWidget; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.annotation.VisibleForTesting; import androidx.core.graphics.drawable.IconCompat; import androidx.core.graphics.drawable.RoundedBitmapDrawable; Loading Loading @@ -1295,4 +1295,15 @@ public final class Utils extends com.android.settingslib.Utils { com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser); 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(); } } src/com/android/settings/deviceinfo/StorageCategoryFragment.java +3 −1 Original line number Diff line number Diff line Loading @@ -211,7 +211,9 @@ public class StorageCategoryFragment extends DashboardFragment setLoading(false /* loading */, false /* animate */); final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes; // TODO(b/288103116): replace with new API to get TotalBytes before rounding // once support by StorageManager. final long privateUsedBytes = Utils.getPrimaryStorageSize() - mStorageInfo.freeBytes; mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo()); mPreferenceController.setUsedSize(privateUsedBytes); mPreferenceController.setTotalSize(mStorageInfo.totalBytes); Loading src/com/android/settings/deviceinfo/StorageDashboardFragment.java +3 −1 Original line number Diff line number Diff line Loading @@ -387,7 +387,9 @@ public class StorageDashboardFragment extends DashboardFragment setLoading(false /* loading */, false /* animate */); final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes; // TODO(b/288103116): replace with new API to get TotalBytes before rounding // once support by StorageManager. final long privateUsedBytes = Utils.getPrimaryStorageSize() - mStorageInfo.freeBytes; mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo()); mPreferenceController.setUsedSize(privateUsedBytes); mPreferenceController.setTotalSize(mStorageInfo.totalBytes); Loading src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java +6 −2 Original line number Diff line number Diff line Loading @@ -74,10 +74,14 @@ public class TopLevelStoragePreferenceController extends BasePreferenceControlle return ThreadUtils.postOnBackgroundThread(() -> { final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo( getStorageManagerVolumeProvider()); storageCacheHelper.cacheUsedSize(info.totalBytes - info.freeBytes); // TODO(b/288103116): replace with new API to get TotalBytes before rounding // once support by StorageManager. long usedBytes = Utils.getPrimaryStorageSize() - info.freeBytes; storageCacheHelper.cacheUsedSize(usedBytes); ThreadUtils.postOnMainThread(() -> { preference.setSummary( getSummary(info.totalBytes - info.freeBytes, info.totalBytes)); getSummary(usedBytes, info.totalBytes)); }); }); } Loading src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceController.java +4 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ 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; Loading Loading @@ -92,7 +93,9 @@ public class StorageUsageProgressBarPreferenceController extends BasePreferenceC if (mStorageEntry.isPrivate()) { // StorageStatsManager can only query private storages. mTotalBytes = mStorageStatsManager.getTotalBytes(mStorageEntry.getFsUuid()); mUsedBytes = mTotalBytes // TODO(b/288103116): replace with new API to get TotalBytes before rounding // once support by StorageManager. mUsedBytes = Utils.getPrimaryStorageSize() - mStorageStatsManager.getFreeBytes(mStorageEntry.getFsUuid()); } else { final File rootFile = mStorageEntry.getPath(); Loading Loading
src/com/android/settings/Utils.java +12 −1 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ 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; Loading Loading @@ -97,7 +98,6 @@ import android.widget.TabWidget; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.annotation.VisibleForTesting; import androidx.core.graphics.drawable.IconCompat; import androidx.core.graphics.drawable.RoundedBitmapDrawable; Loading Loading @@ -1295,4 +1295,15 @@ public final class Utils extends com.android.settingslib.Utils { com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser); 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(); } }
src/com/android/settings/deviceinfo/StorageCategoryFragment.java +3 −1 Original line number Diff line number Diff line Loading @@ -211,7 +211,9 @@ public class StorageCategoryFragment extends DashboardFragment setLoading(false /* loading */, false /* animate */); final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes; // TODO(b/288103116): replace with new API to get TotalBytes before rounding // once support by StorageManager. final long privateUsedBytes = Utils.getPrimaryStorageSize() - mStorageInfo.freeBytes; mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo()); mPreferenceController.setUsedSize(privateUsedBytes); mPreferenceController.setTotalSize(mStorageInfo.totalBytes); Loading
src/com/android/settings/deviceinfo/StorageDashboardFragment.java +3 −1 Original line number Diff line number Diff line Loading @@ -387,7 +387,9 @@ public class StorageDashboardFragment extends DashboardFragment setLoading(false /* loading */, false /* animate */); final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes; // TODO(b/288103116): replace with new API to get TotalBytes before rounding // once support by StorageManager. final long privateUsedBytes = Utils.getPrimaryStorageSize() - mStorageInfo.freeBytes; mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo()); mPreferenceController.setUsedSize(privateUsedBytes); mPreferenceController.setTotalSize(mStorageInfo.totalBytes); Loading
src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java +6 −2 Original line number Diff line number Diff line Loading @@ -74,10 +74,14 @@ public class TopLevelStoragePreferenceController extends BasePreferenceControlle return ThreadUtils.postOnBackgroundThread(() -> { final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo( getStorageManagerVolumeProvider()); storageCacheHelper.cacheUsedSize(info.totalBytes - info.freeBytes); // TODO(b/288103116): replace with new API to get TotalBytes before rounding // once support by StorageManager. long usedBytes = Utils.getPrimaryStorageSize() - info.freeBytes; storageCacheHelper.cacheUsedSize(usedBytes); ThreadUtils.postOnMainThread(() -> { preference.setSummary( getSummary(info.totalBytes - info.freeBytes, info.totalBytes)); getSummary(usedBytes, info.totalBytes)); }); }); } Loading
src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceController.java +4 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ 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; Loading Loading @@ -92,7 +93,9 @@ public class StorageUsageProgressBarPreferenceController extends BasePreferenceC if (mStorageEntry.isPrivate()) { // StorageStatsManager can only query private storages. mTotalBytes = mStorageStatsManager.getTotalBytes(mStorageEntry.getFsUuid()); mUsedBytes = mTotalBytes // TODO(b/288103116): replace with new API to get TotalBytes before rounding // once support by StorageManager. mUsedBytes = Utils.getPrimaryStorageSize() - mStorageStatsManager.getFreeBytes(mStorageEntry.getFsUuid()); } else { final File rootFile = mStorageEntry.getPath(); Loading