If backup service is not available, remove Settings->Backup and Backup->"Backup is disabled by

admin" from search results.

"Backup -> Backup" still appears due to the PrivacySettingsActivity. On clicking that,
we get "Backup is disabled by admin" which is OK

Bug: 129743816

Test: 1. atest -v UserBackupSettingsActivityTest
2. atest -v BackupInactivePreferenceControllerTest
3. Create and switch to secondary user. Type "backup" in settings search. Note that only
"Backup->Backup" is shown and on clicking it, we get "Backup is disabled by admin"

Change-Id: Ic13e2d745c9511cbebe27aa4c6f5cd89b277fc37
This commit is contained in:
Chandan Nath
2019-04-10 17:02:02 +01:00
parent 96b534951c
commit 826a91c56e
6 changed files with 56 additions and 32 deletions

View File

@@ -98,7 +98,7 @@ public class UserBackupSettingsActivity extends FragmentActivity implements Inde
*/
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
private static final String BACKUP_SEARCH_INDEX_KEY = "backup";
private static final String BACKUP_SEARCH_INDEX_KEY = "Backup";
@Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
@@ -119,6 +119,15 @@ public class UserBackupSettingsActivity extends FragmentActivity implements Inde
return result;
}
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
if (!new BackupSettingsHelper(context).showBackupSettingsForUser()) {
keys.add(BACKUP_SEARCH_INDEX_KEY);
}
return keys;
}
};
@VisibleForTesting