[Nexus 4 Android Development] bigxie:
Serious_Beans,

Thanks for your findings! It really helped me out while I was investigating this tonight. I found some interesting results, and I figured out why adding a string to the BAND_NAMES array fixed the FC.

What's going on here is when we hit the 'select radio band' option, the radio is queried to see which bands are supported. In the case of the N4, there's 3 modes supported. The reply can be seen using adb logcat -b radio:

D/RILJ ( 810): [4137]> QUERY_AVAILABLE_BAND_MODE
D/RILJ ( 810): [4137]< QUERY_AVAILABLE_BAND_MODE {3, 2, 6, 7}

Once it knows the modes, it needs to draw the list of selections, but FC's when trying to access BAND_NAMES[6], since it's not defined up top (index 6 refers to the 7th element in the array, which is out of bounds). So adding a string fixes it and allows the list to draw.

But I did some further investigation, since there's another mode (7), which it never gets to! It turns out that a for loop is run to catch all the modes, and the number of times it loops is defined by the "size", which is the first element of the array (3, in this case). But the loop only runs 2 times since the condition is while i<size, and i starts at 1. Changing it to i<=size allows it to catch the last frequency mode (7).

But, then, what do modes 6 and 7 mean? For that, I looked in /hardware/ril/include/telephony/ril.h

/**
* RIL_REQUEST_SET_BAND_MODE
*
* Assign a specified band for RF configuration.
*
* "data" is int *
* ((int *)data)[0] is == 0 for "unspecified" (selected by baseband automatically)
* ((int *)data)[0] is == 1 for "EURO band" (GSM-900 / DCS-1800 / WCDMA-IMT-2000)
* ((int *)data)[0] is == 2 for "US band" (GSM-850 / PCS-1900 / WCDMA-850 / WCDMA-PCS-1900)
* ((int *)data)[0] is == 3 for "JPN band" (WCDMA-800 / WCDMA-IMT-2000)
* ((int *)data)[0] is == 4 for "AUS band" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000)
* ((int *)data)[0] is == 5 for "AUS band 2" (GSM-900 / DCS-1800 / WCDMA-850)
* ((int *)data)[0] is == 6 for "Cellular (800-MHz Band)"
* ((int *)data)[0] is == 7 for "PCS (1900-MHz Band)"
* ((int *)data)[0] is == 8 for "Band Class 3 (JTACS Band)"
* ((int *)data)[0] is == 9 for "Band Class 4 (Korean PCS Band)"
* ((int *)data)[0] is == 10 for "Band Class 5 (450-MHz Band)"
* ((int *)data)[0] is == 11 for "Band Class 6 (2-GMHz IMT2000 Band)"
* ((int *)data)[0] is == 12 for "Band Class 7 (Upper 700-MHz Band)"
* ((int *)data)[0] is == 13 for "Band Class 8 (1800-MHz Band)"
* ((int *)data)[0] is == 14 for "Band Class 9 (900-MHz Band)"
* ((int *)data)[0] is == 15 for "Band Class 10 (Secondary 800-MHz Band)"
* ((int *)data)[0] is == 16 for "Band Class 11 (400-MHz European PAMR Band)"
* ((int *)data)[0] is == 17 for "Band Class 15 (AWS Band)"
* ((int *)data)[0] is == 18 for "Band Class 16 (US 2.5-GHz Band)"
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* GENERIC_FAILURE
*/

So I added their meanings to the BAND_NAMES array and compiled, and voila, the list is working and all the options are listed too.

I attached my BandMode.java file if anyone wants to look it over. I commented on the debugging stuff I put in there to figure out the array values and why the for loop was incorrect.

Also, I'm not sure if what I did will break this feature on any other devices, since I don't know if the output of their QUERY_AVAILABLE_BAND_MODE will behave the same as the N4 (size, mode 1, mode 2, etc...).

And finally, I find it strange that Google only defined the first 6 elements of the BAND_NAMES array in AOSP. Our N4 goes up to mode 7, what if other devices go even higher?

Any thoughts are appreciated. It's a bit late at night and I may not be thinking of everything or made a mistake. I did test the USA bands option, since I knew of some 1900MHz towers in town, and it was working. I did not test Cellular and PCS since I didn't make those fixes until after I got back home.

Thanks!