From db18cdae661b87ff2de3847947906da735f8d5eb Mon Sep 17 00:00:00 2001 From: yinxu Date: Mon, 12 Mar 2018 14:07:49 -0700 Subject: Fix a bug when calling onError(int) The lambda expression is executed on executor, so it is possible that the message has been updated. The correct way is to fetch the message.arg1 and use that value in the lamda expression. Bug:73750871 Test: Unit Test Change-Id: Id13f5fabf7eaad6970ab66a83a17aba7f1eebfce --- telephony/java/android/telephony/TelephonyScanManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telephony/java/android/telephony/TelephonyScanManager.java b/telephony/java/android/telephony/TelephonyScanManager.java index 946cecfa261c..99e2db883e52 100644 --- a/telephony/java/android/telephony/TelephonyScanManager.java +++ b/telephony/java/android/telephony/TelephonyScanManager.java @@ -145,7 +145,8 @@ public final class TelephonyScanManager { break; case CALLBACK_SCAN_ERROR: try { - executor.execute(() -> callback.onError(message.arg1)); + final int errorCode = message.arg1; + executor.execute(() -> callback.onError(errorCode)); } catch (Exception e) { Rlog.e(TAG, "Exception in networkscan callback onError", e); } -- cgit v1.2.3-59-g8ed1b