blob: 639f4c6b827ee6204d175cfc28ee2b48f758dbce [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/* Copyright Statement:
2 *
3 * This software/firmware and related documentation ("MediaTek Software") are
4 * protected under relevant copyright laws. The information contained herein
5 * is confidential and proprietary to MediaTek Inc. and/or its licensors.
6 * Without the prior written permission of MediaTek inc. and/or its licensors,
7 * any reproduction, modification, use or disclosure of MediaTek Software,
8 * and information contained herein, in whole or in part, shall be strictly prohibited.
9 */
10/* MediaTek Inc. (C) 2010. All rights reserved.
11 *
12 * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
13 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
14 * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
15 * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
18 * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
19 * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
20 * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
21 * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
22 * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
23 * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
24 * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
25 * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
26 * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
27 * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
28 * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
29 * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
30 *
31 * The following software/firmware and/or related documentation ("MediaTek Software")
32 * have been modified by MediaTek Inc. All revisions are subject to any receiver's
33 * applicable license agreements with MediaTek Inc.
34 */
35#include <alloca.h>
36#include <stdlib.h>
37#include <stdio.h>
38#include <cutils/jstring.h>
39#include <log/log.h>
40
41#include "common.h"
42#include "network.h"
43
44#undef LOG_TAG
45#define LOG_TAG "DEMO_NETWORK"
46
47//if signal_strength_printf isn't 0, open signal strength printf log.
48//otherwise close.
49int signal_strength_printf = 0;
50
51int getSignalStrength (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
52 android::Parcel p;
53
54 if(1 != argc)
55 {
56 free(pRI);
57 RLOGD("getSignalStrength param num should be 0");
58 return 0;
59 }
60
61 pRI->pCI->dispatchFunction(p, pRI);
62 return 0;
63}
64
65int getOperator (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
66 android::Parcel p;
67
68 if (1 != argc) {
69 free(pRI);
70 RLOGD("getOperator param num should be 0");
71 return 0;
72 }
73
74 pRI->pCI->dispatchFunction(p, pRI);
75 return 0;
76}
77
78int getNetworkSelectionMode (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
79 android::Parcel p;
80
81 if (1 != argc) {
82 free(pRI);
83 RLOGD("getNetworkSelectionMode param num should be 0");
84 return 0;
85 }
86
87 pRI->pCI->dispatchFunction(p, pRI);
88 return 0;
89}
90
91int setNetworkSelectionModeAutomatic (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
92 android::Parcel p;
93
94 if (1 != argc) {
95 free(pRI);
96 RLOGD("setNetworkSelectionModeAutomatic param num should be 0");
97 return 0;
98 }
99
100 pRI->pCI->dispatchFunction(p, pRI);
101 return 0;
102}
103
104int setNetworkSelectionModeManual(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
105 android::Parcel p;
106 size_t pos = p.dataPosition();
107
108 writeStringToParcel(p, (const char *)argv[1]);
109
110 p.setDataPosition(pos);
111 pRI->pCI->dispatchFunction(p, pRI);
112
113 return 0;
114}
115
116int getAvailableNetworks (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
117 android::Parcel p;
118
119 if (1 != argc) {
120 free(pRI);
121 RLOGD("getAvailableNetworks param num should be 0");
122 return 0;
123 }
124
125 pRI->pCI->dispatchFunction(p, pRI);
126 return 0;
127}
128
129int getVoiceRegistrationState (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
130 android::Parcel p;
131
132 if (1 != argc) {
133 free(pRI);
134 RLOGD("getVoiceRegistrationState param num should be 0");
135 return 0;
136 }
137
138 pRI->pCI->dispatchFunction(p, pRI);
139
140 return 0;
141}
142
143int getDataRegistrationState (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
144 android::Parcel p;
145
146 if(1 != argc)
147 {
148 free(pRI);
149 RLOGD("getVoiceRegistrationState param num should be 0");
150 return -1;
151 }
152
153 pRI->pCI->dispatchFunction(p, pRI);
154 return 0;
155}
156
157int getImsRegistrationState (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
158 android::Parcel p;
159
160 if(1 != argc)
161 {
162 free(pRI);
163 RLOGD("getImsRegistrationState param num should be 0");
164 return -1;
165 }
166
167 pRI->pCI->dispatchFunction(p, pRI);
168
169 return 0;
170}
171
172int getPreferredNetworkType (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
173 android::Parcel p;
174
175 if(1 != argc)
176 {
177 free(pRI);
178 RLOGD("getPreferredNetworkType param num should be 0");
179 return 0;
180 //TBD check;
181 }
182
183 pRI->pCI->dispatchFunction(p, pRI);
184
185 return 0;
186}
187
188int setPreferredNetworkType(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
189 android::Parcel p;
190 size_t pos = p.dataPosition();
191 p.writeInt32(1);
192 p.writeInt32(atoi(argv[1]));
193 p.setDataPosition(pos);
194 pRI->pCI->dispatchFunction(p, pRI);
195 update_preferred_network_type(atoi(argv[1]), socket_id);
196 return 0;
197}
198
199int setLocationUpdates(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
200 android::Parcel p;
201 size_t pos = p.dataPosition();
202 p.writeInt32(1);
203 p.writeInt32(atoi(argv[1])? 1 : 0);
204 p.setDataPosition(pos);
205 pRI->pCI->dispatchFunction(p, pRI);
206
207 return 0;
208}
209
210int getCellInfoList (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
211 android::Parcel p;
212
213 if (1 != argc) {
214 free(pRI);
215 RLOGD("getCellInfoList param num should be 0");
216 return 0;
217 }
218
219 pRI->pCI->dispatchFunction(p, pRI);
220
221 return 0;
222}
223
224int setCellInfoListRate(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
225 android::Parcel p;
226 size_t pos = p.dataPosition();
227 p.writeInt32(1);
228 p.writeInt32(atoi(argv[1]));
229 p.setDataPosition(pos);
230 pRI->pCI->dispatchFunction(p, pRI);
231
232 return 0;
233}
234
235int getNeighboringCids (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
236 android::Parcel p;
237
238 if (1 != argc) {
239 free(pRI);
240 RLOGD("getNeighboringCids param num should be 0");
241 return 0;
242 }
243
244 pRI->pCI->dispatchFunction(p, pRI);
245
246 return 0;
247}
248
249int setBandMode (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
250 android::Parcel p;
251 size_t pos = p.dataPosition();
252 p.writeInt32(1);
253 p.writeInt32(atoi(argv[1]));
254 p.setDataPosition(pos);
255 pRI->pCI->dispatchFunction(p, pRI);
256
257 return 0;
258}
259
260int queryAvailableBandMode (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
261 android::Parcel p;
262
263 if (1 != argc) {
264 free(pRI);
265 RLOGD("queryAvailableBandMode param num should be 0");
266 return 0;
267 }
268
269 pRI->pCI->dispatchFunction(p, pRI);
270
271 return 0;
272}
273
274int setRadioPower (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
275 android::Parcel p;
276 size_t pos = p.dataPosition();
277 p.writeInt32(1);
278 p.writeInt32(atoi(argv[1])? 1 : 0);
279 p.setDataPosition(pos);
280 pRI->pCI->dispatchFunction(p, pRI);
281
282 return 0;
283}
284
285int getVoiceRadioTechnology (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
286 android::Parcel p;
287
288 if (1 != argc) {
289 free(pRI);
290 RLOGD("getNeighboringCids param num should be 0");
291 return 0;
292 }
293
294 pRI->pCI->dispatchFunction(p, pRI);
295
296 return 0;
297}
298//RIL_REQUEST_SET_RADIO_CAPABILITY
299int setRadioCapability(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
300{
301 if(7 != argc)
302 {
303 RLOGD("setRadioCapability param should be lost!");
304 return 0;
305 }
306 android::Parcel p;
307 size_t pos = p.dataPosition();
308
309 //version
310 p.writeInt32(atoi(argv[1]));
311 //session
312 p.writeInt32(atoi(argv[2]));
313 //phase
314 p.writeInt32(atoi(argv[3]));
315 //rat
316 p.writeInt32(atoi(argv[4]));
317 //logicalModemUuid
318 writeStringToParcel(p,(const char *) argv[5]);
319 //status
320 p.writeInt32(atoi(argv[6]));
321
322 p.setDataPosition(pos);
323 pRI->pCI->dispatchFunction(p, pRI);
324
325 return 0;
326}
327//RIL_REQUEST_GET_RADIO_CAPABILITY
328int getRadioCapability(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
329{
330 android::Parcel p;
331
332 if(1 != argc)
333 {
334 free(pRI);
335 RLOGD("getRadioCapability param num should be 0");
336 return 0;
337 }
338
339 pRI->pCI->dispatchFunction(p, pRI);
340 return 0;
341}
342
343int updateSignalPrintf(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
344{
345 signal_strength_printf=atoi(argv[1]);
346 printf("\nthe signal strength printf log will %s\n", signal_strength_printf == 0 ? "close" : "open");
347 free(pRI);
348}
349//RIL_REQUEST_MODEM_POWEROFF
350int setModemPowerOFF (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
351 android::Parcel p;
352 pRI->pCI->dispatchFunction(p, pRI);
353 return 0;
354}
355//RIL_REQUEST_MODEM_POWERON
356int setModemPowerON (int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
357 android::Parcel p;
358 pRI->pCI->dispatchFunction(p, pRI);
359 return 0;
360}
361
362//RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION
363int supplyNetworkDepersonalization(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
364 if(argc != 2)
365 {
366 free(pRI);
367 RLOGD("the peremeters numbers isn't right , so return");
368 return -1;
369 }
370 android::Parcel p;
371 size_t pos = p.dataPosition();
372 p.writeInt32(1);
373 writeStringToParcel(p, argv[1]);
374 p.setDataPosition(pos);
375
376 pRI->pCI->dispatchFunction(p, pRI);
377 return 0;
378}
379
380//RIL_REQUEST_REPORT_AIRPLANE_MODE
381int setReportAirplaneMode(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
382 if(argc != 2) {
383 RLOGW("parameter is invalid");
384 free(pRI);
385 return 0;
386 }
387
388 int state = (atoi(argv[1])!= 0) ? 1 : 0;
389
390 android::Parcel p;
391 size_t pos = p.dataPosition();
392 p.writeInt32(1);
393 p.writeInt32(state);
394 p.setDataPosition(pos);
395 pRI->pCI->dispatchFunction(p, pRI);
396 return 0;
397}
398
399//RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT
400/**
401* ”data” is NULL
402*”response” is const char ** that should be an arry of n*6, where n is the number of available networks
403*
404*((const char **)response)[n+0] is long alpha ONS or EONS
405*((const char **)response)[n+1] is short alpha ONS or EONS
406*((const char **)response)[n+2] is 5 or 6 digit numeric code
407*((const char **)response)[n+3] is a string value of :
408* “unkonwn”
409* “available”
410* “current”
411* “forbidden”
412*((const char **)response)[n+4] is lac
413*((const char **)response)[n+5] is a string value of the Act: “2G”, “3G”, “4G”
414**/
415int getAvailableNetworksWithAct(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
416 android::Parcel p;
417 pRI->pCI->dispatchFunction(p, pRI);
418 return 0;
419}
420