Launcher3: MemInfoView: Fix free memory calculation

* The current implementation of free memory calculation utilizes activity manager methods.
  However, due to the limited capabilities of the activity manager, this results in
  a very low or inaccurate report of free memory. A significant difference is observed
  when comparing it to the free RAM reported by the settings application running
  activity. This change aims to rectify these inconsistencies by employing the same
  calculation method used in the settings application for reporting free memory.

  Additionally, this change incorporates UI performance enhancements by leveraging ThreadUtils from SettingsLib.

visual Test: Compare the reported free memory to the free memory reported in the settings application's running activities. Memory usage was almost similar.
perf Test: Observe any lag or hiccups when performing gestures to access the recents overview.

references:
memory calculation: https://github.com/RisingOS-staging/android_packages_apps_Settings/blob/fourteen/src/com/android/settings/applications/RunningProcessesView.java#L364
ui perf opt: https://github.com/RisingOS-staging/android_packages_apps_Settings/blob/fourteen/src/com/android/settings/development/MemoryUsagePreferenceController.java#L58

Squashed:

    From: minaripenguin <minaripenguin@users.noreply.github.com>
    Date: Fri, 15 Nov 2024 18:03:21 +0800
    Subject: MeminfoView: Prevent memory leaks

    * reduces launcher memory usage from 300mb down to 200mb

    Signed-off-by: minaripenguin <minaripenguin@users.noreply.github.com>
    Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>

Signed-off-by: minaripenguin <minaripenguin@users.noreply.github.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: Jackeagle <jackeagle102@gmail.com>
1 file changed