use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageDashboardFragmentTest method test_loadWhenQuotaOnAndVolumeInfoLoadedButAppsMissing.
@Test
public void test_loadWhenQuotaOnAndVolumeInfoLoadedButAppsMissing() {
View fakeView = mock(View.class, RETURNS_DEEP_STUBS);
RecyclerView fakeRecyclerView = mock(RecyclerView.class, RETURNS_DEEP_STUBS);
when(fakeView.findViewById(anyInt())).thenReturn(fakeView);
mFragment = spy(mFragment);
when(mFragment.getView()).thenReturn(fakeView);
when(mFragment.getListView()).thenReturn(fakeRecyclerView);
PrivateStorageInfo info = new PrivateStorageInfo(0, 0);
mFragment.setPrivateStorageInfo(info);
mFragment.maybeSetLoading(true);
verify(mFragment).setLoading(true, false);
}
use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageDashboardFragmentTest method test_dontLoadWhenQuotaOnAndAllLoaded.
@Test
public void test_dontLoadWhenQuotaOnAndAllLoaded() {
View fakeView = mock(View.class, RETURNS_DEEP_STUBS);
RecyclerView fakeRecyclerView = mock(RecyclerView.class, RETURNS_DEEP_STUBS);
when(fakeView.findViewById(anyInt())).thenReturn(fakeView);
mFragment = spy(mFragment);
when(mFragment.getView()).thenReturn(fakeView);
when(mFragment.getListView()).thenReturn(fakeRecyclerView);
mFragment.setAppsStorageResult(new SparseArray<>());
PrivateStorageInfo storageInfo = new PrivateStorageInfo(0, 0);
mFragment.setPrivateStorageInfo(storageInfo);
mFragment.maybeSetLoading(true);
verify(mFragment, never()).setLoading(true, false);
}
use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by omnirom.
the class LowStorageSlice method getSlice.
@Override
public Slice getSlice() {
// Get used storage percentage from StorageManager.
final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(new StorageManagerVolumeProvider(mContext.getSystemService(StorageManager.class)));
final double usedPercentage = (double) (info.totalBytes - info.freeBytes) / info.totalBytes;
// Generate Low storage Slice.
final String percentageString = NumberFormat.getPercentInstance().format(usedPercentage);
final String freeSizeString = Formatter.formatFileSize(mContext, info.freeBytes);
final ListBuilder listBuilder = new ListBuilder(mContext, CustomSliceRegistry.LOW_STORAGE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext));
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_storage);
if (usedPercentage < LOW_STORAGE_THRESHOLD) {
// For clients that ignore error checking, a generic storage slice will be given.
final CharSequence titleStorage = mContext.getText(R.string.storage_settings);
final String summaryStorage = mContext.getString(R.string.storage_summary, percentageString, freeSizeString);
return listBuilder.addRow(buildRowBuilder(titleStorage, summaryStorage, icon)).setIsError(true).build();
}
final CharSequence titleLowStorage = mContext.getText(R.string.storage_menu_free);
final String summaryLowStorage = mContext.getString(R.string.low_storage_summary, percentageString, freeSizeString);
return listBuilder.addRow(buildRowBuilder(titleLowStorage, summaryLowStorage, icon)).build();
}
use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by omnirom.
the class LowStorageSliceTest method getSlice_lowStorage_shouldNotHaveErrorHint.
@Test
@Config(shadows = ShadowPrivateStorageInfo.class)
public void getSlice_lowStorage_shouldNotHaveErrorHint() {
ShadowPrivateStorageInfo.setPrivateStorageInfo(new PrivateStorageInfo(10L, 100L));
final Slice slice = mLowStorageSlice.getSlice();
assertThat(slice.hasHint(HINT_ERROR)).isFalse();
}
Aggregations