NwInfoSrvSignal.c
29 KB
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
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* NwInfoSrvSignal.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* Service of network infomation.
* This file handles signal information.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/****************************************************************************
* Include
****************************************************************************/
#include "NwInfoSrv.h"
#include "MMIDataType.h"
#include "kal_general_types.h"
#include "NwInfoSrvGprot.h"
#include "ps_public_enum.h"
#include "kal_public_api.h"
#include "DebugInitDef_Int.h"
#include "mmi_msg_struct.h"
#include "MMI_common_app_trc.h"
#include "kal_trace.h"
#include "mmi_common_app_trc.h"
#include "mmi_frm_events_gprot.h"
#include "string.h"
#include "mmi_cb_mgr_gprot.h"
#include "mmi_frm_utility_gprot.h"
#include "mmi_rp_srv_nw_info_def.h"
#include "mmi_frm_timer_gprot.h"
/****************************************************************************
* Configurations
****************************************************************************/
/*
* The maximum number of the grids of signal icon
* For example, if the signal icon ranges 0 ~ 4 grids(5 icons), this value
* should be 4
*/
#if defined(__TOPWELL_MMI_NW_SIGNAL_LEVEL_5__)
#define SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM 5
#elif defined(__TOPWELL_MMI_NW_SIGNAL_LEVEL_6__)
#define SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM 6
#elif defined(__TOPWELL_MMI_NW_SIGNAL_LEVEL_7__)
#define SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM 7
#else
#define SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM 4
#endif
/*
* The delay interval to degrade one signal grid.
* When signal degrades significantly, this design can let the degrading
* one-by-one, with this interval, to improve the UE.
*/
#define SRV_NW_INFO_SIGNAL_DEGRADING_TIME_INTERVAL 3000 /* in ms */
/* The percentage interval of one grid */
#define SRV_NW_INFO_GRID_INTERVAL \
(100 / ((SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM) + 1))
#if defined(__UMTS_RAT__) && !defined(__UMTS_TDD128_MODE__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* __UMTS_RAT__ */
/*
* Structure for smooth signal degrading
*/
typedef struct
{
MMI_BOOL timer_exists; /* We have triggered the timer */
U8 target_percentage[MMI_SIM_TOTAL];
} srv_nw_info_signal_ani_cntx_struct;
static srv_nw_info_signal_ani_cntx_struct g_srv_nw_info_signal_ani_cntx;
/****************************************************************************
* Functions
****************************************************************************/
/*****************************************************************************
* FUNCTION
* Q_DBM
* DESCRIPTION
* Convert dBm value to qdBm
* PARAMETERS
* dBm [IN]
* RETURNS
* qdBm
*****************************************************************************/
#define Q_DBM(dBm) ((S32)(dBm) * 4)
/*****************************************************************************
* FUNCTION
* PERCENTAGE_OF
* DESCRIPTION
* Calculate the percentage value by expected grids & maximum grids.
*
* For example. if you prepared a 5 grids icon, namely, 6 images for 0 ~ 5
* grids, set the percentage to the middle value of the range of the grid#
* that the grid# you expect can be displayed.
*
* 0 1 2 3 4 5 Grid#
*
* 0 16.7 33.3 49.7 64.4 83.1 100 Range bound
* +-------+-------+-------+-------+-------+-------+
* 0 25 42 57 74 100 Percentage
*
* PARAMETERS
* expected_grids [IN] Number of grids which is expected,
* ranges 0 ~ max_grids(included)
* max_grids [IN] Maximum number of grids
* RETURNS
* Suitable percentage value for the expectation
*****************************************************************************/
#define PERCENTAGE_OF(expected_grids) \
(((expected_grids) * 100 + 50) / ((SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM) + 1))
/*****************************************************************************
* FUNCTION
* srv_nw_info_get_next_degraging_perc
* DESCRIPTION
* Get next percentage value for smooth degrading
* PARAMETERS
* curr_percentage [IN] Current percentage
* target_percentage [IN] Target percentage
* RETURNS
* Next percentage
*****************************************************************************/
static S32 srv_nw_info_get_next_degraging_perc(
S32 curr_percentage,
S32 target_percentage)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
const U8 SIGNAL_STEP_PERCENTAGES[SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM + 1] =
{
0,
PERCENTAGE_OF(1),
PERCENTAGE_OF(2),
PERCENTAGE_OF(3),
#if SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM > 4
PERCENTAGE_OF(4),
#endif
#if SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM > 5
PERCENTAGE_OF(5),
#endif
#if SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM > 6
PERCENTAGE_OF(6),
#endif
#if SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM > 7
PERCENTAGE_OF(7),
#endif
100
};
const S32 STEP_ARR_SIZE = SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM + 1;
S32 i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 1; i < STEP_ARR_SIZE; i++)
{
if ((S32)SIGNAL_STEP_PERCENTAGES[i] >= curr_percentage)
{
break;
}
}
--i;
/* Now SIGNAL_STEP_PERCENTAGES[i] < curr_percentage */
if (2 * (curr_percentage - (S32)SIGNAL_STEP_PERCENTAGES[i]) <=
SRV_NW_INFO_GRID_INTERVAL) /* The same grid */
{
--i;
}
if (i <= 0)
{
i = 0;
}
if (SIGNAL_STEP_PERCENTAGES[i] <= target_percentage)
{
return target_percentage;
}
return SIGNAL_STEP_PERCENTAGES[i];
}
static void srv_nw_info_sent_signal_changed(mmi_sim_enum sim, U32 old_percentage, U32 new_percentage)
{
srv_nw_info_signal_strength_changed_evt_struct strength_evt;
MMI_TRACE(SRV_NW_INFO_TRC_GROUP, TRC_SRV_NW_INFO_SIGNAL_STRENGTH,
sim, old_percentage, new_percentage);
MMI_FRM_INIT_EVENT(&strength_evt, EVT_ID_SRV_NW_INFO_SIGNAL_STRENGTH_CHANGED);
strength_evt.sim = sim;
strength_evt.old_percentage = (U8)old_percentage;
strength_evt.new_percentage = (U8)new_percentage;
MMI_FRM_CB_EMIT_EVENT(&strength_evt);
}
/*****************************************************************************
* FUNCTION
* srv_nw_info_update_next_percentage
* DESCRIPTION
* Update next percentage of given SIM for smooth degrading
* PARAMETERS
* cntx [IN] Context
* sim [IN] Network of SIM
* target_percentage [IN] Target percentage
* start_timer [OUT] Need to trigger timer for next degrading
* RETURNS
* void
*****************************************************************************/
static void srv_nw_info_update_next_percentage(
srv_nw_info_cntx_struct *cntx,
mmi_sim_enum sim,
S32 target_percentage,
MMI_BOOL *start_timer)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 diff;
U8 old_signal_strength_in_percentage;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
old_signal_strength_in_percentage = cntx->signal.strength_in_percentage;
diff = (S32)cntx->signal.strength_in_percentage - target_percentage;
if (diff == 0)
{
/* Do nothing */
return;
}
else if (diff <= SRV_NW_INFO_GRID_INTERVAL) /* target > curr || 0 or 1 grid difference */
{
/* Update directly */
cntx->signal.strength_in_percentage = target_percentage;
}
else /* Signal degrades & large(>1 grids) difference */
{
cntx->signal.strength_in_percentage = (U8)srv_nw_info_get_next_degraging_perc(
cntx->signal.strength_in_percentage,
target_percentage);
*start_timer = MMI_TRUE;
}
srv_nw_info_sent_signal_changed(sim, old_signal_strength_in_percentage, cntx->signal.strength_in_percentage);
}
/*****************************************************************************
* FUNCTION
* srv_nw_info_update_signal_strength
* DESCRIPTION
* Update next percentage of each SIM for smooth degrading.
* This will be invoked by degrading animation timer
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void srv_nw_info_update_signal_strength(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 i;
srv_nw_info_cntx_struct *cntx;
MMI_BOOL start_timer;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
start_timer = MMI_FALSE;
for (i = 0; i < MMI_SIM_TOTAL; i++)
{
mmi_sim_enum sim = mmi_frm_index_to_sim(i);
cntx = srv_nw_info_get_cntx(sim);
srv_nw_info_update_next_percentage(
cntx,
sim,
g_srv_nw_info_signal_ani_cntx.target_percentage[i],
&start_timer);
}
if (start_timer)
{
g_srv_nw_info_signal_ani_cntx.timer_exists = MMI_TRUE;
StartTimer(
TIMER_ID_SRV_NW_INFO_SIGNAL_ANIMATION,
SRV_NW_INFO_SIGNAL_DEGRADING_TIME_INTERVAL,
srv_nw_info_update_signal_strength);
}
else
{
g_srv_nw_info_signal_ani_cntx.timer_exists = MMI_FALSE;
}
}
/*****************************************************************************
* FUNCTION
* srv_nw_info_set_target_signal_percentage
* DESCRIPTION
* Set
* PARAMETERS
* cntx [IN] Context
* sim [IN] Network of SIM
* target_percentage [IN] Target percentage
* RETURNS
* void
*****************************************************************************/
void srv_nw_info_set_target_signal_percentage(
srv_nw_info_cntx_struct *cntx,
mmi_sim_enum sim,
S32 target_percentage)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 sim_index;
MMI_BOOL start_timer;
U8 old_signal_strength_in_percentage;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
cntx = srv_nw_info_get_cntx(sim);
sim_index = mmi_frm_sim_to_index(sim);
g_srv_nw_info_signal_ani_cntx.target_percentage[sim_index] = target_percentage;
old_signal_strength_in_percentage = cntx->signal.strength_in_percentage;
if (target_percentage == cntx->signal.strength_in_percentage)
{
/* Do nothing */
MMI_TRACE(SRV_NW_INFO_TRC_GROUP, TRC_SRV_NW_INFO_SIGNAL_STRENGTH,
sim, old_signal_strength_in_percentage, cntx->signal.strength_in_percentage);
}
else if (target_percentage > cntx->signal.strength_in_percentage)
{
/* Update right away */
cntx->signal.strength_in_percentage = (U8)target_percentage;
srv_nw_info_sent_signal_changed(sim, old_signal_strength_in_percentage, cntx->signal.strength_in_percentage);
}
else /* target_percentage < cntx->signal.strength_in_percentage */
{
if (!g_srv_nw_info_signal_ani_cntx.timer_exists)
{
/* the same as (!IsMyTimerExist(TIMER_ID_SRV_NW_INFO_SIGNAL_ANIMATION)) */
start_timer = MMI_FALSE;
srv_nw_info_update_next_percentage(cntx, sim, target_percentage, &start_timer);
if (start_timer)
{
g_srv_nw_info_signal_ani_cntx.timer_exists = MMI_TRUE;
StartTimer(
TIMER_ID_SRV_NW_INFO_SIGNAL_ANIMATION,
SRV_NW_INFO_SIGNAL_DEGRADING_TIME_INTERVAL,
srv_nw_info_update_signal_strength);
}
}
else
{
/* Let the timer to update the signal */
}
}
}
/*****************************************************************************
* FUNCTION
* srv_nw_info_get_band_from_l4_value
* DESCRIPTION
* Map L4 band enum to srv_nw_band_enum
* PARAMETERS
* l4_band [IN]
* RETURNS
* Percentage
*****************************************************************************/
static srv_nw_band_enum srv_nw_info_get_band_from_l4_value(kal_uint8 l4_band)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
srv_nw_band_enum band;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
band = SRV_NW_BAND_NONE;
switch (l4_band)
{
case NW_BAND_PGSM900:
case NW_BAND_EGSM900:
case NW_BAND_RGSM900:
band = SRV_NW_BAND_GSM900;
break;
case NW_BAND_DCS1800:
band = SRV_NW_BAND_DCS1800;
break;
case NW_BAND_PCS1900:
band = SRV_NW_BAND_PCS1900;
break;
case NW_BAND_GSM450:
band = SRV_NW_BAND_GSM450;
break;
case NW_BAND_GSM480:
band = SRV_NW_BAND_GSM480;
break;
case NW_BAND_GSM850:
band = SRV_NW_BAND_GSM850;
break;
default:
band = SRV_NW_BAND_OTHERS;
break;
}
return band;
}
#if defined(__TOPWELL_MMI_NETWORK_INFO_USER_DEFINE__)
typedef struct{
S32 Rssi;
S32 Percent;
}SRV_RSSI_PERCENT;
static SRV_RSSI_PERCENT g_rssi_percent[SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM]={
#if defined(__TOPWELL_RSSI_PERCENT_CONFIG_01__)
{42, 80},
{26, 60},
{15, 40},
{3, 20},
#elif defined(__TOPWELL_RSSI_PERCENT_CONFIG_02__) && defined(__TOPWELL_T351__)
{93, 80}, //52
{66, 60}, // 33
{42, 40}, //21
{17, 20}, //6
#elif defined(__TOPWELL_RSSI_PERCENT_CONFIG_02__) && defined(__TOPWELL_T3286__)
{85, 100}, //54
{66, 80}, //43
{45, 60}, //32
{26, 40}, //21
{6, 20}, //10
#else
{97, 80},
{39, 60},
{21, 40},
{10, 20},
#endif
};
#endif
/*****************************************************************************
* FUNCTION
* srv_nw_info_get_percentage_from_gsm_rssi
* DESCRIPTION
* Convert GSM RSSI to percentage value
* PARAMETERS
* rssi_in_qdBm [IN]
* RETURNS
* Percentage
*****************************************************************************/
static U8 srv_nw_info_get_percentage_from_gsm_rssi(S32 rssi_in_qdBm)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 percentage = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/*
* You may use macro PERCENTAGE_OF() here to calculate the percentage
* by expected grids.
*/
if (rssi_in_qdBm < Q_DBM(-107))
{
percentage = 0;
}
else if (rssi_in_qdBm < Q_DBM(-77))
{
#if defined(__TOPWELL_MMI_NETWORK_INFO_USER_DEFINE__)
S32 temp_rssi;
U16 i;
temp_rssi = (rssi_in_qdBm - Q_DBM(-107));
kal_prompt_trace(MOD_CC, "FUZ RSSI = %d", temp_rssi);
for(i=0;i<SRV_NW_INFO_SIGNAL_MAX_GRIDS_NUM;i++)
{
if (temp_rssi >= g_rssi_percent[i].Rssi)
{
percentage = g_rssi_percent[i].Percent;
break;
}
}
#else
percentage =
((rssi_in_qdBm - Q_DBM(-107)) * 100) / (Q_DBM(-77) - Q_DBM(-107));
#endif
}
else
{
percentage = 100;
}
return (U8)percentage;
}
#ifdef __UMTS_RAT__
/* under construction !*/
#ifdef __UMTS_TDD128_MODE__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#else /* __UMTS_TDD128_MODE__ */
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* __UMTS_TDD128_MODE__ */
#endif /* __UMTS_RAT__ */
/*****************************************************************************
* FUNCTION
* srv_nw_info_rx_level_ind_hdlr
* DESCRIPTION
* Handler of NW_RX_LEVEL_IND.
* Update signal strength and camp-on band information.
* PARAMETERS
* sim [IN] From which layer
* msg [IN] mmi_nw_rx_level_ind_struct*
* RETURNS
* MMI_FALSE; continue message routing
*****************************************************************************/
MMI_BOOL srv_nw_info_rx_level_ind_hdlr(void *msg, S32 src_mod)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
mmi_sim_enum sim;
srv_nw_info_cntx_struct *cntx;
mmi_nw_rx_level_ind_struct *rx_level_ind;
U8 target_percentage;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
sim = mmi_frm_l4c_mod_to_sim((module_type)src_mod);
cntx = srv_nw_info_get_cntx(sim);
rx_level_ind = (mmi_nw_rx_level_ind_struct*)msg;
/* qdBm = dBm * 4 */
if (rx_level_ind->rat == L4C_RAT_GSM)
{
if (rx_level_ind->rssi_in_qdbm < 0)
{
cntx->signal.gsm_band = srv_nw_info_get_band_from_l4_value(rx_level_ind->current_band);
cntx->signal.gsm_RSSI_in_qdBm = rx_level_ind->rssi_in_qdbm;
target_percentage = srv_nw_info_get_percentage_from_gsm_rssi(cntx->signal.gsm_RSSI_in_qdBm);
#ifdef __OP01_3G__
if (target_percentage <= 0 &&
srv_nw_info_get_service_availability(sim) == SRV_NW_INFO_SA_FULL_SERVICE ||
srv_nw_info_is_need_display_fake_nw_status(sim) == MMI_TRUE)
{
// CMCC request not display empty signal icon
target_percentage = 1;
}
#endif /* __OP01_3G__ */
srv_nw_info_set_target_signal_percentage(cntx, sim, target_percentage);
}
}
#ifdef __UMTS_RAT__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#ifdef __UMTS_TDD128_MODE__
/* under construction !*/
/* under construction !*/
#ifdef __OP01_3G__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* __OP01_3G__ */
#else
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
/* under construction !*/
/* under construction !*/
#endif /* __UMTS_RAT__ */
return MMI_FALSE;
}
/*****************************************************************************
* Please refer to NwInfoSrvGprot.h
*****************************************************************************/
srv_nw_band_enum srv_nw_info_get_camp_on_band(mmi_sim_enum sim)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
srv_nw_info_cntx_struct *cntx;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
cntx = srv_nw_info_get_cntx(sim);
if (cntx->service_availability == SRV_NW_INFO_SA_NO_SERVICE)
{
return SRV_NW_BAND_NONE;
}
if (cntx->protocol != MMI_GSM)
{
return SRV_NW_BAND_OTHERS;
}
return (cntx->signal.gsm_band);
}
/*****************************************************************************
* Please refer to NwInfoSrvGprot.h
*****************************************************************************/
U8 srv_nw_info_get_signal_strength_in_percentage(mmi_sim_enum sim)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
srv_nw_info_cntx_struct *cntx;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
cntx = srv_nw_info_get_cntx(sim);
return (cntx->signal.strength_in_percentage);
}