Show "Backup service isn't active" if backup isnt active for work
profile Bug: 127821779 Test: 1) Set up work profile. 2) adb shell bmgr --user 19 activate true 3) Settings -> System -> Backup -> Work -> Shows google backup settings 4) adb shell bmgr --user 19 activate false 5) Settings -> System -> Backup -> Work -> "Backup service isn't active" Change-Id: Ifc16cf3e69fd9db87d519cbad68f0f8e9d8ef6f3
This commit is contained in:
@@ -632,10 +632,14 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
showDev, isAdmin)
|
||||
|| somethingChanged;
|
||||
|
||||
// Enable/disable backup settings depending on whether backup is activated for the user.
|
||||
boolean isBackupActive = new BackupSettingsHelper(this).isBackupServiceActive();
|
||||
// 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.
|
||||
boolean enableBackupTile = um.isManagedProfile()
|
||||
|| new BackupSettingsHelper(this).isBackupServiceActive();
|
||||
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
|
||||
UserBackupSettingsActivity.class.getName()), isBackupActive, isAdmin)
|
||||
UserBackupSettingsActivity.class.getName()), enableBackupTile, isAdmin)
|
||||
|| somethingChanged;
|
||||
|
||||
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
|
||||
|
@@ -28,9 +28,6 @@ public class BackupInactivePreferenceController extends BasePreferenceController
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!PrivacySettingsUtils.isAdminUser(mContext)) {
|
||||
return DISABLED_FOR_USER;
|
||||
}
|
||||
if (PrivacySettingsUtils.isInvisibleKey(mContext, PrivacySettingsUtils.BACKUP_INACTIVE)) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
@@ -20,8 +20,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -38,7 +36,6 @@ import org.robolectric.annotation.Config;
|
||||
public class BackupInactivePreferenceControllerTest {
|
||||
private Context mContext;
|
||||
private BackupInactivePreferenceController mController;
|
||||
private Preference mPreference;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -54,23 +51,14 @@ public class BackupInactivePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_isAdmiUser_isnotInvisibleKey_shouldBeAvailable() {
|
||||
ShadowPrivacySettingsUtils.setIsAdminUser(true);
|
||||
public void getAvailabilityStatus_isnotInvisibleKey_shouldBeAvailable() {
|
||||
ShadowPrivacySettingsUtils.setIsInvisibleKey(false);
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_isnotAdmiUser_shouldBeDisabledForUser() {
|
||||
ShadowPrivacySettingsUtils.setIsAdminUser(false);
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_isAdmiUser_isInvisibleKey_shouldBeDisabledUnsupported() {
|
||||
ShadowPrivacySettingsUtils.setIsAdminUser(true);
|
||||
public void getAvailabilityStatus_isInvisibleKey_shouldBeDisabledUnsupported() {
|
||||
ShadowPrivacySettingsUtils.setIsInvisibleKey(true);
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
|
Reference in New Issue
Block a user