[Multi-user] Change Backup Settings page to support multi-user.

With multi-user backup, backup will be available or secondary users and profiles too.

1. When there are profile users, this CL changes UI flow A to B
A. Settings Homepage -> System -> Google Backup Settings for primary user
to
B. Settings Homepage -> System -> Profile Select Dialog -> Google Backup Settings for chosen profile.
Change done as per https://g3doc.corp.google.com/company/teams/apps-android-settings/howto/ia.md?cl=head
2. Functionality remains the same when there are no profiles (BackupSettingsHelper, BackupSettingsContentProvider)
3.  Also, enabled Backup Settings for secondary users. (Previously, backup settings were only shown for
system user).(SettingsGateway)

Bug: 121198738

Test: 1) System -> Backup -> shows Profile Select Dialog -> Backup page for selected profile
2) On secondary user without profile, System -> Backup (with summary) -> Backup page for secondary user.

Change-Id: I6e21279978a5dfc6eca6f5a34bbfc15a34eac68b
This commit is contained in:
Chandan Nath
2019-01-28 21:15:13 +00:00
parent d3be363004
commit 0bfef63812
13 changed files with 179 additions and 249 deletions

View File

@@ -24,6 +24,7 @@ import android.content.Intent;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -34,7 +35,7 @@ import com.android.settings.Settings.PrivacySettingsActivity;
import java.net.URISyntaxException;
/**
* Helper class for {@link BackupSettingsActivity} that interacts with {@link IBackupManager}.
* Helper class for {@link UserBackupSettingsActivity} that interacts with {@link IBackupManager}.
*/
public class BackupSettingsHelper {
private static final String TAG = "BackupSettingsHelper";
@@ -48,6 +49,24 @@ public class BackupSettingsHelper {
mContext = context;
}
/**
* If there is only one profile, show whether the backup is on or off.
* Otherwise, show nothing.
*/
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.