Import translations. DO NOT MERGE
am: cb6b15bbf1 -s ours
Change-Id: I061cd1fa3e5b949154af4e2a4fc596a72765de44
diff --git a/res/values-en-rCA/arrays.xml b/res/values-en-rCA/arrays.xml
new file mode 100644
index 0000000..6f94388
--- /dev/null
+++ b/res/values-en-rCA/arrays.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array name="automatic_storage_management_days">
+ <item msgid="4262697175462957945">"Over 30 days old"</item>
+ <item msgid="2920779420892632946">"Over 60 days old"</item>
+ <item msgid="1402081670011072896">"Over 90 days old"</item>
+ </string-array>
+</resources>
diff --git a/res/values-en-rCA/strings.xml b/res/values-en-rCA/strings.xml
new file mode 100644
index 0000000..1eb9d62
--- /dev/null
+++ b/res/values-en-rCA/strings.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="app_name" msgid="963247385700831716">"Storage Manager"</string>
+ <string name="cancel" msgid="7021218262867558825">"Cancel"</string>
+ <string name="storage_menu_free" msgid="1878247401436882778">"Free up space"</string>
+ <string name="deletion_helper_title" msgid="7928959984891140427">"Choose items to remove"</string>
+ <string name="deletion_helper_app_summary" msgid="4904590040180275237">"<xliff:g id="DAYS">%1$d</xliff:g> days ago"</string>
+ <!-- no translation found for deletion_helper_app_summary_item_size (3770886184921427886) -->
+ <skip />
+ <string name="deletion_helper_app_summary_never_used" msgid="2695210890063792461">"Not used in last year"</string>
+ <string name="deletion_helper_app_summary_unknown_used" msgid="8576377054665785558">"Not sure when last used"</string>
+ <string name="deletion_helper_free_button" msgid="1760529213407548661">"Free up <xliff:g id="FREEABLE">%1$s</xliff:g>"</string>
+ <string name="deletion_helper_photos_title" msgid="2602723121486729972">"Backed up photos & videos"</string>
+ <string name="deletion_helper_photos_age_summary" msgid="1820871709448371984">"Over 30 days old"</string>
+ <!-- no translation found for deletion_helper_photos_summary (3194825464552700889) -->
+ <skip />
+ <string name="deletion_helper_downloads_title" msgid="8002058095019254694">"Downloads"</string>
+ <!-- no translation found for deletion_helper_downloads_category_summary (8545989355108311347) -->
+ <skip />
+ <!-- no translation found for deletion_helper_downloads_summary_empty (3988054032360371887) -->
+ <skip />
+ <string name="deletion_helper_clear_dialog_message" msgid="4896104662649947320">"<xliff:g id="CLEARABLE_BYTES">%1$s</xliff:g> will be removed from your device"</string>
+ <string name="deletion_helper_clear_dialog_remove" msgid="3386502418767917932">"Remove"</string>
+ <string name="deletion_helper_upsell_title" msgid="8512037674466762017">"Manage storage automatically?"</string>
+ <string name="deletion_helper_upsell_summary" msgid="2301597713694474407">"<xliff:g id="USED">%1$s</xliff:g> now free. Let Storage Manager automatically free up space by removing backed-up content from your device?"</string>
+ <string name="deletion_helper_upsell_cancel" msgid="7084167642850053889">"No thanks"</string>
+ <string name="deletion_helper_upsell_activate" msgid="7157360257760895976">"Turn on"</string>
+ <string name="deletion_helper_apps_group_title" msgid="2578309121350341258">"Infrequently used apps"</string>
+ <!-- no translation found for deletion_helper_apps_group_summary (360315517252452356) -->
+ <skip />
+ <string name="deletion_helper_automatic_title" msgid="4610119358490679299">"Automatic"</string>
+ <string name="deletion_helper_manual_title" msgid="3905192395039688529">"Manual"</string>
+ <string name="deletion_helper_preference_title" msgid="803484286872745892">"Free space now"</string>
+ <string name="automatic_storage_manager_service_label" msgid="648592272375278978">"Automatic Storage Management Service"</string>
+ <string name="automatic_storage_manager_notification_title" product="default" msgid="8480483265300964701">"Your phone is low on space"</string>
+ <string name="automatic_storage_manager_notification_title" product="tablet" msgid="3150907918531844467">"Your tablet is low on space"</string>
+ <string name="automatic_storage_manager_notification_summary" msgid="2267399886362245822">"Let Storage Manager free up space by automatically removing old photos and videos when your phone starts to get full again."</string>
+ <string name="automatic_storage_manager_cancel_button" msgid="1826365037494962803">"No thanks"</string>
+ <string name="automatic_storage_manager_activate_button" msgid="6257070263061898041">"Turn on"</string>
+ <string name="deletion_helper_photos_loading_title" msgid="2768067991066779772">"Backed up photos & videos"</string>
+ <string name="deletion_helper_photos_loading_summary" msgid="8203033249458245854">"Finding items…"</string>
+ <string name="deletion_helper_no_threshold" msgid="6943179204098250444">"Show all items"</string>
+ <string name="deletion_helper_default_threshold" msgid="8410389370069021113">"Hide recent items"</string>
+ <string name="deletion_helper_clear_dialog_message_first_time" msgid="386144597646356521">"<xliff:g id="CLEARABLE_BYTES">%1$s</xliff:g> will be removed from your device"</string>
+ <string name="automatic_storage_manager_activation_warning" msgid="7657017408180001078">"Your storage is now being managed by the storage manager"</string>
+ <string name="empty_state_title" msgid="4033285438176545309">"Nothing to remove"</string>
+ <string name="empty_state_review_items_link" msgid="8411186441239304545">"Review recent items"</string>
+ <string name="empty_state_summary" msgid="8439893007424243790">"There aren\'t any older files to remove. To make space, remove recent photos, videos and apps."</string>
+ <string name="app_requesting_space" msgid="857425181289960167">"<xliff:g id="APP">%1$s</xliff:g> needs <xliff:g id="CLEARABLE_BYTES">%2$s</xliff:g> of space"</string>
+</resources>
diff --git a/res/values-en-rXC/arrays.xml b/res/values-en-rXC/arrays.xml
new file mode 100644
index 0000000..c651ee5
--- /dev/null
+++ b/res/values-en-rXC/arrays.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array name="automatic_storage_management_days">
+ <item msgid="4262697175462957945">"Over 30 days old"</item>
+ <item msgid="2920779420892632946">"Over 60 days old"</item>
+ <item msgid="1402081670011072896">"Over 90 days old"</item>
+ </string-array>
+</resources>
diff --git a/res/values-en-rXC/strings.xml b/res/values-en-rXC/strings.xml
new file mode 100644
index 0000000..0cbbebc
--- /dev/null
+++ b/res/values-en-rXC/strings.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="app_name" msgid="963247385700831716">"Storage Manager"</string>
+ <string name="cancel" msgid="7021218262867558825">"Cancel"</string>
+ <string name="storage_menu_free" msgid="1878247401436882778">"Free up space"</string>
+ <string name="deletion_helper_title" msgid="7928959984891140427">"Choose items to remove"</string>
+ <string name="deletion_helper_app_summary" msgid="4904590040180275237">"<xliff:g id="DAYS">%1$d</xliff:g> days ago"</string>
+ <!-- no translation found for deletion_helper_app_summary_item_size (3770886184921427886) -->
+ <skip />
+ <string name="deletion_helper_app_summary_never_used" msgid="2695210890063792461">"Not used in last year"</string>
+ <string name="deletion_helper_app_summary_unknown_used" msgid="8576377054665785558">"Not sure when last used"</string>
+ <string name="deletion_helper_free_button" msgid="1760529213407548661">"Free up <xliff:g id="FREEABLE">%1$s</xliff:g>"</string>
+ <string name="deletion_helper_photos_title" msgid="2602723121486729972">"Backed up photos & videos"</string>
+ <string name="deletion_helper_photos_age_summary" msgid="1820871709448371984">"Over 30 days old"</string>
+ <!-- no translation found for deletion_helper_photos_summary (3194825464552700889) -->
+ <skip />
+ <string name="deletion_helper_downloads_title" msgid="8002058095019254694">"Downloads"</string>
+ <!-- no translation found for deletion_helper_downloads_category_summary (8545989355108311347) -->
+ <skip />
+ <!-- no translation found for deletion_helper_downloads_summary_empty (3988054032360371887) -->
+ <skip />
+ <string name="deletion_helper_clear_dialog_message" msgid="4896104662649947320">"<xliff:g id="CLEARABLE_BYTES">%1$s</xliff:g> will be removed from your device"</string>
+ <string name="deletion_helper_clear_dialog_remove" msgid="3386502418767917932">"Remove"</string>
+ <string name="deletion_helper_upsell_title" msgid="8512037674466762017">"Manage storage automatically?"</string>
+ <string name="deletion_helper_upsell_summary" msgid="2301597713694474407">"<xliff:g id="USED">%1$s</xliff:g> now free. Let Storage manager automatically free up space by removing backed up content from your device?"</string>
+ <string name="deletion_helper_upsell_cancel" msgid="7084167642850053889">"No thanks"</string>
+ <string name="deletion_helper_upsell_activate" msgid="7157360257760895976">"Turn on"</string>
+ <string name="deletion_helper_apps_group_title" msgid="2578309121350341258">"Infrequently used apps"</string>
+ <!-- no translation found for deletion_helper_apps_group_summary (360315517252452356) -->
+ <skip />
+ <string name="deletion_helper_automatic_title" msgid="4610119358490679299">"Automatic"</string>
+ <string name="deletion_helper_manual_title" msgid="3905192395039688529">"Manual"</string>
+ <string name="deletion_helper_preference_title" msgid="803484286872745892">"Free space now"</string>
+ <string name="automatic_storage_manager_service_label" msgid="648592272375278978">"Automatic Storage Management Service"</string>
+ <string name="automatic_storage_manager_notification_title" product="default" msgid="8480483265300964701">"Your phone is low on space"</string>
+ <string name="automatic_storage_manager_notification_title" product="tablet" msgid="3150907918531844467">"Your tablet is low on space"</string>
+ <string name="automatic_storage_manager_notification_summary" msgid="2267399886362245822">"Let Storage Manager free up space by automatically removing old photos and videos when your phone starts to get full again."</string>
+ <string name="automatic_storage_manager_cancel_button" msgid="1826365037494962803">"No thanks"</string>
+ <string name="automatic_storage_manager_activate_button" msgid="6257070263061898041">"Turn on"</string>
+ <string name="deletion_helper_photos_loading_title" msgid="2768067991066779772">"Backed up photos & videos"</string>
+ <string name="deletion_helper_photos_loading_summary" msgid="8203033249458245854">"Finding items…"</string>
+ <string name="deletion_helper_no_threshold" msgid="6943179204098250444">"Show all items"</string>
+ <string name="deletion_helper_default_threshold" msgid="8410389370069021113">"Hide recent items"</string>
+ <string name="deletion_helper_clear_dialog_message_first_time" msgid="386144597646356521">"<xliff:g id="CLEARABLE_BYTES">%1$s</xliff:g> will be removed from your device"</string>
+ <string name="automatic_storage_manager_activation_warning" msgid="7657017408180001078">"Your storage is now being managed by the storage manager"</string>
+ <string name="empty_state_title" msgid="4033285438176545309">"Nothing to remove"</string>
+ <string name="empty_state_review_items_link" msgid="8411186441239304545">"Review recent items"</string>
+ <string name="empty_state_summary" msgid="8439893007424243790">"There aren\'t any older files to remove. To make space, remove recent photos, videos, and apps."</string>
+ <string name="app_requesting_space" msgid="857425181289960167">"<xliff:g id="APP">%1$s</xliff:g> needs <xliff:g id="CLEARABLE_BYTES">%2$s</xliff:g> of space"</string>
+</resources>
diff --git a/robotests/Android.mk b/robotests/Android.mk
index 421b4eb..64948ad 100644
--- a/robotests/Android.mk
+++ b/robotests/Android.mk
@@ -8,13 +8,12 @@
# Include the testing libraries (JUnit4 + Robolectric libs).
LOCAL_STATIC_JAVA_LIBRARIES := \
- platform-system-robolectric \
+ mockito-robolectric-prebuilt \
truth-prebuilt
LOCAL_JAVA_LIBRARIES := \
junit \
- platform-robolectric-prebuilt \
- sdk_vcurrent
+ platform-robolectric-prebuilt
# TODO: Remove the use of LOCAL_INSTRUMENTATION_FOR and use a different build flag.
LOCAL_INSTRUMENTATION_FOR := StorageManager
diff --git a/robotests/src/com/android/storagemanager/automatic/AutomaticStorageManagementJobServiceTest.java b/robotests/src/com/android/storagemanager/automatic/AutomaticStorageManagementJobServiceTest.java
index 3aee15c..5895835 100644
--- a/robotests/src/com/android/storagemanager/automatic/AutomaticStorageManagementJobServiceTest.java
+++ b/robotests/src/com/android/storagemanager/automatic/AutomaticStorageManagementJobServiceTest.java
@@ -59,6 +59,15 @@
import java.util.ArrayList;
import java.util.List;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.nullable;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
@RunWith(RobolectricTestRunner.class)
@Config(manifest=TestingConstants.MANIFEST, sdk=TestingConstants.SDK_VERSION)
public class AutomaticStorageManagementJobServiceTest {
@@ -94,9 +103,11 @@
mVolumes.add(mVolumeInfo);
when(mStorageVolumeProvider.getPrimaryStorageSize()).thenReturn(100L);
when(mStorageVolumeProvider.getVolumes()).thenReturn(mVolumes);
- when(mStorageVolumeProvider.getFreeBytes(any(StorageStatsManager.class), eq(mVolumeInfo)))
+ when(mStorageVolumeProvider.getFreeBytes(
+ nullable(StorageStatsManager.class), eq(mVolumeInfo)))
.thenReturn(0L);
- when(mStorageVolumeProvider.getTotalBytes(any(StorageStatsManager.class), eq(mVolumeInfo)))
+ when(mStorageVolumeProvider.getTotalBytes(
+ nullable(StorageStatsManager.class), eq(mVolumeInfo)))
.thenReturn(100L);
mApplication = ShadowApplication.getInstance();
@@ -110,8 +121,9 @@
// actually tries to run the job.
when(mFeatureFactory.getStorageManagementJobProvider())
.thenReturn(mStorageManagementJobProvider);
- when(mStorageManagementJobProvider.onStartJob(any(Context.class),
- any(JobParameters.class), any(Integer.class))).thenReturn(false);
+ when(mStorageManagementJobProvider.onStartJob(
+ nullable(Context.class), nullable(JobParameters.class), anyInt()))
+ .thenReturn(false);
ReflectionHelpers.setStaticField(FeatureFactory.class, "sFactory", mFeatureFactory);
// And we can't forget to initialize the actual job service.
@@ -167,7 +179,8 @@
@Test
public void testJobDoesntRunIfStorageNotFull() throws Exception {
activateASM();
- when(mStorageVolumeProvider.getFreeBytes(any(StorageStatsManager.class), eq(mVolumeInfo)))
+ when(mStorageVolumeProvider.getFreeBytes(
+ nullable(StorageStatsManager.class), eq(mVolumeInfo)))
.thenReturn(100L);
assertThat(mJobService.onStartJob(mJobParameters)).isFalse();
assertStorageManagerJobDidNotRun();
@@ -176,12 +189,14 @@
@Test
public void testJobOnlyRunsIfFreeStorageIsUnder15Percent() throws Exception {
activateASM();
- when(mStorageVolumeProvider.getFreeBytes(any(StorageStatsManager.class), eq(mVolumeInfo)))
+ when(mStorageVolumeProvider.getFreeBytes(
+ nullable(StorageStatsManager.class), eq(mVolumeInfo)))
.thenReturn(15L);
assertThat(mJobService.onStartJob(mJobParameters)).isFalse();
assertStorageManagerJobDidNotRun();
- when(mStorageVolumeProvider.getFreeBytes(any(StorageStatsManager.class), eq(mVolumeInfo)))
+ when(mStorageVolumeProvider.getFreeBytes(
+ nullable(StorageStatsManager.class), eq(mVolumeInfo)))
.thenReturn(14L);
assertThat(mJobService.onStartJob(mJobParameters)).isFalse();
assertStorageManagerJobRan();
@@ -205,13 +220,14 @@
when(nonPrivateVolume.getType()).thenReturn(VolumeInfo.TYPE_PUBLIC);
mVolumes.add(nonPrivateVolume);
when(mStorageVolumeProvider.getFreeBytes(
- any(StorageStatsManager.class), eq(nonPrivateVolume)))
+ nullable(StorageStatsManager.class), eq(nonPrivateVolume)))
.thenReturn(0L);
when(mStorageVolumeProvider.getTotalBytes(
- any(StorageStatsManager.class), eq(nonPrivateVolume)))
+ nullable(StorageStatsManager.class), eq(nonPrivateVolume)))
.thenReturn(100L);
activateASM();
- when(mStorageVolumeProvider.getFreeBytes(any(StorageStatsManager.class), eq(mVolumeInfo)))
+ when(mStorageVolumeProvider.getFreeBytes(
+ nullable(StorageStatsManager.class), eq(mVolumeInfo)))
.thenReturn(15L);
assertThat(mJobService.onStartJob(mJobParameters)).isFalse();
@@ -227,14 +243,15 @@
when(privateVolumeInfo.isMountedReadable()).thenReturn(true);
when(privateVolumeInfo.getFsUuid()).thenReturn(StorageManager.UUID_PRIVATE_INTERNAL);
when(mStorageVolumeProvider.getFreeBytes(
- any(StorageStatsManager.class), eq(privateVolumeInfo)))
+ nullable(StorageStatsManager.class), eq(privateVolumeInfo)))
.thenReturn(0L);
when(mStorageVolumeProvider.getTotalBytes(
- any(StorageStatsManager.class), eq(privateVolumeInfo)))
+ nullable(StorageStatsManager.class), eq(privateVolumeInfo)))
.thenReturn(100L);
mVolumes.add(privateVolumeInfo);
activateASM();
- when(mStorageVolumeProvider.getFreeBytes(any(StorageStatsManager.class), eq(mVolumeInfo)))
+ when(mStorageVolumeProvider.getFreeBytes(
+ nullable(StorageStatsManager.class), eq(mVolumeInfo)))
.thenReturn(15L);
assertThat(mJobService.onStartJob(mJobParameters)).isFalse();
@@ -321,7 +338,7 @@
}
private void assertJobFinished(boolean retryNeeded) {
- verify(mJobService).jobFinished(any(JobParameters.class), eq(retryNeeded));
+ verify(mJobService).jobFinished(nullable(JobParameters.class), eq(retryNeeded));
}
private void assertStorageManagerJobRan() {
diff --git a/robotests/src/com/android/storagemanager/deletionhelper/DeletionHelperSettingsTest.java b/robotests/src/com/android/storagemanager/deletionhelper/DeletionHelperSettingsTest.java
index b2b81b6..388f8b8 100644
--- a/robotests/src/com/android/storagemanager/deletionhelper/DeletionHelperSettingsTest.java
+++ b/robotests/src/com/android/storagemanager/deletionhelper/DeletionHelperSettingsTest.java
@@ -23,7 +23,9 @@
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
@@ -31,6 +33,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.storage.StorageManager;
+import android.support.v7.preference.PreferenceScreen;
import com.android.storagemanager.testing.StorageManagerRobolectricTestRunner;
import com.android.storagemanager.testing.TestingConstants;
@@ -74,4 +77,30 @@
assertThat(DeletionHelperSettings.getGaugeString(mContext, intent, PACKAGE_NAME))
.isNotNull();
}
+
+ @Test
+ public void downloadsNotDeletedInNoThresholdMode() throws Exception {
+ DeletionHelperSettings settings =
+ spy(DeletionHelperSettings.newInstance(AppsAsyncLoader.NO_THRESHOLD));
+ PreferenceScreen preferenceScreen = mock(PreferenceScreen.class);
+ doReturn(preferenceScreen).when(settings).getPreferenceScreen();
+ DownloadsDeletionType downloadsDeletionType = mock(DownloadsDeletionType.class);
+ settings.setDownloadsDeletionType(downloadsDeletionType);
+
+ settings.setupEmptyState();
+ settings.clearData();
+
+ verify(downloadsDeletionType, never()).clearFreeableData(any());
+ }
+
+ @Test
+ public void onFreeableChangeChecksForNull() throws Exception {
+ DeletionHelperSettings settings =
+ DeletionHelperSettings.newInstance(AppsAsyncLoader.NO_THRESHOLD);
+ AppDeletionType appBackend = mock(AppDeletionType.class);
+ when(appBackend.isEmpty()).thenReturn(true);
+ settings.mAppBackend = appBackend;
+
+ settings.onFreeableChanged(0, 0L);
+ }
}
diff --git a/src/com/android/storagemanager/deletionhelper/DeletionHelperSettings.java b/src/com/android/storagemanager/deletionhelper/DeletionHelperSettings.java
index fca2380..1a63b17 100644
--- a/src/com/android/storagemanager/deletionhelper/DeletionHelperSettings.java
+++ b/src/com/android/storagemanager/deletionhelper/DeletionHelperSettings.java
@@ -23,6 +23,7 @@
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.storage.StorageManager;
+import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
@@ -66,7 +67,7 @@
private List<DeletionType> mDeletableContentList;
private AppDeletionPreferenceGroup mApps;
- private AppDeletionType mAppBackend;
+ @VisibleForTesting AppDeletionType mAppBackend;
private DownloadsDeletionPreferenceGroup mDownloadsPreference;
private DownloadsDeletionType mDownloadsDeletion;
private PhotosDeletionPreference mPhotoPreference;
@@ -189,11 +190,19 @@
updateFreeButtonText();
}
- private void setupEmptyState() {
- mDownloadsPreference.setChecked(false);
+ @VisibleForTesting
+ void setupEmptyState() {
final PreferenceScreen screen = getPreferenceScreen();
- screen.removePreference(mDownloadsPreference);
+ if (mDownloadsPreference != null) {
+ mDownloadsPreference.setChecked(false);
+ screen.removePreference(mDownloadsPreference);
+ }
screen.removePreference(mApps);
+
+ // Nulling out the downloads preferences means we won't accidentally delete what isn't
+ // visible.
+ mDownloadsDeletion = null;
+ mDownloadsPreference = null;
}
private boolean isEmptyState() {
@@ -237,13 +246,17 @@
@Override
public void onFreeableChanged(int numItems, long bytesFreeable) {
if (numItems > 0 || bytesFreeable > 0 || allTypesEmpty()) {
- mLoadingController.onCategoryLoad();
+ if (mLoadingController != null) {
+ mLoadingController.onCategoryLoad();
+ }
}
// bytesFreeable is the number of bytes freed by a single deletion type. If it is non-zero,
// there is stuff to free and we can enable it. If it is zero, though, we still need to get
// getTotalFreeableSpace to check all deletion types.
- mFree.setEnabled(bytesFreeable != 0 || getTotalFreeableSpace(COUNT_CHECKED_ONLY) != 0);
+ if (mFree != null) {
+ mFree.setEnabled(bytesFreeable != 0 || getTotalFreeableSpace(COUNT_CHECKED_ONLY) != 0);
+ }
updateFreeButtonText();
// Transition to empty state if all types have reported there is nothing to delete. Skip
@@ -255,7 +268,7 @@
private boolean allTypesEmpty() {
return mAppBackend.isEmpty()
- && mDownloadsDeletion.isEmpty()
+ && (mDownloadsDeletion == null || mDownloadsDeletion.isEmpty())
&& (mPhotoVideoDeletion == null || mPhotoVideoDeletion.isEmpty());
}
@@ -277,7 +290,9 @@
if (mDownloadsPreference != null) {
mDownloadsDeletion.clearFreeableData(getActivity());
}
- mAppBackend.clearFreeableData(getActivity());
+ if (mAppBackend != null) {
+ mAppBackend.clearFreeableData(getActivity());
+ }
}
@Override
@@ -323,6 +338,11 @@
return view;
}
+ @VisibleForTesting
+ void setDownloadsDeletionType(DownloadsDeletionType downloadsDeletion) {
+ mDownloadsDeletion = downloadsDeletion;
+ }
+
private void initializeButtons() {
ButtonBarProvider activity = (ButtonBarProvider) getActivity();
activity.getButtonBar().setVisibility(View.VISIBLE);