GBC_downapp.c 29.7 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 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



#include "MMI_include.h"
#include "GBC_mtk_option.h"
#include "GBC_base_net_work_pub.h"
#include "mmi_rp_all_defs.h"

const U8 img_array_loadimg_dat[50] = {
	//0xac, 0x67, 0xa8, 0x47, 0xcf, 0x77, 0xaf, 0x6f, 0x6d, 0x67, 0x2b, 0x57, 0xe9, 0x3e, 0x86, 0x2e, 
	//0x44, 0x1e, 0x03, 0x0e, 0x60, 0x05, 0x60, 0x05, 0x81, 0x05, 0xa1, 0x05, 0xe1, 0x0d, 0x02, 0x0e, 
	//0x42, 0x16, 0x63, 0x16, 0xe7, 0x2e, 0xd0, 0x5f
	0xac, 0x67, 0xa8, 0x47, 0xcf, 0x77, 0xaf, 0x6f, 0x6d, 0x67, 0x2b, 0x57, 0xe9, 0x3e, 0x86, 0x2e, 0x86, 0x2e, 
	0x44, 0x1e, 0x44, 0x1e, 0x03, 0x0e, 0x03, 0x0e, 0x60, 0x05, 0x60, 0x05, 0x60, 0x05, 0x60, 0x05, 0x81, 0x05, 0xa1, 0x05, 0xe1, 0x0d, 0x02, 0x0e, 
	0x42, 0x16, 0x63, 0x16, 0xe7, 0x2e, 0xd0, 0x5f
};

#define __DOWNAPP_USE_TEXT_IMG__
#ifdef __DOWNAPP_USE_TEXT_IMG__
const U8 img_array_loading_text_gif[178] = {
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x48, 0x00, 0x11, 0x00, 0x80, 0x01, 0x00, 0xff, 0xff, 0xff, 
0xff, 0xff, 0xff, 0x21, 0xf9, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 
0x48, 0x00, 0x11, 0x00, 0x00, 0x02, 0x89, 0x8c, 0x8f, 0xa9, 0xcb, 0xed, 0x08, 0x52, 0x7c, 0x54, 
0xce, 0x8a, 0xa5, 0x06, 0x97, 0xfb, 0x0f, 0x72, 0x8b, 0xf8, 0x84, 0xe6, 0x17, 0x9c, 0xd1, 0x44, 
0x32, 0x97, 0xa2, 0x9a, 0xce, 0x3b, 0x6b, 0x06, 0x6d, 0x97, 0x2f, 0xde, 0xf0, 0x63, 0x5e, 0xaa, 
0xd0, 0x7c, 0xbf, 0x5e, 0x2c, 0x74, 0xd8, 0x51, 0x5a, 0xb7, 0x0c, 0x31, 0x59, 0x8c, 0xa6, 0x74, 
0x30, 0xa7, 0xc7, 0x58, 0x75, 0x41, 0x90, 0x90, 0x5b, 0xac, 0x96, 0x62, 0x86, 0xb9, 0xac, 0x61, 
0x17, 0x9b, 0x15, 0x6e, 0x77, 0x2b, 0x1b, 0x4e, 0xe9, 0x12, 0x37, 0x31, 0x43, 0xb8, 0x59, 0x0e, 
0x87, 0xb5, 0xd3, 0xcb, 0x99, 0x6c, 0x2c, 0xf5, 0x34, 0xc5, 0x17, 0xa4, 0x06, 0x74, 0x36, 0xd7, 
0x23, 0x55, 0xd8, 0x47, 0xd2, 0x92, 0x37, 0xa8, 0x48, 0x08, 0x16, 0x87, 0x24, 0xc2, 0x32, 0x76, 
0xc4, 0xb4, 0xa2, 0x29, 0xd9, 0xe7, 0xe5, 0x25, 0xe7, 0x94, 0xa1, 0x65, 0xa8, 0x67, 0x50, 0x00, 
0x00, 0x3b
};

const U8 img_array_loading_text_eng_gif[172] = {
0x47,0x49,0x46,0x38,0x39,0x61,0x48,0x00,0x11,0x00,0x80,0x01,0x00,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0x21,0xF9,0x04,0x01,0x00,0x00,0x01,0x00,0x2C,0x00,0x00,0x00,0x00,
0x48,0x00,0x11,0x00,0x00,0x02,0x83,0x8C,0x8F,0xA9,0xCB,0xED,0x0F,0xA3,0x9C,0xB4,
0xDA,0x8B,0x73,0x05,0x99,0x73,0x09,0x84,0xA1,0x96,0x7C,0x97,0x09,0x22,0xA8,0xB6,
0x52,0xED,0xB3,0x9A,0xE2,0x27,0x1F,0xA3,0x68,0xC8,0x78,0xBE,0x07,0xB3,0x97,0xF3,
0x8D,0x78,0xB3,0x52,0xD0,0xE6,0x43,0x06,0x6B,0x34,0x95,0x02,0x88,0xA4,0x31,0x55,
0xB1,0xE3,0x11,0xE8,0x19,0x2E,0xAD,0x49,0x23,0x0A,0xFA,0xED,0xF2,0x8C,0xE2,0x2E,
0x56,0x18,0x6E,0x2A,0x7F,0x65,0xB0,0xF3,0x5B,0x6D,0x6F,0xCF,0x51,0x2E,0x74,0x5B,
0x97,0xC3,0x9D,0x76,0xA5,0xF9,0xDD,0x97,0x66,0xE3,0x96,0x87,0x56,0x44,0xA5,0x25,
0xA6,0x86,0x67,0x38,0xB8,0x83,0x43,0x78,0x75,0x43,0x42,0x49,0xF9,0x52,0x89,0x19,
0x71,0x99,0xC9,0x89,0xB8,0xD9,0x09,0x9A,0x50,0x00,0x00,0x3B
};

const U8 img_array_loading_icon1_gif[84] = {
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x13, 0x00, 0x16, 0x00, 0x80, 0x01, 0x00, 0xff, 0xff, 0xff, 
0xff, 0xff, 0xff, 0x21, 0xf9, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 
0x13, 0x00, 0x16, 0x00, 0x00, 0x02, 0x2b, 0x8c, 0x1f, 0xa0, 0x8a, 0xed, 0x0f, 0xa3, 0x3c, 0x8b, 
0x4d, 0x53, 0xc1, 0xc5, 0x35, 0xe6, 0xdf, 0x21, 0xe0, 0xf7, 0x8c, 0x8b, 0x37, 0x4e, 0xe0, 0x96, 
0x6d, 0x9c, 0xe6, 0x62, 0x31, 0x6b, 0xa9, 0xed, 0x45, 0xe2, 0xb7, 0x6d, 0xf6, 0xfe, 0x0f, 0x5c, 
0x14, 0x00, 0x00, 0x3b
};
const U8 img_array_loading_icon2_gif[81] = {
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x13, 0x00, 0x13, 0x00, 0x80, 0x01, 0x00, 0xff, 0xff, 0xff, 
0xff, 0xff, 0xff, 0x21, 0xf9, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 
0x13, 0x00, 0x13, 0x00, 0x00, 0x02, 0x28, 0x8c, 0x1f, 0xa0, 0x8a, 0xed, 0x0f, 0xa3, 0x3c, 0x8b, 
0x4d, 0x53, 0xc1, 0xc5, 0x35, 0xe6, 0xdf, 0x21, 0xe0, 0xf7, 0x8c, 0x8b, 0x37, 0x4e, 0xe0, 0x96, 
0x95, 0x16, 0xf5, 0x72, 0xa1, 0xe8, 0x90, 0x97, 0xad, 0x9a, 0xfa, 0xce, 0xf7, 0x55, 0x01, 0x00, 
0x3b
};
const U8 img_array_loading_icon3_gif[79] = {
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x13, 0x00, 0x10, 0x00, 0x80, 0x01, 0x00, 0xff, 0xff, 0xff, 
0xff, 0xff, 0xff, 0x21, 0xf9, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 
0x13, 0x00, 0x10, 0x00, 0x00, 0x02, 0x26, 0x8c, 0x1f, 0xa0, 0x8a, 0xed, 0x0f, 0xa3, 0x3c, 0x8b, 
0x4d, 0x53, 0xc1, 0xc5, 0x35, 0xe6, 0xdf, 0x21, 0xe0, 0xf7, 0x8c, 0x8b, 0x68, 0x99, 0x5c, 0x98, 
0x90, 0xeb, 0x49, 0xb1, 0xad, 0x3c, 0x37, 0xe6, 0x8d, 0xe7, 0x7a, 0x56, 0x00, 0x00, 0x3b
};

/*
const U8 img_array_loading_icon_gif[377] = {
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x13, 0x00, 0x16, 0x00, 0x80, 0x01, 0x00, 0xff, 0xff, 0xff, 
0xff, 0xff, 0xff, 0x21, 0xff, 0x0b, 0x4e, 0x45, 0x54, 0x53, 0x43, 0x41, 0x50, 0x45, 0x32, 0x2e, 
0x30, 0x03, 0x01, 0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, 0x05, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x00, 
0x00, 0x00, 0x00, 0x13, 0x00, 0x16, 0x00, 0x00, 0x02, 0x2b, 0x8c, 0x1f, 0xa0, 0x8a, 0xed, 0x0f, 
0xa3, 0x3c, 0x8b, 0x4d, 0x53, 0xc1, 0xc5, 0x35, 0xe6, 0xdf, 0x21, 0xe0, 0xf7, 0x8c, 0x8b, 0x37, 
0x4e, 0xe0, 0x96, 0x6d, 0x9c, 0xe6, 0x62, 0x31, 0x6b, 0xa9, 0xed, 0x45, 0xe2, 0xb7, 0x6d, 0xf6, 
0xfe, 0x0f, 0x5c, 0x14, 0x00, 0x00, 0x21, 0xf9, 0x04, 0x05, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x00, 
0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x4c, 0x01, 0x00, 0x21, 0xf9, 0x04, 
0x09, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x02, 
0x0a, 0x8c, 0x8f, 0xa9, 0xcb, 0xed, 0x0f, 0xa3, 0x9c, 0xb3, 0x00, 0x00, 0x21, 0xf9, 0x04, 0x05, 
0x00, 0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x16, 0x00, 0x00, 0x02, 0x27, 
0x8c, 0x8f, 0xa9, 0xcb, 0xed, 0x0d, 0x62, 0x7c, 0xb4, 0x5a, 0x23, 0x67, 0xcd, 0xc0, 0x72, 0xa8, 
0x2d, 0x52, 0x32, 0x2a, 0x25, 0x19, 0x62, 0x29, 0xda, 0xa9, 0x2d, 0xd8, 0x9d, 0xce, 0xe7, 0xad, 
0xd4, 0x7b, 0xe5, 0xfa, 0xce, 0xe7, 0x05, 0x00, 0x21, 0xf9, 0x04, 0x05, 0x00, 0x00, 0x01, 0x00, 
0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x4c, 0x01, 0x00, 0x21, 
0xf9, 0x04, 0x09, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x02, 0x00, 0x03, 0x00, 0x0f, 0x00, 0x09, 0x00, 
0x00, 0x02, 0x0a, 0x8c, 0x8f, 0xa9, 0xcb, 0xed, 0x0f, 0xa3, 0x9c, 0xb3, 0x00, 0x00, 0x21, 0xf9, 
0x04, 0x05, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x16, 0x00, 0x00, 
0x02, 0x27, 0x8c, 0x8f, 0xa9, 0xcb, 0xed, 0x0f, 0xa3, 0x9c, 0x01, 0x58, 0x4b, 0xb3, 0xae, 0x17, 
0xc8, 0xee, 0x45, 0x60, 0x73, 0x91, 0x18, 0x52, 0x2a, 0x69, 0xb2, 0x1a, 0x2d, 0x7b, 0x72, 0xa1, 
0xe9, 0xbd, 0xcc, 0xf8, 0xc5, 0xdb, 0xce, 0x1b, 0x05, 0x00, 0x21, 0xf9, 0x04, 0x05, 0x00, 0x00, 
0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x4c, 0x01, 
0x00, 0x21, 0xf9, 0x04, 0x05, 0x00, 0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 
0x01, 0x00, 0x00, 0x02, 0x02, 0x4c, 0x01, 0x00, 0x3b
};
*/

#endif



static U16 timer_percent, real_percent, net_retry_times=0;

//主要用于关闭GPRS的标志
static U16 s_nShowDownScrFlag = 0;
//主要用于部分机器初次下载打不开G 网的情况
static U16 is_start_recving_app = 0;

static U16 loading_icon_gif_x, loading_icon_gif_y;
static gdi_handle loading_gif_handle;

static char* app_name_ptr;
static char* app_file_name_ptr;
static char app_url_ptr[128];

kal_bool isAppDownloaded = KAL_FALSE;   //app下载完成的标识


//APP DIR
const char gbcp_APP_PATH[] = "@GBC";
const char gbcp_TEMP_APP_NAME[] = "@GBC\\downdata.app";

extern U16 g_gbcp_down_app_retry_id;
extern U32 gbcp_mobile_open_time;
extern const S16 GBK_ui_device_width;
extern const S16 GBC_ui_device_height;



static void down_app_net_start(void);
void draw_down_screen_bg(void);
static void update_progress_bar(int percent);
static void timer_update_progress_bar(void);

static void DelAppDownScreen(void);
static void DownAppProgressUpdate(int  percent);
static void EntryDownAppScreen(void);
static void down_app_status_cb(S32 iStatus, S32 iPercent, void *pvCnt);
static void gbcp_draw_loading_text_img(int x, int y);
static void gbcp_draw_loading_icon_gif(void);



extern kal_bool GBC_lsk_rsk_pen_up_handle(mmi_pen_point_struct point);
extern kal_bool GBC_lsk_rsk_pen_down_handle(mmi_pen_point_struct point);
extern void GBC_TGYY_Back_History(void);
#define  GPRS_WARNING_NEW
#ifdef GPRS_WARNING_NEW
extern void entry_GBC_ltx_app(void);
extern void entry_GBC_QQ_app(void);
extern void entry_GBC_Plane_app(void);
extern void entry_GBC_Lord_app(void);
extern void entry_GBC_Vary_app(void);
#ifdef __GBC_TETRIS_FEATURES__
extern void Tetris_Entry_Screen(void);
#endif

//zt add 14.11.29
#ifdef __GBC_GOBANG_FEATURES__
extern void Gobang_Entry_Screen(void);
#endif

extern void Weather_Entry_Screen(void);
extern void Ebook_Entry_Screen(void);
extern void mmi_entry_gbc_locating(void);
extern void entry_GBC_Ics_update_app(void);

#ifdef __GBC_LISTEN_NEWS__
extern void gbc_listen_news_entry(void);
#endif
#ifdef __GBC_HUANGLI__
extern void gbc_huangli_entry(void);
#endif
#ifdef __GBC_NETP_FEATURES__
extern void gbc_netphone_entry(void);
#endif
//zt add 14.9.15
#ifdef __GBC_FAMILY_FEATURES__
extern void gbc_family_entry(void);
#endif

//zt add 14.12.29
#ifdef __MTK_WC_FEATURES__
extern void mtk_wc_entry(void);
#endif

BOOL gbc_g_gprs_flag = FALSE;
void GoBackHistory_ext(void)
{
	GoBackHistory();
	gbc_g_gprs_flag = FALSE;
}
void GBC_ShowGprsInfo(void (*f) (void))
{
	/*请先退出后台应用!*/
	DisplayConfirm(STR_GLOBAL_YES, IMG_GLOBAL_OK, STR_GLOBAL_NO, IMG_GLOBAL_BACK, (UI_string_type)GetString(STR_GPRS_WARNING), IMG_GLOBAL_QUESTION, 0);
	SetLeftSoftkeyFunction(f, KEY_EVENT_UP);
	SetRightSoftkeyFunction(GoBackHistory_ext, KEY_EVENT_UP);
	
	SetCenterSoftkeyFunction(f, KEY_EVENT_UP);
	ChangeCenterSoftkey(NULL, IMG_GLOBAL_COMMON_CSK);
}

#endif


/* 开始下载中间的应用程序*/
void TtpDownGypsApp(char* filename, char* appname, char* app_url)
{
	char temp_path[48];
	int delay_time = 0;
	int url_length;
	#ifdef GPRS_WARNING_NEW
	if(GBC_is_sim_valid())
	{
		if (gbc_g_gprs_flag == FALSE)
		{
			if (strstr(appname,"qq"))
			{
				GBC_ShowGprsInfo(entry_GBC_QQ_app);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			else if (strstr(appname,"ltx"))
			{
				GBC_ShowGprsInfo(entry_GBC_ltx_app);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			else if (strstr(appname,"plane"))
			{
				GBC_ShowGprsInfo(entry_GBC_Plane_app);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			else if (strstr(appname,"lord"))
			{
				GBC_ShowGprsInfo(entry_GBC_Lord_app);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			else if (strstr(appname,"vary"))
			{
				GBC_ShowGprsInfo(entry_GBC_Vary_app);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			#ifdef __GBC_TETRIS_FEATURES__
			else if (strstr(appname,"tetris"))
			{
				GBC_ShowGprsInfo(Tetris_Entry_Screen);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			#endif
			//zt add 14.11.29
			#ifdef __GBC_GOBANG_FEATURES__
			else if (strstr(appname,"gobang"))
			{
				GBC_ShowGprsInfo(Gobang_Entry_Screen);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			#endif
			else if (strstr(appname,"weather"))
			{
				GBC_ShowGprsInfo(Weather_Entry_Screen);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			else if (strstr(appname,"novel"))
			{
				GBC_ShowGprsInfo(Ebook_Entry_Screen);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			else if (strstr(appname,"locating"))
			{
				GBC_ShowGprsInfo(mmi_entry_gbc_locating);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			else if (strstr(appname,"ldxdlres"))
			{
				GBC_ShowGprsInfo(entry_GBC_Ics_update_app);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			#ifdef __GBC_LISTEN_NEWS__
			else if (strstr(appname,"hearnews"))
			{
				GBC_ShowGprsInfo(gbc_listen_news_entry);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			#endif
 			#ifdef __GBC_HUANGLI__
			else if (strstr(appname,"huangli"))
			{
				GBC_ShowGprsInfo(gbc_huangli_entry);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			#endif
			#ifdef __GBC_NETP_FEATURES__
			else if (strstr(appname,"netp"))
			{
				GBC_ShowGprsInfo(gbc_netphone_entry);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			#endif
			//zt add 14.9.15
			#ifdef __GBC_FAMILY_FEATURES__
			else if (strstr(appname,"family"))
			{
				GBC_ShowGprsInfo(gbc_family_entry);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			#endif
			//zt add 14.12.29
			#ifdef __MTK_WC_FEATURES__
			else if (strstr(appname,"jia"))
			{
				GBC_ShowGprsInfo(mtk_wc_entry);
				gbc_g_gprs_flag = TRUE;
				return;
			}
			#endif
		}
		gbc_g_gprs_flag = FALSE;
	}
	#endif
	//added by lees1206:关闭网络补扣
    //GBC_update_close();

	timer_percent = 0;
	is_start_recving_app = 0;
	net_retry_times = 0;
	


	//正式开始下载
	app_name_ptr = appname;
	app_file_name_ptr = filename;
	//app_url_ptr = app_url;
	gbcp_create_dir((char*)gbcp_APP_PATH);
	gbcp_file_write((char*)gbcp_TEMP_APP_NAME, "", 0, FALSE);
	
//zt add 14.12.29
#ifdef __MTK_WC_FEATURES__
	if(strstr(appname,"jia"))
	{
		mtk_wc_download_entry();
		return;
	}
#endif
	//显示下载提示框
	EntryDownAppScreen();

	url_length = strlen(app_url);
	if(url_length < 128)
	{
		strcpy(app_url_ptr, app_url);
	}
	else
	{
		gbcp_prompt_trace("下载app url长度错误");
		return;
	}
	


	//开机后不到40 秒延时启动网络
	delay_time = 40 - (app_getcurrtime() - gbcp_mobile_open_time);
	gbcp_prompt_trace("TtpDownGypsApp: delay_time=%d.", delay_time);
	if(delay_time > 0)
		StartTimer(g_gbcp_down_app_retry_id, delay_time*1000, down_app_net_start);
	else
		//StartTimer(g_gbcp_down_app_retry_id, 10*1000, down_app_net_start);
		down_app_net_start();
}

static void down_app_net_start(void)
{
	char temp_path[48];

	gbcp_prompt_trace("down_app_net_start...");
#if 0
	//创建一个网络对象(自启动)
	down_app_net_p = dzd_create_http_worker ("GET", app_url, RecvMwAppHandler, NULL);
#endif
	sprintf(temp_path, "%c:\\%s", gbcp_t_card_drv(), gbcp_TEMP_APP_NAME);
	GBC_down_single_task_start(app_url_ptr, down_app_status_cb, NULL, NULL, (S8*)temp_path);
}

static void down_app_net_retry(void)
{
	gbcp_prompt_trace("down_app_net_retry...");
	GBC_down_single_task_pause();
	StartTimer(g_gbcp_down_app_retry_id, 200, down_app_net_start);
}
#ifdef __GBC_MTK_12A

mmi_ret mmi_gbc_downapp_hdlr_internal_leave_proc(mmi_event_struct *evt)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    switch(evt->evt_id)
    {
    case EVT_ID_SCRN_GOBACK:
        break;
    case EVT_ID_SCRN_DELETE_REQ:
        break;
    case EVT_ID_SCRN_DEINIT:
        DelAppDownScreen();
        break;
    }
    return MMI_RET_OK;
}
#endif
extern MMI_ID g_gbc_gid;
static void gbcp_app_down_ok_handler();
static void EntryDownAppScreen(void)
{
	//set flag
	s_nShowDownScrFlag = 1;
	loading_gif_handle = GDI_ERROR_HANDLE;
	
	gbcp_EntryNewScreen(gbcp_DOWN_APP_SCR_ID, NULL, EntryDownAppScreen, NULL);
	ClearAllKeyHandler();

	//有中断事件后要判断是否下载完
	if(isAppDownloaded == KAL_TRUE)
	{
		StartTimer(g_gbcp_down_app_retry_id, 100, gbcp_app_down_ok_handler);
		return;
	}
	
	draw_down_screen_bg();
	update_progress_bar(timer_percent);

	gui_lock_double_buffer();
	gbcp_ChangeLeftSoftkey(0, 0);
	gbcp_ChangeRightSoftkey(0, 0);
	gbcp_ChangeRightSoftkey(STR_GLOBAL_CANCEL, IMG_GLOBAL_BACK);
	gui_unlock_double_buffer();
	gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);

	SetRightSoftkeyFunction(GBC_TGYY_Back_History, KEY_EVENT_UP); 
#if 1 //高仿爱疯可能不能注册该事件
	mmi_pen_register_down_handler((mmi_pen_hdlr)GBC_lsk_rsk_pen_down_handle);
	mmi_pen_register_up_handler((mmi_pen_hdlr)GBC_lsk_rsk_pen_up_handle);
#endif

#ifdef __GBC_MTK_12A
	mmi_frm_scrn_set_leave_proc(g_gbc_gid,gbcp_DOWN_APP_SCR_ID, mmi_gbc_downapp_hdlr_internal_leave_proc);

#else
	gbcp_SetDelScrnIDCallbackHandler(
		gbcp_DOWN_APP_SCR_ID,
		(HistoryDelCBPtr) DelAppDownScreen);
#endif

	GBC_turn_on_backlight();
	GBC_gui_start_timer(1000, timer_update_progress_bar);
	
}
extern int g_gbc_run;     //zt add 14.10.25
static void DelAppDownScreen(void)
{
	gbcp_prompt_trace("DelAppDownScreen...");
	GBC_restore_backlight();
	s_nShowDownScrFlag = 0;
	g_gbc_run = 0; //zt add 14.10.25

	GBC_gui_cancel_timer(timer_update_progress_bar);
	#if 1
	GBC_gui_cancel_timer(gbcp_draw_loading_icon_gif);
	#else
	gdi_image_stop_animation(loading_gif_handle);
	loading_gif_handle = GDI_ERROR_HANDLE;
	#endif
#if 0
	//强制关闭网络
	dzd_destroy_http_worker(&down_app_net_p);
	//关闭gprs
	dzd_net_close_gprs();
#else
	GBC_down_single_task_pause();
	//修正G图标不消失
	GBC_close_network_link();
#endif
	GBC_turn_off_backlight();

}
void update_progress_bar(int percent)
{
#ifdef __MMI_MAINLCD_320X480__
#define barlen	251
#define bar_x	36
#define bar_y	226
#define txt_x	121
#define txt_y	197
#define per_x	146
#define per_y	227
#elif defined( __MMI_MAINLCD_176X220__ )
#define barlen	138
#define bar_x	19
#define bar_y	92//93
#define txt_x	40
#define txt_y	63
#define per_x	74   
#define per_y	94
#elif defined( __MMI_MAINLCD_128X160__ )
#define barlen	100
#define bar_x	12
#define bar_y	85
#define txt_x		20
#define txt_y		55
#define per_x	74
#define per_y	90
#elif defined( __MMI_MAINLCD_160X128__ )
#define barlen	100
#define bar_x	25
#define bar_y	85
#define txt_x		20
#define txt_y		55
#define per_x	74
#define per_y	90
#elif defined( __MMI_MAINLCD_220X176__ )
#define barlen	171
#define bar_x	27
#define bar_y	96
#define txt_x	       81
#define txt_y	       67
#define per_x	106 
#define per_y	97
#else
#define barlen	171
#define bar_x	34
#define bar_y	146
#define txt_x	81
#define txt_y	117
#define per_x	106
#define per_y	147
#endif
	color bar_c = {0xb6, 0xb6, 0xb6, 100};
	color txt_c = {0xfe, 0xfe, 0xfe, 100};
	color per_c = {0x11, 0x11, 0x11, 100};
	int i,j,progres_len;
	U16 *buf_ptr;
	//U16 *saved_pix = (U16*)img_array_loadimg_dat;
	U16 saved_pix[25];
	U16 unicode_text[]={27491, 22312, 19979, 36733, 0}; //"正在下载"
	U8 unicode_text_eng[] = {0x44, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x6E, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x61, 0x00,
		0x64, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x00, 0x00};    //"Downloading"
	char per_text[12];
	// add by hypeagle 20130816 for align center
	WCHAR per_textw[12];
	int per_w,per_h;

	if(GetActiveScreenId() != gbcp_DOWN_APP_SCR_ID)
		return;

	#ifndef __DOWNAPP_USE_TEXT_IMG__
	GBC_set_text_font();
	if(isChinese == 1)
	{
		gbcp_print_w_text(txt_x, txt_y, 120, unicode_text, txt_c);
	}
	else
	{
		gbcp_print_w_text(txt_x, txt_y, 120, unicode_text_eng, txt_c);
	}
	#else
	gbcp_draw_loading_text_img((GBK_ui_device_width-96)/2, txt_y);
	#endif
	gui_fill_rectangle(bar_x, bar_y, bar_x+barlen-1, bar_y+25-1, bar_c);

#if 0
	gdi_image_draw_ext(
		bar_x,
		bar_y,
		(U8*)img_array_load_gif,
		GDI_IMAGE_TYPE_GIF,
		sizeof(img_array_load_gif));
	gdi_layer_get_buffer_ptr((U8**)&buf_ptr);
	buf_ptr += (UI_device_width*bar_y + bar_x);
	for(i=0;i<20;i++)
	{
		saved_pix[i] = *(buf_ptr + UI_device_width*i);
	}
	gbcp_file_write("loadimg.dat", saved_pix, sizeof(saved_pix), FALSE);
#else
	memcpy(saved_pix, img_array_loadimg_dat, sizeof(saved_pix));
	gdi_layer_get_buffer_ptr((U8**)&buf_ptr);
	buf_ptr += (UI_device_width*bar_y + bar_x);
#endif

	progres_len = barlen*percent/100;
	for(i=0;i<25;i++)
	{
		for(j=0;j<progres_len;j++)
		{
			buf_ptr[j] = saved_pix[i];
		}
		buf_ptr += UI_device_width;
	}
	//sprintf(per_text, "%d%%", percent);
	// add by hypeagle 20130816 for align center
	//mmi_asc_to_ucs2_ex((CHAR * )per_textw,(CHAR * )per_text);
	//zt modifly 2014.8.30
	kal_wsprintf(per_textw, "%d", percent);
	kal_wstrcat(per_textw, L"%");
	gui_measure_string((UI_string_type)per_textw,&per_w,&per_h);
	gbcp_print_w_text(bar_x + (barlen - per_w)/2, bar_y + (25 -per_h)/2, per_w, per_textw, per_c); // modify at 20140828 from 20 to 25
	
	//gbcp_print_text(per_x, per_y, per_text, per_c, FALSE);
	if(percent > 0)
		gui_BLT_double_buffer(bar_x, bar_y, bar_x+barlen, bar_y+25);
}

extern kal_bool isChinese;
static void gbcp_draw_loading_text_img(int x, int y)
{
	//draw text
	if(isChinese == 1)
	{
		gbcp_gdi_image_draw_ext(x, y, (U8*)img_array_loading_text_gif, GDI_IMAGE_TYPE_GIF, sizeof(img_array_loading_text_gif));
	}
	else
	{
		gbcp_gdi_image_draw_ext(x, y, (U8*)img_array_loading_text_eng_gif, GDI_IMAGE_TYPE_GIF, sizeof(img_array_loading_text_eng_gif));
	}
	//下载箭头1
	loading_icon_gif_x = x+72+1;
	loading_icon_gif_y = y-4;

	if(loading_gif_handle == GDI_ERROR_HANDLE)
		gbcp_draw_loading_icon_gif();
}

static void gbcp_draw_loading_icon_gif(void)
{
	#if 1
 	color c={0x0,0x0,0x0,100};
	static U8* icons[3]={(U8*)img_array_loading_icon1_gif, (U8*)img_array_loading_icon2_gif, (U8*)img_array_loading_icon3_gif};
	static U16 i=0;
	static U16 lens[3]={sizeof(img_array_loading_icon1_gif), sizeof(img_array_loading_icon2_gif), sizeof(img_array_loading_icon3_gif)};

	if(GetActiveScreenId() != gbcp_DOWN_APP_SCR_ID)
		return;
	loading_gif_handle = 0xff; 
	gui_fill_rectangle(loading_icon_gif_x, loading_icon_gif_y, loading_icon_gif_x+19, loading_icon_gif_y+22, c);
	gbcp_gdi_image_draw_ext(loading_icon_gif_x, loading_icon_gif_y+i*3, (U8*)icons[i], GDI_IMAGE_TYPE_GIF, lens[i]);
	gui_BLT_double_buffer(loading_icon_gif_x, loading_icon_gif_y, loading_icon_gif_x+19, loading_icon_gif_y+22);
	i++; i%=3;
	GBC_gui_start_timer(200, gbcp_draw_loading_icon_gif);
	#else
	int ret;
	
    ret = gdi_anim_draw_mem(loading_icon_gif_x, loading_icon_gif_y, 
		img_array_loading_icon_gif, GDI_IMAGE_TYPE_GIF, sizeof(img_array_loading_icon_gif), &loading_gif_handle);
	gbcp_prompt_trace("gdi_image_draw_animation ret=%d", ret);
	#endif
	
	#if 0
    /* gdi will not blt first frame, so we need blt it self */
    gdi_image_get_dimension(audply_main_animation.animation_img, &width, &height);
    gdi_layer_blt_previous(
        audply_main_animation.x,
        audply_main_animation.y,
        audply_main_animation.x + width,
        audply_main_animation.y + height);
	#endif
}

void draw_down_screen_bg(void)
{
	int i;
	color c={0x3c,0x3c,0x3c,100};

	for(i = 0; i < UI_device_height; i++)
	{
		if(c.r > 0)
		{
			c.r --; c.g --; c.b --;
		}
		gui_draw_horizontal_line(0, UI_device_width-1, i, c);
	}
}

static void timer_update_progress_bar(void)
{
	int i = (rand()%10)*100;

	if(timer_percent < 80)
	{
		timer_percent++;
		update_progress_bar(timer_percent);
	}
	GBC_gui_start_timer(500+i, timer_update_progress_bar);
}

extern 	int gbc_QQApplicationId;
//add by zill 修正不正确挂起和恢复背景音乐 20130817
extern void GBC_mmi_sndrec_bgsound_suspend();
extern void GBC_mmi_sndrec_bgsound_resume();
static void gbcp_app_down_ok_handler(void)
{
	char filepath[96]={0};

	int appid = -1;

	kal_wsprintf((WCHAR *)filepath, "%c:\\%s\\%s", (S8)gbcp_t_card_drv(), gbcp_APP_PATH, app_file_name_ptr);

	
	//add by zill 修正不正确挂起和恢复背景音乐 20130817
	GBC_mmi_sndrec_bgsound_suspend();	
	appid = mw_start_app_file (filepath, app_name_ptr);	
	if( appid < 0 )
	{
		GBC_mmi_sndrec_bgsound_resume();
	}
	if(strcmp(GBC_QQ_APP,app_file_name_ptr)==0)
	{
		gbc_QQApplicationId = appid;
	}
	
	gbcp_DeleteScreenIfPresent(gbcp_DOWN_APP_SCR_ID);
}

static void gbcp_app_file_rename(void)
{
	char FileName[64];
	char NewName[128];

	kal_wsprintf((WCHAR *)FileName, "%c:\\%s", (S8)gbcp_t_card_drv(), "@GBC\\setup.app");
	kal_wsprintf((WCHAR *)NewName, "%c:\\%s\\%s", (S8)gbcp_t_card_drv(), gbcp_APP_PATH, app_file_name_ptr);

	//rename file
	FS_Rename((WCHAR *)FileName, (WCHAR *)NewName);
}

static WCHAR* __wcsncpy(WCHAR *str,const WCHAR *cstr,int n)
{
	memcpy(str,cstr,n*sizeof(WCHAR));
	str[n] = 0;
	return str;
}

static int make_dir_straight(WCHAR *path)
{
	int len = 0;
	int i,j;
	WCHAR a_path[32];

	len = wcslen( (WCHAR*)path );  //T008 +
	for( i = 0 ; i < len ; ++i )
	{
		if( path[i] == L'\\' )
		{
			__wcsncpy( a_path , path , i );
			FS_CreateDir( a_path );
		}
	}
	return 1;
}

static int FORCE_FS_Write( FS_HANDLE FileHandle , void * DataPtr , UINT Length )
{
	UINT writtenBytes , j;
	unsigned char *p;
	int ret;
	
	if( DataPtr == NULL || Length == 0 )
		return;
	
	ret = FS_Write( FileHandle , DataPtr , Length , (UINT*)&writtenBytes );

	while( ret >= 0 && writtenBytes < Length )
	{
		p = (unsigned char *)DataPtr + writtenBytes ;

		ret = FS_Write( FileHandle , DataPtr , Length - writtenBytes , (UINT*)&j );

		writtenBytes += j;

		if( j == 0 ) break;
	}

	return ret;
}

static void gbcp_expode_downloaded_appfile()
{
	FS_HANDLE FH = -1;
	FS_HANDLE FDst = -1;

	char wFilePath[256] = {0};

	U32 fileFlag , fileCount;
	U16 filenameLen;
	U32 filename[128];
	U32 fileSize , reserved;

	U32 dataLen;
	U32 ret;
	
	unsigned char *tmpbuff = (unsigned char *)gbcp_med_malloc( 4096 ); 

	int i , k;

	if( tmpbuff == NULL ) 
		return;

	gbcp_prompt_trace( "gbcp_expode_downloaded_appfile %s" , gbcp_TEMP_APP_NAME );
	
	kal_wsprintf( (WCHAR*)wFilePath , "%c:\\%s" , (S8)gbcp_t_card_drv() , gbcp_TEMP_APP_NAME );

	FH = FS_Open((const WCHAR*)wFilePath, FS_READ_ONLY ); 

	if ( FH >= 0 )
	{ 

		FS_Seek( FH , 0 , FS_FILE_BEGIN );

		FS_Read( FH , &fileFlag , 4 , NULL );
		FS_Read( FH , &fileCount , 4 , NULL );

		gbcp_prompt_trace( "有文件个数 %d" , fileCount );

		if( fileCount > 0 && fileCount < 256 && fileFlag == 0x50495A4D )
		{
			for( i = 0 ; i < fileCount ; ++i )
			{
				filenameLen = 0;
				memset( filename , 0 , 128 );
				FS_Read( FH , &fileSize , 4 , &ret );					
				FS_Read( FH , &reserved , 4 , NULL );
				FS_Read( FH , &filenameLen , 2 , NULL );
				FS_Read( FH , filename , filenameLen , NULL );

				gbcp_prompt_trace( "[%d]%s size=%d" , i , filename , fileSize );

				kal_wsprintf( (WCHAR*)wFilePath , "%c:\\%s" , (S8)gbcp_t_card_drv() , filename );

				make_dir_straight( (WCHAR*)wFilePath );

				FDst = FS_Open( (WCHAR*)wFilePath , FS_CREATE_ALWAYS | FS_READ_WRITE );

				k = 0;
				while( k < fileSize )
				{
					dataLen = fileSize - k;
					if( dataLen > 4096 ) dataLen = 4096;
					
					FS_Read( FH , tmpbuff , dataLen , &ret );
					
					if( FDst >= 0 )
					{
						FORCE_FS_Write( FDst, tmpbuff , ret );
					}

					k += ret;
					if( ret == 0 )
						break;
				}

				if( FDst >= 0 )
				{
					FS_Close( FDst );
				}
				
			} 
		}

		gbcp_med_free( &tmpbuff );

		FS_Close( FH );


	} 

	gbcp_prompt_trace( "解包成功" );

	return;
}

#ifdef __GBC_USER_ROM_APP__

void gbc_down_rom_app(char* appBuf, int bufSize)
{
	FS_HANDLE FDst = -1;

	char wFilePath[256] = {0};

	U32 fileFlag , fileCount;
	U16 filenameLen;
	U32 filename[128];
	U32 fileSize , reserved;

	U32 dataLen;
	U32 ret;

	char* bufMark = NULL;
	
	unsigned char *tmpbuff = (unsigned char *)gbcp_med_malloc( 4096 ); 

	int i , k;

	if( tmpbuff == NULL ) 
		return;

	bufMark = appBuf;

	memcpy(&fileFlag, bufMark, 4);
	bufMark += 4;
	memcpy(&fileCount, bufMark, 4);
	bufMark += 4;

	gbcp_prompt_trace( "有文件个数 %d" , fileCount );

	if( fileCount > 0 && fileCount < 256 && fileFlag == 0x50495A4D )
	{
		for( i = 0 ; i < fileCount ; ++i )
		{
			filenameLen = 0;
			memset( filename , 0 , 128 );
			
			memcpy(&fileSize, bufMark, 4);
			bufMark += 4;
			memcpy(&reserved, bufMark, 4);
			bufMark += 4;
			memcpy(&filenameLen, bufMark, 2);
			bufMark += 2;
			memcpy(filename, bufMark, filenameLen);
			bufMark += filenameLen;
			
			gbcp_prompt_trace("[%d]%s size=%d", i, filename, fileSize);

			kal_wsprintf((WCHAR*)wFilePath, "%c:\\%s", (S8)gbcp_t_card_drv(), filename);

			make_dir_straight( (WCHAR*)wFilePath );

			FDst = FS_Open((WCHAR*)wFilePath, FS_CREATE_ALWAYS|FS_READ_WRITE);

			k = 0;
			while( k < fileSize )
			{
				dataLen = fileSize - k;
				if( dataLen > 4096 ) dataLen = 4096;
				
				memcpy(tmpbuff, bufMark, dataLen);
				bufMark += dataLen;
				ret = dataLen;
				if( FDst >= 0 )
				{
					FORCE_FS_Write( FDst, tmpbuff , ret );
				}

				k += ret;
				if( ret == 0 )
					break;
			}

			if( FDst >= 0 )
			{
				FS_Close( FDst );
			}
		} 
	}

	gbcp_med_free(&tmpbuff);

	gbcp_prompt_trace("gbc_down_rom_app--解包成功");

	gbcp_app_file_rename();
	return;
}
#endif

static void down_app_status_cb(S32 iStatus, S32 iPercent, void *pvCnt)
{
	int percent = iPercent;
	//char tail[32]={0};

	gbcp_prompt_trace("网络状态iStatus=%d, iPercent=%d",iStatus, iPercent);

	switch(iStatus)
	{
		case __DOWNLOAD_STATUS_DOWNLOADING://正在下载状态
		{
			//sprintf(tail, "...%d%%", iPercent);
			//gbcp_prompt_trace("iPercent=%d.", iPercent);
			//标志着开始下载了...
			is_start_recving_app = TRUE;
			real_percent = iPercent;
			if(real_percent > timer_percent)
				timer_percent = real_percent;
			if(real_percent > 80)
				update_progress_bar(real_percent);
			break;
		}
		//下载完成状态
		case __DOWNLOAD_STATUS_COMPLETED:
		{
			percent = 100;
			isAppDownloaded = KAL_TRUE;
			//strcpy(tail, "...100%%");

			gbcp_expode_downloaded_appfile();//分割文件 by zill 20120703 23:24 先分割文件,分割的文件中会存在 gbcp_TEMP_APP_NAME
			
			gbcp_app_file_rename();
			GBC_gui_cancel_timer(timer_update_progress_bar);
			#if 1
			GBC_gui_cancel_timer(gbcp_draw_loading_icon_gif);
			#else
			gdi_image_stop_animation(loading_gif_handle);
			loading_gif_handle = GDI_ERROR_HANDLE;
			#endif
			update_progress_bar(100);
			//准备加载...
			//若在非app下载界面(比如锁屏了), 直接返回
			if(GetActiveScreenId() != gbcp_DOWN_APP_SCR_ID)
			{
				return;
			}
			if(s_nShowDownScrFlag) //显示下载的情况
			{
				StartTimer(g_gbcp_down_app_retry_id, 100, gbcp_app_down_ok_handler);
				//GBC_gui_start_timer(100, gbcp_app_down_ok_handler);
			}
			break;
		}	
		//下载失败状态
		case __DOWNLOAD_STATUS_CREATE_SOCKET_FAILED:
		case __DOWNLOAD_STAUTS_FAILED:		
		{
			if(s_nShowDownScrFlag)
			{
				if(!is_start_recving_app && ++net_retry_times < 3 )
				{
					//retry , 主要用于部分机器初次下载打不开G 网的情况
					gbcp_prompt_trace("net retry, 主要用于部分机器初次下载打不开G 网的情况!");
					StartTimer(g_gbcp_down_app_retry_id, 200, down_app_net_retry);
				}
				else
				{
					gbcp_prompt_trace("网络连接失败!");
					//弹出错误提示框
					gbcp_down_app_fail_popup();
					//---
					gbcp_DeleteScreenIfPresent(gbcp_DOWN_APP_SCR_ID);
				}
			}
			
			break;
		}
	}
}

//zt add 14.12.29
#ifdef __MTK_WC_FEATURES__
void mtk_wc_download_complete()
{
	gbcp_expode_downloaded_appfile();//分割文件 by zill 20120703 23:24 先分割文件,分割的文件中会存在 gbcp_TEMP_APP_NAME
	gbcp_app_file_rename();

	StartTimer(g_gbcp_down_app_retry_id, 100, gbcp_app_down_ok_handler);
}
#endif