Move SmartReplyView inflation off the UI thread.
To avoid blocking the UI thread we here move the inflation of SmartReplyView and its smart suggestion buttons off the UI thread. We move these inflations into NotificationContentInflater where they are performed before the inflations of other notification content views - reusing the existing AsyncTask to run these inflations on a background thread. More specifically: for both the expanded state and the heads-up state of a notification we 1. inflate a SmartReplyView, 2. inflate the buttons within that view (reply buttons and action buttons), and 3. create a SmartRepliesAndActions object from the AsyncTask (on a background thread). We then pass these objects back to the UI thread where we attach them to the view hierarchy or use them to make certain decisions. In terms of thread-safety the background thread reads constants from SmartReplyConstants so that class must be thread-safe (at least so that the background thread doesn't store a local copy of the constants). We also pass a SmartReplyController reference on the background thread, that reference is only used on the UI thread (in onClick listeners). Bug:119801785 Test: post message notification containing smart replies and actions. Post both heads-up and notification shade notifications. Click on replies and actions. Ensure the smart-buttons are updated when a notification is updated. Change-Id: I4698a6895cf65c46461cc429b2b6eb5905acb629
Loading
Please register or sign in to comment