From 923e186f97b3aeb67f4ddbb686e7c92336a7a4ef Mon Sep 17 00:00:00 2001 From: twyen Date: Thu, 25 Jan 2018 15:09:19 -0800 Subject: Prevent VvmNetworkRequestCallback from releasing twice It is unclear from the docs or implementation what callbacks are invoked when the network is lost, or does the system release the callback for us somewhere else. In this CL VvmNetworkRequestCallback.releaseNetwork() will be guarded from calling twice, and log levels for callbacks are raised. Bug: 64243619 Test: N/A, repro steps unknown. PiperOrigin-RevId: 183298754 Change-Id: I5e589b2b59478b270890056fa08abb306ee1600c --- .../voicemail/impl/sync/VvmNetworkRequestCallback.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'java/com/android/voicemail/impl') diff --git a/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java b/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java index 60ba166ba..c0ab6788e 100644 --- a/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java +++ b/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java @@ -56,6 +56,7 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw private final VoicemailStatus.Editor status; private boolean requestSent = false; private boolean resultReceived = false; + private boolean released = false; public VvmNetworkRequestCallback( Context context, PhoneAccountHandle phoneAccount, VoicemailStatus.Editor status) { @@ -112,7 +113,7 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw @Override @CallSuper public void onLost(Network network) { - VvmLog.d(TAG, "onLost"); + VvmLog.i(TAG, "onLost"); resultReceived = true; onFailed(NETWORK_REQUEST_FAILED_LOST); } @@ -126,7 +127,7 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw @CallSuper public void onUnavailable() { - // TODO(twyen): a bug this is hidden, do we really need this? + VvmLog.i(TAG, "onUnavailable"); resultReceived = true; onFailed(NETWORK_REQUEST_FAILED_TIMEOUT); } @@ -156,8 +157,13 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw } public void releaseNetwork() { - VvmLog.d(TAG, "releaseNetwork"); - getConnectivityManager().unregisterNetworkCallback(this); + VvmLog.i(TAG, "releaseNetwork"); + if (!released) { + getConnectivityManager().unregisterNetworkCallback(this); + released = true; + } else { + VvmLog.w(TAG, "already released"); + } } public ConnectivityManager getConnectivityManager() { @@ -170,7 +176,7 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw @CallSuper public void onFailed(String reason) { - VvmLog.d(TAG, "onFailed: " + reason); + VvmLog.i(TAG, "onFailed: " + reason); if (carrierConfigHelper.isCellularDataRequired()) { carrierConfigHelper.handleEvent(status, OmtpEvents.DATA_NO_CONNECTION_CELLULAR_REQUIRED); } else { -- cgit v1.2.3