1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
|
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.internal.telephony;
import static com.android.internal.telephony.RILConstants.*;
import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN;
import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE;
import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS;
import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS;
import static android.telephony.TelephonyManager.NETWORK_TYPE_HSDPA;
import static android.telephony.TelephonyManager.NETWORK_TYPE_HSUPA;
import static android.telephony.TelephonyManager.NETWORK_TYPE_HSPA;
import static android.telephony.TelephonyManager.NETWORK_TYPE_HSPAP;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.LocalSocket;
import android.net.LocalSocketAddress;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.Parcel;
import android.os.PowerManager;
import android.os.SystemProperties;
import android.os.PowerManager.WakeLock;
import android.telephony.NeighboringCellInfo;
import android.telephony.PhoneNumberUtils;
import android.telephony.SignalStrength;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.text.TextUtils;
import android.util.Log;
import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.IccCardApplicationStatus;
import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
import com.android.internal.telephony.cdma.CdmaInformationRecords;
import com.android.internal.telephony.IccRefreshResponse;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* {@hide}
*/
class RILRequest {
static final String LOG_TAG = "RILJ";
//***** Class Variables
static int sNextSerial = 0;
static Object sSerialMonitor = new Object();
private static Object sPoolSync = new Object();
private static RILRequest sPool = null;
private static int sPoolSize = 0;
private static final int MAX_POOL_SIZE = 4;
//***** Instance Variables
int mSerial;
int mRequest;
long creationTime;
Message mResult;
Parcel mp;
RILRequest mNext;
/**
* Retrieves a new RILRequest instance from the pool.
*
* @param request RIL_REQUEST_*
* @param result sent when operation completes
* @return a RILRequest instance from the pool.
*/
static RILRequest obtain(int request, Message result) {
RILRequest rr = null;
synchronized(sPoolSync) {
if (sPool != null) {
rr = sPool;
sPool = rr.mNext;
rr.mNext = null;
sPoolSize--;
}
}
if (rr == null) {
rr = new RILRequest();
}
synchronized(sSerialMonitor) {
rr.mSerial = sNextSerial++;
}
rr.mRequest = request;
rr.mResult = result;
rr.creationTime = System.currentTimeMillis();
rr.mp = Parcel.obtain();
if (result != null && result.getTarget() == null) {
throw new NullPointerException("Message target must not be null");
}
// first elements in any RIL Parcel
rr.mp.writeInt(request);
rr.mp.writeInt(rr.mSerial);
return rr;
}
/**
* Returns a RILRequest instance to the pool.
*
* Note: This should only be called once per use.
*/
void release() {
synchronized (sPoolSync) {
if (sPoolSize < MAX_POOL_SIZE) {
this.mNext = sPool;
sPool = this;
sPoolSize++;
mResult = null;
}
}
}
private RILRequest() {
}
static void
resetSerial() {
synchronized(sSerialMonitor) {
sNextSerial = 0;
}
}
String
serialString() {
//Cheesy way to do %04d
StringBuilder sb = new StringBuilder(8);
String sn;
sn = Integer.toString(mSerial);
//sb.append("J[");
sb.append('[');
for (int i = 0, s = sn.length() ; i < 4 - s; i++) {
sb.append('0');
}
sb.append(sn);
sb.append(']');
return sb.toString();
}
void
onError(int error, Object ret) {
CommandException ex;
ex = CommandException.fromRilErrno(error);
if (RIL.RILJ_LOGD) Log.d(LOG_TAG, serialString() + "< "
+ RIL.requestToString(mRequest)
+ " error: " + ex);
if (mResult != null) {
AsyncResult.forMessage(mResult, ret, ex);
mResult.sendToTarget();
}
if (mp != null) {
mp.recycle();
mp = null;
}
}
}
/**
* RIL implementation of the CommandsInterface.
*
* {@hide}
*/
public class RIL extends BaseCommands implements CommandsInterface {
static final String LOG_TAG = "RILJ";
static final boolean RILJ_LOGD = true;
static final boolean RILJ_LOGV = false; // STOP SHIP if true
/**
* Wake lock timeout should be longer than the longest timeout in
* the vendor ril.
*/
private static final int DEFAULT_WAKE_LOCK_TIMEOUT = 60000;
//***** Instance Variables
LocalSocket mSocket;
HandlerThread mSenderThread;
RILSender mSender;
Thread mReceiverThread;
RILReceiver mReceiver;
WakeLock mWakeLock;
int mWakeLockTimeout;
// The number of requests pending to be sent out, it increases before calling
// EVENT_SEND and decreases while handling EVENT_SEND. It gets cleared while
// WAKE_LOCK_TIMEOUT occurs.
int mRequestMessagesPending;
// The number of requests sent out but waiting for response. It increases while
// sending request and decreases while handling response. It should match
// mRequestList.size() unless there are requests no replied while
// WAKE_LOCK_TIMEOUT occurs.
int mRequestMessagesWaiting;
//I'd rather this be LinkedList or something
ArrayList<RILRequest> mRequestsList = new ArrayList<RILRequest>();
Object mLastNITZTimeInfo;
// When we are testing emergency calls
AtomicBoolean mTestingEmergencyCall = new AtomicBoolean(false);
// Number of per-network elements expected in QUERY_AVAILABLE_NETWORKS's response.
// 4 elements is default, but many RILs actually return 5, making it impossible to
// divide the response array without prior knowledge of the number of elements.
protected int mQANElements = 4;
//***** Events
static final int EVENT_SEND = 1;
static final int EVENT_WAKE_LOCK_TIMEOUT = 2;
//***** Constants
// match with constant in ril.cpp
static final int RIL_MAX_COMMAND_BYTES = (8 * 1024);
static final int RESPONSE_SOLICITED = 0;
static final int RESPONSE_UNSOLICITED = 1;
static final String SOCKET_NAME_RIL = "rild";
static final int SOCKET_OPEN_RETRY_MILLIS = 4 * 1000;
// The number of the required config values for broadcast SMS stored in the C struct
// RIL_CDMA_BroadcastServiceInfo
private static final int CDMA_BSI_NO_OF_INTS_STRUCT = 3;
private static final int CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES = 31;
BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
sendScreenState(true);
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
sendScreenState(false);
} else {
Log.w(LOG_TAG, "RIL received unexpected Intent: " + intent.getAction());
}
}
};
class RILSender extends Handler implements Runnable {
public RILSender(Looper looper) {
super(looper);
}
// Only allocated once
byte[] dataLength = new byte[4];
//***** Runnable implementation
public void
run() {
//setup if needed
}
//***** Handler implementation
@Override public void
handleMessage(Message msg) {
RILRequest rr = (RILRequest)(msg.obj);
RILRequest req = null;
switch (msg.what) {
case EVENT_SEND:
/**
* mRequestMessagePending++ already happened for every
* EVENT_SEND, thus we must make sure
* mRequestMessagePending-- happens once and only once
*/
boolean alreadySubtracted = false;
try {
LocalSocket s;
s = mSocket;
if (s == null) {
rr.onError(RADIO_NOT_AVAILABLE, null);
rr.release();
if (mRequestMessagesPending > 0)
mRequestMessagesPending--;
alreadySubtracted = true;
return;
}
synchronized (mRequestsList) {
mRequestsList.add(rr);
mRequestMessagesWaiting++;
}
if (mRequestMessagesPending > 0)
mRequestMessagesPending--;
alreadySubtracted = true;
byte[] data;
data = rr.mp.marshall();
rr.mp.recycle();
rr.mp = null;
if (data.length > RIL_MAX_COMMAND_BYTES) {
throw new RuntimeException(
"Parcel larger than max bytes allowed! "
+ data.length);
}
// parcel length in big endian
dataLength[0] = dataLength[1] = 0;
dataLength[2] = (byte)((data.length >> 8) & 0xff);
dataLength[3] = (byte)((data.length) & 0xff);
//Log.v(LOG_TAG, "writing packet: " + data.length + " bytes");
s.getOutputStream().write(dataLength);
s.getOutputStream().write(data);
} catch (IOException ex) {
Log.e(LOG_TAG, "IOException", ex);
req = findAndRemoveRequestFromList(rr.mSerial);
// make sure this request has not already been handled,
// eg, if RILReceiver cleared the list.
if (req != null || !alreadySubtracted) {
rr.onError(RADIO_NOT_AVAILABLE, null);
rr.release();
}
} catch (RuntimeException exc) {
Log.e(LOG_TAG, "Uncaught exception ", exc);
req = findAndRemoveRequestFromList(rr.mSerial);
// make sure this request has not already been handled,
// eg, if RILReceiver cleared the list.
if (req != null || !alreadySubtracted) {
rr.onError(GENERIC_FAILURE, null);
rr.release();
}
} finally {
// Note: We are "Done" only if there are no outstanding
// requests or replies. Thus this code path will only release
// the wake lock on errors.
releaseWakeLockIfDone();
}
if (!alreadySubtracted && mRequestMessagesPending > 0) {
mRequestMessagesPending--;
}
break;
case EVENT_WAKE_LOCK_TIMEOUT:
// Haven't heard back from the last request. Assume we're
// not getting a response and release the wake lock.
synchronized (mWakeLock) {
if (mWakeLock.isHeld()) {
// The timer of WAKE_LOCK_TIMEOUT is reset with each
// new send request. So when WAKE_LOCK_TIMEOUT occurs
// all requests in mRequestList already waited at
// least DEFAULT_WAKE_LOCK_TIMEOUT but no response.
// Reset mRequestMessagesWaiting to enable
// releaseWakeLockIfDone().
//
// Note: Keep mRequestList so that delayed response
// can still be handled when response finally comes.
if (mRequestMessagesWaiting != 0) {
Log.d(LOG_TAG, "NOTE: mReqWaiting is NOT 0 but"
+ mRequestMessagesWaiting + " at TIMEOUT, reset!"
+ " There still msg waitng for response");
mRequestMessagesWaiting = 0;
if (RILJ_LOGD) {
synchronized (mRequestsList) {
int count = mRequestsList.size();
Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
" mRequestList=" + count);
for (int i = 0; i < count; i++) {
rr = mRequestsList.get(i);
Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] "
+ requestToString(rr.mRequest));
}
}
}
}
// mRequestMessagesPending shows how many
// requests are waiting to be sent (and before
// to be added in request list) since star the
// WAKE_LOCK_TIMEOUT timer. Since WAKE_LOCK_TIMEOUT
// is the expected time to get response, all requests
// should already sent out (i.e.
// mRequestMessagesPending is 0 )while TIMEOUT occurs.
if (mRequestMessagesPending != 0) {
Log.e(LOG_TAG, "ERROR: mReqPending is NOT 0 but"
+ mRequestMessagesPending + " at TIMEOUT, reset!");
mRequestMessagesPending = 0;
}
mWakeLock.release();
}
}
break;
}
}
}
/**
* Reads in a single RIL message off the wire. A RIL message consists
* of a 4-byte little-endian length and a subsequent series of bytes.
* The final message (length header omitted) is read into
* <code>buffer</code> and the length of the final message (less header)
* is returned. A return value of -1 indicates end-of-stream.
*
* @param is non-null; Stream to read from
* @param buffer Buffer to fill in. Must be as large as maximum
* message size, or an ArrayOutOfBounds exception will be thrown.
* @return Length of message less header, or -1 on end of stream.
* @throws IOException
*/
private static int readRilMessage(InputStream is, byte[] buffer)
throws IOException {
int countRead;
int offset;
int remaining;
int messageLength;
// First, read in the length of the message
offset = 0;
remaining = 4;
do {
countRead = is.read(buffer, offset, remaining);
if (countRead < 0 ) {
Log.e(LOG_TAG, "Hit EOS reading message length");
return -1;
}
offset += countRead;
remaining -= countRead;
} while (remaining > 0);
messageLength = ((buffer[0] & 0xff) << 24)
| ((buffer[1] & 0xff) << 16)
| ((buffer[2] & 0xff) << 8)
| (buffer[3] & 0xff);
// Then, re-use the buffer and read in the message itself
offset = 0;
remaining = messageLength;
do {
countRead = is.read(buffer, offset, remaining);
if (countRead < 0 ) {
Log.e(LOG_TAG, "Hit EOS reading message. messageLength=" + messageLength
+ " remaining=" + remaining);
return -1;
}
offset += countRead;
remaining -= countRead;
} while (remaining > 0);
return messageLength;
}
class RILReceiver implements Runnable {
byte[] buffer;
RILReceiver() {
buffer = new byte[RIL_MAX_COMMAND_BYTES];
}
public void
run() {
int retryCount = 0;
try {for (;;) {
LocalSocket s = null;
LocalSocketAddress l;
try {
s = new LocalSocket();
l = new LocalSocketAddress(SOCKET_NAME_RIL,
LocalSocketAddress.Namespace.RESERVED);
s.connect(l);
} catch (IOException ex){
try {
if (s != null) {
s.close();
}
} catch (IOException ex2) {
//ignore failure to close after failure to connect
}
// don't print an error message after the the first time
// or after the 8th time
if (retryCount == 8) {
Log.e (LOG_TAG,
"Couldn't find '" + SOCKET_NAME_RIL
+ "' socket after " + retryCount
+ " times, continuing to retry silently");
} else if (retryCount > 0 && retryCount < 8) {
Log.i (LOG_TAG,
"Couldn't find '" + SOCKET_NAME_RIL
+ "' socket; retrying after timeout");
}
try {
Thread.sleep(SOCKET_OPEN_RETRY_MILLIS);
} catch (InterruptedException er) {
}
retryCount++;
continue;
}
retryCount = 0;
mSocket = s;
Log.i(LOG_TAG, "Connected to '" + SOCKET_NAME_RIL + "' socket");
/* Compatibility with qcom's DSDS (Dual SIM) stack */
if (needsOldRilFeature("qcomdsds")) {
String str = "SUB1";
byte[] data = str.getBytes();
try {
mSocket.getOutputStream().write(data);
Log.i(LOG_TAG, "Data sent!!");
} catch (IOException ex) {
Log.e(LOG_TAG, "IOException", ex);
} catch (RuntimeException exc) {
Log.e(LOG_TAG, "Uncaught exception ", exc);
}
}
int length = 0;
try {
InputStream is = mSocket.getInputStream();
for (;;) {
Parcel p;
length = readRilMessage(is, buffer);
if (length < 0) {
// End-of-stream reached
break;
}
p = Parcel.obtain();
p.unmarshall(buffer, 0, length);
p.setDataPosition(0);
//Log.v(LOG_TAG, "Read packet: " + length + " bytes");
processResponse(p);
p.recycle();
}
} catch (java.io.IOException ex) {
Log.i(LOG_TAG, "'" + SOCKET_NAME_RIL + "' socket closed",
ex);
} catch (Throwable tr) {
Log.e(LOG_TAG, "Uncaught exception read length=" + length +
"Exception:" + tr.toString());
}
Log.i(LOG_TAG, "Disconnected from '" + SOCKET_NAME_RIL
+ "' socket");
setRadioState (RadioState.RADIO_UNAVAILABLE);
try {
mSocket.close();
} catch (IOException ex) {
}
mSocket = null;
RILRequest.resetSerial();
// Clear request list on close
clearRequestsList(RADIO_NOT_AVAILABLE, false);
}} catch (Throwable tr) {
Log.e(LOG_TAG,"Uncaught exception", tr);
}
/* We're disconnected so we don't know the ril version */
notifyRegistrantsRilConnectionChanged(-1);
}
}
//***** Constructors
public RIL(Context context, int preferredNetworkType, int cdmaSubscription) {
super(context);
if (RILJ_LOGD) {
riljLog("RIL(context, preferredNetworkType=" + preferredNetworkType +
" cdmaSubscription=" + cdmaSubscription + ")");
}
mCdmaSubscription = cdmaSubscription;
mPreferredNetworkType = preferredNetworkType;
mSetPreferredNetworkType = preferredNetworkType;
mPhoneType = RILConstants.NO_PHONE;
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOG_TAG);
mWakeLock.setReferenceCounted(false);
mWakeLockTimeout = SystemProperties.getInt(TelephonyProperties.PROPERTY_WAKE_LOCK_TIMEOUT,
DEFAULT_WAKE_LOCK_TIMEOUT);
mRequestMessagesPending = 0;
mRequestMessagesWaiting = 0;
mSenderThread = new HandlerThread("RILSender");
mSenderThread.start();
Looper looper = mSenderThread.getLooper();
mSender = new RILSender(looper);
ConnectivityManager cm = (ConnectivityManager)context.getSystemService(
Context.CONNECTIVITY_SERVICE);
if (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false) {
riljLog("Not starting RILReceiver: wifi-only");
} else {
riljLog("Starting RILReceiver");
mReceiver = new RILReceiver();
mReceiverThread = new Thread(mReceiver, "RILReceiver");
mReceiverThread.start();
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
context.registerReceiver(mIntentReceiver, filter);
}
}
//***** CommandsInterface implementation
@Override public void
getVoiceRadioTechnology(Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_VOICE_RADIO_TECH, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
@Override public void
setOnNITZTime(Handler h, int what, Object obj) {
super.setOnNITZTime(h, what, obj);
// Send the last NITZ time if we have it
if (mLastNITZTimeInfo != null) {
mNITZTimeRegistrant
.notifyRegistrant(
new AsyncResult (null, mLastNITZTimeInfo, null));
mLastNITZTimeInfo = null;
}
}
public void
getIccCardStatus(Message result) {
//Note: This RIL request has not been renamed to ICC,
// but this request is also valid for SIM and RUIM
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_SIM_STATUS, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
@Override public void
supplyIccPin(String pin, Message result) {
supplyIccPinForApp(pin, null, result);
}
@Override public void
supplyIccPinForApp(String pin, String aid, Message result) {
//Note: This RIL request has not been renamed to ICC,
// but this request is also valid for SIM and RUIM
RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PIN, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
boolean oldRil = needsOldRilFeature("facilitylock");
rr.mp.writeInt(oldRil ? 1 : 2);
rr.mp.writeString(pin);
if (!oldRil)
rr.mp.writeString(aid);
send(rr);
}
@Override public void
supplyIccPuk(String puk, String newPin, Message result) {
supplyIccPukForApp(puk, newPin, null, result);
}
@Override public void
supplyIccPukForApp(String puk, String newPin, String aid, Message result) {
//Note: This RIL request has not been renamed to ICC,
// but this request is also valid for SIM and RUIM
RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PUK, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
boolean oldRil = needsOldRilFeature("facilitylock");
rr.mp.writeInt(oldRil ? 2 : 3);
rr.mp.writeString(puk);
rr.mp.writeString(newPin);
if (!oldRil)
rr.mp.writeString(aid);
send(rr);
}
@Override public void
supplyIccPin2(String pin, Message result) {
supplyIccPin2ForApp(pin, null, result);
}
@Override public void
supplyIccPin2ForApp(String pin, String aid, Message result) {
//Note: This RIL request has not been renamed to ICC,
// but this request is also valid for SIM and RUIM
RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PIN2, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
boolean oldRil = needsOldRilFeature("facilitylock");
rr.mp.writeInt(oldRil ? 1 : 2);
rr.mp.writeString(pin);
if (!oldRil)
rr.mp.writeString(aid);
send(rr);
}
@Override public void
supplyIccPuk2(String puk2, String newPin2, Message result) {
supplyIccPuk2ForApp(puk2, newPin2, null, result);
}
@Override public void
supplyIccPuk2ForApp(String puk, String newPin2, String aid, Message result) {
//Note: This RIL request has not been renamed to ICC,
// but this request is also valid for SIM and RUIM
RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PUK2, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
boolean oldRil = needsOldRilFeature("facilitylock");
rr.mp.writeInt(oldRil ? 2 : 3);
rr.mp.writeString(puk);
rr.mp.writeString(newPin2);
if (!oldRil)
rr.mp.writeString(aid);
send(rr);
}
@Override public void
changeIccPin(String oldPin, String newPin, Message result) {
changeIccPinForApp(oldPin, newPin, null, result);
}
@Override public void
changeIccPinForApp(String oldPin, String newPin, String aid, Message result) {
//Note: This RIL request has not been renamed to ICC,
// but this request is also valid for SIM and RUIM
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_SIM_PIN, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
boolean oldRil = needsOldRilFeature("facilitylock");
rr.mp.writeInt(oldRil ? 2 : 3);
rr.mp.writeString(oldPin);
rr.mp.writeString(newPin);
if (!oldRil)
rr.mp.writeString(aid);
send(rr);
}
@Override public void
changeIccPin2(String oldPin2, String newPin2, Message result) {
changeIccPin2ForApp(oldPin2, newPin2, null, result);
}
@Override public void
changeIccPin2ForApp(String oldPin2, String newPin2, String aid, Message result) {
//Note: This RIL request has not been renamed to ICC,
// but this request is also valid for SIM and RUIM
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_SIM_PIN2, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
boolean oldRil = needsOldRilFeature("facilitylock");
rr.mp.writeInt(oldRil ? 2 : 3);
rr.mp.writeString(oldPin2);
rr.mp.writeString(newPin2);
if (!oldRil)
rr.mp.writeString(aid);
send(rr);
}
public void
changeBarringPassword(String facility, String oldPwd, String newPwd, Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_BARRING_PASSWORD, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
rr.mp.writeInt(3);
rr.mp.writeString(facility);
rr.mp.writeString(oldPwd);
rr.mp.writeString(newPwd);
send(rr);
}
public void
supplyNetworkDepersonalization(String netpin, Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
rr.mp.writeInt(1);
rr.mp.writeString(netpin);
send(rr);
}
public void
getCurrentCalls (Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_CURRENT_CALLS, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
@Deprecated public void
getPDPContextList(Message result) {
getDataCallList(result);
}
public void
getDataCallList(Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_DATA_CALL_LIST, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
dial (String address, int clirMode, Message result) {
dial(address, clirMode, null, result);
}
public void
dial(String address, int clirMode, UUSInfo uusInfo, Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_DIAL, result);
rr.mp.writeString(address);
rr.mp.writeInt(clirMode);
rr.mp.writeInt(0); // UUS information is absent
if (uusInfo == null) {
rr.mp.writeInt(0); // UUS information is absent
} else {
rr.mp.writeInt(1); // UUS information is present
rr.mp.writeInt(uusInfo.getType());
rr.mp.writeInt(uusInfo.getDcs());
rr.mp.writeByteArray(uusInfo.getUserData());
}
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getIMSI(Message result) {
getIMSIForApp(null, result);
}
public void
getIMSIForApp(String aid, Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMSI, result);
boolean skipNullAid = needsOldRilFeature("skipnullaid");
boolean writeAidOnly = needsOldRilFeature("writeaidonly");
if (!writeAidOnly && (aid != null || !skipNullAid)) {
rr.mp.writeInt(1);
rr.mp.writeString(aid);
}
if (writeAidOnly)
rr.mp.writeString(aid);
if (RILJ_LOGD) riljLog(rr.serialString() +
"> getIMSI: " + requestToString(rr.mRequest)
+ " aid: " + aid);
send(rr);
}
public void
getIMEI(Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMEI, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getIMEISV(Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMEISV, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
hangupConnection (int gsmIndex, Message result) {
if (RILJ_LOGD) riljLog("hangupConnection: gsmIndex=" + gsmIndex);
RILRequest rr = RILRequest.obtain(RIL_REQUEST_HANGUP, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " " +
gsmIndex);
rr.mp.writeInt(1);
rr.mp.writeInt(gsmIndex);
send(rr);
}
public void
hangupWaitingOrBackground (Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND,
result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
hangupForegroundResumeBackground (Message result) {
RILRequest rr
= RILRequest.obtain(
RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND,
result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
switchWaitingOrHoldingAndActive (Message result) {
RILRequest rr
= RILRequest.obtain(
RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE,
result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
conference (Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_CONFERENCE, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void setPreferredVoicePrivacy(boolean enable, Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
result);
rr.mp.writeInt(1);
rr.mp.writeInt(enable ? 1:0);
send(rr);
}
public void getPreferredVoicePrivacy(Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE,
result);
send(rr);
}
public void
separateConnection (int gsmIndex, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SEPARATE_CONNECTION, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + gsmIndex);
rr.mp.writeInt(1);
rr.mp.writeInt(gsmIndex);
send(rr);
}
public void
acceptCall (Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_ANSWER, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
rejectCall (Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_UDUB, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
explicitCallTransfer (Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_EXPLICIT_CALL_TRANSFER, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getLastCallFailCause (Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_LAST_CALL_FAIL_CAUSE, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* @deprecated
*/
public void
getLastPdpFailCause (Message result) {
getLastDataCallFailCause (result);
}
/**
* The preferred new alternative to getLastPdpFailCause
*/
public void
getLastDataCallFailCause (Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
setMute (boolean enableMute, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SET_MUTE, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + enableMute);
rr.mp.writeInt(1);
rr.mp.writeInt(enableMute ? 1 : 0);
send(rr);
}
public void
getMute (Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_GET_MUTE, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getSignalStrength (Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SIGNAL_STRENGTH, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getVoiceRegistrationState (Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_VOICE_REGISTRATION_STATE, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getDataRegistrationState (Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_DATA_REGISTRATION_STATE, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getOperator(Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_OPERATOR, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
sendDtmf(char c, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_DTMF, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
rr.mp.writeString(Character.toString(c));
send(rr);
}
public void
startDtmf(char c, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_DTMF_START, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
rr.mp.writeString(Character.toString(c));
send(rr);
}
public void
stopDtmf(Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_DTMF_STOP, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
sendBurstDtmf(String dtmfString, int on, int off, Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_BURST_DTMF, result);
rr.mp.writeInt(3);
rr.mp.writeString(dtmfString);
rr.mp.writeString(Integer.toString(on));
rr.mp.writeString(Integer.toString(off));
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " : " + dtmfString);
send(rr);
}
public void
sendSMS (String smscPDU, String pdu, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SEND_SMS, result);
rr.mp.writeInt(2);
rr.mp.writeString(smscPDU);
rr.mp.writeString(pdu);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
sendCdmaSms(byte[] pdu, Message result) {
int address_nbr_of_digits;
int subaddr_nbr_of_digits;
int bearerDataLength;
ByteArrayInputStream bais = new ByteArrayInputStream(pdu);
DataInputStream dis = new DataInputStream(bais);
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_CDMA_SEND_SMS, result);
try {
rr.mp.writeInt(dis.readInt()); //teleServiceId
rr.mp.writeByte((byte) dis.readInt()); //servicePresent
rr.mp.writeInt(dis.readInt()); //serviceCategory
rr.mp.writeInt(dis.read()); //address_digit_mode
rr.mp.writeInt(dis.read()); //address_nbr_mode
rr.mp.writeInt(dis.read()); //address_ton
rr.mp.writeInt(dis.read()); //address_nbr_plan
address_nbr_of_digits = (byte) dis.read();
rr.mp.writeByte((byte) address_nbr_of_digits);
for(int i=0; i < address_nbr_of_digits; i++){
rr.mp.writeByte(dis.readByte()); // address_orig_bytes[i]
}
rr.mp.writeInt(dis.read()); //subaddressType
rr.mp.writeByte((byte) dis.read()); //subaddr_odd
subaddr_nbr_of_digits = (byte) dis.read();
rr.mp.writeByte((byte) subaddr_nbr_of_digits);
for(int i=0; i < subaddr_nbr_of_digits; i++){
rr.mp.writeByte(dis.readByte()); //subaddr_orig_bytes[i]
}
bearerDataLength = dis.read();
rr.mp.writeInt(bearerDataLength);
for(int i=0; i < bearerDataLength; i++){
rr.mp.writeByte(dis.readByte()); //bearerData[i]
}
}catch (IOException ex){
if (RILJ_LOGD) riljLog("sendSmsCdma: conversion from input stream to object failed: "
+ ex);
}
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void deleteSmsOnSim(int index, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_DELETE_SMS_ON_SIM,
response);
rr.mp.writeInt(1);
rr.mp.writeInt(index);
if (false) {
if (RILJ_LOGD) riljLog(rr.serialString() + "> "
+ requestToString(rr.mRequest)
+ " " + index);
}
send(rr);
}
public void deleteSmsOnRuim(int index, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM,
response);
rr.mp.writeInt(1);
rr.mp.writeInt(index);
if (false) {
if (RILJ_LOGD) riljLog(rr.serialString() + "> "
+ requestToString(rr.mRequest)
+ " " + index);
}
send(rr);
}
public void writeSmsToSim(int status, String smsc, String pdu, Message response) {
status = translateStatus(status);
RILRequest rr = RILRequest.obtain(RIL_REQUEST_WRITE_SMS_TO_SIM,
response);
rr.mp.writeInt(status);
rr.mp.writeString(pdu);
rr.mp.writeString(smsc);
if (false) {
if (RILJ_LOGD) riljLog(rr.serialString() + "> "
+ requestToString(rr.mRequest)
+ " " + status);
}
send(rr);
}
public void writeSmsToRuim(int status, String pdu, Message response) {
status = translateStatus(status);
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM,
response);
rr.mp.writeInt(status);
rr.mp.writeString(pdu);
if (false) {
if (RILJ_LOGD) riljLog(rr.serialString() + "> "
+ requestToString(rr.mRequest)
+ " " + status);
}
send(rr);
}
/**
* Translates EF_SMS status bits to a status value compatible with
* SMS AT commands. See TS 27.005 3.1.
*/
private int translateStatus(int status) {
switch(status & 0x7) {
case SmsManager.STATUS_ON_ICC_READ:
return 1;
case SmsManager.STATUS_ON_ICC_UNREAD:
return 0;
case SmsManager.STATUS_ON_ICC_SENT:
return 3;
case SmsManager.STATUS_ON_ICC_UNSENT:
return 2;
}
// Default to READ.
return 1;
}
public void
setupDataCall(String radioTechnology, String profile, String apn,
String user, String password, String authType, String protocol,
Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SETUP_DATA_CALL, result);
rr.mp.writeInt(7);
rr.mp.writeString(radioTechnology);
rr.mp.writeString(profile);
rr.mp.writeString(apn);
rr.mp.writeString(user);
rr.mp.writeString(password);
rr.mp.writeString(authType);
rr.mp.writeString(protocol);
if (RILJ_LOGD) riljLog(rr.serialString() + "> "
+ requestToString(rr.mRequest) + " " + radioTechnology + " "
+ profile + " " + apn + " " + user + " "
+ password + " " + authType + " " + protocol);
send(rr);
}
public void
deactivateDataCall(int cid, int reason, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_DEACTIVATE_DATA_CALL, result);
rr.mp.writeInt(2);
rr.mp.writeString(Integer.toString(cid));
rr.mp.writeString(Integer.toString(reason));
if (RILJ_LOGD) riljLog(rr.serialString() + "> " +
requestToString(rr.mRequest) + " " + cid + " " + reason);
send(rr);
}
public void
setRadioPower(boolean on, Message result) {
boolean allow = SystemProperties.getBoolean("persist.ril.enable", true);
if (!allow) {
return;
}
RILRequest rr = RILRequest.obtain(RIL_REQUEST_RADIO_POWER, result);
rr.mp.writeInt(1);
rr.mp.writeInt(on ? 1 : 0);
if (RILJ_LOGD) {
riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ (on ? " on" : " off"));
}
send(rr);
}
public void
setSuppServiceNotifications(boolean enable, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, result);
rr.mp.writeInt(1);
rr.mp.writeInt(enable ? 1 : 0);
if (RILJ_LOGD) riljLog(rr.serialString() + "> "
+ requestToString(rr.mRequest));
send(rr);
}
public void
acknowledgeLastIncomingGsmSms(boolean success, int cause, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SMS_ACKNOWLEDGE, result);
rr.mp.writeInt(2);
rr.mp.writeInt(success ? 1 : 0);
rr.mp.writeInt(cause);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + success + " " + cause);
send(rr);
}
public void
acknowledgeLastIncomingCdmaSms(boolean success, int cause, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, result);
rr.mp.writeInt(success ? 0 : 1); //RIL_CDMA_SMS_ErrorClass
// cause code according to X.S004-550E
rr.mp.writeInt(cause);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + success + " " + cause);
send(rr);
}
public void
acknowledgeIncomingGsmSmsWithPdu(boolean success, String ackPdu, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, result);
rr.mp.writeInt(2);
rr.mp.writeString(success ? "1" : "0");
rr.mp.writeString(ackPdu);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ ' ' + success + " [" + ackPdu + ']');
send(rr);
}
public void
iccIO (int command, int fileid, String path, int p1, int p2, int p3,
String data, String pin2, Message result) {
iccIOForApp(command, fileid, path, p1, p2, p3, data, pin2, null, result);
}
public void
iccIOForApp (int command, int fileid, String path, int p1, int p2, int p3,
String data, String pin2, String aid, Message result) {
//Note: This RIL request has not been renamed to ICC,
// but this request is also valid for SIM and RUIM
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SIM_IO, result);
rr.mp.writeInt(command);
rr.mp.writeInt(fileid);
rr.mp.writeString(path);
rr.mp.writeInt(p1);
rr.mp.writeInt(p2);
rr.mp.writeInt(p3);
rr.mp.writeString(data);
rr.mp.writeString(pin2);
rr.mp.writeString(aid);
if (RILJ_LOGD) riljLog(rr.serialString() + "> iccIO: "
+ requestToString(rr.mRequest)
+ " 0x" + Integer.toHexString(command)
+ " 0x" + Integer.toHexString(fileid) + " "
+ " path: " + path + ","
+ p1 + "," + p2 + "," + p3
+ " aid: " + aid);
send(rr);
}
public void
getCLIR(Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_GET_CLIR, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
setCLIR(int clirMode, Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SET_CLIR, result);
// count ints
rr.mp.writeInt(1);
rr.mp.writeInt(clirMode);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + clirMode);
send(rr);
}
public void
queryCallWaiting(int serviceClass, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_QUERY_CALL_WAITING, response);
rr.mp.writeInt(1);
rr.mp.writeInt(serviceClass);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + serviceClass);
send(rr);
}
public void
setCallWaiting(boolean enable, int serviceClass, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SET_CALL_WAITING, response);
rr.mp.writeInt(2);
rr.mp.writeInt(enable ? 1 : 0);
rr.mp.writeInt(serviceClass);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + enable + ", " + serviceClass);
send(rr);
}
public void
setNetworkSelectionModeAutomatic(Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC,
response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
setNetworkSelectionModeManual(String operatorNumeric, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + operatorNumeric);
rr.mp.writeString(operatorNumeric);
send(rr);
}
public void
getNetworkSelectionMode(Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE,
response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getAvailableNetworks(Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_QUERY_AVAILABLE_NETWORKS,
response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
setCallForward(int action, int cfReason, int serviceClass,
String number, int timeSeconds, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SET_CALL_FORWARD, response);
rr.mp.writeInt(action);
rr.mp.writeInt(cfReason);
rr.mp.writeInt(serviceClass);
rr.mp.writeInt(PhoneNumberUtils.toaFromString(number));
rr.mp.writeString(number);
rr.mp.writeInt (timeSeconds);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + action + " " + cfReason + " " + serviceClass
+ timeSeconds);
send(rr);
}
public void
queryCallForwardStatus(int cfReason, int serviceClass,
String number, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_QUERY_CALL_FORWARD_STATUS, response);
rr.mp.writeInt(2); // 2 is for query action, not in used anyway
rr.mp.writeInt(cfReason);
rr.mp.writeInt(serviceClass);
rr.mp.writeInt(PhoneNumberUtils.toaFromString(number));
rr.mp.writeString(number);
rr.mp.writeInt (0);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + cfReason + " " + serviceClass);
send(rr);
}
public void
queryCLIP(Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_QUERY_CLIP, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getBasebandVersion (Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_BASEBAND_VERSION, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
@Override
public void
queryFacilityLock(String facility, String password, int serviceClass,
Message response) {
queryFacilityLockForApp(facility, password, serviceClass, null, response);
}
@Override
public void
queryFacilityLockForApp(String facility, String password, int serviceClass, String appId,
Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_QUERY_FACILITY_LOCK, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
boolean oldRil = needsOldRilFeature("facilitylock");
// count strings
rr.mp.writeInt(oldRil ? 3 : 4);
rr.mp.writeString(facility);
rr.mp.writeString(password);
rr.mp.writeString(Integer.toString(serviceClass));
if (!oldRil)
rr.mp.writeString(appId);
send(rr);
}
@Override
public void
setFacilityLock (String facility, boolean lockState, String password,
int serviceClass, Message response) {
setFacilityLockForApp(facility, lockState, password, serviceClass, null, response);
}
@Override
public void
setFacilityLockForApp(String facility, boolean lockState, String password,
int serviceClass, String appId, Message response) {
String lockString;
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SET_FACILITY_LOCK, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " [" + facility + " " + lockState
+ " " + serviceClass + " " + appId + "]");
boolean oldRil = needsOldRilFeature("facilitylock");
// count strings
rr.mp.writeInt(oldRil ? 4 : 5);
rr.mp.writeString(facility);
lockString = (lockState)?"1":"0";
rr.mp.writeString(lockString);
rr.mp.writeString(password);
rr.mp.writeString(Integer.toString(serviceClass));
if (!oldRil)
rr.mp.writeString(appId);
send(rr);
}
public void
sendUSSD (String ussdString, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SEND_USSD, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + ussdString);
rr.mp.writeString(ussdString);
send(rr);
}
// inherited javadoc suffices
public void cancelPendingUssd (Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_CANCEL_USSD, response);
if (RILJ_LOGD) riljLog(rr.serialString()
+ "> " + requestToString(rr.mRequest));
send(rr);
}
public void resetRadio(Message result) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_RESET_RADIO, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void invokeOemRilRequestRaw(byte[] data, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_OEM_HOOK_RAW, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ "[" + IccUtils.bytesToHexString(data) + "]");
rr.mp.writeByteArray(data);
send(rr);
}
public void invokeOemRilRequestStrings(String[] strings, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_OEM_HOOK_STRINGS, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
rr.mp.writeStringArray(strings);
send(rr);
}
/**
* Assign a specified band for RF configuration.
*
* @param bandMode one of BM_*_BAND
* @param response is callback message
*/
public void setBandMode (int bandMode, Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_SET_BAND_MODE, response);
rr.mp.writeInt(1);
rr.mp.writeInt(bandMode);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " " + bandMode);
send(rr);
}
/**
* Query the list of band mode supported by RF.
*
* @param response is callback message
* ((AsyncResult)response.obj).result is an int[] with every
* element representing one avialable BM_*_BAND
*/
public void queryAvailableBandMode (Message response) {
RILRequest rr
= RILRequest.obtain(RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE,
response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void sendTerminalResponse(String contents, Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
rr.mp.writeString(contents);
send(rr);
}
/**
* {@inheritDoc}
*/
public void sendEnvelope(String contents, Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
rr.mp.writeString(contents);
send(rr);
}
/**
* {@inheritDoc}
*/
public void sendEnvelopeWithStatus(String contents, Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ '[' + contents + ']');
rr.mp.writeString(contents);
send(rr);
}
/**
* {@inheritDoc}
*/
public void handleCallSetupRequestFromSim(
boolean accept, Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
int[] param = new int[1];
param[0] = accept ? 1 : 0;
rr.mp.writeIntArray(param);
send(rr);
}
/**
* {@inheritDoc}
*/
@Override
public void setCurrentPreferredNetworkType() {
if (RILJ_LOGD) riljLog("setCurrentPreferredNetworkType: " + mSetPreferredNetworkType);
setPreferredNetworkType(mSetPreferredNetworkType, null);
}
protected int mSetPreferredNetworkType;
/**
* {@inheritDoc}
*/
public void setPreferredNetworkType(int networkType , Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, response);
rr.mp.writeInt(1);
rr.mp.writeInt(networkType);
mSetPreferredNetworkType = networkType;
mPreferredNetworkType = networkType;
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " : " + networkType);
send(rr);
}
/**
* {@inheritDoc}
*/
public void getPreferredNetworkType(Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void getNeighboringCids(Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void setLocationUpdates(boolean enable, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_LOCATION_UPDATES, response);
rr.mp.writeInt(1);
rr.mp.writeInt(enable ? 1 : 0);
if (RILJ_LOGD) riljLog(rr.serialString() + "> "
+ requestToString(rr.mRequest) + ": " + enable);
send(rr);
}
/**
* {@inheritDoc}
*/
public void getSmscAddress(Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_SMSC_ADDRESS, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void setSmscAddress(String address, Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_SMSC_ADDRESS, result);
rr.mp.writeString(address);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " : " + address);
send(rr);
}
/**
* {@inheritDoc}
*/
public void reportSmsMemoryStatus(boolean available, Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, result);
rr.mp.writeInt(1);
rr.mp.writeInt(available ? 1 : 0);
if (RILJ_LOGD) riljLog(rr.serialString() + "> "
+ requestToString(rr.mRequest) + ": " + available);
send(rr);
}
/**
* {@inheritDoc}
*/
public void reportStkServiceIsRunning(Message result) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING, result);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void getGsmBroadcastConfig(Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_GET_BROADCAST_CONFIG, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_SET_BROADCAST_CONFIG, response);
int numOfConfig = config.length;
rr.mp.writeInt(numOfConfig);
for(int i = 0; i < numOfConfig; i++) {
rr.mp.writeInt(config[i].getFromServiceId());
rr.mp.writeInt(config[i].getToServiceId());
rr.mp.writeInt(config[i].getFromCodeScheme());
rr.mp.writeInt(config[i].getToCodeScheme());
rr.mp.writeInt(config[i].isSelected() ? 1 : 0);
}
if (RILJ_LOGD) {
riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " with " + numOfConfig + " configs : ");
for (int i = 0; i < numOfConfig; i++) {
riljLog(config[i].toString());
}
}
send(rr);
}
/**
* {@inheritDoc}
*/
public void setGsmBroadcastActivation(boolean activate, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_BROADCAST_ACTIVATION, response);
rr.mp.writeInt(1);
rr.mp.writeInt(activate ? 0 : 1);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
//***** Private Methods
protected void sendScreenState(boolean on) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_SCREEN_STATE, null);
rr.mp.writeInt(1);
rr.mp.writeInt(on ? 1 : 0);
if (RILJ_LOGD) riljLog(rr.serialString()
+ "> " + requestToString(rr.mRequest) + ": " + on);
send(rr);
}
protected void
onRadioAvailable() {
// In case screen state was lost (due to process crash),
// this ensures that the RIL knows the correct screen state.
// TODO: Should query Power Manager and send the actual
// screen state. Just send true for now.
sendScreenState(true);
}
protected RadioState getRadioStateFromInt(int stateInt) {
RadioState state;
/* RIL_RadioState ril.h */
switch(stateInt) {
case 0: state = RadioState.RADIO_OFF; break;
case 1: state = RadioState.RADIO_UNAVAILABLE; break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 13: state = RadioState.RADIO_ON; break;
default:
throw new RuntimeException(
"Unrecognized RIL_RadioState: " + stateInt);
}
return state;
}
protected void switchToRadioState(RadioState newState) {
setRadioState(newState);
}
/**
* Holds a PARTIAL_WAKE_LOCK whenever
* a) There is outstanding RIL request sent to RIL deamon and no replied
* b) There is a request pending to be sent out.
*
* There is a WAKE_LOCK_TIMEOUT to release the lock, though it shouldn't
* happen often.
*/
private void
acquireWakeLock() {
synchronized (mWakeLock) {
mWakeLock.acquire();
mRequestMessagesPending++;
mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
Message msg = mSender.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT);
mSender.sendMessageDelayed(msg, mWakeLockTimeout);
}
}
private void
releaseWakeLockIfDone() {
synchronized (mWakeLock) {
if (mWakeLock.isHeld() &&
(mRequestMessagesPending == 0) &&
(mRequestMessagesWaiting == 0)) {
mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
mWakeLock.release();
}
}
}
protected void
send(RILRequest rr) {
Message msg;
if (mSocket == null) {
rr.onError(RADIO_NOT_AVAILABLE, null);
rr.release();
return;
}
msg = mSender.obtainMessage(EVENT_SEND, rr);
acquireWakeLock();
msg.sendToTarget();
}
protected void
processResponse (Parcel p) {
int type;
type = p.readInt();
if (type == RESPONSE_UNSOLICITED) {
processUnsolicited (p);
} else if (type == RESPONSE_SOLICITED) {
processSolicited (p);
}
releaseWakeLockIfDone();
}
/**
* Release each request in mReqeustsList then clear the list
* @param error is the RIL_Errno sent back
* @param loggable true means to print all requests in mRequestslist
*/
protected void clearRequestsList(int error, boolean loggable) {
RILRequest rr;
synchronized (mRequestsList) {
int count = mRequestsList.size();
if (RILJ_LOGD && loggable) {
Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
" mReqPending=" + mRequestMessagesPending +
" mRequestList=" + count);
}
for (int i = 0; i < count ; i++) {
rr = mRequestsList.get(i);
if (RILJ_LOGD && loggable) {
Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] " +
requestToString(rr.mRequest));
}
rr.onError(error, null);
rr.release();
}
mRequestsList.clear();
mRequestMessagesWaiting = 0;
}
}
protected RILRequest findAndRemoveRequestFromList(int serial) {
synchronized (mRequestsList) {
for (int i = 0, s = mRequestsList.size() ; i < s ; i++) {
RILRequest rr = mRequestsList.get(i);
if (rr.mSerial == serial) {
mRequestsList.remove(i);
if (mRequestMessagesWaiting > 0)
mRequestMessagesWaiting--;
return rr;
}
}
}
return null;
}
protected void
processSolicited (Parcel p) {
int serial, error;
boolean found = false;
serial = p.readInt();
error = p.readInt();
RILRequest rr;
rr = findAndRemoveRequestFromList(serial);
if (rr == null) {
Log.w(LOG_TAG, "Unexpected solicited response! sn: "
+ serial + " error: " + error);
return;
}
Object ret = null;
if (error == 0 || p.dataAvail() > 0) {
// either command succeeds or command fails but with data payload
try {switch (rr.mRequest) {
/*
cat libs/telephony/ril_commands.h \
| egrep "^ *{RIL_" \
| sed -re 's/\{([^,]+),[^,]+,([^}]+).+/case \1: ret = \2(p); break;/'
*/
case RIL_REQUEST_GET_SIM_STATUS: ret = responseIccCardStatus(p); break;
case RIL_REQUEST_ENTER_SIM_PIN: ret = responseInts(p); break;
case RIL_REQUEST_ENTER_SIM_PUK: ret = responseInts(p); break;
case RIL_REQUEST_ENTER_SIM_PIN2: ret = responseInts(p); break;
case RIL_REQUEST_ENTER_SIM_PUK2: ret = responseInts(p); break;
case RIL_REQUEST_CHANGE_SIM_PIN: ret = responseInts(p); break;
case RIL_REQUEST_CHANGE_SIM_PIN2: ret = responseInts(p); break;
case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: ret = responseInts(p); break;
case RIL_REQUEST_GET_CURRENT_CALLS: ret = responseCallList(p); break;
case RIL_REQUEST_DIAL: ret = responseVoid(p); break;
case RIL_REQUEST_GET_IMSI: ret = responseString(p); break;
case RIL_REQUEST_HANGUP: ret = responseVoid(p); break;
case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: ret = responseVoid(p); break;
case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: {
if (mTestingEmergencyCall.getAndSet(false)) {
if (mEmergencyCallbackModeRegistrant != null) {
riljLog("testing emergency call, notify ECM Registrants");
mEmergencyCallbackModeRegistrant.notifyRegistrant();
}
}
ret = responseVoid(p);
break;
}
case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: ret = responseVoid(p); break;
case RIL_REQUEST_CONFERENCE: ret = responseVoid(p); break;
case RIL_REQUEST_UDUB: ret = responseVoid(p); break;
case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseInts(p); break;
case RIL_REQUEST_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break;
case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseStrings(p); break;
case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseStrings(p); break;
case RIL_REQUEST_OPERATOR: ret = responseStrings(p); break;
case RIL_REQUEST_RADIO_POWER: ret = responseVoid(p); break;
case RIL_REQUEST_DTMF: ret = responseVoid(p); break;
case RIL_REQUEST_SEND_SMS: ret = responseSMS(p); break;
case RIL_REQUEST_SEND_SMS_EXPECT_MORE: ret = responseSMS(p); break;
case RIL_REQUEST_SETUP_DATA_CALL: ret = responseSetupDataCall(p); break;
case RIL_REQUEST_SIM_IO: ret = responseICC_IO(p); break;
case RIL_REQUEST_SEND_USSD: ret = responseVoid(p); break;
case RIL_REQUEST_CANCEL_USSD: ret = responseVoid(p); break;
case RIL_REQUEST_GET_CLIR: ret = responseInts(p); break;
case RIL_REQUEST_SET_CLIR: ret = responseVoid(p); break;
case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: ret = responseCallForward(p); break;
case RIL_REQUEST_SET_CALL_FORWARD: ret = responseVoid(p); break;
case RIL_REQUEST_QUERY_CALL_WAITING: ret = responseInts(p); break;
case RIL_REQUEST_SET_CALL_WAITING: ret = responseVoid(p); break;
case RIL_REQUEST_SMS_ACKNOWLEDGE: ret = responseVoid(p); break;
case RIL_REQUEST_GET_IMEI: ret = responseString(p); break;
case RIL_REQUEST_GET_IMEISV: ret = responseString(p); break;
case RIL_REQUEST_ANSWER: ret = responseVoid(p); break;
case RIL_REQUEST_DEACTIVATE_DATA_CALL: ret = responseVoid(p); break;
case RIL_REQUEST_QUERY_FACILITY_LOCK: ret = responseInts(p); break;
case RIL_REQUEST_SET_FACILITY_LOCK: ret = responseInts(p); break;
case RIL_REQUEST_CHANGE_BARRING_PASSWORD: ret = responseVoid(p); break;
case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: ret = responseInts(p); break;
case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: ret = responseVoid(p); break;
case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: ret = responseVoid(p); break;
case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : ret = responseOperatorInfos(p); break;
case RIL_REQUEST_DTMF_START: ret = responseVoid(p); break;
case RIL_REQUEST_DTMF_STOP: ret = responseVoid(p); break;
case RIL_REQUEST_BASEBAND_VERSION: ret = responseString(p); break;
case RIL_REQUEST_SEPARATE_CONNECTION: ret = responseVoid(p); break;
case RIL_REQUEST_SET_MUTE: ret = responseVoid(p); break;
case RIL_REQUEST_GET_MUTE: ret = responseInts(p); break;
case RIL_REQUEST_QUERY_CLIP: ret = responseInts(p); break;
case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: ret = responseInts(p); break;
case RIL_REQUEST_DATA_CALL_LIST: ret = responseDataCallList(p); break;
case RIL_REQUEST_RESET_RADIO: ret = responseVoid(p); break;
case RIL_REQUEST_OEM_HOOK_RAW: ret = responseRaw(p); break;
case RIL_REQUEST_OEM_HOOK_STRINGS: ret = responseStrings(p); break;
case RIL_REQUEST_SCREEN_STATE: ret = responseVoid(p); break;
case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: ret = responseVoid(p); break;
case RIL_REQUEST_WRITE_SMS_TO_SIM: ret = responseInts(p); break;
case RIL_REQUEST_DELETE_SMS_ON_SIM: ret = responseVoid(p); break;
case RIL_REQUEST_SET_BAND_MODE: ret = responseVoid(p); break;
case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: ret = responseInts(p); break;
case RIL_REQUEST_STK_GET_PROFILE: ret = responseString(p); break;
case RIL_REQUEST_STK_SET_PROFILE: ret = responseVoid(p); break;
case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: ret = responseString(p); break;
case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: ret = responseVoid(p); break;
case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: ret = responseInts(p); break;
case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: ret = responseVoid(p); break;
case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: ret = responseVoid(p); break;
case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: ret = responseGetPreferredNetworkType(p); break;
case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: ret = responseCellList(p); break;
case RIL_REQUEST_SET_LOCATION_UPDATES: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: ret = responseInts(p); break;
case RIL_REQUEST_SET_TTY_MODE: ret = responseVoid(p); break;
case RIL_REQUEST_QUERY_TTY_MODE: ret = responseInts(p); break;
case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: ret = responseInts(p); break;
case RIL_REQUEST_CDMA_FLASH: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_BURST_DTMF: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_SEND_SMS: ret = responseSMS(p); break;
case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: ret = responseVoid(p); break;
case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: ret = responseGmsBroadcastConfig(p); break;
case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: ret = responseVoid(p); break;
case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: ret = responseCdmaBroadcastConfig(p); break;
case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_SUBSCRIPTION: ret = responseStrings(p); break;
case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: ret = responseInts(p); break;
case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: ret = responseVoid(p); break;
case RIL_REQUEST_DEVICE_IDENTITY: ret = responseStrings(p); break;
case RIL_REQUEST_GET_SMSC_ADDRESS: ret = responseString(p); break;
case RIL_REQUEST_SET_SMSC_ADDRESS: ret = responseVoid(p); break;
case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: ret = responseVoid(p); break;
case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: ret = responseInts(p); break;
case RIL_REQUEST_ISIM_AUTHENTICATION: ret = responseString(p); break;
case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: ret = responseVoid(p); break;
case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: ret = responseICC_IO(p); break;
case RIL_REQUEST_VOICE_RADIO_TECH: ret = responseInts(p); break;
default:
throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest);
//break;
}} catch (Throwable tr) {
// Exceptions here usually mean invalid RIL responses
Log.w(LOG_TAG, rr.serialString() + "< "
+ requestToString(rr.mRequest)
+ " exception, possible invalid RIL response", tr);
if (rr.mResult != null) {
AsyncResult.forMessage(rr.mResult, null, tr);
rr.mResult.sendToTarget();
}
rr.release();
return;
}
}
// Here and below fake RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, see b/7255789.
// This is needed otherwise we don't automatically transition to the main lock
// screen when the pin or puk is entered incorrectly.
switch (rr.mRequest) {
case RIL_REQUEST_ENTER_SIM_PUK:
case RIL_REQUEST_ENTER_SIM_PUK2:
if (mIccStatusChangedRegistrants != null) {
if (RILJ_LOGD) {
riljLog("ON enter sim puk fakeSimStatusChanged: reg count="
+ mIccStatusChangedRegistrants.size());
}
mIccStatusChangedRegistrants.notifyRegistrants();
}
break;
}
if (error != 0) {
switch (rr.mRequest) {
case RIL_REQUEST_ENTER_SIM_PIN:
case RIL_REQUEST_ENTER_SIM_PIN2:
case RIL_REQUEST_CHANGE_SIM_PIN:
case RIL_REQUEST_CHANGE_SIM_PIN2:
case RIL_REQUEST_SET_FACILITY_LOCK:
if (mIccStatusChangedRegistrants != null) {
if (RILJ_LOGD) {
riljLog("ON some errors fakeSimStatusChanged: reg count="
+ mIccStatusChangedRegistrants.size());
}
mIccStatusChangedRegistrants.notifyRegistrants();
}
break;
}
rr.onError(error, ret);
rr.release();
return;
}
if (RILJ_LOGD) riljLog(rr.serialString() + "< " + requestToString(rr.mRequest)
+ " " + retToString(rr.mRequest, ret));
if (rr.mResult != null) {
AsyncResult.forMessage(rr.mResult, ret, null);
rr.mResult.sendToTarget();
}
rr.release();
}
protected String
retToString(int req, Object ret) {
if (ret == null) return "";
switch (req) {
// Don't log these return values, for privacy's sake.
case RIL_REQUEST_GET_IMSI:
case RIL_REQUEST_GET_IMEI:
case RIL_REQUEST_GET_IMEISV:
if (!RILJ_LOGV) {
// If not versbose logging just return and don't display IMSI and IMEI, IMEISV
return "";
}
}
StringBuilder sb;
String s;
int length;
if (ret instanceof int[]){
int[] intArray = (int[]) ret;
length = intArray.length;
sb = new StringBuilder("{");
if (length > 0) {
int i = 0;
sb.append(intArray[i++]);
while ( i < length) {
sb.append(", ").append(intArray[i++]);
}
}
sb.append("}");
s = sb.toString();
} else if (ret instanceof String[]) {
String[] strings = (String[]) ret;
length = strings.length;
sb = new StringBuilder("{");
if (length > 0) {
int i = 0;
sb.append(strings[i++]);
while ( i < length) {
sb.append(", ").append(strings[i++]);
}
}
sb.append("}");
s = sb.toString();
}else if (req == RIL_REQUEST_GET_CURRENT_CALLS) {
ArrayList<DriverCall> calls = (ArrayList<DriverCall>) ret;
sb = new StringBuilder(" ");
for (DriverCall dc : calls) {
sb.append("[").append(dc).append("] ");
}
s = sb.toString();
} else if (req == RIL_REQUEST_GET_NEIGHBORING_CELL_IDS) {
ArrayList<NeighboringCellInfo> cells;
cells = (ArrayList<NeighboringCellInfo>) ret;
sb = new StringBuilder(" ");
for (NeighboringCellInfo cell : cells) {
sb.append(cell).append(" ");
}
s = sb.toString();
} else {
s = ret.toString();
}
return s;
}
protected void
processUnsolicited (Parcel p) {
int response;
Object ret;
response = p.readInt();
try {switch(response) {
/*
cat libs/telephony/ril_unsol_commands.h \
| egrep "^ *{RIL_" \
| sed -re 's/\{([^,]+),[^,]+,([^}]+).+/case \1: \2(rr, p); break;/'
*/
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: ret = responseVoid(p); break;
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: ret = responseVoid(p); break;
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: ret = responseVoid(p); break;
case RIL_UNSOL_RESPONSE_NEW_SMS: ret = responseString(p); break;
case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: ret = responseString(p); break;
case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: ret = responseInts(p); break;
case RIL_UNSOL_ON_USSD: ret = responseStrings(p); break;
case RIL_UNSOL_NITZ_TIME_RECEIVED: ret = responseString(p); break;
case RIL_UNSOL_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break;
case RIL_UNSOL_DATA_CALL_LIST_CHANGED: ret = responseDataCallList(p);break;
case RIL_UNSOL_SUPP_SVC_NOTIFICATION: ret = responseSuppServiceNotification(p); break;
case RIL_UNSOL_STK_SESSION_END: ret = responseVoid(p); break;
case RIL_UNSOL_STK_PROACTIVE_COMMAND: ret = responseString(p); break;
case RIL_UNSOL_STK_EVENT_NOTIFY: ret = responseString(p); break;
case RIL_UNSOL_STK_CALL_SETUP: ret = responseInts(p); break;
case RIL_UNSOL_SIM_SMS_STORAGE_FULL: ret = responseVoid(p); break;
case RIL_UNSOL_SIM_REFRESH: ret = responseSimRefresh(p); break;
case RIL_UNSOL_CALL_RING: ret = responseCallRing(p); break;
case RIL_UNSOL_RESTRICTED_STATE_CHANGED: ret = responseInts(p); break;
case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: ret = responseVoid(p); break;
case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: ret = responseCdmaSms(p); break;
case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: ret = responseRaw(p); break;
case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: ret = responseVoid(p); break;
case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
case RIL_UNSOL_CDMA_CALL_WAITING: ret = responseCdmaCallWaiting(p); break;
case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: ret = responseInts(p); break;
case RIL_UNSOL_CDMA_INFO_REC: ret = responseCdmaInformationRecord(p); break;
case RIL_UNSOL_OEM_HOOK_RAW: ret = responseRaw(p); break;
case RIL_UNSOL_RINGBACK_TONE: ret = responseInts(p); break;
case RIL_UNSOL_RESEND_INCALL_MUTE: ret = responseVoid(p); break;
case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: ret = responseInts(p); break;
case RIL_UNSOl_CDMA_PRL_CHANGED: ret = responseInts(p); break;
case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
case RIL_UNSOL_RIL_CONNECTED: ret = responseInts(p); break;
case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: ret = responseInts(p); break;
case RIL_UNSOL_STK_SEND_SMS_RESULT: ret = responseInts(p); break; // Samsung STK
default:
throw new RuntimeException("Unrecognized unsol response: " + response);
//break; (implied)
}} catch (Throwable tr) {
Log.e(LOG_TAG, "Exception processing unsol response: " + response +
"Exception:" + tr.toString());
return;
}
switch(response) {
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
/* has bonus radio state int */
RadioState newState = getRadioStateFromInt(p.readInt());
if (RILJ_LOGD) unsljLogMore(response, newState.toString());
switchToRadioState(newState);
break;
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
if (RILJ_LOGD) unsljLog(response);
mCallStateRegistrants
.notifyRegistrants(new AsyncResult(null, null, null));
break;
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
if (RILJ_LOGD) unsljLog(response);
mVoiceNetworkStateRegistrants
.notifyRegistrants(new AsyncResult(null, null, null));
break;
case RIL_UNSOL_RESPONSE_NEW_SMS: {
if (RILJ_LOGD) unsljLog(response);
// FIXME this should move up a layer
String a[] = new String[2];
a[1] = (String)ret;
SmsMessage sms;
sms = SmsMessage.newFromCMT(a);
if (mGsmSmsRegistrant != null) {
mGsmSmsRegistrant
.notifyRegistrant(new AsyncResult(null, sms, null));
}
break;
}
case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mSmsStatusRegistrant != null) {
mSmsStatusRegistrant.notifyRegistrant(
new AsyncResult(null, ret, null));
}
break;
case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM:
if (RILJ_LOGD) unsljLogRet(response, ret);
int[] smsIndex = (int[])ret;
if(smsIndex.length == 1) {
if (mSmsOnSimRegistrant != null) {
mSmsOnSimRegistrant.
notifyRegistrant(new AsyncResult(null, smsIndex, null));
}
} else {
if (RILJ_LOGD) riljLog(" NEW_SMS_ON_SIM ERROR with wrong length "
+ smsIndex.length);
}
break;
case RIL_UNSOL_ON_USSD:
String[] resp = (String[])ret;
if (resp.length < 2) {
resp = new String[2];
resp[0] = ((String[])ret)[0];
resp[1] = null;
}
if (RILJ_LOGD) unsljLogMore(response, resp[0]);
if (mUSSDRegistrant != null) {
mUSSDRegistrant.notifyRegistrant(
new AsyncResult (null, resp, null));
}
break;
case RIL_UNSOL_NITZ_TIME_RECEIVED:
if (RILJ_LOGD) unsljLogRet(response, ret);
// has bonus long containing milliseconds since boot that the NITZ
// time was received
long nitzReceiveTime = p.readLong();
Object[] result = new Object[2];
result[0] = ret;
result[1] = Long.valueOf(nitzReceiveTime);
boolean ignoreNitz = SystemProperties.getBoolean(
TelephonyProperties.PROPERTY_IGNORE_NITZ, false);
if (ignoreNitz) {
if (RILJ_LOGD) riljLog("ignoring UNSOL_NITZ_TIME_RECEIVED");
} else {
if (mNITZTimeRegistrant != null) {
mNITZTimeRegistrant
.notifyRegistrant(new AsyncResult (null, result, null));
} else {
// in case NITZ time registrant isnt registered yet
mLastNITZTimeInfo = result;
}
}
break;
case RIL_UNSOL_SIGNAL_STRENGTH:
// Note this is set to "verbose" because it happens
// frequently
if (RILJ_LOGV) unsljLogvRet(response, ret);
if (mSignalStrengthRegistrant != null) {
mSignalStrengthRegistrant.notifyRegistrant(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_DATA_CALL_LIST_CHANGED:
if (RILJ_LOGD) unsljLogRet(response, ret);
boolean oldRil = needsOldRilFeature("skipbrokendatacall");
if (oldRil && "IP".equals(((ArrayList<DataCallState>)ret).get(0).type))
break;
mDataNetworkStateRegistrants.notifyRegistrants(new AsyncResult(null, ret, null));
break;
case RIL_UNSOL_SUPP_SVC_NOTIFICATION:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mSsnRegistrant != null) {
mSsnRegistrant.notifyRegistrant(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_STK_SESSION_END:
if (RILJ_LOGD) unsljLog(response);
if (mCatSessionEndRegistrant != null) {
mCatSessionEndRegistrant.notifyRegistrant(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_STK_PROACTIVE_COMMAND:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mCatProCmdRegistrant != null) {
mCatProCmdRegistrant.notifyRegistrant(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_STK_EVENT_NOTIFY:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mCatEventRegistrant != null) {
mCatEventRegistrant.notifyRegistrant(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_STK_CALL_SETUP:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mCatCallSetUpRegistrant != null) {
mCatCallSetUpRegistrant.notifyRegistrant(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_SIM_SMS_STORAGE_FULL:
if (RILJ_LOGD) unsljLog(response);
if (mIccSmsFullRegistrant != null) {
mIccSmsFullRegistrant.notifyRegistrant();
}
break;
case RIL_UNSOL_SIM_REFRESH:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mIccRefreshRegistrants != null) {
mIccRefreshRegistrants.notifyRegistrants(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_CALL_RING:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mRingRegistrant != null) {
mRingRegistrant.notifyRegistrant(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_RESTRICTED_STATE_CHANGED:
if (RILJ_LOGD) unsljLogvRet(response, ret);
if (mRestrictedStateRegistrant != null) {
mRestrictedStateRegistrant.notifyRegistrant(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
if (RILJ_LOGD) unsljLog(response);
if (mIccStatusChangedRegistrants != null) {
mIccStatusChangedRegistrants.notifyRegistrants();
}
break;
case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS:
if (RILJ_LOGD) unsljLog(response);
SmsMessage sms = (SmsMessage) ret;
if (mCdmaSmsRegistrant != null) {
mCdmaSmsRegistrant
.notifyRegistrant(new AsyncResult(null, sms, null));
}
break;
case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
if (RILJ_LOGD) unsljLog(response);
if (mGsmBroadcastSmsRegistrant != null) {
mGsmBroadcastSmsRegistrant
.notifyRegistrant(new AsyncResult(null, ret, null));
}
break;
case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL:
if (RILJ_LOGD) unsljLog(response);
if (mIccSmsFullRegistrant != null) {
mIccSmsFullRegistrant.notifyRegistrant();
}
break;
case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE:
if (RILJ_LOGD) unsljLog(response);
if (mEmergencyCallbackModeRegistrant != null) {
mEmergencyCallbackModeRegistrant.notifyRegistrant();
}
break;
case RIL_UNSOL_CDMA_CALL_WAITING:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mCallWaitingInfoRegistrants != null) {
mCallWaitingInfoRegistrants.notifyRegistrants(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mOtaProvisionRegistrants != null) {
mOtaProvisionRegistrants.notifyRegistrants(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_CDMA_INFO_REC:
ArrayList<CdmaInformationRecords> listInfoRecs;
try {
listInfoRecs = (ArrayList<CdmaInformationRecords>)ret;
} catch (ClassCastException e) {
Log.e(LOG_TAG, "Unexpected exception casting to listInfoRecs", e);
break;
}
for (CdmaInformationRecords rec : listInfoRecs) {
if (RILJ_LOGD) unsljLogRet(response, rec);
notifyRegistrantsCdmaInfoRec(rec);
}
break;
case RIL_UNSOL_OEM_HOOK_RAW:
if (RILJ_LOGD) unsljLogvRet(response, IccUtils.bytesToHexString((byte[])ret));
if (mUnsolOemHookRawRegistrant != null) {
mUnsolOemHookRawRegistrant.notifyRegistrant(new AsyncResult(null, ret, null));
}
break;
case RIL_UNSOL_RINGBACK_TONE:
if (RILJ_LOGD) unsljLogvRet(response, ret);
if (mRingbackToneRegistrants != null) {
boolean playtone = (((int[])ret)[0] == 1);
mRingbackToneRegistrants.notifyRegistrants(
new AsyncResult (null, playtone, null));
}
break;
case RIL_UNSOL_RESEND_INCALL_MUTE:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mResendIncallMuteRegistrants != null) {
mResendIncallMuteRegistrants.notifyRegistrants(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mVoiceRadioTechChangedRegistrants != null) {
mVoiceRadioTechChangedRegistrants.notifyRegistrants(
new AsyncResult(null, ret, null));
}
break;
case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mCdmaSubscriptionChangedRegistrants != null) {
mCdmaSubscriptionChangedRegistrants.notifyRegistrants(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOl_CDMA_PRL_CHANGED:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mCdmaPrlChangedRegistrants != null) {
mCdmaPrlChangedRegistrants.notifyRegistrants(
new AsyncResult (null, ret, null));
}
break;
case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE:
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mExitEmergencyCallbackModeRegistrants != null) {
mExitEmergencyCallbackModeRegistrants.notifyRegistrants(
new AsyncResult (null, null, null));
}
break;
case RIL_UNSOL_RIL_CONNECTED: {
if (RILJ_LOGD) unsljLogRet(response, ret);
// Initial conditions
setRadioPower(false, null);
setPreferredNetworkType(mPreferredNetworkType, null);
setCdmaSubscriptionSource(mCdmaSubscription, null);
notifyRegistrantsRilConnectionChanged(((int[])ret)[0]);
break;
}
// Samsung STK
case RIL_UNSOL_STK_SEND_SMS_RESULT:
if (Resources.getSystem().
getBoolean(com.android.internal.R.bool.config_samsung_stk)) {
if (RILJ_LOGD) unsljLogRet(response, ret);
if (mCatSendSmsResultRegistrant != null) {
mCatSendSmsResultRegistrant.notifyRegistrant(
new AsyncResult (null, ret, null));
}
}
break;
}
}
/**
* Notifiy all registrants that the ril has connected or disconnected.
*
* @param rilVer is the version of the ril or -1 if disconnected.
*/
private void notifyRegistrantsRilConnectionChanged(int rilVer) {
mRilVersion = rilVer;
if (mRilConnectedRegistrants != null) {
mRilConnectedRegistrants.notifyRegistrants(
new AsyncResult (null, new Integer(rilVer), null));
}
}
protected Object
responseInts(Parcel p) {
int numInts;
int response[];
numInts = p.readInt();
response = new int[numInts];
for (int i = 0 ; i < numInts ; i++) {
response[i] = p.readInt();
}
return response;
}
protected Object
responseVoid(Parcel p) {
return null;
}
protected Object
responseCallForward(Parcel p) {
int numInfos;
CallForwardInfo infos[];
numInfos = p.readInt();
infos = new CallForwardInfo[numInfos];
for (int i = 0 ; i < numInfos ; i++) {
infos[i] = new CallForwardInfo();
infos[i].status = p.readInt();
infos[i].reason = p.readInt();
infos[i].serviceClass = p.readInt();
infos[i].toa = p.readInt();
infos[i].number = p.readString();
infos[i].timeSeconds = p.readInt();
}
return infos;
}
protected Object
responseSuppServiceNotification(Parcel p) {
SuppServiceNotification notification = new SuppServiceNotification();
notification.notificationType = p.readInt();
notification.code = p.readInt();
notification.index = p.readInt();
notification.type = p.readInt();
notification.number = p.readString();
return notification;
}
protected Object
responseCdmaSms(Parcel p) {
SmsMessage sms;
sms = SmsMessage.newFromParcel(p);
return sms;
}
protected Object
responseString(Parcel p) {
String response;
response = p.readString();
return response;
}
protected Object
responseStrings(Parcel p) {
int num;
String response[];
response = p.readStringArray();
if (false) {
num = p.readInt();
response = new String[num];
for (int i = 0; i < num; i++) {
response[i] = p.readString();
}
}
return response;
}
protected Object
responseRaw(Parcel p) {
int num;
byte response[];
response = p.createByteArray();
return response;
}
protected Object
responseSMS(Parcel p) {
int messageRef, errorCode;
String ackPDU;
messageRef = p.readInt();
ackPDU = p.readString();
errorCode = p.readInt();
SmsResponse response = new SmsResponse(messageRef, ackPDU, errorCode);
return response;
}
protected Object
responseICC_IO(Parcel p) {
int sw1, sw2;
byte data[] = null;
Message ret;
sw1 = p.readInt();
sw2 = p.readInt();
String s = p.readString();
if (RILJ_LOGV) riljLog("< iccIO: "
+ " 0x" + Integer.toHexString(sw1)
+ " 0x" + Integer.toHexString(sw2) + " "
+ s);
return new IccIoResult(sw1, sw2, s);
}
@Override
public boolean needsOldRilFeature(String feature) {
String[] features = SystemProperties.get("ro.telephony.ril.v3", "").split(",");
for (String found: features) {
if (found.equals(feature))
return true;
}
return false;
}
protected Object
responseIccCardStatus(Parcel p) {
IccCardApplicationStatus appStatus;
boolean oldRil = needsOldRilFeature("icccardstatus");
IccCardStatus cardStatus = new IccCardStatus();
cardStatus.setCardState(p.readInt());
cardStatus.setUniversalPinState(p.readInt());
cardStatus.mGsmUmtsSubscriptionAppIndex = p.readInt();
cardStatus.mCdmaSubscriptionAppIndex = p.readInt();
if (!oldRil)
cardStatus.mImsSubscriptionAppIndex = p.readInt();
int numApplications = p.readInt();
// limit to maximum allowed applications
if (numApplications > IccCardStatus.CARD_MAX_APPS) {
numApplications = IccCardStatus.CARD_MAX_APPS;
}
cardStatus.mApplications = new IccCardApplicationStatus[numApplications];
for (int i = 0 ; i < numApplications ; i++) {
appStatus = new IccCardApplicationStatus();
appStatus.app_type = appStatus.AppTypeFromRILInt(p.readInt());
appStatus.app_state = appStatus.AppStateFromRILInt(p.readInt());
appStatus.perso_substate = appStatus.PersoSubstateFromRILInt(p.readInt());
appStatus.aid = p.readString();
appStatus.app_label = p.readString();
appStatus.pin1_replaced = p.readInt();
appStatus.pin1 = appStatus.PinStateFromRILInt(p.readInt());
appStatus.pin2 = appStatus.PinStateFromRILInt(p.readInt());
cardStatus.mApplications[i] = appStatus;
}
return cardStatus;
}
protected Object
responseSimRefresh(Parcel p) {
IccRefreshResponse response = new IccRefreshResponse();
response.refreshResult = p.readInt();
response.efId = p.readInt();
response.aid = p.readString();
return response;
}
protected Object
responseCallList(Parcel p) {
int num;
int voiceSettings;
ArrayList<DriverCall> response;
DriverCall dc;
num = p.readInt();
response = new ArrayList<DriverCall>(num);
if (RILJ_LOGV) {
riljLog("responseCallList: num=" + num +
" mEmergencyCallbackModeRegistrant=" + mEmergencyCallbackModeRegistrant +
" mTestingEmergencyCall=" + mTestingEmergencyCall.get());
}
for (int i = 0 ; i < num ; i++) {
dc = new DriverCall();
dc.state = DriverCall.stateFromCLCC(p.readInt());
dc.index = p.readInt();
dc.TOA = p.readInt();
dc.isMpty = (0 != p.readInt());
dc.isMT = (0 != p.readInt());
dc.als = p.readInt();
voiceSettings = p.readInt();
dc.isVoice = (0 == voiceSettings) ? false : true;
dc.isVoicePrivacy = (0 != p.readInt());
dc.number = p.readString();
int np = p.readInt();
dc.numberPresentation = DriverCall.presentationFromCLIP(np);
dc.name = p.readString();
dc.namePresentation = p.readInt();
int uusInfoPresent = p.readInt();
if (uusInfoPresent == 1) {
dc.uusInfo = new UUSInfo();
dc.uusInfo.setType(p.readInt());
dc.uusInfo.setDcs(p.readInt());
byte[] userData = p.createByteArray();
dc.uusInfo.setUserData(userData);
riljLogv(String.format("Incoming UUS : type=%d, dcs=%d, length=%d",
dc.uusInfo.getType(), dc.uusInfo.getDcs(),
dc.uusInfo.getUserData().length));
riljLogv("Incoming UUS : data (string)="
+ new String(dc.uusInfo.getUserData()));
riljLogv("Incoming UUS : data (hex): "
+ IccUtils.bytesToHexString(dc.uusInfo.getUserData()));
} else {
riljLogv("Incoming UUS : NOT present!");
}
// Make sure there's a leading + on addresses with a TOA of 145
dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA);
response.add(dc);
if (dc.isVoicePrivacy) {
mVoicePrivacyOnRegistrants.notifyRegistrants();
riljLog("InCall VoicePrivacy is enabled");
} else {
mVoicePrivacyOffRegistrants.notifyRegistrants();
riljLog("InCall VoicePrivacy is disabled");
}
}
Collections.sort(response);
if ((num == 0) && mTestingEmergencyCall.getAndSet(false)) {
if (mEmergencyCallbackModeRegistrant != null) {
riljLog("responseCallList: call ended, testing emergency call," +
" notify ECM Registrants");
mEmergencyCallbackModeRegistrant.notifyRegistrant();
}
}
return response;
}
protected DataCallState getDataCallState(Parcel p, int version) {
DataCallState dataCall = new DataCallState();
dataCall.version = version;
if (version < 5) {
dataCall.cid = p.readInt();
dataCall.active = p.readInt();
dataCall.type = p.readString();
if (version < 4 || needsOldRilFeature("datacallapn")) {
p.readString(); // APN - not used
}
String addresses = p.readString();
if (!TextUtils.isEmpty(addresses)) {
dataCall.addresses = addresses.split(" ");
}
// DataCallState needs an ifname. Since we don't have one use the name from the ThrottleService resource (default=rmnet0).
dataCall.ifname = Resources.getSystem().getString(com.android.internal.R.string.config_datause_iface);
} else {
dataCall.status = p.readInt();
if (needsOldRilFeature("usehcradio"))
dataCall.suggestedRetryTime = -1;
else
dataCall.suggestedRetryTime = p.readInt();
dataCall.cid = p.readInt();
dataCall.active = p.readInt();
dataCall.type = p.readString();
dataCall.ifname = p.readString();
if ((dataCall.status == DataConnection.FailCause.NONE.getErrorCode()) &&
TextUtils.isEmpty(dataCall.ifname)) {
throw new RuntimeException("getDataCallState, no ifname");
}
String addresses = p.readString();
if (!TextUtils.isEmpty(addresses)) {
dataCall.addresses = addresses.split(" ");
}
String dnses = p.readString();
if (!TextUtils.isEmpty(dnses)) {
dataCall.dnses = dnses.split(" ");
}
String gateways = p.readString();
if (!TextUtils.isEmpty(gateways)) {
dataCall.gateways = gateways.split(" ");
}
}
return dataCall;
}
protected Object
responseDataCallList(Parcel p) {
ArrayList<DataCallState> response;
boolean oldRil = needsOldRilFeature("datacall");
int ver = (oldRil ? 3 : p.readInt());
int num = p.readInt();
riljLog("responseDataCallList ver=" + ver + " num=" + num);
response = new ArrayList<DataCallState>(num);
for (int i = 0; i < num; i++) {
response.add(getDataCallState(p, ver));
}
return response;
}
protected Object
responseSetupDataCall(Parcel p) {
boolean oldRil = needsOldRilFeature("datacall");
int ver = (oldRil ? 3 : p.readInt());
int num = p.readInt();
if (RILJ_LOGV) riljLog("responseSetupDataCall ver=" + ver + " num=" + num);
DataCallState dataCall;
if (ver < 5) {
dataCall = new DataCallState();
dataCall.version = ver;
dataCall.cid = Integer.parseInt(p.readString());
dataCall.ifname = p.readString();
if (TextUtils.isEmpty(dataCall.ifname)) {
throw new RuntimeException(
"RIL_REQUEST_SETUP_DATA_CALL response, no ifname");
}
String addresses = p.readString();
if (!TextUtils.isEmpty(addresses)) {
dataCall.addresses = addresses.split(" ");
}
if (num >= 4) {
String dnses = p.readString();
if (RILJ_LOGD) riljLog("responseSetupDataCall got dnses=" + dnses);
if (!TextUtils.isEmpty(dnses)) {
dataCall.dnses = dnses.split(" ");
}
}
if (num >= 5) {
String gateways = p.readString();
if (RILJ_LOGD) riljLog("responseSetupDataCall got gateways=" + gateways);
if (!TextUtils.isEmpty(gateways)) {
dataCall.gateways = gateways.split(" ");
}
}
} else {
if (num != 1) {
throw new RuntimeException(
"RIL_REQUEST_SETUP_DATA_CALL response expecting 1 RIL_Data_Call_response_v5"
+ " got " + num);
}
dataCall = getDataCallState(p, ver);
}
return dataCall;
}
protected Object
responseOperatorInfos(Parcel p) {
String strings[] = (String [])responseStrings(p);
ArrayList<OperatorInfo> ret;
if (strings.length % mQANElements != 0) {
throw new RuntimeException(
"RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
+ strings.length + " strings, expected multiple of " + mQANElements);
}
ret = new ArrayList<OperatorInfo>(strings.length / mQANElements);
for (int i = 0 ; i < strings.length ; i += mQANElements) {
ret.add (
new OperatorInfo(
strings[i+0],
strings[i+1],
strings[i+2],
strings[i+3]));
}
return ret;
}
protected Object
responseCellList(Parcel p) {
int num, rssi;
String location;
ArrayList<NeighboringCellInfo> response;
NeighboringCellInfo cell;
num = p.readInt();
response = new ArrayList<NeighboringCellInfo>();
// Determine the radio access type
String radioString = SystemProperties.get(
TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, "unknown");
int radioType;
if (radioString.equals("GPRS")) {
radioType = NETWORK_TYPE_GPRS;
} else if (radioString.equals("EDGE")) {
radioType = NETWORK_TYPE_EDGE;
} else if (radioString.equals("UMTS")) {
radioType = NETWORK_TYPE_UMTS;
} else if (radioString.equals("HSDPA")) {
radioType = NETWORK_TYPE_HSDPA;
} else if (radioString.equals("HSUPA")) {
radioType = NETWORK_TYPE_HSUPA;
} else if (radioString.equals("HSPA")) {
radioType = NETWORK_TYPE_HSPA;
} else if (radioString.equals("HSPAP")) {
radioType = NETWORK_TYPE_HSPAP;
} else {
radioType = NETWORK_TYPE_UNKNOWN;
}
// Interpret the location based on radio access type
if (radioType != NETWORK_TYPE_UNKNOWN) {
for (int i = 0 ; i < num ; i++) {
rssi = p.readInt();
location = p.readString();
cell = new NeighboringCellInfo(rssi, location, radioType);
response.add(cell);
}
}
return response;
}
protected Object responseGetPreferredNetworkType(Parcel p) {
int [] response = (int[]) responseInts(p);
if (response.length >= 1) {
// Since this is the response for getPreferredNetworkType
// we'll assume that it should be the value we want the
// vendor ril to take if we reestablish a connection to it.
mPreferredNetworkType = response[0];
}
return response;
}
protected Object responseGmsBroadcastConfig(Parcel p) {
int num;
ArrayList<SmsBroadcastConfigInfo> response;
SmsBroadcastConfigInfo info;
num = p.readInt();
response = new ArrayList<SmsBroadcastConfigInfo>(num);
for (int i = 0; i < num; i++) {
int fromId = p.readInt();
int toId = p.readInt();
int fromScheme = p.readInt();
int toScheme = p.readInt();
boolean selected = (p.readInt() == 1);
info = new SmsBroadcastConfigInfo(fromId, toId, fromScheme,
toScheme, selected);
response.add(info);
}
return response;
}
protected Object
responseCdmaBroadcastConfig(Parcel p) {
int numServiceCategories;
int response[];
numServiceCategories = p.readInt();
if (numServiceCategories == 0) {
// TODO: The logic of providing default values should
// not be done by this transport layer. And needs to
// be done by the vendor ril or application logic.
int numInts;
numInts = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES * CDMA_BSI_NO_OF_INTS_STRUCT + 1;
response = new int[numInts];
// Faking a default record for all possible records.
response[0] = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES;
// Loop over CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES set 'english' as
// default language and selection status to false for all.
for (int i = 1; i < numInts; i += CDMA_BSI_NO_OF_INTS_STRUCT ) {
response[i + 0] = i / CDMA_BSI_NO_OF_INTS_STRUCT;
response[i + 1] = 1;
response[i + 2] = 0;
}
} else {
int numInts;
numInts = (numServiceCategories * CDMA_BSI_NO_OF_INTS_STRUCT) + 1;
response = new int[numInts];
response[0] = numServiceCategories;
for (int i = 1 ; i < numInts; i++) {
response[i] = p.readInt();
}
}
return response;
}
protected Object
responseSignalStrength(Parcel p) {
SignalStrength signalStrength = new SignalStrength(p);
return signalStrength;
}
protected ArrayList<CdmaInformationRecords>
responseCdmaInformationRecord(Parcel p) {
int numberOfInfoRecs;
ArrayList<CdmaInformationRecords> response;
/**
* Loop through all of the information records unmarshalling them
* and converting them to Java Objects.
*/
numberOfInfoRecs = p.readInt();
response = new ArrayList<CdmaInformationRecords>(numberOfInfoRecs);
for (int i = 0; i < numberOfInfoRecs; i++) {
CdmaInformationRecords InfoRec = new CdmaInformationRecords(p);
response.add(InfoRec);
}
return response;
}
protected Object
responseCdmaCallWaiting(Parcel p) {
CdmaCallWaitingNotification notification = new CdmaCallWaitingNotification();
notification.number = p.readString();
notification.numberPresentation = notification.presentationFromCLIP(p.readInt());
notification.name = p.readString();
notification.namePresentation = notification.numberPresentation;
notification.isPresent = p.readInt();
notification.signalType = p.readInt();
notification.alertPitch = p.readInt();
notification.signal = p.readInt();
notification.numberType = p.readInt();
notification.numberPlan = p.readInt();
return notification;
}
protected Object
responseCallRing(Parcel p){
char response[] = new char[4];
response[0] = (char) p.readInt(); // isPresent
response[1] = (char) p.readInt(); // signalType
response[2] = (char) p.readInt(); // alertPitch
response[3] = (char) p.readInt(); // signal
return response;
}
protected void
notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec) {
int response = RIL_UNSOL_CDMA_INFO_REC;
if (infoRec.record instanceof CdmaInformationRecords.CdmaDisplayInfoRec) {
if (mDisplayInfoRegistrants != null) {
if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
mDisplayInfoRegistrants.notifyRegistrants(
new AsyncResult (null, infoRec.record, null));
}
} else if (infoRec.record instanceof CdmaInformationRecords.CdmaSignalInfoRec) {
if (mSignalInfoRegistrants != null) {
if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
mSignalInfoRegistrants.notifyRegistrants(
new AsyncResult (null, infoRec.record, null));
}
} else if (infoRec.record instanceof CdmaInformationRecords.CdmaNumberInfoRec) {
if (mNumberInfoRegistrants != null) {
if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
mNumberInfoRegistrants.notifyRegistrants(
new AsyncResult (null, infoRec.record, null));
}
} else if (infoRec.record instanceof CdmaInformationRecords.CdmaRedirectingNumberInfoRec) {
if (mRedirNumInfoRegistrants != null) {
if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
mRedirNumInfoRegistrants.notifyRegistrants(
new AsyncResult (null, infoRec.record, null));
}
} else if (infoRec.record instanceof CdmaInformationRecords.CdmaLineControlInfoRec) {
if (mLineControlInfoRegistrants != null) {
if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
mLineControlInfoRegistrants.notifyRegistrants(
new AsyncResult (null, infoRec.record, null));
}
} else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53ClirInfoRec) {
if (mT53ClirInfoRegistrants != null) {
if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
mT53ClirInfoRegistrants.notifyRegistrants(
new AsyncResult (null, infoRec.record, null));
}
} else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53AudioControlInfoRec) {
if (mT53AudCntrlInfoRegistrants != null) {
if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
mT53AudCntrlInfoRegistrants.notifyRegistrants(
new AsyncResult (null, infoRec.record, null));
}
}
}
static String
requestToString(int request) {
/*
cat libs/telephony/ril_commands.h \
| egrep "^ *{RIL_" \
| sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
*/
switch(request) {
case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
case RIL_REQUEST_DIAL: return "DIAL";
case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
case RIL_REQUEST_HANGUP: return "HANGUP";
case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
case RIL_REQUEST_UDUB: return "UDUB";
case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE";
case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE";
case RIL_REQUEST_OPERATOR: return "OPERATOR";
case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
case RIL_REQUEST_DTMF: return "DTMF";
case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
case RIL_REQUEST_SIM_IO: return "SIM_IO";
case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
case RIL_REQUEST_ANSWER: return "ANSWER";
case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
case RIL_REQUEST_DTMF_START: return "DTMF_START";
case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "SET_SUPP_SVC_NOTIFICATION";
case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM";
case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM";
case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
case RIL_REQUEST_STK_GET_PROFILE: return "REQUEST_STK_GET_PROFILE";
case RIL_REQUEST_STK_SET_PROFILE: return "REQUEST_STK_SET_PROFILE";
case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "REQUEST_STK_SEND_ENVELOPE_COMMAND";
case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "REQUEST_STK_SEND_TERMINAL_RESPONSE";
case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "REQUEST_EXPLICIT_CALL_TRANSFER";
case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "REQUEST_SET_PREFERRED_NETWORK_TYPE";
case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "REQUEST_GET_PREFERRED_NETWORK_TYPE";
case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "REQUEST_GET_NEIGHBORING_CELL_IDS";
case RIL_REQUEST_SET_LOCATION_UPDATES: return "REQUEST_SET_LOCATION_UPDATES";
case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE";
case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: return "RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE";
case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: return "RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE";
case RIL_REQUEST_SET_TTY_MODE: return "RIL_REQUEST_SET_TTY_MODE";
case RIL_REQUEST_QUERY_TTY_MODE: return "RIL_REQUEST_QUERY_TTY_MODE";
case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: return "RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: return "RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
case RIL_REQUEST_CDMA_FLASH: return "RIL_REQUEST_CDMA_FLASH";
case RIL_REQUEST_CDMA_BURST_DTMF: return "RIL_REQUEST_CDMA_BURST_DTMF";
case RIL_REQUEST_CDMA_SEND_SMS: return "RIL_REQUEST_CDMA_SEND_SMS";
case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: return "RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE";
case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_GET_BROADCAST_CONFIG";
case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_SET_BROADCAST_CONFIG";
case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG";
case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG";
case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: return "RIL_REQUEST_GSM_BROADCAST_ACTIVATION";
case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return "RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY";
case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: return "RIL_REQUEST_CDMA_BROADCAST_ACTIVATION";
case RIL_REQUEST_CDMA_SUBSCRIPTION: return "RIL_REQUEST_CDMA_SUBSCRIPTION";
case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM";
case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM";
case RIL_REQUEST_DEVICE_IDENTITY: return "RIL_REQUEST_DEVICE_IDENTITY";
case RIL_REQUEST_GET_SMSC_ADDRESS: return "RIL_REQUEST_GET_SMSC_ADDRESS";
case RIL_REQUEST_SET_SMSC_ADDRESS: return "RIL_REQUEST_SET_SMSC_ADDRESS";
case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "REQUEST_EXIT_EMERGENCY_CALLBACK_MODE";
case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS";
case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING";
case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE";
case RIL_REQUEST_ISIM_AUTHENTICATION: return "RIL_REQUEST_ISIM_AUTHENTICATION";
case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
case RIL_REQUEST_VOICE_RADIO_TECH: return "RIL_REQUEST_VOICE_RADIO_TECH";
default: return "<unknown request>";
}
}
static String
responseToString(int request)
{
/*
cat libs/telephony/ril_unsol_commands.h \
| egrep "^ *{RIL_" \
| sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
*/
switch(request) {
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST";
case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
case RIL_UNSOL_SUPP_SVC_NOTIFICATION: return "UNSOL_SUPP_SVC_NOTIFICATION";
case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FULL";
case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_RESPONSE_CDMA_NEW_SMS";
case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_RESPONSE_NEW_BROADCAST_SMS";
case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "CDMA_SUBSCRIPTION_SOURCE_CHANGED";
case RIL_UNSOl_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
case RIL_UNSOL_STK_SEND_SMS_RESULT: return "RIL_UNSOL_STK_SEND_SMS_RESULT";
default: return "<unknown reponse>";
}
}
protected void riljLog(String msg) {
Log.d(LOG_TAG, msg);
}
protected void riljLogv(String msg) {
Log.v(LOG_TAG, msg);
}
protected void unsljLog(int response) {
riljLog("[UNSL]< " + responseToString(response));
}
protected void unsljLogMore(int response, String more) {
riljLog("[UNSL]< " + responseToString(response) + " " + more);
}
protected void unsljLogRet(int response, Object ret) {
riljLog("[UNSL]< " + responseToString(response) + " " + retToString(response, ret));
}
protected void unsljLogvRet(int response, Object ret) {
riljLogv("[UNSL]< " + responseToString(response) + " " + retToString(response, ret));
}
// ***** Methods for CDMA support
public void
getDeviceIdentity(Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_DEVICE_IDENTITY, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void
getCDMASubscription(Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SUBSCRIPTION, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
@Override
public void setPhoneType(int phoneType) { // Called by CDMAPhone and GSMPhone constructor
if (RILJ_LOGD) riljLog("setPhoneType=" + phoneType + " old value=" + mPhoneType);
mPhoneType = phoneType;
}
/**
* {@inheritDoc}
*/
public void queryCdmaRoamingPreference(Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, response);
rr.mp.writeInt(1);
rr.mp.writeInt(cdmaRoamingType);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " : " + cdmaRoamingType);
send(rr);
}
/**
* {@inheritDoc}
*/
public void setCdmaSubscriptionSource(int cdmaSubscription , Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, response);
rr.mp.writeInt(1);
rr.mp.writeInt(cdmaSubscription);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " : " + cdmaSubscription);
send(rr);
}
/**
* {@inheritDoc}
*/
@Override
public void getCdmaSubscriptionSource(Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void queryTTYMode(Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_QUERY_TTY_MODE, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void setTTYMode(int ttyMode, Message response) {
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_SET_TTY_MODE, response);
rr.mp.writeInt(1);
rr.mp.writeInt(ttyMode);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " : " + ttyMode);
send(rr);
}
/**
* {@inheritDoc}
*/
public void
sendCDMAFeatureCode(String FeatureCode, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_FLASH, response);
rr.mp.writeString(FeatureCode);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ " : " + FeatureCode);
send(rr);
}
public void getCdmaBroadcastConfig(Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG, response);
send(rr);
}
// TODO: Change the configValuesArray to a RIL_BroadcastSMSConfig
public void setCdmaBroadcastConfig(int[] configValuesArray, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG, response);
for(int i = 0; i < configValuesArray.length; i++) {
rr.mp.writeInt(configValuesArray[i]);
}
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void setCdmaBroadcastActivation(boolean activate, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_BROADCAST_ACTIVATION, response);
rr.mp.writeInt(1);
rr.mp.writeInt(activate ? 0 :1);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/**
* {@inheritDoc}
*/
public void exitEmergencyCallbackMode(Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE, response);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
public void requestIsimAuthentication(String nonce, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_ISIM_AUTHENTICATION, response);
rr.mp.writeString(nonce);
if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
send(rr);
}
/* (non-Javadoc)
* @see com.android.internal.telephony.BaseCommands#testingEmergencyCall()
*/
@Override
public void testingEmergencyCall() {
if (RILJ_LOGD) riljLog("testingEmergencyCall");
mTestingEmergencyCall.set(true);
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("RIL:");
pw.println(" mSocket=" + mSocket);
pw.println(" mSenderThread=" + mSenderThread);
pw.println(" mSender=" + mSender);
pw.println(" mReceiverThread=" + mReceiverThread);
pw.println(" mReceiver=" + mReceiver);
pw.println(" mWakeLock=" + mWakeLock);
pw.println(" mWakeLockTimeout=" + mWakeLockTimeout);
synchronized (mRequestsList) {
pw.println(" mRequestMessagesPending=" + mRequestMessagesPending);
pw.println(" mRequestMessagesWaiting=" + mRequestMessagesWaiting);
int count = mRequestsList.size();
pw.println(" mRequestList count=" + count);
for (int i = 0; i < count; i++) {
RILRequest rr = mRequestsList.get(i);
pw.println(" [" + rr.mSerial + "] " + requestToString(rr.mRequest));
}
}
pw.println(" mLastNITZTimeInfo=" + mLastNITZTimeInfo);
pw.println(" mTestingEmergencyCall=" + mTestingEmergencyCall.get());
}
}
|