Fix issue about at which time Bluetooth devices name are indexed

- remembered devices name were only indexed when BT was turned on/off
- allow the same when they are paired
- remove device name from the Index if it is un-paired

Change-Id: I1206a591b0132789c3b003e52c7ffac630e80758
This commit is contained in:
Fabrice Di Meglio
2014-04-08 17:42:29 -07:00
parent e2b9e07e5f
commit 3b22695670
3 changed files with 23 additions and 1 deletions

View File

@@ -35,6 +35,8 @@ import android.view.View.OnClickListener;
import android.widget.ImageView; import android.widget.ImageView;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.search.Index;
import com.android.settings.search.SearchIndexableRaw;
import java.util.List; import java.util.List;
@@ -209,6 +211,15 @@ public final class BluetoothDevicePreference extends Preference implements
if (!mCachedDevice.startPairing()) { if (!mCachedDevice.startPairing()) {
Utils.showError(getContext(), mCachedDevice.getName(), Utils.showError(getContext(), mCachedDevice.getName(),
R.string.bluetooth_pairing_error_message); R.string.bluetooth_pairing_error_message);
} else {
final Context context = getContext();
SearchIndexableRaw data = new SearchIndexableRaw(context);
data.title = mCachedDevice.getName();
data.screenTitle = context.getResources().getString(R.string.bluetooth_settings);
data.enabled = true;
Index.getInstance(context).updateFromSearchIndexableData(data);
} }
} }

View File

@@ -38,6 +38,8 @@ import android.widget.Button;
import android.text.Editable; import android.text.Editable;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.search.Index;
import com.android.settings.search.SearchIndexableRaw;
import java.util.HashMap; import java.util.HashMap;
@@ -230,6 +232,14 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment
if (key.equals(KEY_UNPAIR)) { if (key.equals(KEY_UNPAIR)) {
unpairDevice(); unpairDevice();
finish(); finish();
final Context context = preference.getContext();
SearchIndexableRaw data = new SearchIndexableRaw(context);
data.title = mCachedDevice.getName();
data.screenTitle = context.getResources().getString(R.string.bluetooth_settings);
data.enabled = false;
Index.getInstance(context).updateFromSearchIndexableData(data);
return true; return true;
} }

View File

@@ -239,8 +239,9 @@ public class Index {
return result; return result;
} }
private boolean updateFromSearchIndexableData(SearchIndexableData data) { public boolean updateFromSearchIndexableData(SearchIndexableData data) {
addIndexableData(data); addIndexableData(data);
mDataToProcess.forceUpdate = true;
return updateInternal(); return updateInternal();
} }