From 1b6e7d76edd992715e87767199991f92d8f3a084 Mon Sep 17 00:00:00 2001 From: Antony Sargent Date: Thu, 29 Jun 2017 15:32:12 -0700 Subject: [PATCH] Fix Bluetooth device details crash on screen rotation We were getting the following exception when you rotated the Bluetooth device details screen: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.SubSettings}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set android:windowActionBar to false in your theme to use a Toolbar instead. It turns out that allowing EntityHeaderController to inflate the settings_entity_header.xml view seems to cause this - if you instead manually include a LayoutPreference and hand that to EntityHeaderController, you don't have the problem. The rotation failure couldn't be tested with Robolectric because our version doesn't support using FragmentTestUtil.startFragment for fragments which use PreferenceScreen's ("sorry, not yet implemented"). So instead this includes an app test. Bug: 62447414 Test: runtest --path=BluetoothDeviceDetailsRotationTest.java Change-Id: I8d052d1f4ab6e2b0ca5c0e513ec366bdcc382d99 --- res/xml/bluetooth_device_details_fragment.xml | 5 + .../BluetoothDetailsHeaderController.java | 11 ++- .../BluetoothDetailsMacAddressController.java | 2 +- .../BluetoothDeviceDetailsFragment.java | 22 +++++ .../BluetoothDeviceDetailsRotationTest.java | 99 +++++++++++++++++++ .../BluetoothDetailsControllerTestBase.java | 3 +- .../BluetoothDetailsHeaderControllerTest.java | 8 +- .../BluetoothDeviceDetailsFragmentTest.java | 2 +- .../RemoteDeviceNameDialogFragmentTest.java | 2 +- 9 files changed, 142 insertions(+), 12 deletions(-) create mode 100644 tests/app/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java diff --git a/res/xml/bluetooth_device_details_fragment.xml b/res/xml/bluetooth_device_details_fragment.xml index 098daaa35f4..952ec1a27c5 100644 --- a/res/xml/bluetooth_device_details_fragment.xml +++ b/res/xml/bluetooth_device_details_fragment.xml @@ -18,6 +18,11 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:title="@string/bluetooth_device_advanced_title"> + +