Merge "Always show backup settings (even if backup is deactivated)." into qt-dev
This commit is contained in:
@@ -639,9 +639,8 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
showDev, isAdmin)
|
||||
|| somethingChanged;
|
||||
|
||||
boolean enableBackupTile = new BackupSettingsHelper(this).showBackupSettingsForUser();
|
||||
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
|
||||
UserBackupSettingsActivity.class.getName()), enableBackupTile, isAdmin)
|
||||
UserBackupSettingsActivity.class.getName()), true, isAdmin)
|
||||
|| somethingChanged;
|
||||
|
||||
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
|
||||
|
@@ -28,7 +28,7 @@ public class BackupInactivePreferenceController extends BasePreferenceController
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!new BackupSettingsHelper(mContext).showBackupSettingsForUser()) {
|
||||
if (!new BackupSettingsHelper(mContext).isBackupServiceActive()) {
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
if (PrivacySettingsUtils.isInvisibleKey(mContext, PrivacySettingsUtils.BACKUP_INACTIVE)) {
|
||||
|
@@ -50,14 +50,6 @@ public class BackupSettingsHelper {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public boolean showBackupSettingsForUser() {
|
||||
// For profiles, we want them to be included in the profile select dialog even if
|
||||
// backup is not activated.
|
||||
// For other users, enable/disable backup settings depending on whether backup is activated
|
||||
// for the user.
|
||||
return UserManager.get(mContext).isManagedProfile() || isBackupServiceActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is only one profile, show whether the backup is on or off.
|
||||
* Otherwise, show nothing.
|
||||
|
@@ -123,7 +123,7 @@ public class UserBackupSettingsActivity extends FragmentActivity implements Inde
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
final List<String> keys = super.getNonIndexableKeys(context);
|
||||
if (!new BackupSettingsHelper(context).showBackupSettingsForUser()) {
|
||||
if (!new BackupSettingsHelper(context).isBackupServiceActive()) {
|
||||
keys.add(BACKUP_SEARCH_INDEX_KEY);
|
||||
}
|
||||
return keys;
|
||||
|
@@ -54,18 +54,18 @@ public class BackupInactivePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_isnotInvisibleKey_showBackup_shouldBeAvailable() {
|
||||
public void getAvailabilityStatus_isnotInvisibleKey_backupActive_shouldBeAvailable() {
|
||||
ShadowPrivacySettingsUtils.setIsInvisibleKey(false);
|
||||
ShadowBackupSettingsHelper.showBackupSettingsForUser = true;
|
||||
ShadowBackupSettingsHelper.isBackupServiceActive = true;
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_isnotInvisibleKey_dontShowBackup_shouldBeUnsearchable() {
|
||||
public void getAvailabilityStatus_isnotInvisibleKey_backupNotActive_shouldBeUnsearchable() {
|
||||
ShadowPrivacySettingsUtils.setIsInvisibleKey(false);
|
||||
ShadowBackupSettingsHelper.showBackupSettingsForUser = false;
|
||||
ShadowBackupSettingsHelper.isBackupServiceActive = false;
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
|
||||
@@ -74,7 +74,7 @@ public class BackupInactivePreferenceControllerTest {
|
||||
@Test
|
||||
public void getAvailabilityStatus_isInvisibleKey_shouldBeDisabledUnsupported() {
|
||||
ShadowPrivacySettingsUtils.setIsInvisibleKey(true);
|
||||
ShadowBackupSettingsHelper.showBackupSettingsForUser = true;
|
||||
ShadowBackupSettingsHelper.isBackupServiceActive = true;
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
|
@@ -123,8 +123,8 @@ public class UserBackupSettingsActivityTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_whenShowBackupSettings() {
|
||||
ShadowBackupSettingsHelper.showBackupSettingsForUser = true;
|
||||
public void getNonIndexableKeys_whenBackupServiceActive() {
|
||||
ShadowBackupSettingsHelper.isBackupServiceActive = true;
|
||||
|
||||
assertThat(UserBackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(
|
||||
mApplication, true)).isNotEmpty();
|
||||
@@ -133,8 +133,8 @@ public class UserBackupSettingsActivityTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_whenDontShowBackupSettings() {
|
||||
ShadowBackupSettingsHelper.showBackupSettingsForUser = false;
|
||||
public void getNonIndexableKeys_whenBackupServiceNotActive() {
|
||||
ShadowBackupSettingsHelper.isBackupServiceActive = false;
|
||||
|
||||
assertThat(UserBackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(
|
||||
mApplication, true)).isNotEmpty();
|
||||
@@ -144,11 +144,11 @@ public class UserBackupSettingsActivityTest {
|
||||
|
||||
@Implements(BackupSettingsHelper.class)
|
||||
public static class ShadowBackupSettingsHelper {
|
||||
static boolean showBackupSettingsForUser = true;
|
||||
static boolean isBackupServiceActive = true;
|
||||
|
||||
@Implementation
|
||||
public boolean showBackupSettingsForUser() {
|
||||
return showBackupSettingsForUser;
|
||||
public boolean isBackupServiceActive() {
|
||||
return isBackupServiceActive;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
@@ -163,7 +163,7 @@ public class UserBackupSettingsActivityTest {
|
||||
|
||||
@Resetter
|
||||
public static void reset() {
|
||||
showBackupSettingsForUser = true;
|
||||
isBackupServiceActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user