From 32310ee560d7a700fb1d910666eaaf096d84b643 Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Thu, 12 Apr 2012 23:34:38 +0100 Subject: [PATCH] RadioInfo: Update the network type listing The dropdown for the preferred type in the INFO menu is outdated. ril.h and RILConstants now go up to type 11, due to the addition of the LTE combinations. If a device has one of these new types set up as the default, going into this menu causes a crash for com.android.phone, since it attempts to use array position "type" without verifying if it is that long. Change-Id: I0bf4bb70e21aef79f22e7258c8154e3ec569a215 --- src/com/android/settings/RadioInfo.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java index aa3f2e974e1..2055af01ef1 100644 --- a/src/com/android/settings/RadioInfo.java +++ b/src/com/android/settings/RadioInfo.java @@ -193,9 +193,14 @@ public class RadioInfo extends Activity { ar= (AsyncResult) msg.obj; if (ar.exception == null) { int type = ((int[])ar.result)[0]; + if (type >= mPreferredNetworkLabels.length) { + Log.e(TAG, "[RadioInfo] EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " + + "type=" + type); + type = mPreferredNetworkLabels.length - 1; + } preferredNetworkType.setSelection(type, true); } else { - preferredNetworkType.setSelection(8, true); + preferredNetworkType.setSelection(mPreferredNetworkLabels.length - 1, true); } break; case EVENT_SET_PREFERRED_TYPE_DONE: @@ -1009,7 +1014,7 @@ public class RadioInfo extends Activity { mPreferredNetworkHandler = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View v, int pos, long id) { Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE); - if (pos>=0 && pos<=7) { //IS THIS NEEDED to extend to the entire range of values + if (pos>=0 && pos<=(mPreferredNetworkLabels.length - 2)) { phone.setPreferredNetworkType(pos, msg); } } @@ -1027,5 +1032,9 @@ public class RadioInfo extends Activity { "CDMA only", "EvDo only", "GSM/CDMA auto (PRL)", + "LTE/CDMA auto (PRL)", + "LTE/GSM auto (PRL)", + "LTE/GSM/CDMA auto (PRL)", + "LTE only", "Unknown"}; }