From d2fb98006054f94753d8c58cf6a809840964db2e Mon Sep 17 00:00:00 2001 From: johnwang Date: Wed, 29 Jul 2009 23:30:20 -0700 Subject: [PATCH] Represent SID/NID in decimal format. Interpret SID/NID ad decimal and add try/catch block to prevent crashing in wrong format. Update SID/NID comments. modified: java/com/android/internal/telephony/CommandsInterface.java modified: java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java --- .../internal/telephony/CommandsInterface.java | 6 ++++-- .../telephony/cdma/CdmaServiceStateTracker.java | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/telephony/java/com/android/internal/telephony/CommandsInterface.java b/telephony/java/com/android/internal/telephony/CommandsInterface.java index ebdac4ec4253a..c52fe0620dae7 100644 --- a/telephony/java/com/android/internal/telephony/CommandsInterface.java +++ b/telephony/java/com/android/internal/telephony/CommandsInterface.java @@ -1225,8 +1225,10 @@ public interface CommandsInterface { * Request the device MDN / H_SID / H_NID / MIN. * "response" is const char ** * [0] is MDN if CDMA subscription is available - * [1] is H_SID (Home SID) in hexadecimal if CDMA subscription is available - * [2] is H_NID (Home NID) in hexadecimal if CDMA subscription is available + * [1] is a comma separated list of H_SID (Home SID) in decimal format + * if CDMA subscription is available + * [2] is a comma separated list of H_NID (Home NID) in decimal format + * if CDMA subscription is available * [3] is MIN (10 digits, MIN2+MIN1) if CDMA subscription is available */ public void getCDMASubscription(Message response); diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java index 6356473ea9f72..0cae60466ce9f 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java @@ -401,11 +401,19 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { // TODO: Only grabbing the first SID/NID for now. if (cdmaSubscription[1] != null) { String[] sid = cdmaSubscription[1].split(","); - mHomeSystemId = sid.length > 0 ? Integer.parseInt(sid[0], 16) : 0; + try { + mHomeSystemId = sid.length > 0 ? Integer.parseInt(sid[0]) : 0; + } catch (NumberFormatException e) { + mHomeSystemId = 0; + } } if (cdmaSubscription[2] != null) { String[] nid = cdmaSubscription[2].split(","); - mHomeNetworkId = nid.length > 0 ? Integer.parseInt(nid[0], 16) : 0; + try { + mHomeNetworkId = nid.length > 0 ? Integer.parseInt(nid[0]) : 0; + } catch (NumberFormatException e) { + mHomeNetworkId = 0; + } } mMin = cdmaSubscription[3]; mPrlVersion = cdmaSubscription[4];