Make Quick setttings developer tiles searchable
Bug: 286365859 Test: manual verify Change-Id: I2b3578d4aa80d48a4dcc29cfaac2f25089f0d4e8
This commit is contained in:
@@ -18,21 +18,26 @@ package com.android.settings.development.qstile;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.search.SearchIndexableRaw;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SearchIndexable
|
||||
public class DevelopmentTileConfigFragment extends DashboardFragment {
|
||||
private static final String TAG = "DevelopmentTileConfig";
|
||||
private static final String QS_TILE_PERF = "develop_qs_tile";
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
@@ -56,5 +61,61 @@ public class DevelopmentTileConfigFragment extends DashboardFragment {
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
|
||||
boolean enabled) {
|
||||
List<SearchIndexableRaw> result = new ArrayList<>();
|
||||
// Save the query system property for getNonIndexableKeys to avoid
|
||||
// getTitleServiceList multiple times
|
||||
SharedPreferences sharedPref = context.getSharedPreferences(QS_TILE_PERF,
|
||||
Context.MODE_PRIVATE);
|
||||
|
||||
List<ServiceInfo> services =
|
||||
DevelopmentTilePreferenceController.getTileServiceList(context);
|
||||
PackageManager pm = context.getPackageManager();
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
for (ServiceInfo sInfo : services) {
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = sInfo.loadLabel(pm).toString();
|
||||
data.key = sInfo.name;
|
||||
result.add(data);
|
||||
|
||||
if (sInfo.metaData == null) {
|
||||
continue;
|
||||
}
|
||||
String flag = sInfo.metaData.getString(
|
||||
DevelopmentTiles.META_DATA_REQUIRES_SYSTEM_PROPERTY);
|
||||
if (flag == null) {
|
||||
continue;
|
||||
}
|
||||
editor.putString(sInfo.name, flag);
|
||||
}
|
||||
editor.apply();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
|
||||
SharedPreferences sharedPref = context.getSharedPreferences(QS_TILE_PERF,
|
||||
Context.MODE_PRIVATE);
|
||||
Map<String, ?> map = sharedPref.getAll();
|
||||
for (Map.Entry<String, ?> entry : map.entrySet()) {
|
||||
if (entry.getValue() == null) {
|
||||
continue;
|
||||
}
|
||||
String key = entry.getKey();
|
||||
String flag = entry.getValue().toString();
|
||||
|
||||
if (!SystemProperties.getBoolean(flag, false)) {
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user