From d42fe85bc93e4a27517555f27a8e7a591a135e19 Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Fri, 12 Aug 2016 13:51:51 -0700 Subject: [PATCH] Fix incorrect notification about running out of storage space. Previously, if there were problems generating the boot image, we would display a notification saying the device is out of storage space, regardless of whether the device was actually out of storage. This change makes it so we only display the notification if the device has less than 250MB when the boot image is missing. Test: Verify the following sequence does not display the notification: $ adb shell stop $ adb shell rm /data/dalvik-cache/arm/*.oat $ adb shell setprop dalvik.vm.extra-opts -Xnoimage-dex2oat $ adb shell start Test: Verify the following sequence does display the notification: $ adb shell stop $ adb shell rm /data/dalvik-cache/arm/*.oat $ adb shell setprop dalvik.vm.extra-opts -Xnoimage-dex2oat $ adb shell setprop debug.freemem 104857600 $ adb shell start Bug: 28931369 Change-Id: Ia2291bf674af063a55f339d2a0411e670ca16ba2 --- .../server/storage/DeviceStorageMonitorService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java b/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java index 0ae171768199e..90c711a479414 100644 --- a/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java +++ b/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java @@ -87,6 +87,11 @@ public class DeviceStorageMonitorService extends SystemService { private static final long DEFAULT_DISK_FREE_CHANGE_REPORTING_THRESHOLD = 2 * 1024 * 1024; // 2MB private static final long DEFAULT_CHECK_INTERVAL = MONITOR_INTERVAL*60*1000; + // com.android.internal.R.string.low_internal_storage_view_text_no_boot + // hard codes 250MB in the message as the storage space required for the + // boot image. + private static final long BOOT_IMAGE_STORAGE_REQUIREMENT = 250 * 1024 * 1024; + private long mFreeMem; // on /data private long mFreeMemAfterLastCacheClear; // on /data private long mLastReportedFreeMem; @@ -290,9 +295,10 @@ public class DeviceStorageMonitorService extends SystemService { mLowMemFlag = false; } } - if (!mLowMemFlag && !mIsBootImageOnDisk) { + if (!mLowMemFlag && !mIsBootImageOnDisk && mFreeMem < BOOT_IMAGE_STORAGE_REQUIREMENT) { Slog.i(TAG, "No boot image on disk due to lack of space. Sending notification"); sendNotification(); + mLowMemFlag = true; } if (mFreeMem < mMemFullThreshold) { if (!mMemFullFlag) { @@ -383,7 +389,7 @@ public class DeviceStorageMonitorService extends SystemService { @Override public boolean isMemoryLow() { - return mLowMemFlag || !mIsBootImageOnDisk; + return mLowMemFlag; } @Override