OSDN Git Service

Fix PhysicalKeyboardFragment crash bug.
authorYohei Yukawa <yukawa@google.com>
Fri, 1 Apr 2016 10:53:34 +0000 (03:53 -0700)
committerYohei Yukawa <yukawa@google.com>
Fri, 1 Apr 2016 11:38:25 +0000 (11:38 +0000)
commit1dff385c16a704d01ed5decf4270a63573e69028
treee4c5936a163886b4d161865f76f60e88231ef28e
parenta2dda4122bb73f49fcd118a712c1aa61a303c11b
Fix PhysicalKeyboardFragment crash bug.

The root cause of crash bug #27749932 is that the state mismatch between
when a Loader is created and when the Loader object finishes background
task.  We can easily reproduce this crash by:
  1. Pair two hardware keyboard A and B.
  2. Open Physical Keyboard settings.
  3. Press the power button to turn off the display.
  4. Move keyboard A far away so that it is unpaired.
  5. Press the power button to turn on the display.
  6. Unlock the device.

One of the reasons PhysicalKeyboardFragment was unstable is that loader
ID reuse.  PhysicalKeyboardFragment starts background data loading
because of many events such as #onResume() and #onInputDeviceAdded() but
there are chances that loader ID was reused because we specified
hardware keyboard device index as the loader ID.  This was dangerous
also because device index can change when a device is added and removed.
With his CL each loader object has an unique ID and
PhysicalKeyboardFragment keeps tracking the list of active Loader IDs
only from which PhysicalKeyboardFragment should accept data.

Also, this CL removes dependencies on PhysicalKeyboardFragment from each
loader object so that we can have a clear boundary of responsibility
between data loader and data consumer.

Bug: 27749932
Change-Id: I53fcb2426d028a492c775bb2b4ec6a5419e33bb4
src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java