Merge "Fix a bug where cache was double-counted." into oc-dev
am: 7035a41715
Change-Id: I2c465b9561cea69e5772efd08af7794f762758ca
This commit is contained in:
@@ -543,8 +543,8 @@ public class AppStorageSettings extends AppInfoWithHeader
|
|||||||
mClearCacheButton.setEnabled(false);
|
mClearCacheButton.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
long codeSize = result.getCodeBytes();
|
long codeSize = result.getCodeBytes();
|
||||||
long dataSize = result.getDataBytes();
|
|
||||||
long cacheSize = result.getCacheBytes();
|
long cacheSize = result.getCacheBytes();
|
||||||
|
long dataSize = result.getDataBytes() - cacheSize;
|
||||||
|
|
||||||
if (dataSize <= 0 || !mCanClearData || mDataCleared) {
|
if (dataSize <= 0 || !mCanClearData || mDataCleared) {
|
||||||
mClearDataButton.setEnabled(false);
|
mClearDataButton.setEnabled(false);
|
||||||
|
@@ -70,7 +70,8 @@ public class AppStorageSizesController {
|
|||||||
mTotalSize.setSummary(errorRes);
|
mTotalSize.setSummary(errorRes);
|
||||||
} else {
|
} else {
|
||||||
long codeSize = mLastResult.getCodeBytes();
|
long codeSize = mLastResult.getCodeBytes();
|
||||||
long dataSize = mDataCleared ? 0 : mLastResult.getDataBytes();
|
long dataSize =
|
||||||
|
mDataCleared ? 0 : mLastResult.getDataBytes() - mLastResult.getCacheBytes();
|
||||||
if (mLastCodeSize != codeSize) {
|
if (mLastCodeSize != codeSize) {
|
||||||
mLastCodeSize = codeSize;
|
mLastCodeSize = codeSize;
|
||||||
mAppSize.setSummary(getSizeStr(context, codeSize));
|
mAppSize.setSummary(getSizeStr(context, codeSize));
|
||||||
|
@@ -14,11 +14,9 @@ import com.android.settings.TestConfig;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowApplication;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
|
import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
|
||||||
@@ -82,15 +80,15 @@ public class AppStorageSizesControllerTest {
|
|||||||
when(result.getCodeBytes()).thenReturn(1L);
|
when(result.getCodeBytes()).thenReturn(1L);
|
||||||
when(result.getCacheBytes()).thenReturn(10L);
|
when(result.getCacheBytes()).thenReturn(10L);
|
||||||
when(result.getDataBytes()).thenReturn(100L);
|
when(result.getDataBytes()).thenReturn(100L);
|
||||||
when(result.getTotalBytes()).thenReturn(111L);
|
when(result.getTotalBytes()).thenReturn(101L);
|
||||||
|
|
||||||
mController.setResult(result);
|
mController.setResult(result);
|
||||||
mController.updateUi(mContext);
|
mController.updateUi(mContext);
|
||||||
|
|
||||||
assertThat(mAppPreference.getSummary()).isEqualTo("1.00B");
|
assertThat(mAppPreference.getSummary()).isEqualTo("1.00B");
|
||||||
assertThat(mCachePreference.getSummary()).isEqualTo("10.00B");
|
assertThat(mCachePreference.getSummary()).isEqualTo("10.00B");
|
||||||
assertThat(mDataPreference.getSummary()).isEqualTo("100B");
|
assertThat(mDataPreference.getSummary()).isEqualTo("90.00B");
|
||||||
assertThat(mTotalPreference.getSummary()).isEqualTo("111B");
|
assertThat(mTotalPreference.getSummary()).isEqualTo("101B");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -99,7 +97,7 @@ public class AppStorageSizesControllerTest {
|
|||||||
when(result.getCodeBytes()).thenReturn(1L);
|
when(result.getCodeBytes()).thenReturn(1L);
|
||||||
when(result.getCacheBytes()).thenReturn(10L);
|
when(result.getCacheBytes()).thenReturn(10L);
|
||||||
when(result.getDataBytes()).thenReturn(100L);
|
when(result.getDataBytes()).thenReturn(100L);
|
||||||
when(result.getTotalBytes()).thenReturn(111L);
|
when(result.getTotalBytes()).thenReturn(101L);
|
||||||
|
|
||||||
mController.setResult(result);
|
mController.setResult(result);
|
||||||
mController.setCacheCleared(true);
|
mController.setCacheCleared(true);
|
||||||
@@ -107,8 +105,8 @@ public class AppStorageSizesControllerTest {
|
|||||||
|
|
||||||
assertThat(mAppPreference.getSummary()).isEqualTo("1.00B");
|
assertThat(mAppPreference.getSummary()).isEqualTo("1.00B");
|
||||||
assertThat(mCachePreference.getSummary()).isEqualTo("0.00B");
|
assertThat(mCachePreference.getSummary()).isEqualTo("0.00B");
|
||||||
assertThat(mDataPreference.getSummary()).isEqualTo("100B");
|
assertThat(mDataPreference.getSummary()).isEqualTo("90.00B");
|
||||||
assertThat(mTotalPreference.getSummary()).isEqualTo("101B");
|
assertThat(mTotalPreference.getSummary()).isEqualTo("91.00B");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -117,7 +115,7 @@ public class AppStorageSizesControllerTest {
|
|||||||
when(result.getCodeBytes()).thenReturn(1L);
|
when(result.getCodeBytes()).thenReturn(1L);
|
||||||
when(result.getCacheBytes()).thenReturn(10L);
|
when(result.getCacheBytes()).thenReturn(10L);
|
||||||
when(result.getDataBytes()).thenReturn(100L);
|
when(result.getDataBytes()).thenReturn(100L);
|
||||||
when(result.getTotalBytes()).thenReturn(111L);
|
when(result.getTotalBytes()).thenReturn(101L);
|
||||||
|
|
||||||
mController.setResult(result);
|
mController.setResult(result);
|
||||||
mController.setDataCleared(true);
|
mController.setDataCleared(true);
|
||||||
|
Reference in New Issue
Block a user