OSDN Git Service

Merge change 9502 into donut
authorAndroid (Google) Code Review <android-gerrit@google.com>
Mon, 3 Aug 2009 18:52:25 +0000 (11:52 -0700)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Mon, 3 Aug 2009 18:52:25 +0000 (11:52 -0700)
commita7bd021f95a1773507d31a79ddb904ddfecfefae
tree21cbb81190f7b6da992c63768acfb0fe083a96ca
parente72de3ab19b6227fee51173febee91252b66c78b
parent740dfb83a8f7be0e10782497c6d67991cdd589c9
Merge change 9502 into donut

* changes:
  Fix bug 2025765. Talkback produced a null pointer exception when being enabled and disabled repeatedly due to a race condition between the onDestroy() of the service, and the use of the service itself. The error occurs when one Talkback thread initiates the destruction of the service (call to onDestroy()) when it invokes shutdown() on its TextToSpeech instance (the client of the service). At the same time, Talkback tries to say that "Accessibility" is unchecked from another thread. During onDestroy(), the reference to the TTS engine (sNativeSynth) is reset to null, which is used in the service in speakInternalOnly(), and setLanguage(). The fix consists in the addition of a static variable that signals that the service has entered onDestroy(). Once this flag is set, all method invocations on sNativeSynth will be dismissed. Note that access to the native resources used by sNativeSynth are synchronized at the native layer, therefore preventing sNativeSynth.shutdown() to interfere with a sNativeSynth.speak() call already underway.