We should tell the app that it is inactive, before unbinding. Otherwise when it is told to unbind it will see that it is still supposed to be active and immediately re-bind. Also change the calls to set the active state to go through the message dispatch path, to ensure ordering is correct. Change-Id: I246241eac8f7521f42c4c1eee7f46097337e7303