diff options
author | Daniel Nishi <dhnishi@google.com> | 2016-09-20 17:08:12 -0700 |
---|---|---|
committer | Daniel Nishi <dhnishi@google.com> | 2016-09-20 17:08:12 -0700 |
commit | dbf58432eba75178987aa239d739947c1ab36f45 (patch) | |
tree | 461d3045d7053e9eb16fda252d5f8dca9af6835d | |
parent | 27deac3e8eb2c0f2025fc8f1c8624f882b8b8d9b (diff) | |
download | StorageManager-dbf58432eba75178987aa239d739947c1ab36f45.tar.gz |
Fix a bug where Deletion Helper could crash on deletion size callback.
This resulted from cases where the user very quickly navigates away
from the Deletion Helper while it is still loading. When the clearable
storage information completes, the callback executes and attempts to
update a label on the Activity. If the Activity no longer exists,
then the callback throws a NPE and crashes.
Bug: 31602093
Test: Manually reattempted the repro case.
Change-Id: I505f8a7558b58c94fdb88a558c6e9c0814e45210
-rw-r--r-- | src/com/android/storagemanager/deletionhelper/DeletionHelperSettings.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/com/android/storagemanager/deletionhelper/DeletionHelperSettings.java b/src/com/android/storagemanager/deletionhelper/DeletionHelperSettings.java index d507320..23ca719 100644 --- a/src/com/android/storagemanager/deletionhelper/DeletionHelperSettings.java +++ b/src/com/android/storagemanager/deletionhelper/DeletionHelperSettings.java @@ -231,8 +231,12 @@ public class DeletionHelperSettings extends PreferenceFragment implements } private void updateFreeButtonText() { - mFree.setText(String.format(getActivity().getString(R.string.deletion_helper_free_button), - Formatter.formatFileSize(getActivity(), getTotalFreeableSpace()))); + Activity activity = getActivity(); + if (activity == null) { + return; + } + mFree.setText(String.format(activity.getString(R.string.deletion_helper_free_button), + Formatter.formatFileSize(activity, getTotalFreeableSpace()))); } private long getTotalFreeableSpace() { |