Permalink
Browse files

Hide automatic storage manager preference.

This preference should not be displayed to lower RAM device. Files
Go app will would provide this feature for low RAM devices.
Bug: 63333197
Test: visual

Change-Id: I48464884cf20acc632748e66f8183c276996828c
  • Loading branch information...
rajekumar committed Jul 17, 2017
1 parent 4ff09a2 commit 2156b26b2e38e1e92d33d1dba0a7c33fc2feeaea
@@ -16,13 +16,13 @@
package com.android.settings.deviceinfo.storage;
import android.app.ActivityManager;
import android.app.FragmentManager;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.PreferenceScreen;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
@@ -61,7 +61,7 @@ public void displayPreference(PreferenceScreen screen) {
@Override
public boolean isAvailable() {
return true;
return !ActivityManager.isLowRamDeviceStatic();
}
@Override
@@ -71,6 +71,9 @@ public String getPreferenceKey() {
@Override
public void onResume() {
if (!isAvailable()) {
return;
}
boolean isStorageManagerEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 0) != 0;
mSwitch.setChecked(isStorageManagerEnabled);
@@ -17,7 +17,6 @@
package com.android.settings.deviceinfo.storage;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -33,17 +32,15 @@
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.deletionhelper.ActivationWarningFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
import com.android.settings.widget.MasterSwitchPreference;
import com.android.settings.overlay.FeatureFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -84,10 +81,18 @@ public void setUp() {
}
@Test
public void isAvailable_shouldAlwaysReturnTrue() {
public void isAvailable_shouldReturnTrue_forHighRamDevice() {
assertThat(mController.isAvailable()).isTrue();
}
@Test
@Config(shadows = {SettingsShadowSystemProperties.class})
public void isAvailable_shouldAlwaysReturnFalse_forLowRamDevice() {
SettingsShadowSystemProperties.set("ro.config.low_ram", "true");
assertThat(mController.isAvailable()).isFalse();
SettingsShadowSystemProperties.clear();
}
@Test
public void onResume_shouldReflectEnabledStatus() {
mController.displayPreference(mScreen);

0 comments on commit 2156b26

Please sign in to comment.