OSDN Git Service

Fix Bluetooth device details crash on screen rotation
authorAntony Sargent <asargent@google.com>
Thu, 29 Jun 2017 22:32:12 +0000 (15:32 -0700)
committerAntony Sargent <asargent@google.com>
Fri, 30 Jun 2017 23:34:40 +0000 (16:34 -0700)
commit1b6e7d76edd992715e87767199991f92d8f3a084
treef20ef71ae5b186614067047bd8960d76746bdd1a
parent4e34839a1e988f4dd8948071367c8f12c9a37b1e
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
src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
src/com/android/settings/bluetooth/BluetoothDetailsMacAddressController.java
src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
tests/app/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java [new file with mode: 0644]
tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java
tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java