diff --git a/src/com/android/settings/deviceinfo/hardwareinfo/TotalRAMPreferenceController.java b/src/com/android/settings/deviceinfo/hardwareinfo/TotalRAMPreferenceController.java index f06fef5bd50..e1c55ff7e90 100644 --- a/src/com/android/settings/deviceinfo/hardwareinfo/TotalRAMPreferenceController.java +++ b/src/com/android/settings/deviceinfo/hardwareinfo/TotalRAMPreferenceController.java @@ -49,31 +49,16 @@ public class TotalRAMPreferenceController extends BasePreferenceController { @Override public CharSequence getSummary() { - ActivityManager actManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); - ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo(); - actManager.getMemoryInfo(memInfo); + ActivityManager actManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); + ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo(); + actManager.getMemoryInfo(memInfo); - long totRam = memInfo.totalMem; - double gb = (double) totRam / 1073741824.0; - - String aproxRam; - if (gb > 0 && gb <= 2) { - aproxRam = "2"; - } else if (gb <= 3) { - aproxRam = "3"; - } else if (gb <= 4) { - aproxRam = "4"; - } else if (gb <= 6) { - aproxRam = "6"; - } else if (gb <= 8) { - aproxRam = "8"; - } else if (gb <= 12) { - aproxRam = "12"; - } else { - aproxRam = "12+"; + long totRam = memInfo.totalMem; + double gb = (double) totRam / 1000000000.0; + + DecimalFormat df = new DecimalFormat("#"); + String formattedRam = df.format(gb); + + return formattedRam + " GB"; } - - String actualRam = aproxRam.concat(" GB"); - return actualRam; - } }