From 4a2b4a87d7f715e763d96543222faa134363a0f2 Mon Sep 17 00:00:00 2001 From: Angela Wang Date: Tue, 27 Feb 2024 06:25:43 +0000 Subject: [PATCH] Redirects to connected devices page in a11y pairing page With UX flow change, clicking "View more devices" button will redirect to connected devices page rather than connected device pairing page. Bug: 321840161 Test: atest ViewAllBluetoothDevicesPreferenceControllerTest Change-Id: Icfc03a463e2aaaf3db3c75524c112028b1fd6655 --- ...lBluetoothDevicesPreferenceController.java | 31 ++++--------------- .../BluetoothDevicePairingDetailBase.java | 3 -- ...etoothDevicesPreferenceControllerTest.java | 6 ++-- 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceController.java b/src/com/android/settings/accessibility/ViewAllBluetoothDevicesPreferenceController.java index 213cfbd8099..622d5d8d3c4 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 @@ public class ViewAllBluetoothDevicesPreferenceController extends BasePreferenceC @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 67c32ed5da1..d71328eed3e 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 abstract class BluetoothDevicePairingDetailBase extends DeviceListPrefere 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 @@ public abstract class BluetoothDevicePairingDetailBase extends DeviceListPrefere 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 6c9fbfc1f8c..1f9fbeb36aa 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 @@ public class ViewAllBluetoothDevicesPreferenceControllerTest { } @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(); } }