Merge "Change storage manager default to be a config."
This commit is contained in:
@@ -2953,4 +2953,7 @@
|
||||
<!-- The OEM specified sensor string type for the gesture to launch camera app, this value
|
||||
must match the value of config_cameraLiftTriggerSensorType in OEM's HAL -->
|
||||
<string translatable="false" name="config_cameraLiftTriggerSensorStringType"></string>
|
||||
|
||||
<!-- Default number of days to retain for the automatic storage manager. -->
|
||||
<integer translatable="false" name="config_storageManagerDaystoRetainDefault">90</integer>
|
||||
</resources>
|
||||
|
||||
@@ -3042,4 +3042,6 @@
|
||||
<java-symbol type="integer" name="config_inCallNotificationVolumeRelative" />
|
||||
|
||||
<java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" />
|
||||
|
||||
<java-symbol type="integer" name="config_storageManagerDaystoRetainDefault" />
|
||||
</resources>
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.net.NetworkBadging;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.UserManager;
|
||||
import android.print.PrintManager;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.util.UserIcons;
|
||||
@@ -313,4 +314,20 @@ public class Utils {
|
||||
"No badge resource found for badge value: " + badge);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getDefaultStorageManagerDaysToRetain(Resources resources) {
|
||||
int defaultDays = Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT;
|
||||
try {
|
||||
defaultDays =
|
||||
resources.getInteger(
|
||||
com.android
|
||||
.internal
|
||||
.R
|
||||
.integer
|
||||
.config_storageManagerDaystoRetainDefault);
|
||||
} catch (Resources.NotFoundException e) {
|
||||
// We are likely in a test environment.
|
||||
}
|
||||
return defaultDays;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,12 @@ import org.robolectric.annotation.Config;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
@RunWith(SettingLibRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class UtilsTest {
|
||||
@@ -54,4 +60,18 @@ public class UtilsTest {
|
||||
assertThat(percentage).isEqualTo(expectedPercentages[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStorageManagerDaysToRetainUsesResources() {
|
||||
Resources resources = mock(Resources.class);
|
||||
when(resources.getInteger(
|
||||
eq(
|
||||
com.android
|
||||
.internal
|
||||
.R
|
||||
.integer
|
||||
.config_storageManagerDaystoRetainDefault)))
|
||||
.thenReturn(60);
|
||||
assertThat(Utils.getDefaultStorageManagerDaysToRetain(resources)).isEqualTo(60);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user