diff --git a/res/layout/bluetooth_key_missing.xml b/res/layout/bluetooth_key_missing.xml index b9f8d866bd3..0cb60508907 100644 --- a/res/layout/bluetooth_key_missing.xml +++ b/res/layout/bluetooth_key_missing.xml @@ -29,7 +29,6 @@ android:paddingEnd="24dp"> diff --git a/res/values/strings.xml b/res/values/strings.xml index db9c302edca..2528f36a6c4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2088,13 +2088,17 @@ Change - %1$s not connected + Can’t connect %1$s - For your security, forget this device, then pair it again + For more details, go to device settings Forget device Cancel + + Device settings + + Close Device details @@ -2124,6 +2128,8 @@ Battery Battery, charging + + Try restarting %1$s. If that doesn’t work, forget the device. For your security, only pair it again when you aren’t in a public space.\n\nIf this device isn’t nearby, you don’t need to do anything. diff --git a/src/com/android/settings/bluetooth/BluetoothKeyMissingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothKeyMissingDialogFragment.java index 342af34338e..671e282c338 100644 --- a/src/com/android/settings/bluetooth/BluetoothKeyMissingDialogFragment.java +++ b/src/com/android/settings/bluetooth/BluetoothKeyMissingDialogFragment.java @@ -30,17 +30,18 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import com.android.settings.R; +import com.android.settings.core.SubSettingLauncher; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; import com.android.settingslib.bluetooth.LocalBluetoothManager; /** - * A dialogFragment used by {@link BluetoothKeyMissingDialog} to create a dialog for the - * bluetooth device. + * A dialogFragment used by {@link BluetoothKeyMissingDialog} to create a dialog for the bluetooth + * device. */ public class BluetoothKeyMissingDialogFragment extends InstrumentedDialogFragment implements OnClickListener { - private static final String TAG = "BTKeyMissingDialogFragment"; + private static final String TAG = "BTKeyMissingDialogFrg"; private static final String KEY_CACHED_DEVICE_ADDRESS = "cached_device"; private BluetoothDevice mBluetoothDevice; @@ -67,8 +68,8 @@ public class BluetoothKeyMissingDialogFragment extends InstrumentedDialogFragmen keyMissingTitle.setText( getString(R.string.bluetooth_key_missing_title, mBluetoothDevice.getName())); builder.setView(view); - builder.setPositiveButton(getString(R.string.bluetooth_key_missing_forget), this); - builder.setNegativeButton(getString(R.string.bluetooth_key_missing_cancel), this); + builder.setPositiveButton(getString(R.string.bluetooth_key_missing_device_settings), this); + builder.setNegativeButton(getString(R.string.bluetooth_key_missing_close), this); AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); return dialog; @@ -85,11 +86,18 @@ public class BluetoothKeyMissingDialogFragment extends InstrumentedDialogFragmen @Override public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { - Log.i( - TAG, - "Positive button clicked, remove bond for " - + mBluetoothDevice.getAnonymizedAddress()); - mBluetoothDevice.removeBond(); + Log.i(TAG, "Positive button clicked for " + mBluetoothDevice.getAnonymizedAddress()); + Bundle args = new Bundle(); + args.putString( + BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS, + mBluetoothDevice.getAddress()); + + new SubSettingLauncher(requireContext()) + .setDestination(BluetoothDeviceDetailsFragment.class.getName()) + .setArguments(args) + .setTitleRes(R.string.device_details_title) + .setSourceMetricsCategory(getMetricsCategory()) + .launch(); } else if (which == DialogInterface.BUTTON_NEGATIVE) { Log.i(TAG, "Negative button clicked for " + mBluetoothDevice.getAnonymizedAddress()); } diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothKeyMissingDialogTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothKeyMissingDialogTest.java index 14e263c0fb2..a2bf43a9fdd 100644 --- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothKeyMissingDialogTest.java +++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothKeyMissingDialogTest.java @@ -17,16 +17,18 @@ package com.android.settings.bluetooth; import static com.google.common.truth.Truth.assertThat; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.robolectric.Shadows.shadowOf; import static org.robolectric.shadows.ShadowLooper.shadowMainLooper; import android.bluetooth.BluetoothDevice; +import android.content.Intent; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.FragmentActivity; +import com.android.settings.SettingsActivity; +import com.android.settings.SubSettings; import com.android.settings.testutils.shadow.ShadowAlertDialogCompat; import com.android.settings.testutils.shadow.ShadowBluetoothUtils; import com.android.settingslib.bluetooth.LocalBluetoothManager; @@ -40,6 +42,7 @@ import org.mockito.MockitoAnnotations; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.shadows.ShadowIntent; @RunWith(RobolectricTestRunner.class) @Config(shadows = {ShadowAlertDialogCompat.class, ShadowBluetoothUtils.class}) @@ -71,18 +74,23 @@ public class BluetoothKeyMissingDialogTest { } @Test - public void clickForgetDevice_removeBond() { + public void clickDeviceSettings_launchDeviceDetails() { mFragment.onClick(mFragment.getDialog(), AlertDialog.BUTTON_POSITIVE); - verify(mBluetoothDevice).removeBond(); + Intent startedIntent = shadowOf(mActivity).getNextStartedActivity(); + ShadowIntent shadowIntent = shadowOf(startedIntent); + assertThat(shadowIntent.getIntentClass()).isEqualTo(SubSettings.class); + assertThat(startedIntent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)) + .isEqualTo(BluetoothDeviceDetailsFragment.class.getName()); assertThat(mActivity.isFinishing()).isTrue(); } @Test - public void clickCancel_notRemoveBond() { + public void clickCancel_notLaunchDeviceDetails() { mFragment.onClick(mFragment.getDialog(), AlertDialog.BUTTON_NEGATIVE); - verify(mBluetoothDevice, never()).removeBond(); + Intent startedIntent = shadowOf(mActivity).getNextStartedActivity(); + assertThat(startedIntent).isNull(); assertThat(mActivity.isFinishing()).isTrue(); } }