Merge "Redirects to connected devices page in a11y pairing page" into main
diff --git a/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceController.java b/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceController.java
index 213cfbd..622d5d8 100644
--- a/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceController.java
+++ b/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceController.java
@@ -16,27 +16,19 @@
package com.android.settings.accessibility;
-import static android.app.Activity.RESULT_OK;
-
import android.content.Context;
-import android.content.Intent;
-import android.preference.PreferenceManager;
import android.text.TextUtils;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
-import com.android.settings.bluetooth.BluetoothPairingDetail;
+import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
-import androidx.annotation.VisibleForTesting;
-
/** Preference controller for all bluetooth device preference. */
-public class ViewAllBluetoothDevicesPreferenceController extends BasePreferenceController implements
- PreferenceManager.OnActivityResultListener {
-
- private static final int REQUEST_CODE_BONDED_DEVICE = 270;
+public class ViewAllBluetoothDevicesPreferenceController extends BasePreferenceController {
private DashboardFragment mFragment;
public ViewAllBluetoothDevicesPreferenceController(Context context, String preferenceKey) {
@@ -60,29 +52,18 @@
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
- launchBluetoothPairingDetail();
+ launchConnectedDevicePage();
return true;
}
return false;
}
- @Override
- public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
- // If back from BONDED device page, then no need to show scan result again.
- // Finish the fragment.
- if (requestCode == REQUEST_CODE_BONDED_DEVICE && resultCode == RESULT_OK) {
- mFragment.finish();
- }
- return false;
- }
-
@VisibleForTesting
- void launchBluetoothPairingDetail() {
+ void launchConnectedDevicePage() {
new SubSettingLauncher(mContext)
- .setDestination(BluetoothPairingDetail.class.getName())
+ .setDestination(ConnectedDeviceDashboardFragment.class.getName())
.setSourceMetricsCategory(mFragment.getMetricsCategory())
- .setResultListener(mFragment, REQUEST_CODE_BONDED_DEVICE)
.launch();
}
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePairingDetailBase.java b/src/com/android/settings/bluetooth/BluetoothDevicePairingDetailBase.java
index 67c32ed..d71328e 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePairingDetailBase.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePairingDetailBase.java
@@ -16,7 +16,6 @@
package com.android.settings.bluetooth;
-import static android.app.Activity.RESULT_OK;
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
import android.bluetooth.BluetoothAdapter;
@@ -94,7 +93,6 @@
public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
if (bondState == BluetoothDevice.BOND_BONDED) {
// If one device is connected(bonded), then close this fragment.
- setResult(RESULT_OK);
finish();
return;
} else if (bondState == BluetoothDevice.BOND_BONDING) {
@@ -126,7 +124,6 @@
if (cachedDevice != null && cachedDevice.isConnected()) {
final BluetoothDevice device = cachedDevice.getDevice();
if (device != null && mSelectedList.contains(device)) {
- setResult(RESULT_OK);
finish();
} else {
onDeviceDeleted(cachedDevice);
diff --git a/tests/robotests/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceControllerTest.java
index 6c9fbfc..1f9fbeb 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceControllerTest.java
@@ -74,13 +74,13 @@
}
@Test
- public void handlePreferenceTreeClick_expectedPreference_launchBluetoothPairingDetail() {
- doNothing().when(mController).launchBluetoothPairingDetail();
+ public void handlePreferenceTreeClick_expectedPreference_launchConnectedDevicePage() {
+ doNothing().when(mController).launchConnectedDevicePage();
mPreference.setKey(TEST_KEY);
boolean status = mController.handlePreferenceTreeClick(mPreference);
- verify(mController).launchBluetoothPairingDetail();
+ verify(mController).launchConnectedDevicePage();
assertThat(status).isTrue();
}
}