Fix search results for backup settings.
Make BackupSettingsAcitivity searchable and remove PrivacySettings from the search index. Bug: 35720213 Test: make RunSettingsRoboTests -j40 Change-Id: Id2e091c978e4da078dcc6bc57760ec830e439c0c
This commit is contained in:
@@ -18,18 +18,29 @@ package com.android.settings.backup;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* The activity used to launch the configured Backup activity or the preference screen
|
||||
* if the manufacturer provided their backup settings.
|
||||
*/
|
||||
public class BackupSettingsActivity extends Activity {
|
||||
public class BackupSettingsActivity extends Activity implements Indexable {
|
||||
private static final String TAG = "BackupSettingsActivity";
|
||||
private FragmentManager mFragmentManager;
|
||||
|
||||
@@ -68,6 +79,52 @@ public class BackupSettingsActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For Search.
|
||||
*/
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
private static final String BACKUP_SEARCH_INDEX_KEY = "backup";
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
|
||||
boolean enabled) {
|
||||
|
||||
final List<SearchIndexableRaw> result = new ArrayList<>();
|
||||
|
||||
// Add the activity title
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = context.getResources().getString(R.string.privacy_settings_title);
|
||||
data.screenTitle = context.getResources().getString(
|
||||
R.string.privacy_settings_title);
|
||||
data.keywords = context.getResources().getString(
|
||||
R.string.keywords_backup);
|
||||
data.intentTargetPackage = context.getPackageName();
|
||||
data.intentTargetClass = BackupSettingsActivity.class.getName();
|
||||
data.intentAction = "android.intent.action.MAIN";
|
||||
data.key = BACKUP_SEARCH_INDEX_KEY;
|
||||
result.add(data);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
final List<String> keys = new ArrayList<String>();
|
||||
|
||||
// For non-primary user, no backup is available, so don't show it in search
|
||||
// TODO: http://b/22388012
|
||||
if (UserHandle.myUserId() != UserHandle.USER_SYSTEM) {
|
||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
||||
Log.d(TAG, "Not a system user, not indexing the screen");
|
||||
}
|
||||
keys.add(BACKUP_SEARCH_INDEX_KEY);
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
void setFragmentManager(FragmentManager fragmentManager) {
|
||||
mFragmentManager = fragmentManager;
|
||||
|
Reference in New Issue
Block a user