blob: f1ac525b6db7ddbcd82b69445cbfe9c33abee11d [file] [log] [blame]
xf.li771eb062025-02-09 23:05:11 -08001/**************************************************************************
2*
3* Copyright (c) 2013 ZTE Corporation.
4*
5***************************************************************************
6* Ä£ ¿é Ãû : Atserver
7* ÎÄ ¼þ Ãû : pb_proc.c
8* Ïà¹ØÎļþ :
9* ʵÏÖ¹¦ÄÜ : ATÃüÁî·¢Ëͺͽá¹û´¦ÀíÄ£¿éº¯Êý¶¨Òå
10* ×÷ Õß : syx
11* °æ ±¾ : V1.0
12* Íê³ÉÈÕÆÚ : 2013-04-16
13* ÆäËü˵Ã÷ :
14**************************************************************************/
15
16/**************************************************************************
17* Ð޸ļǼ :
18***************************************************************************/
19/**************************************************************************
20* Ð޸ıàºÅ :
21* ÐÞ ¸Ä ÈË :
22* ÐÞ¸ÄÈÕÆÚ :
23* ÐÞ¸ÄÄÚÈÝ :
24**************************************************************************/
25
26/**************************************************************************
27* #includeÇø
28**************************************************************************/
29//#include "port_com.h"
30//#include "at_main.h"
31//#include "at_proc.h"
xf.libfc6e712025-02-07 01:54:34 -080032#include <ctype.h>
33#include <semaphore.h>
34#include <limits.h>
35#include "pb_com.h"
xf.li771eb062025-02-09 23:05:11 -080036
37/**************************************************************************
38* ³£Á¿¶¨ÒåÇø
39**************************************************************************/
40#define ZPB_UCS2 1
41#define ZPB_UCS2_PREFIX 0x80
42#define ZPB_UCS2_PREFIX_LEN 2
43#define ZPB_NON_GSM 0x20
44#define ZPB_GSM_CHARACTER_SET_SIZE 0x80
45#define ZPB_INIT_LOAD_RECORD_NUM 50
46
47/**************************************************************************
48* Êý¾Ý½á¹¹¶¨ÒåÇø
49**************************************************************************/
50VOID atPb_CvtChCode(UINT16 basePointer, UINT8 srcData, UINT8 *chMsb, UINT8 *chLsb);
51BOOL atPb_CvtU82ToU80(const UINT8 *srcData, UINT32 srcLen, UINT8 *destData, UINT32 destLen);
52BOOL atPb_CvtU81ToU80(const UINT8 *srcData, UINT32 srcLen, UINT8 *destData, UINT32 destLen);
53extern VOID atPb_ClearSimPbmIndexArray(VOID);
54/**************************************************************************
55* staticº¯ÊýÉùÃ÷Çø
56**************************************************************************/
57
58/**************************************************************************
59* È«¾Ö±äÁ¿¶¨ÒåÇø
60**************************************************************************/
61extern sem_t g_Pb_sem_id;
62extern T_zPb_optRsp g_PbOptRsp;
63//UINT32 g_zPb_pbIndex = 0;
64UINT32 g_zPb_DelIndex = 0;
65SINT32 g_zPb_SimIndex[ZPB_SIM_MAX_RECORD+1] = {0};
66SINT32 g_zPb_ApIndex[ZPB_AP_MAX_RECORD+1] = {0};
67T_zPb_DelStatusMultiOrAll g_zPb_DelStatusUsim = {0};
68const unsigned char G_ZPB_NEWUCS2TOGSM[ZPB_GSM_CHARACTER_SET_SIZE*2] =
69 { /*+0x0 +0x1 +0x2 +0x3 +0x4 +0x5 +0x6 +0x7*/
70 /*0x00*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
71 /*0x08*/ ZPB_NON_GSM, ZPB_NON_GSM, 0x0a, ZPB_NON_GSM, ZPB_NON_GSM, 0x0d, ZPB_NON_GSM, ZPB_NON_GSM,
72 /*0x10*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
73 /*0x18*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
74 /*0x20*/ 0x20, 0x21, 0x22, 0x23, 0x02, 0x25, 0x26, 0x27,
75 /*0x28*/ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
76 /*0x30*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
77 /*0x38*/ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
78 /*0x40*/ 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
79 /*0x48*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
80 /*0x50*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
81 /*0x58*/ 0x58, 0x59, 0x5a, 0x5b, ZPB_NON_GSM, 0x5d, ZPB_NON_GSM, 0x11,
82 /*0x60*/ ZPB_NON_GSM, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
83 /*0x68*/ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
84 /*0x70*/ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
85 /*0x78*/ 0x78, 0x79, 0x7a, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
86 /*0x80*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
87 /*0x88*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
88 /*0x90*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
89 /*0x98*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
90 /*0xa0*/ ZPB_NON_GSM, 0x40, ZPB_NON_GSM, 0x01, 0x24, 0x03, ZPB_NON_GSM, 0x5f,
91 /*0xa8*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
92 /*0xb0*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
93 /*0xb8*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, 0x60,
94 /*0xc0*/ 0x41, 0x41, 0x41, 0x41, 0x5b, 0x0e, 0x1c, 0x09,
95 /*0xc8*/ 0x45, 0x1f, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
96 /*0xd0*/ ZPB_NON_GSM, 0x5d, 0x4f, 0x4f, 0x4f, 0x4f, 0x5c, ZPB_NON_GSM,
97 /*0xd8*/ 0x0b, 0x55, 0x55, 0x55, 0x5e, 0x59, ZPB_NON_GSM, 0x1e,
98 /*0xe0*/ 0x7f, 0x61, 0x61, 0x61, 0x7b, 0x0f, 0x1d, 0x09,
99 /*0xe8*/ 0x04, 0x05, 0x65, 0x65, 0x07, 0x69, 0x69, 0x69,
100 /*0xf0*/ ZPB_NON_GSM, 0x7d, 0x08, 0x6f, 0x6f, 0x6f, 0x7c, ZPB_NON_GSM,
101 /*0xf8*/ 0x0c, 0x06, 0x75, 0x75, 0x7e, 0x79, ZPB_NON_GSM, 0x79
102 };
103/**************************************************************************
104* º¯ÊýʵÏÖÇø
105**************************************************************************/
106VOID atPb_Init(VOID)
107{
108 UINT32 pbCount = 0;
109
110 g_zPb_SimIndex[0] = 0;
111
112 sc_cfg_set(ZPB_NV_INIT,ZPB_LOADING);
113 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
114
115 for(pbCount=1; pbCount<=ZPB_SIM_MAX_RECORD; pbCount++)
116 {
117 g_zPb_SimIndex[pbCount] = PBM_ERROR_NOT_FOUND;
118 }
119 if(ZPB_DB_OK != atPb_CreatDb())
120 {
121 slog(PB_PRINT,SLOG_ERR,"pb:atPb_Init:create pbm table failed\n");/*lint !e26*/
122 return;
123 }
124 if(ZPB_DB_OK != atPb_InitApIndex())
125 {
126 slog(PB_PRINT,SLOG_ERR,"pb:atPb_Init:init apIndex failed\n");
127 return;
128 }
129 (VOID)atPb_SetApCapacityTable();
130}
131
132VOID atPb_CfgPbNvInit(VOID)
133{
134 (VOID)sc_cfg_set(ZPB_NV_USIMINDEXMIN, "0");
135 (VOID)sc_cfg_set(ZPB_NV_USIMINDEXMAX, "0");
136 (VOID)sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
137}
138 /**
139 * º¯Êý»áÓÅÏÈʹÓÃ81ºÍ82¸ñʽ±àÂ룬Èç¹û²»Âú×ã±àÂëÌõ¼þ£¬Ñ¡Ôñ80¸ñʽ±àÂë
140 *
141 * @param src Ô´UCS2×Ö½ÚÊý×é
142 * @param srcLen Ô´×Ö½ÚÊý×鳤¶È
143 * @param dest Ä¿±êÊý×é
144 * @return Ä¿±êÊý×鳤¶È
145 */
146int atpb_CvtUcs2ToAlphaField(char *src, int srcLen,char* dest)
147{
148 int i = 0;
149 int min = 0x7FFF;
150 int max = 0;
151 int temp = 0;
152 int outOff = 0;
153
154 printf("[PB] atpb_CvtUcs2ToAlphaField, srcLen=%d\n",srcLen);
155 if(srcLen <= 0 || src == NULL ||dest == NULL)
156 {
157 return -1;
158 }
159
160 if(srcLen <= 2)
161 {
162 dest[0]=0x80;
163 memcpy(dest+1, src, srcLen);
164 printf("[PB] atpb_CvtUcs2ToAlphaField, use 80 code, len =%d\n",srcLen+1);
165 return srcLen+1;
166 }
167
168 // µ±Ô´Êý×éµÄ³¤¶È´óÓÚ2ʱ²ÅÄÜʹÓÃ81»òÕß82¸ñʽ
169
170 // È¡µÃÔ´Êý×éµÄ×îСֵÓë×î´óÖµ
171 for (i = 0; i < srcLen; i += 2)
172 {
173 //ÿ¸ö×Ö·ûµÄµÚ1¸ö×Ö½Ú²»Îª0
174 if (src[i] != 0)
175 {
176 temp = (int) (((src[i] << 8) & 0xFF00) | (src[i+1] & 0xFF));
177 // ÒòΪÔÚ81¸ñʽÖлùÖ·×óÒÆ7λºó×î¸ßλҪ²¹0£¬ËùÒÔ8000µ½FFFF²»ÄÜʹÓÃ81
178#if 0 //kw 3
179 if (temp < 0)
180 {
181 max = min + 130;
182 break;
183 }
xf.libfc6e712025-02-07 01:54:34 -0800184#endif
xf.li771eb062025-02-09 23:05:11 -0800185 if (min > temp)
186 {
187 min = temp;
188 }
189
190 if (max < temp)
191 {
192 max = temp;
193 }
194 }
195 }
196
197 printf("[PB] atpb_CvtUcs2ToAlphaField, min=%d, max=%d\n",min, max);
198 // Èç¹ûËùÓÐ×Ö·ûµÄUCSÂë¶¼ÔÚÁ¬ÐøµÄ128µÄ·¶Î§ÄÚ£¬ÄÇôµÚ1¸ö×Ö½Ú¶¼Ïàͬ
199 if ((max - min) < 129)
200 {
201 // Èç¹ûµÚ15λµ½µÚ8λÏàͬ£¬¾Í¿ÉÒÔʹÓÃ81¸ñʽ±àÂë
202 if ((unsigned char) (min & 0x80) == (unsigned char) (max & 0x80))
203 {
204 // Ëã³ö81¸ñʽµÄ³¤¶È£¬³õʼ»¯Ä¿±êÊý×é
205 //dest = new unsigned char[srcLen / 2 + 3];
206 // ÉèÖÃÄ¿±êÊý×éµÄµÚ2¸ö×Ö½ÚΪ³¤¶È
207 dest[1] = (unsigned char) (srcLen / 2);
208 // ÉèÖõÚ1¸ö×Ö½ÚΪ81
209 dest[0] = (unsigned char) 0x81;
210 // »ùַΪµÚ15λµ½µÚ8룬
211 min = (int) (min & 0x7F80);
212 dest[2] = (unsigned char) ((min >> 7) & 0xFF);
213 outOff = 3;
214 printf("[PB] atpb_CvtUcs2ToAlphaField, use 81 code\n");
215 }
216 // µÚ8¸ö×Ö½Ú²»Ò»Ñù£¨Ò»¸öΪ0£¬Ò»¸öΪ1£©£¬ÄÇô¾ÍʹÓÃ82¸ñʽ
217 else
218 {
219 // Ëã³ö82¸ñʽµÄ³¤¶È£¬³õʼ»¯Ä¿±êÊý×é
220 //dest = new unsigned char[srcLen / 2 + 4];
221 // ÉèÖÃÄ¿±êÊý×éµÄµÚ2¸ö×Ö½ÚΪ³¤¶È
222 dest[1] = (unsigned char) (srcLen / 2);
223 // ÉèÖõÚ1¸ö×Ö½ÚΪ82
224 dest[0] = (unsigned char) 0x82;
225 // »ùַΪԴÊý×é×îСֵ£¨µÚ1¸ö×Ö½ÚΪ0µÄ³ýÍ⣩
226 dest[2] = (unsigned char) ((min >> 8) & 0xFF);
227 dest[3] = (unsigned char) (min & 0xFF);
228 outOff = 4;
229 printf("[PB] atpb_CvtUcs2ToAlphaField, use 82 code\n");
230 }
231
232 for (i = 0; i < srcLen; i += 2)
233 {
234 // Èç¹ûµÚ1¸ö×Ö½ÚΪ0£¬ÔòÈ¡7µ½1룬×î¸ßλ²¹0
235 if (src[i] == 0)
236 {
237 dest[outOff] = (unsigned char) (src[i+1] & 0x7F);
238 }
239 // Èç¹ûµÚ1¸ö×Ö½Ú²»Îª0£¬ÔòÓÃUCSÂë¼õÈ¥»ùÖ·£¬×î¸ßλ²¹1
240 else
241 {
242 temp = (int) ((((src[i] << 8) & 0xFF00) | (src[i+1] & 0xFF)) - min);
243 dest[outOff] = (unsigned char) (temp | 0x80);
244 }
245 outOff++;
246 }
247 printf("[PB] atpb_CvtUcs2ToAlphaField, outOff=%d,dest[%d]=%x\n",outOff,outOff,dest[outOff]);
248 return outOff;
249 }
250
251 // ²»Âú×ã81ºÍ82µÄ¸ñʽҪÇó£¬Ê¹ÓÃ80¸ñʽ±àÂë
252 dest[0]=0x80;
253 memcpy(dest+1, src, srcLen);
254 printf("[PB] atpb_CvtUcs2ToAlphaField, use 80 code, len =%d\n",srcLen+1);
255 return srcLen+1;
256}
257
258
259int atPb_GetU80Code(const UINT8 *srcCode, UINT32 srcCodeLen, UINT8 *destCode, UINT32 destCodeLen)
260{
261 assert(destCode != NULL && srcCode != NULL);
262 if(srcCodeLen == 0 || destCodeLen == 0 || destCodeLen < srcCodeLen)
263 {
264 return -1;
265 }
266 memset(destCode, 0, destCodeLen);
267 destCode[0] = 0x80;
268 printf("chenjie -----atPb_GetU80Code-----srcCode[0] = %d\n", srcCode[0]);
269 switch (srcCode[0])
270 {
271 case 0x80:
272 {
273 memcpy(destCode, srcCode, srcCodeLen);
274 return srcCodeLen;
275 }
276 case 0x81:
277 {
278 atPb_CvtU81ToU80(srcCode + 1, srcCodeLen - 1, destCode + 1, destCodeLen - 1);
279 return srcCode[1]*2+1;
280 }
281 case 0x82:
282 {
283 atPb_CvtU82ToU80(srcCode + 1, srcCodeLen - 1, destCode + 1, destCodeLen - 1);
284 return srcCode[1]*2+1;
285 }
286 default:
287 {
288 return -1;//FALSE;
289 }
290 }
291}
292
293/**************************************************************************
294* º¯ÊýÃû³Æ: atPb_CvtU82ToU80
295* ¹¦ÄÜÃèÊö: ½«UCS282¸ñʽµÄ±àÂëת»»Îª80¸ñʽ
296* ²ÎÊý˵Ã÷: (IN)
297* (OUT)
298* ·µ »Ø Öµ:
299* ÆäËü˵Ã÷: ²»°üÀ¨±àÂëÍ·×Ö½Ú
300**************************************************************************/
301BOOL atPb_CvtU82ToU80(const UINT8 *srcData, UINT32 srcLen, UINT8 *destData, UINT32 destLen)
302{
303 UINT8 chNum = 0;
304 UINT16 basePointer = 0;
305 UINT8 iCurChar = 0;
306 UINT32 iCurSrc = 0;
307
308 chNum = (UINT32)srcData[0];
309 basePointer = (UINT16)srcData[1];
310 basePointer = basePointer << 8;
311 basePointer = basePointer + srcData[2];
312 if(chNum * 2 > destLen)
313 {
314 return FALSE;
315 }
316 for(iCurSrc = 3; iCurSrc < srcLen && iCurChar < chNum; iCurSrc++, iCurChar++)
317 {
318 UINT8 *curDest = destData + 2 * iCurChar;
319 atPb_CvtChCode(basePointer, srcData[iCurSrc], curDest, curDest + 1);
320 }
321 return TRUE;
322}
323
324BOOL atPb_CvtU81ToU80(const UINT8 *srcData, UINT32 srcLen, UINT8 *destData, UINT32 destLen)
325{
326 UINT8 chNum = 0;
327 UINT16 basePointer = 0;
328 UINT8 iCurChar = 0;
329 UINT32 iCurSrc = 0;
330
331 chNum = srcData[0];
332 basePointer = ((UINT16)srcData[1]) << 7;
333 if(chNum * 2 > destLen)
334 {
335 return FALSE;
336 }
337 for(iCurSrc = 2; iCurSrc < srcLen && iCurChar < chNum; iCurSrc++, iCurChar++)
338 {
339 UINT8 *curDest = destData + 2 * iCurChar;
340 atPb_CvtChCode(basePointer, srcData[iCurSrc], curDest, curDest + 1);
341 }
342 return TRUE;
343}
344
345/**************************************************************************
346* º¯ÊýÃû³Æ: atPb_CvtChCode
347* ¹¦ÄÜÃèÊö: ½«U81\U82µÄÊý¾ÝÓòת»»ÎªU80µÄÊý¾ÝÓò
348* ²ÎÊý˵Ã÷: (IN)
349* (OUT)
350* ·µ »Ø Öµ:
351* ÆäËü˵Ã÷:
352**************************************************************************/
353VOID atPb_CvtChCode(UINT16 basePointer, UINT8 srcData, UINT8 *chMsb, UINT8 *chLsb)
354{
355 UINT16 curChar = 0;
356
357 assert(chMsb != NULL && chLsb != NULL);
358 if((srcData & 0x80) == 0)
359 {
360 curChar = srcData;
361 }
362 else
363 {
364 curChar = basePointer + (srcData & 0x7f);
365 }
366 *chMsb = (UINT8)(curChar >> 8);
367 *chLsb = (UINT8)((curChar << 8) >> 8);
368 return;
369}
370
371
372 /**************************************************************************
373* º¯ÊýÃû³Æ£º int atPb_String2Bytes(const char* pSrc, unsigned char* pDst, int nSrcLength)
374* ¹¦ÄÜÃèÊö£º ¿É´òÓ¡×Ö·û´®×ª»»Îª×Ö½ÚÊý¾Ý £¬È磺"C8329BFD0E01" --> {0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01}
375* ·ÃÎÊµÄ±í£º
376* ÐÞ¸ÄµÄ±í£º
377* ÊäÈë²ÎÊý£º
378 pSrc: Ô´×Ö·û´®Ö¸Õë
379 pDst: Ä¿±êÊý¾ÝÖ¸Õë
380 nSrcLength: Ô´×Ö·û´®³¤¶È
381* Êä³ö²ÎÊý£º
382 ÎÞ£»
383* ·µ »Ø Öµ£º
384 Ä¿±êÊý¾Ý³¤¶È£»
385* ÆäËü˵Ã÷£º
386* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
387* -----------------------------------------------
388* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
389**************************************************************************/
390int atPb_String2Bytes(const char* pSrc, unsigned char* pDst, int nSrcLength)
391{
392 int i=0;
393
394 //УÑé²ÎÊý
395 if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
396 {
397 return -1;
398 }
399
400 for(i = 0; i < nSrcLength; i += 2)
401 {
402 // Êä³ö¸ß4λ
403 if(*pSrc >= '0' && *pSrc <= '9')
404 {
405 *pDst = (*pSrc - '0') << 4;
406 }
407 else
408 {
409 *pDst = ((toupper(*pSrc) - 'A') + 10) << 4;
410 }
411
412 pSrc++;
413
414 // Êä³öµÍ4λ
415 if(*pSrc >= '0' && *pSrc <= '9')
416 {
417 *pDst |= *pSrc - '0';
418 }
419 else
420 {
421 *pDst |= (toupper(*pSrc) - 'A') + 10;
422 }
423
424 pSrc++;
425 pDst++;
426 }
427
428 // ·µ»ØÄ¿±êÊý¾Ý³¤¶È
429 return nSrcLength / 2;
430}
431
432 /**************************************************************************
433* º¯ÊýÃû³Æ£º int atPb_Bytes2String(const unsigned char* pSrc, char* pDst, int nSrcLength)
434* ¹¦ÄÜÃèÊö£º ×Ö½ÚÊý¾Ýת»»Îª¿É´òÓ¡×Ö·û´® £¬È磺{0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01} --> "C8329BFD0E01"
435* ·ÃÎÊµÄ±í£º
436* ÐÞ¸ÄµÄ±í£º
437* ÊäÈë²ÎÊý£º
438 pSrc: Ô´Êý¾ÝÖ¸Õë
439 pDst: Ä¿±ê×Ö·û´®Ö¸Õë
440 nSrcLength: Ô´Êý¾Ý³¤¶È
441* Êä³ö²ÎÊý£º
442 ÎÞ£»
443* ·µ »Ø Öµ£º
444 Ä¿±êÊý¾Ý³¤¶È£»
445* ÆäËü˵Ã÷£º
446* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
447* -----------------------------------------------
448* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
449**************************************************************************/
450int atPb_Bytes2String(const unsigned char* pSrc, char* pDst, int nSrcLength)
451{
452 const char tab[]="0123456789ABCDEF"; // 0x0-0xfµÄ×Ö·û²éÕÒ±í
453 int i=0;
454
455 //УÑé²ÎÊý
456 if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
457 {
458 return -1;
459 }
460
461 for(i=0; i<nSrcLength; i++)
462 {
463 *pDst++ = tab[*pSrc >> 4]; // Êä³öµÍ4λ
464 *pDst++ = tab[*pSrc & 0x0f]; // Êä³ö¸ß4λ
465 pSrc++;
466 }
467
468 // Êä³ö×Ö·û´®¼Ó¸ö½áÊø·û
469 *pDst = '\0';
470
471 // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
472 return nSrcLength * 2;
473}
474
475
476/*´òÓ¡web·¢À´µÄµç»°±¾ÐÅÏ¢*/
477static VOID atPb_WebRecodeShow(T_zPb_WebContact const *pFromweb)
478{
479 slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.Index=%d\n",pFromweb->pbIndex);
480 slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.Name=%s\n",pFromweb->name);
481 slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.PbNum1=%s\n",pFromweb->mobilNumber);
482 slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.PbNum2=%s\n",pFromweb->homeNumber);
483 slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.PbNum3=%s\n",pFromweb->officeNumber);
484 slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.email=%s\n",pFromweb->email);
485}
486
487int atPb_IintPbErr(UINT8 *pErrCode)
488{
489 sc_cfg_set(ZPB_NV_INIT, ZPB_LOAD_ERROR);
490 //need break
491 return TRUE;
492}
493
494int atPb_ScpbrSetErr(UINT8 *pErrCode)
495{
496 printf("[PB] atPb_ScpbrSetErr fail and return\n");
497 sc_cfg_set(ZPB_NV_INIT, ZPB_OPERATE_SUC);
498 return TRUE;
499}
500
501VOID atBase_IintPbOk(VOID)
502{
503 sc_cfg_set(ZPB_NV_INIT, ZPB_OPERATE_SUC);
504 printf("[PB] atPb_SendScpbrSet atBase_IintPbOk \n");
505}
506
507/*·¢ËÍÉèÖÃSM´æ´¢Æ÷ÃüÁî*/
508/*int atPb_SendCpbsSetReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
509{
510 return zSvr_SendAtSyn(ZAT_CPBS_SET_CMD,"AT+CPBS=\"SM\"\r\n",cid,pAtRst,atRstSize);
511}*/
512
513/*²éѯpbÐÅÏ¢µÄ×Ü´æ´¢Æ÷¸öÊý¡¢ÒÑÓô洢Æ÷¸öÊýÐÅÏ¢*/
514/*int atPb_SendCpbsReadReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
515{
516 return zSvr_SendAtSyn(ZAT_CPBS_READ_CMD,"AT+CPBS?\r\n",cid,pAtRst,atRstSize);
517}*/
518
519VOID atPb_RecvCpbsReadRsp(T_zPb_AtCpbsReadRes* cpbsInd)
520{
521 CHAR resInfo[20] = {0};
522
523 if(strncmp(cpbsInd->locType,"SM",2) == 0)
524 {
525 (VOID)snprintf(resInfo, 20,"%d",cpbsInd->usedEntries);
526 (VOID)sc_cfg_set(NV_PB_USEDENTRIES,resInfo);
527 memset(resInfo, 0, 20);
528 (VOID)snprintf(resInfo,20,"%d",cpbsInd->totalEntries);
529 (VOID)sc_cfg_set(NV_PB_TOTALENTRIES,resInfo);
530 g_zPb_SimIndex[0] = (UINT32)(cpbsInd->totalEntries);
531 }
532 else
533 {//teet
534 //atBase_SendMsgToSelf(ZAT_CPBS_SET_CMD, ZUFI_NULL, 0);
535 printf("atPb_RecvCpbsReadRsp not SM:%s\n", cpbsInd->locType);
536 }
537}
538
539/*²éѯpbÐÅÏ¢µÄ×î´óË÷Òý¡¢³¤¶ÈµÈÐÅÏ¢*/
540/*int atPb_SendScpbrTest(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
541{
542 return zSvr_SendAtSyn(ZAT_SCPBR_TEST_CMD,"AT^SCPBR=?\r\n",cid,pAtRst,atRstSize);
543}*/
544
545static VOID atPb_SetScpbrResToNv(CHAR const*pbNvKeyWord, UINT32 len)
546{
547 char converted[10] = {0};
548
549 assert(pbNvKeyWord != ZUFI_NULL);
550 (VOID)snprintf(converted,10, "%d", len);
551 (VOID)sc_cfg_set(pbNvKeyWord, converted);
552}
553
554VOID atPb_ScpbrTestRsp(T_zPb_AtScpbrTestRes* scpbsInd)
555{
556 T_zPb_UsimCapacity pbPara = {0};
557 CHAR pbUsed[50]={0};
558 sc_cfg_get(NV_PB_USEDENTRIES,pbUsed,sizeof(pbUsed));
559
560 g_zPb_DelIndex = (UINT32)scpbsInd->minIndex;
561 pbPara.simType = ZPB_USIM;
562 pbPara.maxRecordNum = scpbsInd->maxIndex;
563 pbPara.usedRecordNum = atoi(pbUsed);
564 pbPara.maxNumberLen = scpbsInd->maxNumberLen;
565 pbPara.maxNameLen = scpbsInd->maxTextLen;
566 pbPara.maxAnrLen = scpbsInd->maxNumberLen;
567 pbPara.maxAnr1Len = scpbsInd->maxNumberLen;
568 pbPara.maxEmailLen = scpbsInd->maxEmailLen;
569 atPb_SetScpbrResToNv(ZPB_NV_USIMINDEXMIN, (UINT32)scpbsInd->minIndex);
570 atPb_SetScpbrResToNv(ZPB_NV_USIMINDEXMAX, (UINT32)scpbsInd->maxIndex);
571
572 /*ÉèÖÃsimÈÝÁ¿Êý¾Ý¿â±í*/
573 (VOID)atPb_SetSimCapacityTable(pbPara);
574}
575
576
577
578/*·Ö¶Î¶à´Î¶ÁÈ¡PB ÐÅÏ¢*/
579int atPb_SendScpbrSet_repeat(sem_t tSemId)
580{
581 int min = 0;//klocwork
582 int max = 0;
583 int res = 0;
584 int index = 0;
585 CHAR pbMin[50]={0};
586 CHAR pbMax[50]={0};
587 int indexmin = 0;
588 int indexmax = 0;
589 T_zPb_ScpbrReadRes scpbrReadInfo = {0};
590
591 sc_cfg_get(ZPB_NV_USIMINDEXMIN,pbMin,sizeof(pbMin));
592 sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
593
594 (VOID)sc_cfg_set(ZPB_NV_INIT, ZPB_LOADING);
595
596 //assert(strcmp(cfg_safe_get(ZPB_NV_USIMINDEXMIN),"0") != 0 && strcmp(cfg_safe_get(ZPB_NV_USIMINDEXMAX),"0") != 0);
597 if(strcmp(pbMin,"0") == 0 || strcmp(pbMax,"0") == 0)
598 {
599 sc_cfg_set(ZPB_NV_INIT, ZPB_OPERATE_SUC);
600 printf("atPb_SendScpbrSet card unsupport pb\n");
601 return -1;
602 }
603
604 sscanf(pbMin, "%d", &min);
605 sscanf(pbMax, "%d", &max);
606 if ((min < 0 || min > INT_MAX-1) ||
607 (max < 0 || max > INT_MAX-1)) { //kw 3
608 printf("atPb_SendScpbrSet pb num err min:%d, max:%d\n", min, max);
609 return -1;
610 }
611
612 while(1)
613 {
614 if(indexmin < min)
615 {
616 indexmin = min;
617 indexmax = min+ZPB_INIT_LOAD_RECORD_NUM-1;
618 if(indexmax > max)
619 {
620 indexmax = max;
621 break;
622 }
623 printf("[PB] 111 indexmin=%d, indexmax=%d,(%d-%d)\n",indexmin, indexmax, min, max);
624 }
625 else
626 {
627 indexmin = indexmin+ZPB_INIT_LOAD_RECORD_NUM;
628 if(indexmin > max)
629 {
630 printf("[PB] 333 indexmin=%d, indexmax=%d,(%d-%d)\n",indexmin,indexmax,min,max);
631 break;
632 }
633 indexmax = indexmax+ZPB_INIT_LOAD_RECORD_NUM;
634 if(indexmax > max)
635 {
636 indexmax = max;
637 }
638 printf("[PB] 222 indexmin=%d, indexmax=%d,(%d-%d)\n",indexmin, indexmax,min,max);
639 }
640
641 scpbrReadInfo.minIndex = indexmin;
642 scpbrReadInfo.maxIndex = indexmax;
643 res = ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_READ_PB_REQ, sizeof(T_zPb_ScpbrReadRes), &scpbrReadInfo, 0);
644 sem_wait(&g_Pb_sem_id);
645 if(g_PbOptRsp.result == -1)
646 {
647 break;
648 }
649 }
650
651 return g_PbOptRsp.result;
652}
653#if 0
654/*Ò»´Î¶ÁÈ¡PB ÐÅÏ¢*/
655int atPb_SendScpbrSet(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
656{
657 UINT32 indexmin = 0;
658 UINT32 indexmax = 0;
659 CHAR atcmdMsg[70] = {0};
660 int res = 0;
661 CHAR pbMin[50]={0};
662 CHAR pbMax[50]={0};
663 sc_cfg_get(ZPB_NV_USIMINDEXMIN,pbMin,sizeof(pbMin));
664 sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
665
666 (VOID)sc_cfg_set(ZPB_NV_INIT, ZPB_LOADING);
667
668 //assert(strcmp(cfg_safe_get(ZPB_NV_USIMINDEXMIN),"0") != 0 && strcmp(cfg_safe_get(ZPB_NV_USIMINDEXMAX),"0") != 0);
669 if(strcmp(pbMin,"0") == 0 || strcmp(pbMax,"0") == 0)
670 {
671 //sc_cfg_set(ZPB_NV_INIT, ZPB_OPERATE_SUC);
672 printf("atPb_SendScpbrSet card unsupport pb\n");
673 return ZAT_RESULT_OK;
674 }
675
676 sscanf(pbMin, "%d", &indexmin);
677 sscanf(pbMax, "%d", &indexmax);
678 (VOID)snprintf(atcmdMsg, sizeof(atcmdMsg), "AT^SCPBR=%d,%d\r\n", indexmin, indexmax);
679
680 pthread_mutex_lock(&smsdb_mutex);
681 res = zSvr_SendAtSyn(ZAT_SCPBR_SET_CMD,atcmdMsg,cid,pAtRst,atRstSize);
682 pthread_mutex_unlock(&smsdb_mutex);
683 return res;
684}
xf.libfc6e712025-02-07 01:54:34 -0800685#endif
xf.li771eb062025-02-09 23:05:11 -0800686/*¶Ô¶ÁÈ¡µÄPBÐÕÃû±àÂëΪUcs2*/
687UINT8 atPb_EncodeText(CHAR *pbDst,CHAR const*pbTextSrc, UINT32 dstLen)
688{
689 UINT8 i = 0;
690 CHAR strTarget[ZPB_TEXT_SIZE_BYTES] = {0};
691
692 if(pbTextSrc != ZUFI_NULL)
693 {
694 if(strlen(pbTextSrc) *4 + ZPB_UCS2_PREFIX_LEN < dstLen)
695 {
696 snprintf((CHAR *)&strTarget[0], sizeof(strTarget),"%02X", ZPB_UCS2_PREFIX);
697 for (i = 0; (i < strlen(pbTextSrc)) && (i * 4 + ZPB_UCS2_PREFIX_LEN < dstLen); i++ )
698 {
699 snprintf(strTarget + i * 4 + ZPB_UCS2_PREFIX_LEN, sizeof(strTarget)- i*4 -ZPB_UCS2_PREFIX_LEN,"00%02X", pbTextSrc[i] );
700 }
701 strncpy(pbDst, strTarget,dstLen-1);
702 return ZUFI_SUCC;
703 }
704 }
705 return ZUFI_FAIL;
706}
707
708/*¶ÁÈ¡µç»°±¾¼Ç¼Ö÷¶¯Éϱ¨ÏìÓ¦*/
709VOID atPb_ScpbrSetRsp(T_zPb_ScpbrSetRes* atRes)
710{
711 T_zPb_WebContact pbRecord = {0};
712 CHAR pbDst[ZPB_TEXT_SIZE_BYTES] = {0};
713 CHAR text[ZPB_TEXT_SIZE_BYTES] = {0};
714 int text_len = 0;
715 int tmp_len = 0;
716 CHAR tmp[ZPB_TEXT_SIZE_BYTES] = {0};
717
718 if(atRes->coding != ZPB_UCS2)
719 {
720 if(atPb_EncodeText(pbDst, atRes->text, ZPB_TEXT_SIZE_BYTES) == ZUFI_SUCC)
721 {
722 strncpy(atRes->text,pbDst+2,sizeof(atRes->text)-1);//Ìø¹ý80
723 }
724 else
725 {
726 slog(PB_PRINT,SLOG_ERR, "pb:atPb_ScpbrSetRspencode err!.\n");
727 return;
728 }
729 }
730 else
731 {
732 text_len = atPb_String2Bytes(&atRes->text, &text, strlen(atRes->text));
733 tmp_len = atPb_GetU80Code(&text, text_len, &tmp, ZPB_TEXT_SIZE_BYTES);
734 if(tmp_len < 0) return;
735
736 memset(&text, 0, ZPB_TEXT_SIZE_BYTES);
737 text_len = atPb_Bytes2String(&tmp, &text, tmp_len);
738 if (text_len > 2){
739 memset(&atRes->text, 0, ZPB_TEXT_SIZE_BYTES);
740 memcpy(&atRes->text, text+2, strlen(text)-2);
741 }
742 }
743 pbRecord.pbId = -1;
744 pbRecord.pbIndex = (SINT32)atRes->index;/*ת»»µç»°Ë÷Òý*/
745 strncpy(pbRecord.name, atRes->text,sizeof(pbRecord.name)-1);
746 strncpy(pbRecord.mobilNumber,atRes->number1,sizeof(pbRecord.mobilNumber)-1);
747 strncpy(pbRecord.officeNumber,atRes->number2,sizeof(pbRecord.officeNumber)-1);
748 strncpy(pbRecord.homeNumber,atRes->number3,sizeof(pbRecord.homeNumber)-1);
749 strncpy(pbRecord.email,atRes->email,sizeof(pbRecord.email)-1);
750 pbRecord.pbLocation=ZPB_LOCATION_USIM;
751 (VOID)atPb_LoadARecToPbmTable(&pbRecord);
752 //(VOID)system("adb push /etc_rw/config/pbm.db /usr/zte/zte_conf/config");
753}
754
755VOID atPb_SetDelStatusMultOrAll()
756{
757 if(g_zPb_DelStatusUsim.dealFailNum>0)
758 {
759 if(g_zPb_DelStatusUsim.dealSuccNum>0)
760 {
761 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_MUL_DEL_PART_SUC);
762 }
763 else
764 {
765 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
766 }
767 }
768 else
769 {
770 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
771 }
772 //(VOID)system("adb push /etc_rw/config/pbm.db /usr/zte/zte_conf/config");
773}
774
775/*·¢ËÍɾ³ýÒ»ÌõPbÐÅÏ¢ÃüÁî*/
776/*int atPb_SendScpbwDelReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
777{
778 SINT32 pbIndex = 0;
779 CHAR atcmdMsg[70] = {0};
780
781 pbIndex = *((SINT32*)pAtCmdPara);
782 (VOID)snprintf(atcmdMsg,sizeof(atcmdMsg),"AT^SCPBW=%d\r\n", pbIndex);
783 return zSvr_SendAtSyn(ZAT_SCPBW_DEL_CMD,atcmdMsg,cid,pAtRst,atRstSize);
784}*/
785#if 0
786/*Ö§³Ö´íÎóÂë½âÎö£¬20ÄÚ´æÂú*/
787VOID atPb_RecvScpbwAddErr(UINT8 *pErrCode)
788{
789 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
790 if((strncmp(pErrCode, ZAT_ERRCODE_MEMORY_FULL, 2) == 0))
791 {
792 /*ÏÔʾ¸øWebÒ³Ãæ£¬É¾³ýÒ»ÌõºóÇåΪ"no"*/
793 (VOID)sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "yes");
794 printf("pb:Recv CME ErrCode: 20.\n");
795 }
796 else
797 {
798 printf("pb:Recv At Scpbw add Err.\n");
799 }
800
801 //ÐèÒª½«Ö®Ç°±£´æÔÚÊý¾Ý¿âµÄ¼Ç¼ɾ³ý
802 //atPb_DelRecordFromDBWhenAddErr();
803}
xf.libfc6e712025-02-07 01:54:34 -0800804#endif
xf.li771eb062025-02-09 23:05:11 -0800805VOID atPb_RecvScpbwModifyErr(UINT8 *pErrCode)
806{
807 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
808 printf("pb:Recv At Scpbw modify err.\n");
809}
810
811
812/*****************************************************************************
813* º¯ÊýÃû³Æ£ºweb_AsctoHex
814* ¹¦ÄÜ˵Ã÷£ºÕâ¸öº¯ÊýÓÃÓÚ½«×Ö½Úת»»³É°ë×Ö½Ú¡£ÀýÈ罫"8090ed"ת»»³É
815 0x8090ed;½«"a4"ת»»³É0xa4
816* ÊäÈë²ÎÊý£ºpcASC£º Ä¿±ê×Ö·û´®µÄ´æ·Å»º³å£»
817 iDstLen£º Ä¿±ê»º³åµÄ³¤¶È£»
818 pcHex£º Ô´×Ö·û´®»º³å£»
819 iSrcLen£º Ô´×Ö·û´®³¤¶È±¶¡£
820* Êä³ö²ÎÊý£ºÎÞ
821* ·µ»ØÖµ£º ÎÞ
822****************************************************************************/
823VOID pb_AsctoHex(UINT16 *pcHex, SINT32 iDstLen, UINT8 const *pcASC,SINT32 iSrcLen)
824{
825 UINT32 iOddOrEven = 0;// 1±íʾOdd,0±íʾEven;
826 UINT8 iTemp = 0;
827 SINT32 i = 0;
828
829 if((NULL == pcHex )
830 ||(NULL == pcASC)
831 ||(0 == iDstLen)
832 ||(iDstLen < (iSrcLen/2 +1)))
833 {
834 return;
835 }
836
837 for(i=0; i<iSrcLen; i++)
838 {
839 if(iOddOrEven%2 == 0)
840 {
841 iTemp = *(pcASC + i);
842 if((iTemp >='0')&& (iTemp <='9'))
843 {
844 *(pcHex + i/2) |= (UINT8)(iTemp -48) << 4;
845 }
846 else
847 {
848 *(pcHex + i/2) |= (UINT8)(iTemp -55) << 4;
849 }
850 }
851 else
852 {
853 iTemp = *(pcASC + i);
854 if((iTemp >='0')&& (iTemp <='9'))
855 {
856 *(pcHex + i/2) |= iTemp -48;
857 }
858 else
859 {
860 *(pcHex + i/2) |= iTemp -55;
861 }
862 }
863 iOddOrEven++;
864 }
865}
866
867/**********************************************************************
868* º¯ÊýÃû³Æ£º IfaUcs2IsSMS7
869* ¹¦ÄÜÃèÊö£º Õâ¸öº¯ÊýÓÃÓÚÅжÏUcs2Âë×Ö·û´®ÊÇ·ñ°üº¬ÔÚGsm·ûºÅ±íÖÐ
870* ·ÃÎÊµÄ±í£º
871* ÐÞ¸ÄµÄ±í£º ÎÞ
872* ÊäÈë²ÎÊý£º psUcs2£º ÊäÈëµÄUCS2±àÂë´®£»
873 iLength£º ÊäÈëµÄUCS2×Ö·û´®³¤¶È£¨¿í×Ö·û£©
874* Êä³ö²ÎÊý£º ÎÞ
875* ·µ »Ø Öµ£º ÕûÐÍ 0£ºÃ»Óаüº¬ÔÚ·ûºÅ±íÖУ»1£º°üº¬ÔÚ·ûºÅ±íÖÐ
876* ÆäËü˵Ã÷£º ÎÞ
877* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
878* -----------------------------------------------------------------------
879* 2005/06/30 v1.0 yusong ´´½¨
880***********************************************************************/
881SINT32 atPb_IfUcs2IsSMS7(UINT16 *psUcs2, SINT32 iLength)
882{
883 int iRetVal = 1;
884 char cTemp;
885 int i = 0;
886
887 if(NULL == psUcs2 )
888 {
889 return -1;
890 }
891 for(i = 0; i<iLength; i++)
892 {
893 // СÓÚµÈÓÚ0x00ffµÄUCS2ÂëµÄ´¦Àí
894 if (256 > psUcs2[i])
895 {
896 switch (psUcs2[i])
897 {
898 // ûÓаüº¬ÔÚ×Ô¶¨ÒåµÄUcs2µ½Gsm7ת»»Êý×éÖеÄ×Ö·ûµÄ´¦Àí¡£
899 case 0x0c://12
900 case 0x5b://91
901 case 0x5c://92
902 case 0x5d://93
903 case 0x5e://94
904 case 0x7b://123
905 case 0x7c://124
906 case 0x7d://125
907 case 0x7e://126
908 case 0xa4://164
909 case 0x20://¿Õ¸ñ
910 {
911 break;
912 }
913 // Èç¹ûÔÚ±íÖв鵽µÄ½á¹ûΪZPB_NON_GSM£¬±íÃ÷²»ÊÇGSM7±àÂë
914 default:
915 {
916 cTemp = (char)G_ZPB_NEWUCS2TOGSM[psUcs2[i]];
917 if (ZPB_NON_GSM == cTemp)
918 {
919 iRetVal = 0;
920 }
921 break;
922 }
923 }
924 }
925 // ³¬³öÊý×鷶Χ£¬µ«Óм¸¸öÌØÊâÖµÈÔÊÇGSM7±àÂë
926 else
927 {
928 switch (psUcs2[i])
929 {
930 case 0x0394:
931 case 0x03a6:
932 case 0x0393:
933 case 0x039b:
934 case 0x03a9:
935 case 0x03a0:
936 case 0x03c8:
937 case 0x03a3:
938 case 0x03b8:
939 case 0x039e:
940 {
941 break;
942 }
943 default:
944 {
945 iRetVal = 0;
946 break;
947 }
948 }
949 }
950 if (0 == iRetVal)
951 {
952 break;
953 }
954 }
955 return iRetVal;
956}
957static UINT8 atPb_EncodeNameToUcs2(char *pbDst, UINT32 iDstLen, char const *pbSrc)
958{
959 UINT16 acHex[256] = {0};
960 SINT32 srclen = 0;
961 SINT32 rest = 0;
962 assert(pbDst!= NULL && pbSrc != NULL);
963
964 srclen = (SINT32)strlen(pbSrc);
965 slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_EncodeNameToUcs2 input psSrc=%s,iSrcLen=%d\n", pbSrc, srclen);
966 pb_AsctoHex(acHex, 256, (UINT8 *)pbSrc, srclen);
967
968 rest = atPb_IfUcs2IsSMS7(acHex, srclen/4);
969 if(rest == 1)
970 {
971 return atPb_EncodeText(pbDst, pbSrc, iDstLen);
972 }
973 else if(rest == 0)
974 {
975 if(strlen(pbSrc) + 2 < iDstLen)
976 {
977 memcpy(pbDst, "80", 2);
978 memcpy(pbDst + 2, pbSrc, srclen);
979 return ZUFI_SUCC;
980 }
981 }
982 return ZUFI_FAIL;
983}
984
985
986SINT32 atPb_FindIdleIndex(T_zPb_WebContact const *pbRecv, BOOL pbNewFlag)
987{
988 SINT32 count = 1;
989 SINT32 total = 0;
990 SINT32 *IndexType = NULL;
991
992 if ((NULL == pbRecv))
993 {
994 slog(PB_PRINT,SLOG_ERR,"pb:find_pbm_index:the para of find_pbm_index are NULL\n");
995 return -1;
996 }
997
998 if (TRUE == pbNewFlag) //new a pbm record
999 {
1000 if(ZPB_LOCATION_USIM == pbRecv->pbLocation)
1001 {
1002 total = g_zPb_SimIndex[0];
1003 IndexType = g_zPb_SimIndex;
1004 }
1005 else if(ZPB_LOCATION_AP== pbRecv->pbLocation)
1006 {
1007 total = g_zPb_ApIndex[0];
1008 IndexType = g_zPb_ApIndex;
1009 }
1010
1011 for(; count<=total; count++)
1012 {
1013 if ((NULL != IndexType) && (IndexType[count] == PBM_ERROR_NOT_FOUND))
1014 {
1015 break;
1016 }
1017 }
1018 if (count > total)
1019 {
1020 slog(PB_PRINT,SLOG_ERR,"pb:find_pbm_index:can not find index_id,index_id=%d\n.",count);
1021 return -1;
1022 }
1023 slog(PB_PRINT,SLOG_DEBUG,"pb:find_pbm_index: index_id=%d, total is %d\n", count, total);
1024 return count;
1025 }
1026 else
1027 {
1028 /*modify a pbm record*/
1029 return pbRecv->pbIndex;
1030 }
1031}
1032
1033BOOL atPb_GetASCII(CHAR *pSrc, CHAR *pDst, SINT32 len)
1034{
1035 SINT32 j = 0;
1036 SINT32 i = 0;
1037 CHAR buf[ZPB_TEXT_SIZE_BYTES] = {0};
1038 CHAR str[3] = {0};
1039 SINT32 length = 0;
1040
1041 length = atPb_String2Bytes(pSrc, buf, len);
1042
1043 for(i = 0; i < length; i+=2)
1044 {
1045 if (buf[i] != 0 || buf[i+1] > 127)
1046 {
1047 return FALSE;
1048 }
1049 pDst[j++] = buf[i+1];
1050 }
1051 return TRUE;
1052}
1053
1054VOID atWeb_AddOrModOnePbUsim(T_zPb_WebContact *pWebPbContact, BOOL pbNewFlag, sem_t semId)
1055{
1056 //CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
1057 int atRes = 0;
1058 CHAR pbName[ZPB_TEXT_SIZE_BYTES+3] = {0};
1059 CHAR buf_src[ZPB_TEXT_SIZE_BYTES+3] = {0};
1060 CHAR buf_dest[ZPB_TEXT_SIZE_BYTES+3] = {0};
1061 T_zPb_ScpbwParam scpbwParam = {0};
1062 int len = 0;
1063
1064 atPb_WebRecodeShow(pWebPbContact);
1065
1066 //ÏÈ·¢ATÃüÁî
1067 if(atPb_GetASCII(pWebPbContact->name, pbName,strlen(pWebPbContact->name)))
1068 {
1069 scpbwParam.coding = 0;
1070 }
1071 else
1072 {
1073 len = atPb_String2Bytes(pWebPbContact->name,buf_src,strlen(pWebPbContact->name));
1074 len = atpb_CvtUcs2ToAlphaField(buf_src,len, buf_dest);
1075 atPb_Bytes2String(buf_dest,pbName, len);
1076
1077 //sprintf((CHAR *)&pbName[0], "%02X", ZPB_UCS2_PREFIX);
1078 //strncat(pbName,pWebPbContact->name,ZPB_TEXT_SIZE_BYTES);
1079 scpbwParam.coding = 1;
1080 }
1081 /*web·¢ÏÂÀ´µÄÊý¾ÝÖÐÖ»ÓÐÈý¸öºÅÂ룬ûÓд«ÕæºÅÂë*/
1082 scpbwParam.pbIndex = pWebPbContact->pbIndex;
1083 strncpy(scpbwParam.name,pbName,sizeof(scpbwParam.name)-1);
1084 strncpy(scpbwParam.mobilNumber,pWebPbContact->mobilNumber, sizeof(scpbwParam.mobilNumber)-1);
1085 strncpy(scpbwParam.officeNumber,pWebPbContact->officeNumber, sizeof(scpbwParam.officeNumber)-1);
1086 strncpy(scpbwParam.homeNumber,pWebPbContact->homeNumber,sizeof(scpbwParam.homeNumber)-1);
1087 strncpy(scpbwParam.email,pWebPbContact->email,sizeof(scpbwParam.email)-1);
1088
1089 ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_ADD_MODIFY_PB_REQ, sizeof(T_zPb_ScpbwParam), (unsigned char *)&scpbwParam, 0);
1090 sem_wait(&g_Pb_sem_id);
1091 if(g_PbOptRsp.result != 1)
1092 {
1093 /*Ìí¼Óµç»°±¾*/
1094 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
1095 if(TRUE == pbNewFlag)
1096 {
1097 //atPb_RecvScpbwAddErr(errCode);
1098 printf("pb:add Scpbw error.\n");
1099 }
1100 /*Ð޸ĵ绰±¾*/
1101 else
1102 {
1103 //atPb_RecvScpbwModifyErr(errCode);
1104 printf("pb:modify Scpbw error.\n");
1105 }
1106 return;
1107 }
1108
1109 printf("pb:Send Scpbw ok.\n");
1110 //g_zPb_pbIndex = 0;
1111 if(ZPB_DB_OK == atPb_WriteContactToPbmTable(pWebPbContact, pbNewFlag))
1112 {
1113 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
1114 printf("pb:WriteContactToPbmTable ok.\n");
1115 //g_zPb_pbIndex = pWebPbContact->pbIndex;
1116 }
1117 else
1118 {
1119 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
1120 printf("pb:WriteContactToPbmTable error.\n");
1121 }
1122}
1123
1124VOID atWeb_AddOnePb(T_zPb_WebContact* webPbContact, sem_t semId)
1125{
1126 SINT32 idleIndex = 1;
1127 T_zPb_Header pbHeader = {0};
1128 BOOL pbNewFlag = FALSE;
1129 T_zPb_DelInfo delRecord = {0};
1130 CHAR ptFlag[20]={0};
1131
1132 printf("[PB] atWeb_AddOnePb, pbId=%d!\n",webPbContact->pbId);
1133
1134 if(-1 == webPbContact->pbId) /*new*/
1135 {
1136 slog(PB_PRINT,SLOG_DEBUG, "pb:atWeb_AddOnePb new.\n");
1137 pbNewFlag = TRUE;
1138 idleIndex = atPb_FindIdleIndex(webPbContact, pbNewFlag);
1139 printf("[PB] atWeb_AddOnePb idleIndex=%d.\n", idleIndex);
1140
1141 if(idleIndex!= -1)
1142 {
1143 webPbContact->pbIndex = idleIndex;
1144 }
1145 else
1146 {
1147 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
1148 printf("[PB] memory is full, can not add recode any more.\n");// (VOID)sc_cfg_set("memory","full");
1149 return;
1150 }
1151 }
1152 else /*according to id to select index and location when modify a record*/
1153 {
1154 printf("[PB] atWeb_AddOnePb modify.\n");
1155 pbHeader.pbId = webPbContact->pbId;
1156 if(ZPB_DB_OK != atPb_GetIndexLocationById(&pbHeader))
1157 {
1158 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
1159 return;
1160 }
1161 webPbContact->pbIndex = pbHeader.pbIndex;
1162 webPbContact->pbLocation = pbHeader.pbLocation;
1163 }
1164 printf("[PB] atWeb_AddOnePb:location=%d\n",webPbContact->pbLocation);
1165
1166 //É豸²â
1167 if (ZPB_LOCATION_AP == webPbContact->pbLocation)
1168 {
1169 if(ZPB_DB_OK != atPb_WriteContactToPbmTable(webPbContact, pbNewFlag))
1170 {
1171 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
1172 }
1173 else
1174 {
1175 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
1176 }
1177 }
1178 //¿¨²â
1179 else if (ZPB_LOCATION_USIM == webPbContact->pbLocation)
1180 {
1181 atWeb_AddOrModOnePbUsim(webPbContact, pbNewFlag, semId);
1182 }
1183 //ÆäËü
1184 else
1185 {
1186 printf("[PB] write_pbm_record:location is NULL\n");
1187 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_LOCATION_IS_NULL);
1188 }
1189 printf("[PB] atWeb_AddOnePb del_id=%d.\n",webPbContact->del_id);
1190
1191 //³É¹¦²Åɾ³ý
1192 sc_cfg_get(ZPB_NV_WRITE_FLAG,ptFlag,sizeof(ptFlag));
1193 if(0 == strcmp("0",ptFlag) && -1 != webPbContact->del_id)
1194 {
1195 delRecord.delId[0] = webPbContact->del_id;
1196 atWeb_DelOnepb(&delRecord, semId);
1197 }
1198}
1199
1200
1201VOID atWeb_DelOnepb(T_zPb_DelInfo *delRecord, sem_t semId)
1202{
1203 CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
1204 int atRes = 0;
1205 SINT32 delTime = 0;
1206
1207 /*¸ù¾ÝҪɾ³ýpb¼Ç¼µÄID»ñµÃλÖúÍË÷ÒýÖµ*/
1208 atPb_GetLocationIndexForDel(delRecord, delTime);
1209 printf("[PB] del_a_pbm_record--del index=%d,location=%d\n",delRecord->delIndex[0],delRecord->delLocation);
1210
1211 if (ZPB_LOCATION_AP == delRecord->delLocation)
1212 {
1213 if(ZPB_DB_OK == atPb_DelARecFromPbmTable(delRecord, delTime))
1214 {
1215 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
1216 printf("[PB] atWeb_DelOnepb--del AP success\n");
1217 return;
1218 }
1219 slog(PB_PRINT,SLOG_DEBUG,"pb:del_a_pbm_record:remove rec from pbm table failed\n");/*lint !e26*/
1220 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
1221 }
1222 else if (ZPB_LOCATION_USIM == delRecord->delLocation)
1223 {
1224 CHAR pbMax[50]={0};
1225 sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
1226 if((delRecord->delIndex[0]>=1)&&(delRecord->delIndex[0]<=atoi(pbMax)))/*×î´óÖµ*/
1227 {
1228 //g_zAt_AtActTab[ZAT_SCPBW_DEL_CMD].atBase_AtSendReq((PSTR)&delRecord->delIndex[0]);
1229 //atRes = atPb_SendScpbwDelReq((PSTR)&delRecord->delIndex[0],cid,errCode,ZSVR_AT_RES_CODE_LEN);
1230 ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_DELETE_PB_REQ, sizeof(int), (unsigned char *)&delRecord->delIndex[0], 0);
1231 sem_wait(&g_Pb_sem_id);
1232 if(g_PbOptRsp.result != 1)
1233 {
1234 sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);
1235 }
1236 sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
1237 }
1238
1239 if(ZPB_DB_OK == atPb_DelARecFromPbmTable(delRecord,delTime))
1240 {
1241 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);
1242 printf("[PB] atWeb_DelOnepb--del SIM success\n");
1243 return;
1244 }
1245 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);
1246 }
1247 else
1248 {
1249 slog(PB_PRINT,SLOG_DEBUG,"pb:del_a_pbm_record:location is NULL\n");
1250 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_LOCATION_IS_NULL);
1251 }
1252}
1253
1254VOID atWeb_DelMultPb(T_zPb_DelInfo *delRecord, sem_t semId)
1255{
1256 CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
1257 int atRes = 0;
1258 SINT32 delCount = 0;
1259
1260 (VOID)sc_cfg_set(NV_PHO_DEL,"");
1261 memset(&g_zPb_DelStatusUsim,0,sizeof(T_zPb_DelStatusMultiOrAll));
1262 g_zPb_DelStatusUsim.dealFlag = ZPB_DEL_MULTI_RECORD_USIM;
1263 for(; delCount < delRecord->delTotal; delCount++)
1264 {
1265 slog(PB_PRINT,SLOG_DEBUG,"pb3:delId[%d]=%d,del_pbm_index[%d]=%d\n",delCount,delRecord->delId[delCount],delCount, delRecord->delIndex[delCount] );
1266 atPb_GetLocationIndexForDel(delRecord,delCount);
1267 if (ZPB_LOCATION_AP == delRecord->delLocation)
1268 {
1269 if(ZPB_DB_OK != atPb_DelARecFromPbmTable(delRecord, delCount))
1270 {
1271 slog(PB_PRINT,SLOG_DEBUG,"pb:pbm:remove the i(%d) rec from pbm table failed\n", delCount);
1272 g_zPb_DelStatusUsim.dealFailNum++;
1273 continue;
1274 }
1275 g_zPb_DelStatusUsim.dealSuccNum++;
1276 }
1277 else if (ZPB_LOCATION_USIM == delRecord->delLocation)
1278 {
1279 CHAR pbMax[50]={0};
1280 sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
1281 if((delRecord->delIndex[delCount]>=1)&&(delRecord->delIndex[delCount]<= atoi(pbMax)))/*×î´óÖµ*/
1282 {
1283 printf("pb9:atWeb_DelMultPb:remove the index(%d) rec from pbm table\n", delRecord->delIndex[delCount]);
1284 //atBase_SendMsgToSelf(ZAT_SCPBW_DEL_CMD,(PSTR)&delRecord->delIndex[delCount],10);//strlen(delRecord->delIndex[delCount]));
1285 //atRes = atPb_SendScpbwDelReq((PSTR)&delRecord->delIndex[delCount],cid,errCode,ZSVR_AT_RES_CODE_LEN);
1286 ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_DELETE_PB_REQ, sizeof(int), (unsigned char *)&delRecord->delIndex[delCount], 0);
1287 sem_wait(&g_Pb_sem_id);
1288 if(g_PbOptRsp.result != 1)
1289 {
1290 g_zPb_DelStatusUsim.dealFailNum++;
1291 sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);
1292 }
1293 else
1294 {
1295 g_zPb_DelStatusUsim.dealSuccNum++;
1296 sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
1297 }
1298 }
1299 else
1300 {
1301 continue;
1302 }
1303 (VOID)atPb_DelSimRecFromPbTable(delRecord->delIndex[delCount]);
1304 }
1305 else
1306 {
1307 slog(PB_PRINT,SLOG_DEBUG,"pb:location is NULL\n");
1308 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_LOCATION_IS_NULL);
1309 }
1310 }
1311 /*ɾ³ýÍê±ÏºóÉèÖÃNV*/
1312 atPb_SetDelStatusMultOrAll();
1313}
1314
1315T_zPb_DbResult atPb_DelRecByGroup(VOID)
1316{
1317 T_zPb_DbResult result = ZPB_DB_OK;
1318 T_zPb_ApIndex index = {0};
1319 SINT32 i = 1;
1320
1321 result = atPb_DelRecFromPbmTableByGroup(&index);
1322 //(VOID)system("adb push /etc_rw/config/pbm.db /usr/zte/zte_conf/config");
1323 if(ZPB_DB_OK != result)
1324 {
1325 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
1326 return result;
1327 }
1328 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
1329
1330 for(i=1; i<=ZPB_AP_MAX_RECORD; i++)
1331 {
1332 if(0 != index.apIndex[i])
1333 {
1334 g_zPb_ApIndex[(index.apIndex[i])] = PBM_ERROR_NOT_FOUND;
1335 }
1336 }
1337 return result;
1338}
1339VOID atPb_DelAllRecsSimDb(VOID)
1340{
1341 CHAR sql[ZPB_MAX_BYTES_DB] = {0};
1342 snprintf(sql,sizeof(sql)-1,"delete from %s where Location=%d",ZPB_DB_PBM_TABLE, ZPB_LOCATION_USIM);
1343 if(ZPB_DB_OK == atPb_ExecDbSql(sql,NULL,NULL))
1344 {
1345 atPb_ClearSimPbmIndexArray();
1346
1347 if(ZPB_DB_OK != atPb_ExecDbSql(ZTE_DROP_PBM_SIM_CAPABILITY_SQL,NULL,NULL))
1348 {
1349 printf("[PB] atPb_DelAllRecsSimDb execDb 2222 fail\n");
1350 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
1351 return;
1352 }
1353 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
1354 }
1355 else
1356 {
1357 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
1358 }
1359}
1360VOID atPb_DelAllRecsSim(T_zPb_DelInfo *pdelRecord, sem_t semId)
1361{
1362 CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
1363 int atRes = 0;
1364 UINT32 i = 0;
1365
1366 CHAR sql[ZPB_MAX_BYTES_DB] = {0};
1367 UINT32 count = 0;
1368
1369 if (pdelRecord != NULL)
1370 {
1371 memset(&g_zPb_DelStatusUsim,0,sizeof(T_zPb_DelStatusMultiOrAll));
1372 g_zPb_DelStatusUsim.dealFlag = ZPB_DEL_ALL_RECORD_USIM;
1373 snprintf(sql,sizeof(sql)-1,"select count(*) from %s where Location=%d",ZPB_DB_PBM_TABLE,ZPB_LOCATION_USIM);
1374 (VOID)atPb_ExecDbSql(sql,atPb_DbCountTableLineCb,&count);
1375 if(0 < count)
1376 {
1377 CHAR pbMin[50]={0};
1378 CHAR pbMax[50]={0};
1379 UINT32 i_pbMin = 0;
1380 UINT32 i_pbMax = 0;
1381 sc_cfg_get(ZPB_NV_USIMINDEXMIN,pbMin,sizeof(pbMin));
1382 sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
1383 //klocwork
1384 i_pbMin = atoi(pbMin);
1385 i_pbMax = atoi(pbMax);
1386 if (i_pbMin > ZPB_SIM_MAX_RECORD || i_pbMax > ZPB_SIM_MAX_RECORD) {
1387 printf("[PB] atPb_DelAllRecsSim sim index too large\n");
1388 return;
1389 }
1390
1391 for(i = i_pbMin; i <= i_pbMax; i++)
1392 {
1393 //atRes = atPb_SendScpbwDelReq((PSTR)&i,cid,errCode,ZSVR_AT_RES_CODE_LEN);
1394 ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_DELETE_PB_REQ, sizeof(int), (unsigned char *)&i, 0);
1395 sem_wait(&g_Pb_sem_id);
1396 if(g_PbOptRsp.result != 1)
1397 {
1398 g_zPb_DelStatusUsim.dealFailNum++;
1399 sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);
1400 }
1401 else
1402 {
1403 g_zPb_DelStatusUsim.dealSuccNum++;
1404 sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
1405 }
1406 }
1407 /*ɾ³ýÍê±Ï,ɾ³ýÊý¾Ý¿âÀïµÄ¼Ç¼*/
1408 snprintf(sql,sizeof(sql)-1,"delete from %s where Location=%d",ZPB_DB_PBM_TABLE, ZPB_LOCATION_USIM);
1409 if(ZPB_DB_OK == atPb_ExecDbSql(sql,NULL,NULL))
1410 {
1411 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
1412 atPb_ClearSimPbmIndexArray();
1413 }
1414 else
1415 {
1416 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
1417 }
1418 atPb_SetDelStatusMultOrAll(); (VOID)sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
1419 }
1420 }
1421}
1422
1423VOID atWeb_DelAllpb(T_zPb_DelInfo *delRecord, sem_t semId)
1424{
1425 printf("[PB] atWeb_DelAllpb delLocation=%d\n",delRecord->delLocation);
1426 if (ZPB_LOCATION_AP == delRecord->delLocation)
1427 {
1428 if(ZPB_DB_OK == atPb_DelAllRecsFromPbmTable(delRecord))
1429 {
1430 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
1431 }
1432 else
1433 {
1434 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
1435 }
1436 //(VOID)system("adb push /etc_rw/config/pbm.db /usr/zte/zte_conf/config");
1437 }
1438 else if (ZPB_LOCATION_USIM == delRecord->delLocation)
1439 {
1440 atPb_DelAllRecsSim(delRecord, semId);
1441 }
1442 else if(ZPB_LOCATION_ALL == delRecord->delLocation)
1443 {
1444 delRecord->delLocation = ZPB_LOCATION_AP;
1445 (VOID)atPb_DelAllRecsFromPbmTable(delRecord);
1446 delRecord->delLocation = ZPB_LOCATION_USIM;
1447 atPb_DelAllRecsSim(delRecord, semId);
1448 }
1449 else if(ZPB_LOCATION_GROUP == delRecord->delLocation)
1450 {
1451 (VOID)atPb_DelRecByGroup();
1452 }
1453 else
1454 {
1455 printf("[PB] atWeb_DelAllpb location is NULL\n");
1456 (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_LOCATION_IS_NULL);
1457 return;
1458 }
1459}
1460