Loading res/values/strings.xml +0 −4 Original line number Diff line number Diff line Loading @@ -6071,10 +6071,6 @@ <!-- Backup and reset Settings screen --><skip /> <!-- Backup and reset settings menu and activity title --> <string name="privacy_settings_title">Backup</string> <!-- Summary for the Backup settings when it is turned on. --> <string name="backup_summary_state_on">On</string> <!-- Summary for the Backup settings when it is turned off. --> <string name="backup_summary_state_off">Off</string> <!-- Backup section title --> <string name="backup_section_title">Backup & restore</string> <!-- Personal data section title --> src/com/android/settings/backup/BackupSettingsHelper.java +0 −19 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.content.Intent; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.text.TextUtils; import android.util.Log; Loading @@ -50,24 +49,6 @@ public class BackupSettingsHelper { mContext = context; } /** * If there is only one profile, show whether the backup is on or off. * Otherwise, show nothing. */ public String getSummary() { UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); if (userManager.getUserProfiles().size() == 1) { try { int resId = mBackupManager.isBackupEnabled() ? R.string.backup_summary_state_on : R.string.backup_summary_state_off; return mContext.getText(resId).toString(); } catch (RemoteException e) { Log.e(TAG, "Error getting isBackupEnabled", e); } } return null; } /** * Returns an intent to launch backup settings from backup transport if the intent was provided * by the transport. Otherwise returns the intent to launch the default backup settings screen. Loading tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java +0 −37 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; import com.android.settings.R; Loading @@ -48,8 +47,6 @@ import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.shadow.api.Shadow; import org.robolectric.shadows.ShadowUserManager; @RunWith(RobolectricTestRunner.class) @Config(shadows = BackupSettingsHelperTest.ShadowBackupManagerStub.class) Loading @@ -72,46 +69,12 @@ public class BackupSettingsHelperTest { @Mock private static IBackupManager mBackupManager; private ShadowUserManager mUserManager; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application.getApplicationContext()); when(mBackupManager.getCurrentTransport()).thenReturn("test_transport"); mBackupSettingsHelper = new BackupSettingsHelper(mContext); mUserManager = Shadow.extract(mContext.getSystemService(Context.USER_SERVICE)); } @Test public void testGetSummary_backupEnabledOnlyOneProfile_showsOn() throws Exception { mUserManager.addUserProfile(new UserHandle(0)); when(mBackupManager.isBackupEnabled()).thenReturn(true); String backupSummary = mBackupSettingsHelper.getSummary(); assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_on)); } @Test public void testGetSummary_backupDisabledOnlyOneProfile_showsOff() throws Exception { mUserManager.addUserProfile(new UserHandle(0)); when(mBackupManager.isBackupEnabled()).thenReturn(false); String backupSummary = mBackupSettingsHelper.getSummary(); assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_off)); } @Test public void testGetSummary_TwoProfiles_returnsNull() throws Exception { mUserManager.addUserProfile(new UserHandle(0)); mUserManager.addUserProfile(new UserHandle(10)); when(mBackupManager.isBackupEnabled()).thenReturn(true); String backupSummary = mBackupSettingsHelper.getSummary(); assertThat(backupSummary).isNull(); } @Test Loading Loading
res/values/strings.xml +0 −4 Original line number Diff line number Diff line Loading @@ -6071,10 +6071,6 @@ <!-- Backup and reset Settings screen --><skip /> <!-- Backup and reset settings menu and activity title --> <string name="privacy_settings_title">Backup</string> <!-- Summary for the Backup settings when it is turned on. --> <string name="backup_summary_state_on">On</string> <!-- Summary for the Backup settings when it is turned off. --> <string name="backup_summary_state_off">Off</string> <!-- Backup section title --> <string name="backup_section_title">Backup & restore</string> <!-- Personal data section title -->
src/com/android/settings/backup/BackupSettingsHelper.java +0 −19 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.content.Intent; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.text.TextUtils; import android.util.Log; Loading @@ -50,24 +49,6 @@ public class BackupSettingsHelper { mContext = context; } /** * If there is only one profile, show whether the backup is on or off. * Otherwise, show nothing. */ public String getSummary() { UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); if (userManager.getUserProfiles().size() == 1) { try { int resId = mBackupManager.isBackupEnabled() ? R.string.backup_summary_state_on : R.string.backup_summary_state_off; return mContext.getText(resId).toString(); } catch (RemoteException e) { Log.e(TAG, "Error getting isBackupEnabled", e); } } return null; } /** * Returns an intent to launch backup settings from backup transport if the intent was provided * by the transport. Otherwise returns the intent to launch the default backup settings screen. Loading
tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java +0 −37 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; import com.android.settings.R; Loading @@ -48,8 +47,6 @@ import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.shadow.api.Shadow; import org.robolectric.shadows.ShadowUserManager; @RunWith(RobolectricTestRunner.class) @Config(shadows = BackupSettingsHelperTest.ShadowBackupManagerStub.class) Loading @@ -72,46 +69,12 @@ public class BackupSettingsHelperTest { @Mock private static IBackupManager mBackupManager; private ShadowUserManager mUserManager; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application.getApplicationContext()); when(mBackupManager.getCurrentTransport()).thenReturn("test_transport"); mBackupSettingsHelper = new BackupSettingsHelper(mContext); mUserManager = Shadow.extract(mContext.getSystemService(Context.USER_SERVICE)); } @Test public void testGetSummary_backupEnabledOnlyOneProfile_showsOn() throws Exception { mUserManager.addUserProfile(new UserHandle(0)); when(mBackupManager.isBackupEnabled()).thenReturn(true); String backupSummary = mBackupSettingsHelper.getSummary(); assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_on)); } @Test public void testGetSummary_backupDisabledOnlyOneProfile_showsOff() throws Exception { mUserManager.addUserProfile(new UserHandle(0)); when(mBackupManager.isBackupEnabled()).thenReturn(false); String backupSummary = mBackupSettingsHelper.getSummary(); assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_off)); } @Test public void testGetSummary_TwoProfiles_returnsNull() throws Exception { mUserManager.addUserProfile(new UserHandle(0)); mUserManager.addUserProfile(new UserHandle(10)); when(mBackupManager.isBackupEnabled()).thenReturn(true); String backupSummary = mBackupSettingsHelper.getSummary(); assertThat(backupSummary).isNull(); } @Test Loading