Unify storage calculations.

Due to one calculation using longs and the other using doubles, there
were situations where the percentage was off-by-one between the two
places.

By changing both places to now use doubles to calculate percentages, the
numbers should be unified.

Change-Id: I4f4ed19326562e198273adc60a1593c7d1a6b6a7
Fixes: 37923610
Test: Manual
This commit is contained in:
Daniel Nishi
2017-06-26 13:42:36 -07:00
parent c619ad77bb
commit 5d272ce4ff
2 changed files with 6 additions and 6 deletions

View File

@@ -39,6 +39,7 @@ import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.DonutView;
import java.text.NumberFormat;
import java.util.Locale;
/**
@@ -46,7 +47,7 @@ import java.util.Locale;
* on a given storage volume. It is visualized with a donut graphing the % used.
*/
public class StorageSummaryDonutPreference extends Preference implements View.OnClickListener {
private int mPercent = -1;
private double mPercent = -1;
public StorageSummaryDonutPreference(Context context) {
this(context, null);
@@ -64,8 +65,7 @@ public class StorageSummaryDonutPreference extends Preference implements View.On
return;
}
mPercent = MathUtils.constrain((int) ((usedBytes * 100) / totalBytes),
(usedBytes > 0) ? 1 : 0, 100);
mPercent = usedBytes / (double) totalBytes;
}
@Override