diff options
author | Felipe Leme <felipeal@google.com> | 2016-02-26 00:32:27 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-02-26 00:32:29 +0000 |
commit | 17fc60e13c2a3b78c0f613d46355e23664fd69f3 (patch) | |
tree | 85d721d664c5fe1d58df9c1cf6c931259ebaf5f7 /packages/Shell/src | |
parent | 594e131160d191a76f2f183e46d434e55a6f1eac (diff) | |
parent | 8648a15406d43c8af12e9cfe2355b1eee201d479 (diff) |
Merge "Using Message.obtain() to decrease number of Messages allocated." into nyc-dev
Diffstat (limited to 'packages/Shell/src')
-rw-r--r-- | packages/Shell/src/com/android/shell/BugreportProgressService.java | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 85d127c833bf..587fd6cb7a83 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -149,6 +149,9 @@ public class BugreportProgressService extends Service { private static final int MSG_SCREENSHOT_REQUEST = 4; private static final int MSG_SCREENSHOT_RESPONSE = 5; + // Passed to Message.obtain() when msg.arg2 is not used. + private static final int UNUSED_ARG2 = -2; + /** * Delay before a screenshot is taken. * <p> @@ -664,11 +667,8 @@ public class BugreportProgressService extends Service { final String screenshotPath = new File(mScreenshotsDir, info.getPathNextScreenshot()).getAbsolutePath(); - final Message requestMsg = new Message(); - requestMsg.what = MSG_SCREENSHOT_REQUEST; - requestMsg.arg1 = id; - requestMsg.obj = screenshotPath; - mScreenshotHandler.sendMessage(requestMsg); + Message.obtain(mScreenshotHandler, MSG_SCREENSHOT_REQUEST, id, UNUSED_ARG2, screenshotPath) + .sendToTarget(); } /** @@ -694,12 +694,8 @@ public class BugreportProgressService extends Service { boolean taken = takeScreenshot(mContext, screenshotFile); setTakingScreenshot(false); - final Message resultMsg = new Message(); - resultMsg.what = MSG_SCREENSHOT_RESPONSE; - resultMsg.arg1 = requestMsg.arg1; - resultMsg.arg2 = taken ? 1 : 0; - resultMsg.obj = screenshotFile; - mMainHandler.sendMessage(resultMsg); + Message.obtain(mMainHandler, MSG_SCREENSHOT_RESPONSE, requestMsg.arg1, taken ? 1 : 0, + screenshotFile).sendToTarget(); } private void handleScreenshotResponse(Message resultMsg) { |