Merge "Finish bluetooth detail fragment if device is BOND_NONE"

This commit is contained in:
TreeHugger Robot
2019-12-27 03:03:49 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.bluetooth;
import static android.bluetooth.BluetoothDevice.BOND_NONE;
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
import android.app.settings.SettingsEnums;
@@ -127,6 +128,20 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
: null);
}
@Override
public void onResume() {
super.onResume();
finishFragmentIfNecessary();
}
@VisibleForTesting
void finishFragmentIfNecessary() {
if (mCachedDevice.getBondState() == BOND_NONE) {
finish();
return;
}
}
@Override
public int getMetricsCategory() {
return SettingsEnums.BLUETOOTH_DEVICE_DETAILS;

View File

@@ -16,6 +16,8 @@
package com.android.settings.bluetooth;
import static android.bluetooth.BluetoothDevice.BOND_NONE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -126,4 +128,13 @@ public class BluetoothDeviceDetailsFragmentTest {
RemoteDeviceNameDialogFragment dialog = (RemoteDeviceNameDialogFragment) captor.getValue();
assertThat(dialog).isNotNull();
}
@Test
public void finishFragmentIfNecessary_deviceIsBondNone_finishFragment() {
when(mCachedDevice.getBondState()).thenReturn(BOND_NONE);
mFragment.finishFragmentIfNecessary();
verify(mFragment).finish();
}
}