ScrLockerClassic.c 38.9 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 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258
/*****************************************************************************
*  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) 2010
*
*  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:
 * ---------
 *  ScrLockerClassic.c
 *
 * Project:
 * --------
 *  MAUI
 *
 * Description:
 * ------------
 *  This file implements the classic screen locker.
 *
 * 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!
 *
 * 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!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

/****************************************************************************
 * Include
 ****************************************************************************/

#include "MMI_features.h"

#ifdef __MMI_SCREEN_LOCK_CLASSIC__

#include "IdleGprot.h"
#include "ScrSaverGprot.h"
#include "MMIDataType.h"
#include "GlobalConstants.h"
#include "mmi_rp_app_scr_locker_def.h"
#include "ScrLockerPopup.h"
#include "kal_public_api.h"
#include "DebugInitDef_Int.h"
#include "kal_general_types.h"
#include "ScrLockerClassic.h"
#include "mmi_frm_scenario_gprot.h"
#include "GlobalResDef.h"
#include "l4c_nw_cmd.h"
#include "mmi_rp_app_uiframework_def.h"
#include "wgui_categories_popup.h"
#include "wgui_categories_util.h"
#include "ScrLockerMain.h"
#include "mmi_frm_input_gprot.h"
#include "ScrLockerGprot.h"
#include "ScrLockerObject.h"
#include "gui_typedef.h"
#include "ScrLockerFactory.h"
#include "FactoryGprot.h"
#include "CommonScreens.h"
#include "CommonScreensResDef.h"
#include "ProfilesSrvGprot.h"
#include "gpiosrvgprot.h"

#include "MMI_ap_dcm_config.h"

#if defined(__MMI_BT_DIALER_SUPPORT__)
#include "BTMMIScr.h"
#include "mmi_rp_app_bluetooth_def.h"
#include "IdleObject.h"
#endif

#ifdef __MMI_AP_DCM_SCRLOCK__
#pragma arm section rodata = "DYNAMIC_CODE_SCRLOCK_RODATA" , code = "DYNAMIC_CODE_SCRLOCK_ROCODE"
#endif

/****************************************************************************
 * Function
 ****************************************************************************/

/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_get_unlock_trigger_key
 * DESCRIPTION
 *  This function gets the key code to trigger the unlock process.
 * PARAMETERS
 *  void
 * RETURNS
 *  Key code.
 *****************************************************************************/
static U16 mmi_slk_classic_get_unlock_trigger_key(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifndef __MMI_BTD_BOX_UI_STYLE__
#ifdef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
    if (mmi_frm_kbd_is_key_supported(KEY_RSK))
    {
        return KEY_RSK;
    }
#elif defined(__TOPWELL_MMI_UNLOCK_STAR_KEY__)
    if (mmi_frm_kbd_is_key_supported(KEY_STAR))
    {
        return KEY_STAR;
    }
#else

    if (mmi_frm_kbd_is_key_supported(KEY_LSK))
    {
        return KEY_LSK;
    }
#endif
    else
    {
        return KEY_SEND;
    }
#else/*__MMI_BTD_BOX_UI_STYLE__*/
       return  KEY_RSK;
#endif /*__MMI_BTD_BOX_UI_STYLE__*/

}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_get_unlock_final_key
 * DESCRIPTION
 *  This function gets the key code to unlock the handset.
 * PARAMETERS
 *  void
 * RETURNS
 *  key code.
 *****************************************************************************/
static U16 mmi_slk_classic_get_unlock_final_key(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#if defined(__TOPWELL_MMI_SCREEN_LOCK_STAR__) 
    return KEY_STAR;
#elif defined(__TOPWELL_MMI_SCREEN_LOCK_POUND__)   
 	return KEY_POUND;
#else
#ifdef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
    return KEY_POUND;

#else
    return KEY_END;
#endif
#endif    
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_get_soft_key
 * DESCRIPTION
 *  This function gets the soft key string used when the handset is locked.
 *  Basically, screen locker will automatically handle the softkey string and
 *  image. But, for some APP that dose not use framework softkey component, e.g.
 *  media or Java APP, they can use this API to get the softkey string if they
 *  wants to support the locked state.
 * PARAMETERS
 *  lsk_str_id           : [IN]      Left softkey string ID
 *  rsk_str_id           : [IN]      Right softkey string ID
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_slk_classic_get_softkey_id(U16 *lsk_str_id, U16 *rsk_str_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (lsk_str_id)
    {
        *lsk_str_id = 0; /* reset */
    }

    if (rsk_str_id)
    {
        *rsk_str_id = 0; /* reset */
    }
    
  #ifdef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
  if (rsk_str_id)
  {
      *rsk_str_id = STR_ID_SLK_UNLOCK;
  }
  #elif defined(__TOPWELL_MMI_SCREEN_LOCK_POUND__)   
  if (rsk_str_id)
  {
      *rsk_str_id = STR_ID_SLK_UNLOCK;
  }
  #else
    if (lsk_str_id)
    {
        *lsk_str_id = STR_ID_SLK_UNLOCK;
    }

  #endif
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_popup_callback
 * DESCRIPTION
 *  This function
 * PARAMETERS
 *  event           : [IN]
 * RETURNS
 *  void
 *****************************************************************************/
static mmi_ret mmi_slk_classic_popup_callback(mmi_event_struct *event)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_alert_result_evt_struct *evt = (mmi_alert_result_evt_struct *)event;
    mmi_slk_classic_struct *obj = (mmi_slk_classic_struct *)evt->user_tag;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    switch(evt->evt_id)
    {
        case EVT_ID_ALERT_ENTER:
            obj->is_unlocking = MMI_TRUE;
            break;
        
        case EVT_ID_ALERT_QUIT:
        {
            switch(evt->result)
            {
                case MMI_ALERT_NORMAL_EXIT:
                case MMI_ALERT_INTERRUPT_EXIT:
                    obj->popup_id = 0;
                    obj->is_unlocking = MMI_FALSE;
                    break;
                default:
                    break;
            }
        }
        break;
    }

    return MMI_RET_OK;
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_unlock_popup_bt
 * DESCRIPTION
 *  This function 
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
#ifdef __MMI_BTD_BOX_UI_STYLE__
void mmi_slk_classic_unlock_popup_bt(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_popup_property_struct arg;

    /*----------------------------------------------------------------*/
    /* Code Body													  */
    /*----------------------------------------------------------------*/
    //MMI_ASSERT(obj);
    mmi_popup_property_init(&arg);
    arg.parent_id = mmi_idle_get_group_id();
    #ifdef __MMI_TOUCH_SCREEN__
        mmi_popup_display(get_string(STR_ID_SLK_UNLOCK_2), MMI_EVENT_INFO, &arg);
    #else /*__MMI_TOUCH_SCREEN__*/
        mmi_popup_display(get_string(STR_ID_SLK_UNLOCK_3), MMI_EVENT_INFO, &arg);
    #endif /*__MMI_TOUCH_SCREEN__*/
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_popup_unlocked_done_bt
 * DESCRIPTION
 *  This function 
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_slk_classic_popup_unlocked_done_bt(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_popup_property_struct arg;

    /*----------------------------------------------------------------*/
    /* Code Body													  */
    /*----------------------------------------------------------------*/
    //MMI_ASSERT(obj);

    mmi_popup_property_init(&arg);
    arg.parent_id = mmi_idle_get_group_id();

    mmi_popup_display(get_string(STR_ID_SLK_KBD_UNLOCKED_MSG), MMI_EVENT_INFO, &arg);
}
#endif /*__MMI_BTD_BOX_UI_STYLE__*/

#ifdef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_handle_popup_close_req
 * DESCRIPTION
 *  This function handles the close req of the popup.
 * PARAMETERS
 *  event               : [IN]          Event
 * RETURNS
 *  mmi_ret
 *****************************************************************************/
static mmi_ret mmi_slk_classic_handle_popup_close_req(mmi_event_struct *event)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_slk_popup_close_req_evt_struct *evt;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(event);

    evt = (mmi_slk_popup_close_req_evt_struct *)event;

    mmi_slk_popup_close(evt->sender_id);

    return MMI_RET_OK;
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_group_evt_hdlr
 * DESCRIPTION
 *  This function is the group event handler.
 * PARAMETERS
 *  event               : [IN]          Event
 * RETURNS
 *  mmi_ret
 *****************************************************************************/
static mmi_ret mmi_slk_classic_group_evt_hdlr(mmi_event_struct *event)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_ret ret;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(event);

    switch(event->evt_id)
    {
        case EVT_ID_SLK_POPUP_CLOSE_REQ:
            ret = mmi_slk_classic_handle_popup_close_req(event);
            break;

        default:
            ret = MMI_RET_OK;
            break;
    }

    return ret;
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_create_popup
 * DESCRIPTION
 *  This function creates a popup group.
 * PARAMETERS
 *  obj             : [IN]          Object
 *  proc            : [IN]          Parent proc function
 * RETURNS
 *  Group id.
 *****************************************************************************/
static mmi_id mmi_slk_classic_create_popup(
    mmi_slk_classic_struct *obj,
    mmi_proc_func proc)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_id grp_id;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    grp_id = mmi_frm_group_create(
                mmi_idle_get_group_id(),
                GRP_ID_AUTO_GEN,
                proc,
                obj);

    MMI_ASSERT(grp_id != GRP_ID_INVALID);

    mmi_frm_group_enter(grp_id, MMI_FRM_NODE_SMART_CLOSE_FLAG);

    return mmi_slk_popup_create(grp_id);
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_enter_unlock_me_by_key
 * DESCRIPTION
 *  This function is the enter function of the "Unlock me" screen. (Keypad only)
 * PARAMETERS
 *  user_data           : [IN]          User data
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_slk_classic_enter_unlock_me_by_key(void *user_data)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_slk_classic_struct *obj = (mmi_slk_classic_struct *)user_data;
    U16 str_id;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);

#ifdef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
    str_id = STR_ID_SLK_KBD_UNLOCK_ME_MSG_BWUI;

#else
#if defined(__TOPWELL_MMI_SCREEN_LOCK_STAR__)    
    str_id = STR_ID_SLK_KBD_UNLOCK_ME_MSG_STAR;
#elif defined(__TOPWELL_MMI_SCREEN_LOCK_POUND__)   
 	str_id = STR_ID_SLK_KBD_UNLOCK_ME_MSG_POUND;
#else
    str_id = STR_ID_SLK_KBD_UNLOCK_ME_MSG;
#endif
#endif

    ShowCategory64Screen(str_id, IMG_ID_SLK_LOCKED, NULL);

    SetKeyDownHandler(
        mmi_scr_locker_close,
        mmi_slk_classic_get_unlock_final_key());

    obj->is_unlocking = MMI_TRUE;
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_exit_unlock_me_by_key
 * DESCRIPTION
 *  This function is the exit function of the "unlock me" popup.
 * PARAMETERS
 *  user_data           : [IN]          User data
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_slk_classic_exit_unlock_me_by_key(void *user_data)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_slk_classic_struct *obj = (mmi_slk_classic_struct *)user_data;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);
    obj->is_unlocking = MMI_FALSE;
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_popup_unlocked
 * DESCRIPTION
 *  This function displays the "Unlocked" popup.
 * PARAMETERS
 *  obj             : [IN]          Object
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_slk_classic_popup_unlocked(mmi_slk_classic_struct *obj)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_id cui_id;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    cui_id = mmi_slk_classic_create_popup(obj, mmi_slk_classic_group_evt_hdlr);

    mmi_slk_popup_set_string(cui_id, STR_ID_SLK_KBD_UNLOCKED_MSG);

    mmi_slk_popup_set_image(cui_id, IMG_ID_SLK_UNLOCKED);

    mmi_slk_popup_run(cui_id);
}

#endif /* defined(__MMI_TOUCH_SCREEN__) */


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_popup_unlock_me
 * DESCRIPTION
 *  This function displays the "Unlock me" popup.
 * PARAMETERS
 *  obj             : [IN]          Object
 * RETURNS
 *  void
 *****************************************************************************/
#if defined(__TOPWELL_MMI_PRIVACY_PROTECTION__)
#include "PhoneSetup.h"
#endif 

#if defined(__TOPWELL_MMI_KEYPAD_LOCK_PSW__)
void topwell_mmi_unlock_func(void)
{
    if(srv_secset_phone_lock_is_enabled())
    {
        mmi_topwell_password_launch(GRP_ID_ROOT, mmi_scr_locker_close, NULL);     
    }
    else
    {
        mmi_scr_locker_close();
    }
}
#endif

static void mmi_slk_classic_popup_unlock_me(mmi_slk_classic_struct *obj)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_popup_property_struct arg;
    U16 str_id;
    #ifdef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
        mmi_id cui_id;
    #endif
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);

    #ifdef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
        cui_id = mmi_slk_classic_create_popup(obj, mmi_slk_classic_group_evt_hdlr);

        mmi_slk_popup_set_display(
             cui_id,
             mmi_slk_classic_enter_unlock_me_by_key,
             mmi_slk_classic_exit_unlock_me_by_key,
             obj);

         mmi_slk_popup_run(cui_id);

    #else
#if defined(__TOPWELL_MMI_PRIVACY_PROTECTION__)
	if (mmi_privacy_protection_launch3(PRIVACY_KEYPADLOCK, mmi_scr_locker_close, MMI_TRUE))
	{
		return;
	}
#endif	
    mmi_popup_property_init(&arg);
 
#ifdef __TOPWELL_MMI_IDLE_MULTI_PAGE__
	arg.parent_id = GRP_ID_ROOT;
#else
    arg.parent_id = mmi_idle_get_group_id();
#endif
    arg.callback = mmi_slk_classic_popup_callback;
    arg.user_tag = obj;
#if defined(__TOPWELL_MMI_UNLOCK_POPUP_SHOW_ICON__)
		arg.f_msg_icon = 1;
		arg.msg_icon = IMG_ID_UNLOCK_POPUP_IMG;
#endif	
#if defined(__TOPWELL_MMI_SCREEN_LOCK_STAR__)    
    str_id = STR_ID_SLK_KBD_UNLOCK_ME_MSG_STAR;
#elif defined(__TOPWELL_MMI_SCREEN_LOCK_POUND__)  
	str_id = STR_ID_SLK_KBD_UNLOCK_ME_MSG_POUND;
#else    
    str_id = STR_ID_SLK_KBD_UNLOCK_ME_MSG;
#endif
    obj->popup_id = mmi_popup_display(get_string(str_id), MMI_EVENT_INFO, &arg);

    SetKeyDownHandler(
    #if defined(__TOPWELL_MMI_KEYPAD_LOCK_PSW__)
        topwell_mmi_unlock_func,
    #else
        mmi_scr_locker_close,
    #endif
        mmi_slk_classic_get_unlock_final_key());

	#ifdef __TOPWELL_MMI_UNLOCK_NO_ALERT_SOUND__
	if(mmi_scr_locker_is_locked())
		srv_prof_play_tone(SRV_PROF_TONE_NONE, NULL);
	else
	#endif
    	srv_prof_play_tone(SRV_PROF_TONE_SUCCESS, NULL);
    #endif
}


#ifndef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_popup_help_msg
 * DESCRIPTION
 *  This function displays the help message.
 * PARAMETERS
 *  obj             : [IN]          Object
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_slk_classic_popup_help_msg(mmi_slk_classic_struct *obj)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_popup_property_struct arg;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);

    mmi_popup_property_init(&arg);
#ifdef __TOPWELL_MMI_IDLE_MULTI_PAGE__
    arg.parent_id = GRP_ID_ROOT;
#else
    arg.parent_id = mmi_idle_get_group_id();
#endif
#if defined(__TOPWELL_MMI_UNLOCK_POPUP_SHOW_ICON__)
	arg.f_msg_icon = 1;
	arg.msg_icon = IMG_ID_UNLOCK_POPUP_IMG;
#endif

#if defined(__TOPWELL_MMI_PRIVACY_PROTECTION__)
	if (mmi_privacy_protection_launch3(PRIVACY_KEYPADLOCK, NULL, MMI_FALSE))
	{
		mmi_popup_display(get_string(STR_ID_SLK_KBD_HELP_MSG3), MMI_EVENT_INFO, &arg);
	}
	else
#endif	
    if (mmi_frm_kbd_is_key_supported(KEY_LSK))
    {
    #if defined(__TOPWELL_MMI_SCREEN_LOCK_STAR__) 
        mmi_popup_display(get_string(STR_ID_SLK_KBD_HELP_MSG_STAR), MMI_EVENT_INFO, &arg);
	#elif defined(__TOPWELL_MMI_SCREEN_LOCK_POUND__) 
	    mmi_popup_display(get_string(STR_ID_SLK_KBD_HELP_MSG_POUND), MMI_EVENT_INFO, &arg);
    #else
        mmi_popup_display(get_string(STR_ID_SLK_KBD_HELP_MSG), MMI_EVENT_INFO, &arg);
    #endif
    }
    else
    {
        mmi_popup_display(get_string(STR_ID_SLK_KBD_HELP_MSG2), MMI_EVENT_INFO, &arg);
    }
}
#endif


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_on_suspend
 * DESCRIPTION
 *  This function handles the suspend event.
 * PARAMETERS
 *  obj             : [IN]          Object
 *  is_closed       : [IN]          Suspend because the lock is closed
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_slk_classic_on_suspend(
    mmi_slk_obj_struct *obj,
    MMI_BOOL is_closed)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    mmi_slk_obj_on_suspend(obj, is_closed);

#ifndef __MMI_BTD_BOX_UI_STYLE__
#ifdef __MMI_TOUCH_SCREEN__
    mmi_slk_pen_unblock();
#endif
    wgui_softkey_unlock_softkey(MMI_LEFT_SOFTKEY);
    wgui_softkey_unlock_softkey(MMI_RIGHT_SOFTKEY);
    wgui_softkey_unlock_softkey(MMI_CENTER_SOFTKEY);

#ifdef __MMI_CLAMSHELL__ //for MAUI_03343481
    change_left_softkey(STR_ID_IDLE_MAIN_MENU,0);
    change_left_softkey(STR_ID_IDLE_CONTACT, 0);
    wgui_softkey_update();
#endif
#endif /*__MMI_BTD_BOX_UI_STYLE__*/
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_on_resume
 * DESCRIPTION
 *  This function handles the resume event.
 * PARAMETERS
 *  obj             : [IN]          Object
 *  is_created      : [IN]          Resume because the lock is created
 * RETURNS
 *  void
 *****************************************************************************/
#ifdef __TOPWELL_SLIDE_TO_KEYBAD_UNLOCK__
extern void topwell_display_touch_idle_screen_glide_block(void);
#endif
static void mmi_slk_classic_on_resume(
    mmi_slk_obj_struct *obj,
    MMI_BOOL is_created)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 lsk_str_id, rsk_str_id;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    mmi_slk_obj_on_resume(obj, is_created);
#ifdef __TOPWELL_SLIDE_TO_KEYBAD_UNLOCK__
		mmi_slk_classic_get_softkey_id(&lsk_str_id, &rsk_str_id);
		if(mmi_idle_is_active())
		{
		  lsk_str_id = 0;
		  rsk_str_id = 0;	
		  topwell_display_touch_idle_screen_glide_block();
		}
#else

#ifndef __MMI_BTD_BOX_UI_STYLE__
#ifdef __MMI_TOUCH_SCREEN__
    mmi_slk_pen_block();
#endif
    mmi_slk_classic_get_softkey_id(&lsk_str_id, &rsk_str_id);

    wgui_softkey_lock_softkey(lsk_str_id, 0, MMI_LEFT_SOFTKEY);
    wgui_softkey_lock_softkey(rsk_str_id, 0, MMI_RIGHT_SOFTKEY);
    wgui_softkey_lock_softkey(0, 0, MMI_CENTER_SOFTKEY);
 #endif /*__MMI_BTD_BOX_UI_STYLE__*/
#endif
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_on_create
 * DESCRIPTION
 *  This function creates the screen locker.
 * PARAMETERS
 *  obj                 : [IN]          Object
 *  parent_proc         : [IN]          Parent proc function
 * RETURNS
 *  Group id.
 *****************************************************************************/
static mmi_id mmi_slk_classic_on_create(
    mmi_slk_obj_struct *obj,
    mmi_proc_func parent_proc)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_slk_classic_struct *p = (mmi_slk_classic_struct *)obj;

#if defined(__MMI_BT_DIALER_SUPPORT__)
    mmi_id parent_id;
    mmi_idle_obj_struct * idle_object;
#endif

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(p);

    /*
     * Shall not callback to parent.
     */
    p->parent_proc = parent_proc;
    p->this_gid = GRP_ID_INVALID;

    mmi_slk_classic_on_resume(obj, MMI_TRUE);

#if defined(__MMI_BT_DIALER_SUPPORT__)
    //There must be a button bar at the bottom of idle screen.
    //so need to update first time.
#ifndef __MMI_BTD_BOX_UI_STYLE__
    wgui_softkey_update();
#endif /*__MMI_BTD_BOX_UI_STYLE__*/

    idle_object = (mmi_idle_obj_struct *)mmi_idle_get_obj();
    parent_id = idle_object->this_gid;
    /* check the SCR_BT_CONNECTING screen is exist or not */
    if (mmi_frm_scrn_is_present(parent_id,SCR_BT_CONNECTING,MMI_FRM_NODE_ALL_FLAG))
    {
        /* check the SCR_BT_CONNECTING screen is active or not.
        note: if the screen is active, return flase */
        if (!(mmi_frm_scrn_is_present(parent_id,SCR_BT_CONNECTING,MMI_FRM_NODE_EXCLUDE_ACTIVE_SCRN_FLAG)))
        {
            mmi_frm_scrn_close(parent_id, SCR_BT_CONNECTING);  
            mmi_bt_entry_progress_scr();
        }
    }
#elif !defined(__MMI_TOUCH_IDLESCREEN_SHORTCUTS__) && !defined(__MMI_BT_BOX_IDLE_SHORTCUTS__)
    // softkey needs to update first time,
    // other time like go back history, it will be updated by idle enter function
    // TODO: framework should emit the event after show category
    // then update can be done by scrlocker self.
#ifdef __TOPWELL_SLIDE_TO_KEYBAD_UNLOCK__
    if(mmi_idle_is_active() == MMI_FALSE)
    	{
		    wgui_softkey_update();
    	}
#else
    wgui_softkey_update();
#endif
#endif /* defined(__MMI_BT_DIALER_SUPPORT__) */

    mmi_slk_emit_locked(obj);

    return GRP_ID_INVALID;
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_on_close
 * DESCRIPTION
 *  This function closes the screen locker.
 * PARAMETERS
 *  obj             : [IN]          Object
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_slk_classic_on_close(mmi_slk_obj_struct *obj)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_slk_classic_struct *p = (mmi_slk_classic_struct *)obj;
 #if defined(__TOPWELL_MMI_UNLOCK_POPUP_SHOW_ICON__) // Lshuzhao modify
    mmi_popup_property_struct arg;
 #endif   

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);
#if defined(__TOPWELL_MMI_UNLOCK_POPUP_SHOW_ICON__) // Lshuzhao modify
    mmi_popup_property_init(&arg);
    arg.parent_id = mmi_idle_get_group_id();
    arg.f_msg_icon = 1;
    arg.msg_icon = IMG_ID_UNLOCK_POPUP_IMG;
#endif    

    #ifdef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
        mmi_slk_classic_popup_unlocked(NULL);
    #endif

    #ifdef __MMI_BTD_BOX_UI_STYLE__
        mmi_slk_classic_popup_unlocked_done_bt();
    #endif 

    if(p->popup_id)
    {
        mmi_alert_dismiss(p->popup_id);
    }

    mmi_slk_classic_on_suspend(obj, MMI_TRUE);

    //mmi_slk_emit_unlocked(obj);

    mmi_slk_obj_emit_closed_ind(obj);

    mmi_factory_delete_obj(
        (mmi_factory_obj_struct *)obj,
        mmi_slk_get_cfg_table(), 
        mmi_slk_buffer_free);
#ifdef __TOPWELL_BASE_BUG__  
#ifdef __TOPWELL_T326_B28_TWL__
   //
#else
    #if defined(__TOPWELL_MMI_UNLOCK_POPUP_SHOW_ICON__) // Lshuzhao modify
        mmi_popup_display(get_string(STR_ID_SLK_LAWMO_POPUP_UNLOCKED), MMI_EVENT_INFO, &arg);
    #else     
    	mmi_display_popup(get_string(STR_ID_SLK_LAWMO_POPUP_UNLOCKED), MMI_EVENT_SUCCESS);
    #endif
#endif	
#endif       
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_on_run
 * DESCRIPTION
 *  This function runs the screen locker.
 * PARAMETERS
 *  obj             : [IN]          Object
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_slk_classic_on_run(mmi_slk_obj_struct *obj)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    //srv_backlight_half_mode();
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_on_key
 * DESCRIPTION
 *  This function handles the key event.
 * PARAMETERS
 *  obj                 : [IN]          Object
 *  key_evt             : [IN]          Key event
 * RETURNS
 *  void
 *****************************************************************************/
 
#if defined(__TOPWELL_MMI_SOS_INTEGRATION__)
extern void mmi_sos_start_launch(void);
#endif
static mmi_ret mmi_slk_classic_on_key(
    mmi_slk_obj_struct *obj,
    mmi_frm_key_evt_struct *key_evt)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_slk_classic_struct *p;
    mmi_ret ret;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /*
     * Ask parent.
     */
    ret = mmi_slk_obj_on_key(obj, key_evt);
    if (ret != MMI_RET_OK)
    {
        return ret;
    }

    p = (mmi_slk_classic_struct *)obj;

    /*
     * Continue the key routing for unlocking screen (non-touch project only).
     */
    if ((p->is_unlocking == MMI_TRUE) &&
        (key_evt->key_code == mmi_slk_classic_get_unlock_final_key()))
    {
        return MMI_RET_OK;
    }
#if defined(__TOPWELL_MMI_SOS_INTEGRATION__)
	if ((key_evt->key_type == KEY_LONG_PRESS)&&(key_evt->key_code == KEY_ENTER))
		{
		mmi_sos_start_launch();
		return MMI_RET_OK;
		}
#endif

    /*
     * Start unlock process or prompt the user to unlock phone.
     */
    #if defined(__TOPWELL_MMI_UNLOCK_LSK_KEY__) || defined(__TOPWELL_MMI_UNLOCK_STAR_KEY__)
	if (key_evt->key_type == KEY_EVENT_DOWN)	
	    #ifndef __MMI_BTD_BOX_UI_STYLE__
	    	mmi_slk_classic_popup_help_msg(p);	/* Shall stop key routing. */
	    #else
	    	mmi_slk_classic_unlock_popup_bt();
	    #endif /*__MMI_BTD_BOX_UI_STYLE__*/
    #endif
    #if defined(__TOPWELL_MMI_UNLOCK_LSK_KEY__)|| defined(__TOPWELL_MMI_UNLOCK_STAR_KEY__)
	if (key_evt->key_type == KEY_LONG_PRESS)
	#else
    #ifndef __MMI_BTD_BOX_UI_STYLE__
    if (key_evt->key_type == KEY_EVENT_DOWN)
    #else
    if (key_evt->key_type == KEY_EVENT_UP)
    #endif /*__MMI_BTD_BOX_UI_STYLE__*/
	#endif
    {
        if (key_evt->key_code == mmi_slk_classic_get_unlock_trigger_key())
        {
        #if !defined( __MMI_BTD_BOX_UI_STYLE__)&&!defined(__TOPWELL_MMI_UNLOCK_LSK_KEY__)&& !defined(__TOPWELL_MMI_UNLOCK_STAR_KEY__)
        	mmi_slk_classic_popup_unlock_me(p); /* Shall stop key routing. */
        #else	
        	mmi_scr_locker_close();
        	srv_prof_play_tone(SRV_PROF_TONE_SUCCESS, NULL);
        #endif /*__MMI_BTD_BOX_UI_STYLE__*/
        }
        #ifndef __MMI_SCREEN_LOCK_CLASSIC_NEPTUNE_LIKE_BWUI__
        else
        {
          #ifndef __MMI_BTD_BOX_UI_STYLE__
            mmi_slk_classic_popup_help_msg(p);  /* Shall stop key routing. */
          #else
	    mmi_slk_classic_unlock_popup_bt();
          #endif /*__MMI_BTD_BOX_UI_STYLE__*/
        }
        #endif
    }

    return MMI_RET_STOP_KEY_HANDLE;
}


/*****************************************************************************
 * FUNCTION
 *  mmi_slk_classic_on_init
 * DESCRIPTION
 *  This function initializes the object.
 * PARAMETERS
 *  obj             : [IN]          Object
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_slk_classic_on_init(void *obj)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_slk_classic_struct *p;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    mmi_slk_obj_on_init((mmi_slk_obj_struct *)obj);

    p = (mmi_slk_classic_struct *)obj;

    /* Member variable. */
    p->type = MMI_SCR_LOCKER_TYPE_CLASSIC;
    //if invalid, ncenter notification will show when locked
    //p->scenario = MMI_SCENARIO_ID_INVALID; /* Do not modify scenario. */

    /* Member function. */
    p->on_create = mmi_slk_classic_on_create;
    p->on_close = mmi_slk_classic_on_close;
    p->on_run = mmi_slk_classic_on_run;
    p->on_key = mmi_slk_classic_on_key;
    p->on_suspend = mmi_slk_classic_on_suspend;
    p->on_resume = mmi_slk_classic_on_resume;
}

#ifdef __MMI_AP_DCM_SCRLOCK__
#pragma arm section rodata , code
#endif

#endif