From b2bf3350a2c83b1eba43ae85ed1aa5bc59a59897 Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Wed, 25 Jan 2012 12:42:51 -0800 Subject: [PATCH] Fix ClassCastException In "Change I95ed2aae: Stop using shared DUN APN when tethering stops", sha1: 8beff9586ff89a1e59469e9820fd9e9d704300d2, an assumption is made that the msg.obj is always an ApnContext, this is not true for CDMA. Eventually we plan on removing the destinction between GSM and CDMA but for now we need to handle it handle it. Bug: 5904734 Change-Id: I86873dc7aeda5234c14a6fe1e4ec7345ee30e957 --- .../java/com/android/internal/telephony/DataConnection.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/telephony/java/com/android/internal/telephony/DataConnection.java b/telephony/java/com/android/internal/telephony/DataConnection.java index 1336818661a5d..d0e304fc1a794 100644 --- a/telephony/java/com/android/internal/telephony/DataConnection.java +++ b/telephony/java/com/android/internal/telephony/DataConnection.java @@ -328,8 +328,11 @@ public abstract class DataConnection extends StateMachine { String reason = null; if (dp.onCompletedMsg != null) { + // Get ApnContext, but only valid on GSM devices this is a string on CDMA devices. Message msg = dp.onCompletedMsg; - alreadySent = (ApnContext)msg.obj; + if (msg.obj instanceof ApnContext) { + alreadySent = (ApnContext)msg.obj; + } reason = dp.reason; if (VDBG) { log(String.format("msg=%s msg.obj=%s", msg.toString(),