Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53982804 authored by Daniel Nishi's avatar Daniel Nishi
Browse files

Change storage manager default to be a config.

This allows OEMs to customize the default behavior of the automatic
storage manager.

Bug: 38499322
Test: SettingsLib Robotest
Change-Id: I7d78865923fa7ff20b796a7075da0f35c7af1807
parent 87b99e0e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2958,4 +2958,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>
+2 −0
Original line number Diff line number Diff line
@@ -3040,4 +3040,6 @@
  <java-symbol type="integer" name="config_inCallNotificationVolumeRelative" />

  <java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" />

  <java-symbol type="integer" name="config_storageManagerDaystoRetainDefault" />
</resources>
+17 −0
Original line number Diff line number Diff line
@@ -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;
    }
}
+20 −0
Original line number Diff line number Diff line
@@ -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);
    }
}