From bc737e93f697de2dda221f8f97f0ce0ff05edd0b Mon Sep 17 00:00:00 2001 From: Przemyslaw Brudny Date: Wed, 26 May 2021 19:31:06 +0200 Subject: [PATCH] [EGD-5885] Added SimLockHandler Refactored LockWindow TitleBar handling. Added Sim pin request block on lockedPhone. Added Sim info popup added when pin changed. Updated assets. Removed old PinLock structures. Cleared LockBox structures. Removed old settings sim setters. New CellularMessage adaptation. Cleared Lock structure. --- art/phone/common/info_icon_W_G.png | Bin 0 -> 4115 bytes art/phone/common/unlock_icon_W_G.png | Bin 0 -> 5071 bytes image/assets/images/pin_lock_info.vpi | Bin 3099 -> 0 bytes image/assets/images/unlock_icon_W_G.vpi | Bin 0 -> 6825 bytes image/assets/lang/English.json | 35 +- image/assets/lang/Svenska.json | 26 +- module-apps/Application.cpp | 26 +- module-apps/Application.hpp | 3 + .../ApplicationDesktop.cpp | 156 +------- .../ApplicationDesktop.hpp | 14 - .../windows/DesktopMainWindow.cpp | 8 - .../windows/PostUpdateWindow.cpp | 27 +- .../windows/PostUpdateWindow.hpp | 7 +- .../windows/OnBoardingSimSelectWindow.cpp | 4 +- .../ApplicationSettings.cpp | 16 +- .../windows/PINSettingsWindow.cpp | 15 +- .../windows/SecurityMainWindow.cpp | 27 -- .../ApplicationSettings.cpp | 21 +- .../ApplicationSettings.hpp | 15 +- .../application-settings/CMakeLists.txt | 1 - .../windows/SettingsMainWindow.cpp | 1 - .../windows/SimSelectWindow.cpp | 32 -- .../windows/SimSelectWindow.hpp | 13 - module-apps/locks/CMakeLists.txt | 23 +- module-apps/locks/data/LockData.hpp | 36 +- module-apps/locks/data/LockStyle.hpp | 57 +-- module-apps/locks/data/SimLockMessages.hpp | 50 +++ .../locks/handlers/PhoneLockHandler.cpp | 10 +- .../locks/handlers/PhoneLockHandler.hpp | 6 +- .../locks/handlers/PhoneLockSubject.cpp | 6 +- .../locks/handlers/PhoneLockSubject.hpp | 3 +- module-apps/locks/handlers/PinLockHandler.cpp | 314 ---------------- module-apps/locks/handlers/PinLockHandler.hpp | 72 ---- module-apps/locks/handlers/SimLockHandler.cpp | 354 ++++++++++++++++++ module-apps/locks/handlers/SimLockHandler.hpp | 68 ++++ module-apps/locks/handlers/SimLockSubject.cpp | 43 +++ module-apps/locks/handlers/SimLockSubject.hpp | 28 ++ module-apps/locks/widgets/Lock.cpp | 12 - module-apps/locks/widgets/Lock.hpp | 48 +-- module-apps/locks/widgets/LockBox.hpp | 2 +- .../locks/widgets/LockBoxAlternatingSize.cpp | 47 +++ .../locks/widgets/LockBoxAlternatingSize.hpp | 30 ++ ...ockBaseBox.cpp => LockBoxConstantSize.cpp} | 36 +- ...ockBaseBox.hpp => LockBoxConstantSize.hpp} | 24 +- module-apps/locks/widgets/LockHash.hpp | 4 +- module-apps/locks/widgets/PhoneLockBox.cpp | 67 ++-- module-apps/locks/widgets/PhoneLockBox.hpp | 16 +- module-apps/locks/widgets/PukLockBox.cpp | 105 ------ module-apps/locks/widgets/PukLockBox.hpp | 35 -- module-apps/locks/widgets/SimLockBox.cpp | 113 +++--- module-apps/locks/widgets/SimLockBox.hpp | 31 +- module-apps/locks/windows/LockInputWindow.cpp | 247 ++++++++++++ module-apps/locks/windows/LockInputWindow.hpp | 80 ++++ module-apps/locks/windows/LockWindow.cpp | 111 ------ module-apps/locks/windows/LockWindow.hpp | 61 --- .../locks/windows/PinLockBaseWindow.cpp | 98 ----- .../locks/windows/PinLockBaseWindow.hpp | 33 -- module-apps/locks/windows/PinLockWindow.cpp | 168 --------- module-apps/locks/windows/PinLockWindow.hpp | 38 -- module-apps/popups/CMakeLists.txt | 4 + module-apps/popups/Popups.cpp | 5 + module-apps/popups/Popups.hpp | 4 + .../popups/data/PopupRequestParams.hpp | 32 ++ .../lock-popups/PhoneLockChangeInfoWindow.cpp | 21 +- .../lock-popups/PhoneLockChangeInfoWindow.hpp | 5 +- .../lock-popups/PhoneLockInputWindow.cpp | 39 +- .../lock-popups/PhoneLockInputWindow.hpp | 9 +- .../lock-popups/PhoneLockedInfoWindow.cpp | 26 +- .../lock-popups/PhoneLockedInfoWindow.hpp | 7 +- .../popups/lock-popups/SimInfoWindow.cpp | 67 ++++ .../popups/lock-popups/SimInfoWindow.hpp | 23 ++ .../popups/lock-popups/SimLockInputWindow.cpp | 123 ++++++ .../popups/lock-popups/SimLockInputWindow.hpp | 32 ++ module-gui/gui/widgets/Icon.cpp | 2 +- module-gui/gui/widgets/ImageBox.cpp | 5 + module-gui/gui/widgets/ImageBox.hpp | 1 + module-services/service-appmgr/CMakeLists.txt | 1 - .../service-appmgr/data/SimActionsParams.cpp | 43 --- .../model/ApplicationManager.cpp | 191 ++++++---- .../service-appmgr/service-appmgr/Actions.hpp | 9 - .../service-appmgr/data/SimActionsParams.hpp | 65 ---- .../model/ApplicationManager.hpp | 8 +- .../service-cellular/CellularMessage.hpp | 1 - .../service-desktop/DesktopMessages.hpp | 1 - 84 files changed, 1699 insertions(+), 1948 deletions(-) create mode 100644 art/phone/common/info_icon_W_G.png create mode 100644 art/phone/common/unlock_icon_W_G.png delete mode 100644 image/assets/images/pin_lock_info.vpi create mode 100644 image/assets/images/unlock_icon_W_G.vpi delete mode 100644 module-apps/application-settings/windows/SimSelectWindow.cpp delete mode 100644 module-apps/application-settings/windows/SimSelectWindow.hpp create mode 100644 module-apps/locks/data/SimLockMessages.hpp delete mode 100644 module-apps/locks/handlers/PinLockHandler.cpp delete mode 100644 module-apps/locks/handlers/PinLockHandler.hpp create mode 100644 module-apps/locks/handlers/SimLockHandler.cpp create mode 100644 module-apps/locks/handlers/SimLockHandler.hpp create mode 100644 module-apps/locks/handlers/SimLockSubject.cpp create mode 100644 module-apps/locks/handlers/SimLockSubject.hpp create mode 100644 module-apps/locks/widgets/LockBoxAlternatingSize.cpp create mode 100644 module-apps/locks/widgets/LockBoxAlternatingSize.hpp rename module-apps/locks/widgets/{PhoneLockBaseBox.cpp => LockBoxConstantSize.cpp} (55%) rename module-apps/locks/widgets/{PhoneLockBaseBox.hpp => LockBoxConstantSize.hpp} (61%) delete mode 100644 module-apps/locks/widgets/PukLockBox.cpp delete mode 100644 module-apps/locks/widgets/PukLockBox.hpp create mode 100644 module-apps/locks/windows/LockInputWindow.cpp create mode 100644 module-apps/locks/windows/LockInputWindow.hpp delete mode 100644 module-apps/locks/windows/LockWindow.cpp delete mode 100644 module-apps/locks/windows/LockWindow.hpp delete mode 100644 module-apps/locks/windows/PinLockBaseWindow.cpp delete mode 100644 module-apps/locks/windows/PinLockBaseWindow.hpp delete mode 100644 module-apps/locks/windows/PinLockWindow.cpp delete mode 100644 module-apps/locks/windows/PinLockWindow.hpp create mode 100644 module-apps/popups/lock-popups/SimInfoWindow.cpp create mode 100644 module-apps/popups/lock-popups/SimInfoWindow.hpp create mode 100644 module-apps/popups/lock-popups/SimLockInputWindow.cpp create mode 100644 module-apps/popups/lock-popups/SimLockInputWindow.hpp delete mode 100644 module-services/service-appmgr/data/SimActionsParams.cpp delete mode 100644 module-services/service-appmgr/service-appmgr/data/SimActionsParams.hpp diff --git a/art/phone/common/info_icon_W_G.png b/art/phone/common/info_icon_W_G.png new file mode 100644 index 0000000000000000000000000000000000000000..ab0d6081e08e7280ff154c5d5c78eba4bb1d30b1 GIT binary patch literal 4115 zcmYLMc|6oz)c?)KjGd8C7_u)JWX-;hG1kFQvXv51c8bQ9B@eQN?8e%}sO~hPvFJ8w;6I_C?z&m&Fx!9TZgXK zjh4V4BpGw0TJV*TqFj8WW;+au!*|0Te3|<-_M&ujbQC=+rzST$zAvbzHadzO|9LuL zX{uJ^JKh#A+O>GN{bg-^vTAL*&MWx+p~mAg(S$bvk44s>a!6Uo%gYCEpS3>v<=s>3 z@kzF2`Qj)^d=&}|n&zpOGxMpJefng}c=SF`0~0OfoOR#i{!v_X@{}iM82Ay z-DI!bZ#@+S1zKK&SV2QFV(0WYfbodxm!BAW)WpO@h2Q#w)eJ+^%RH*TFB=+^F@=@l z3Z64%{S@C-i{-$X*6w5=m3&_MMp?l2oY=1Ub4lC6v{(zV?+@6?kefXgr$@UwBG1H~ zPJi#;9Y~jIY>c_q=%NR#9mK{W^xU*}`qtOi&*fY83S)LmQC)j`Zx3V)uUb)j(MX2M2_)h%`aO+54%f49_KJkb>77xz=;mPQl%b18g?Q z%*^aAlGx6;l>3TJxGLH4{hY``}vInV|ew4x=tBVI}0>Lyr8&P zXsuW2Pyzu$yWI?r;S|ne_)t>Eb{*2qB&vx=>`9vi8kyhHHvzJgb#!!8vJBj|H#f)q z>~_f0a(WQxI~rPAKc8o!&ZefOi$jZs2u(E&G&;ZO4#IP9f4@h;Q`#uuIQIMAko+7i7+qXA0KJLOjtlEb14fO`Z8$t;PB93LOUiBNIjut=3RlN zhZlR^BJDR#H)@C5H~H&1BPyO+iTbrtkUIfeGhCR?INWo$Ntc5WDV29@`98i5WOhBE zIpm`H@9mzA7rX<~)?a(BCwi9KjmWDQ96FlCQ^i@qd$Uiw&KLVw7?&8ga`5PYeG|4i z@;SvafVbvu%cEm&m>gtSBHK8YxpRshqJgK{#V9b#T(M;|ih1*-o@qoJFNUdS`cFoW z7Sq*65|?;gqZ^~)d_3o^#fw0`%rtC4uoo1zI6yUKm@Z4O``})nBDt|hgO8ydY}_tP zw&aWh_Lh;kBqjlcdqTY206iLX0Zn%)454XLJa#-gJ6mfb9iNVUba@z+5u*WEYYDM{ z&=L#_&hIr7NQ1$M3Mg_If}}ifIVb2425$#URD|G~J1i2rW55)Vl@Mmj(vJmHvHIHr z@n0qM^4_*KoQm2(93lGf44B)wMIm6}fUCH3Wmd`frl=kE$rm8Loo=xGa-O6ipih={ zgNQ^FOj{=xfGA)&3ZyIQrWQD6wbWB=Jas*a?e-rDV~C?rYnG$Zmz*Ub0EhUT=Bti& z={0(N1#oqweL^o!zbr&VM~h)=pDNnUr`Vw(S9K|48mfG)(EO^*O8qs~hS+75V>u8v za1{;3qW6&wV6+abBmO=_qMzykW?w2J*e6*Bph3xsfsoEuA2zQU&3XM*g>e#t{d9RPLV6FrA>_DLCG@0T#eXBC@xj8A@=v}$ga~xC z!+e?2w&$89-}VK{Sr&y-BN4vTB*)wL{^@T&wa$Z?2A^S>(N>~RhHMsR{A^B;?N2a) zLNtLcm3d9q4qZ`O3Gx?(2-Qb<;*DraKH`H8HZr${OK;65tf^QLn-W-3oU&vISv~aX zK{vs|v$Mia9mUmi7svU55rHS?s^LZD5vp!%zy5LR#?G~dG_7>^sbz#qaW-9wU;>dw ziMC}WbR}mezkVv)f4)7OJ+iQ7JXE)crJN%xZz+X&f50!Brr!V7jZjNI_*~;27nPO3 zt5%V4QCZ;eg%;XtPxiy)*ID?pfI*o{ctZrH>xUHe2jM;3kQA5;g~q2s-5zEpG7p#8 zO^UD{q#km(4B;tXJ|c&_crd`_)DApW))=Dm(YxGc_|R3iUW);XcugFc<71R>6a@8xj*Az zB?rCAt%gp$xos+{dP;+hY}5)jq3T7H(Qu%=(OSO<=yF=7i)PO++gnhPX?Pa|4_6I6 z3G7(Momo<79&SRDZIK3lF1}~@?f8>Ui^Yv8=nuBbtAksFVwcYShPC~Q=AS>RbQ6wV zh$P;boNPO=Qib92b4jonGs^$uad01saE%Y8mT~+0l>zY0QqFH#%g^&>;clZV&6zWZ^oW zr0z$O?hTi32_K)6abC4F`0bso2e^YiVgX8(KQohIp7_U1mqQea2kuM~O#rzpkTYI^ zxELjiBKDhsYH&R38|PXYs7uFnq-HvUlNCn7)m@W%5%QqspFM-tT8%y;K46#+4%mMC z)%RuJ%*-hLiam`ck{FW|@R`zZ*U)SDBpvhtsww2m)~!pj!7VLar#`8EHzp8)Fcp`{ z&Ehc&y*~l(WOnRqpP9)HT}_INNg>lss5J-ubR8Zy8`7Y_7Ra}Vvg;5PSp|gyX*tXfhb4Qt;c8N7zhwN8w2t%Ks~da%2OFPA6&)DG z|K55}IXK^6M<>Fy{!3x!??h9>Pn)s|AIh0#Mo*7AJuo zrzB)bZK8K&n`C+V6&}Oj4mRTsYp~{zyah-fD4qR#$R0Uo-JfIe4{3v%Es;&~)L-4E z9f%`1jSeT@RZ~-ogO#L6zBa0tJik7Sop2sG=}`T3e7L>7zj&}YeS4AYR0lTxGyIXF zR4>U`7qETfG}$d6_e}+GHZL{SoRD2MGB%caeEnE0j2qCQKrJczMob_jtvTi1wa>Dl zgAWT%c^)$oc{l~a%N564p(x40&dwRs3O1%iv9?X33PgeYU8S)r1c)doDz5)*h&2}a zNV{PmKn;}^fiP@aHGr_|WSPhl}Ms6NTloC*@0|HQ`!Zr^%rV+e5s2|FTd z*Hzd-XlZ+U`^M;`$!F8Ug>?K|!IGRrm`)4Tc&DK#_`Zwk!0@oiDe4_#pK%JBxn^1a zKY%4N32QZnZl~xVi5JGk$Cc08=jR=7>QptyzG+*Y1R_*NTE>nYEn?Vp0p78X9}9a~ zz7ZK17*xcNC^qV1Wh&qFkdZ_20dChEm}pr&>c+IPHsks4(7R zXb#QaavHoCG6Y2#W^Aflrb&pZ(yRMlIp4(UPxS)o9_55hsoBmdYpJp7qobXI8t4rv zgPj-2iJl`eMGr@m8>OwiX`(oSb&T1n?ndM!YqrVUiJH?Gn#ANtH*RikOZP1tjym0h z&M#SLbXa5wQpO_1Ttnj|CS{sK%74lnui)o?A@#TggaAZgE;l!~g|RLP`?{{q#-Oaw z(Bt!#*44Zc-Z^z9KEF_Q*DtSn`w;CztLcKO{l0?2HXn@L?%ws*m<)Yi1QK`z4Z1^3 za8l;4kcRW1en=_G7$%W0dLpO!*Ic_~T>U-$p3W&HI{cE*0 z`>Pxd5(FL5WENwyEr<&d0#nBBQh);Kb{D@sC6rJ~k?o~cE2BC_SD5Dq?B7eL&JkEO*^C^(eu5n=CorfSMwdahyXJ9Ny;?pJR2-~R zHi-!Tx-h7ycP)=lkVs(D^wrXY-YUdrVFYSwYE%>wtn#nu@$fxgUYuU|;8Y{JNsyZO ziY&;ax8=W={ZP*Z2bc>VQwv8N4V>SEy%!;A{u%}Glb9&L&gE!}VlTc1oM#IfO-ua}D?-dG6f3vz w{)Amk`#5yNNOclYNPyNw?bxvn%izvvB^LKgbOK;5e=Bp0o{4UywqyAJ0MOA`uK)l5 literal 0 HcmV?d00001 diff --git a/art/phone/common/unlock_icon_W_G.png b/art/phone/common/unlock_icon_W_G.png new file mode 100644 index 0000000000000000000000000000000000000000..0a878726bc07f8fb1e4d67e92a054f68cd888b7b GIT binary patch literal 5071 zcmYLNbyQT{*S<4?bk0zM(nxoAcY}aZ14D-h0ulp^q=bNUGlYQBof1k)D%~KBARyhp z@%`ib&RYBIbI;w+z3ZN}&$FL%BXzY^2yh?a0sugurmCoq_Q-#R{Se)MleQW}JJ4%= z6?vdygk}eQp=fKOW~ZeEu%pM=04Tx{!1xz}wnu0KfCnfL@Br;W|K?EO|GSGsJ^26e zzd+Skj5h!P5mQr?GxP!NXFuPj>4Ee~IJX^Kt7-=7LHHtBNZby4@QB)EG2LhpdL&Re zMZ-2CDD+6~NJ$QHNcb?=2cpz1@CaJa>(I7FRp~R*A#++BzO*>In4Vqg{|1+(Hhr09 z^0d4H-Tvf2pYt;+-`^a^UEZEA57P$S(Ax*zUmtXY|IS)mh6ZGNP4Oi@)k&$n_AhuZ z%uhr8vMDdC*?z)7e;XG_lexdCy*%op9nKJP#yIS_yDEidO_{n$>4gpp&kwmYZ=~2A z4~tNIWZQs~eGwGJ?1ZtcAnyiwI@0d%t}C_7CJf8#Uqm;j7!LZ5)ni|omSayTl;cdB zIn}?g8`lycv(*ht6Ld`Qk3R1R(F2^$MV1kaeak`jkMX83t)jUac&Xjms`H9cnw0f5Vcc;^q8eE2NU)Bt;*p-$yd|t$F z9Udi;xq$`Vo*LWgWkfypo{>wk3Ly}FS9yK*O#>5U7jU&xyxDrtF0flrf&MxM%}{l& z^AA;otQ;x3qcZnUa!1mJSvzWhfGbZ&Zp7L=2PVqZvf1Nfp0J$H`uxk*a**fTOg#2I zhONmLzxoTx!`R7;v^3(aAE`Ayc>p%vilZrgRy~_RQCjw!rP;BHaLo&jQloNyOTwsTv{_c)YH2f&%c~nD1qB%($|q_e=ffg#na=M^F6stQwa5e*dAyYt#P> zE;FfS5Wd7vU>z&*J;$`Bul&ka_>~xAoW&~D+?(x6;OJUi572xRM#m67Pz;>xP^
|<=zixu8x9QHioI}0pe951}8s~*C zrg~=O9L@zEIVWpqbsOUS+;LifO>|5(MnBE$)<-j3WMka7zKbszw|a3KTVy^tTOYWz zIBJwP`=8+d)#b)SmG;ei5l1MAKlQ~G`aa44PXf{z{dxNp6gYqY!>dcr(?=0JL>RNV zJv2vW%6m#AJRpfY!Pym>Z}1mZdH8*+S1U(L)%B1(rC;HdF}2Y(a7g2^fSI<7r6& zJYEnr?|1o6WXL>q*YmBR^zoQo+YcTC=fCiSBd;F7l2i2A0J|_j?hz)BQ2yV{<;2RX z(r64tso;kCM}X-SKdT%N94EM5jM4cprW1GQ=a?*JXDyRI1w%w-44-X{51@3IA1B6^jlF~E}9@a#8yKgLypDSS1plsxRD3z4o1D9-Ww?7RD^*m_NgYuT;ic8ElUhMpy;@9~?Yu)?%b z6=lejTyfDcanW%X7OkMl6JMK~*!V!$rG@VXnLGCRtbOkKDNcgmH@p0(%^6{)ozW%B z+K^`-vc0IMeae3{>>muazAsimv)?P5R{f(|;TG~m#PM)I?(t>U{}&cxs`q3rEg zzkRut8)tzy>gm^pxm=rK-&fa*)o7dJqgvQrQ%u5NUWns54D(fW6ePOaL| zWl_G44ar@n+Wx$wz2F*b83?&$jaJZ}(%Y*zQ?PJPv19l8ZI3_a`mT zgd#5mmtf0LFLh5r#KG^%j`lYlB6Y!J-Idm#DStb|F<;GN3sLzc9@w+!N?&akd}S$h z$#UA)0lumFfPJZPhhfqNZd*q*5>-mpBOgzaQ zb8*=gO78r+ty!Lxf`L!Jet~*Z(i+31i?YniBF_Yv!=PaUKcOGlFOVg^5t%Rr!=ht4 zU)%zEfDn!ogI`DfrN%a?ZVcILJ%E5vuofX7@rL(4s@j?xhhFg=YOE!wtT0RrKB@I? zx#drlS;-1*%`1f{D0^?zrA==P3Ecxa`oe(fv|r4rX4ZS#M)NaLCIWK$j22`to?N;< zq&)P0+X(RbeLd0eo4Iwk|zBkrAoOa!$r>`L*yX%?Q?6Zx=7QP?FZVtb} z4_dTy9tN0JKfE457c&0kowC}I1a5r96OVrSghhqMB5iBZ-nBRx?#nkkZHK}5s#bXj zma3wy?nANk0=f0O*%#zb?X!G0(;I$WDy$REQMG){)yg}LsD6^=P(e4-sEAkAa`h6# zd#{e(9a(oLzlQwUu^xNIAO8BggZUaqlXVKV{FMZW7`@Zep|uF`G)jJ&s^fF|0qX1y z7Gk2b#u!ss4ev~}CO9is2FWAKOrB6HRKX)eNpx}CGS*RaMtPZ*Q3 zk7cFpctpTkmaTW5n}Otpoz>k+|K?TeojU|YVIV0(+E^u3s-J%ScSi&v&M{?jpOQ(l z0!bv`*-+~o2040dzDquzMYtJRhBZ1+ryRWRkuI-S&z!Jcw%D7WgVI6qP>IweN6e|}+9@ES;F03Q1EQ}@v$~KDEwK2z?y>ijZHrnF5dm12uqY9Q| z5`cY0XxqV*c$mo=?mGU|4!7}hisM{X02u^jvt0>#pNxxE&CGcFh(PF;j*CXVB;tvmgO*w0b=e4xA^Ldsyt49sQ9N>efG$|UTDTgvH}5nBaYv$;&tpd zSMo5%5|}lH#&u-OCH#%ey`D)X4OP{QCe{6m(=1ifg{(Tul{AY}Z~xTbNyf?ZI=VuO z-E^!cKC;rIFPF*${|K-(LqavQ_ds|#X zZgZ40YFh1)CATT>^G6Gj;oWgt)uh%EaStk~M*UD1pa{6(#V2&!D2{vbE8w zIF1%!d~1YU*Q^{q`kG|$jan_xb{{Fdbt|72<%u%wXc@s!76LmWMvJ6Q!{}j$$f9Rr znR3N^^$#QvhQ%p}l--2T8>^ZxyuTsU^+5j9URH2n zU)z@=JS5VQ^!-ASo~XpMg@1W7TEy8}tv8j|%4`m2+RtD_)0>8;dX2OC5##gK0+Rxx zl5nF+i+yRkZ7;Kc)5*=O*CRMi^jhH;5p#mLS~vmoqE4U9h1&-iU}Qg^Kp>DGT#X9} zP1D-?u7CG4xG@ub=S3%SoA^vWk%*$En#6o>q@Z7~1I}jcZO2vZ?s*ye!O8v7i{fP% z?wEx6v3aBqWF`VrBA#mQKMY#nXBGzeJuv6!jichq6n4$9AiRo^<-PPH)+=N~J%^Rk zil~x$$ju5(G~9U$8N zmeq(EEbayylWk+jn=6av)& zmrm@mPELZ4`hX<70lqe*;@KD}NbB(DlQI|v7Uni`Y|l~$`HIb%*dDzLi{Rcu=ofMHo$ds zq4~A#3n~ycC7iM*&w~l+@`10$j-9q-KA1mfN>!DSjA&+l5ogG)uOpkl=1a|^qbr7;&EN?4*p^vN&S-8&NfzUf;LRv>N&!dTTfkM+~8zq_`DCZCj z9>*>~nqDekKSI-*^jg1hU}KYe{qJB*{Mco`K*44%a{ung}*{Q}|nZPglfNfGW z#++&}{RJMeUBWxc?<>DAz_DB?2Hj*Idu2iP@7oTti2Y-Q;uB7cd$Wp*O} zE;}FP#p+BhU@qb$){cvUf5Kj1U9AK}Ri>TH{1WZAU{Ki&`jGWEJd zon89dT~bbBB?F=kS*NlCRpNeC!%^by-=j+rPVaZOzq84F%L*|-j>xyzQF4G_6BGQ{ zgTeB8tz@sB<@2{2_eg{oBbn&+4C*&MrshiPGi#@OalhXUoK9r)_UTJa TC_%^nex|7@X)9L9!-D?@ULu1e literal 0 HcmV?d00001 diff --git a/image/assets/images/pin_lock_info.vpi b/image/assets/images/pin_lock_info.vpi deleted file mode 100644 index 7ebe9d162b54b5e540c053e7bf2c0e790f8ba0ae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3099 zcmeH}-Ahza6veOeJ&w**CmppJ6f-eFiY%-wdXOF@C_+ReB0@wWA}S)HXaDc^Z=ZGM z&frlLf?j%=#aerveLn7)efC*)mgVIv%bw&}Hth&|V65*5yJzgSW7U2)jkOJP;bxAy zVXS3%Q@G*ky0NCIw}k7it{H2XdPlhC>Z-B2sdt5|uC9n}30GWQHdZt5BdN=-E=k=H zF1gwldoJv|+B3$wcZEGy7v*^&Ty%9oo;~4$tMg(nh4Zd<#aZ$N$N2ls%OEmR~IzZz}s9 z9m~AbvyLIP2_7=XfB0~ev1On4;;7$cWg4v+)FLumrRt>XR;+bYGctu57whA9%^K8L zQ&I8Oyy`^to4i4dwfn2Qb@#@4|3%)Q@`8{L6>PXSzAL;ooMBLTneY^E5T}!VuhMTD zuOk_F@xbDBWR_FS7S#0n$_vfN6JhZ}li^qyf|`Eg)BQlYcS!dcGn(Z{7cI8S_C z2z}c)iwam?7=vnW>TU~N#uqBw<7H+*yc6lYWjr47`_#TA&SQ@j>hJ^mz*7`J)v?e= zJ?I~M&__~mNK4TAQ)(Xyb&z_0PVEDs_EYaKsl6}MUh4fdwfBVDWiN8_8vYhh=-(BJ z3nrp|PpC$yWkUUtP)pTq!CqE0R9VPaW&B=1xB?G16w zQ^dbh#JQe%LWPK5x)=Ml@L}GF@s;;m9fG&@=s8c1DL!>o%}}{|jL!x>$U%0C)Oydz z8S?myZ8D6i3c#vH@#(4lfSWbPu*%zFf9mQc*cm)7y|Do)1G4hBX@e|jq)qImYt|gX zGEKU)H!(hR$&3Fs*FPF(|x?wwP>e>INOqiI4Ss>^a){`;c~&g3pFe zVt$$f(er{<7m6F8frgs z-#gnT@2W> z{v`uE#ehlH&%hm}JfHKtMHOT2Tr08NosEN-e0M>G2QmTKSxc_rIwoI-3u!7VEiqxW zNW&1O7mg6P`hOS^%V4*=(tsUN)!}8}#(DwZY?zJGWck$1k!R?RPWKGKO!Cy!h&&kV}-&h2f? zw_KmV67utWUBd@9w%(TdfDbI89zyv^3-!<&Jst*Pfwo+O5zAi1la~-+L>V-TLR=x(hBxP+p9wo}EwH!V z^Pul@|4mJZhqATV;|J%J>=t{jIVErFVSTQ8)9u)74$cR@Q6uSUgUUjV{cq=+L_oy+Q@A7F9-?zKHxLDgb(Gz%9mh@_8NgfwR5q*h#&wl2?1HvWO_CU%#P& zP~7HpGiLTz-})?5r1hI5)?WLE*B+Vo-%4pO3#k4ZE}bB~*7)wfEgN?8HtZJf<{LrQ zZTKxC(Zg>rS-)YoqQh@mso?!?afja!Q}4~U&KTx)|KlnOqsiI!+-G3wzpuAY?ci|t z8*Hwur#=he;Wx+at+`GM79)CGeKSvGdc#XGsH{AFVWVn~btYx!rsC$mGyvG{u%;|} zFphGh&Egb0`Y!auE;|KO(8?2#&_I-Vzzoc;8l!#rAN^H_qpX`lQ^`2%e?h_qbj@F( F{s9lRkjnr7 literal 0 HcmV?d00001 diff --git a/image/assets/lang/English.json b/image/assets/lang/English.json index 7b83940895728257432b33f9457fdccf4796d5d0..d0b2a868abde0b38ae001c157cfff3d6cb7ce11f 100644 --- a/image/assets/lang/English.json +++ b/image/assets/lang/English.json @@ -228,23 +228,24 @@ "app_desktop_info_mmi_imei": "IMEI (MEID)", "app_desktop_info_mmi_result_success": "Success", "app_desktop_info_mmi_result_failed": "Failed", - "app_desktop_header_sim_setup": "$SIM setup", - "app_desktop_sim_enter_pin_unlock": "Type current $PINTYPE code:", - "app_desktop_sim_change_pin": "Change PIN code", - "app_desktop_sim_enter_new_pin": "Enter new PIN code:", - "app_desktop_sim_confirm_new_pin": "Confirm new PIN code:", - "app_desktop_sim_setup_wrong_pin_last_attempt": "Wrong PIN code. You have

1 attempt left.
", - "app_desktop_sim_setup_wrong_pin": "Wrong PIN code. You have

$ATTEMPTS attempts left.
", - "app_desktop_sim_wrong_pin_confirmation": "Wrong PIN code.", - "app_desktop_sim_pin_changed_successfully": "PIN code changed successfully", - "app_desktop_sim_cme_error": "SIM card

CME error:$CMECODE
", - "app_desktop_sim_puk_blocked": "The SIM card is blocked.

Please, contact the operator.
", - "app_desktop_sim_setup_enter_puk": "The SIM card is blocked.

To unblock it, type the PUK code:
", - "app_desktop_sim_setup_wrong_puk": "Wrong PUK code.

You have $ATTEMPTS attempts left
", - "app_desktop_sim_setup_wrong_puk_last_attempt": "Wrong PUK code.

You have 1 attempt left
", - "app_desktop_sim_setup_wrong_puk_last_attempt_warning": "If the code is wrong this time, the

SIM card will be blocked and you'll

have to contact the operator.
", - "app_desktop_sim_card_unlocked": "SIM card unlocked", - "app_desktop_sim_card_locked": "SIM card locked", + "sim_header_setup": "$SIM setup", + "sim_enter_pin_unlock": "Enter the PIN code to set up

the $PINTYPE card:
", + "sim_enter_enter_current": "Type current Pin Code:", + "sim_change_pin": "Change PIN code", + "sim_enter_new_pin": "Enter new PIN code:", + "sim_confirm_new_pin": "Confirm new PIN code:", + "sim_setup_wrong_pin": "Wrong PIN code. You have

$ATTEMPTS attempts left.
", + "sim_setup_wrong_pin_last_attempt": "Wrong PIN code. You have

1 attempt left.
", + "sim_wrong_pin_confirmation": "Wrong PIN code.", + "sim_pin_changed_successfully": "PIN code changed successfully", + "sim_cme_error": "SIM card

CME error:$CMECODE
", + "sim_puk_blocked": "The SIM card is blocked.

Please, contact the operator.
", + "sim_setup_enter_puk": "The SIM card is blocked.

To unblock it, type the PUK code:
", + "sim_setup_wrong_puk": "Wrong PUK code.

You have $ATTEMPTS attempts left
", + "sim_setup_wrong_puk_last_attempt": "Wrong PUK code.

You have 1 attempt left
", + "sim_setup_wrong_puk_last_attempt_warning": "If the code is wrong this time, the

SIM card will be blocked and you'll

have to contact the operator.
", + "sim_card_pin_disabled": "SIM card pin disabled", + "sim_card_pin_enabled": "SIM card pin enabled", "app_desktop_press_to_unlock": "Press Unlock and then #", "app_desktop_unread_messages": "Unread messages", "app_desktop_missed_calls": "Missed calls", diff --git a/image/assets/lang/Svenska.json b/image/assets/lang/Svenska.json index f11d4228bfc29a10c9150bb809e6d751200be3ab..227e986928229508fc4cc2d47240d35abffcc816 100644 --- a/image/assets/lang/Svenska.json +++ b/image/assets/lang/Svenska.json @@ -216,19 +216,19 @@ "app_desktop_info_mmi_imei": "IMEI-nummer (MEID)", "app_desktop_info_mmi_result_success": "Lyckades", "app_desktop_info_mmi_result_failed": "Misslyckades", - "app_desktop_header_sim_setup": "$SIM-inställningar", - "app_desktop_sim_enter_pin_unlock": "Den förra PIN-koden:", - "app_desktop_sim_enter_new_pin": "Den nya PIN-koden:", - "app_desktop_sim_confirm_new_pin": "Bekräfta ny PIN-kod:", - "app_desktop_sim_setup_wrong_pin_last_attempt": "Fel PIN-kod. Du har

1 försök kvar.
", - "app_desktop_sim_setup_wrong_pin": "Fel PIN-kod. Du har

$ATTEMPTS försök kvar.
", - "app_desktop_sim_wrong_pin_confirmation": "Fel PIN-kod.", - "app_desktop_sim_cme_error": "SIM-kort

CME error:$CMECODE
", - "app_desktop_sim_puk_blocked": "SIM-kortet är låst.

Var god kontakta operatör.
", - "app_desktop_sim_setup_enter_puk": "SIM-kortet är låst.

För att låsa upp det, skriv in PUK-koden:
", - "app_desktop_sim_setup_wrong_puk": "Fel PUK-kod.

Du har $ATTEMPTS försök kvar.
", - "app_desktop_sim_setup_wrong_puk_last_attempt": "Fel PUK-kod.

Du har 1 försök kvar.
", - "app_desktop_sim_setup_wrong_puk_last_attempt_warning": "Om koden är fel den här gången

kommer SIM-kortet låsas och du kommer

behöva kontakta operatören.
", + "sim_header_setup": "$SIM-inställningar", + "sim_enter_pin_unlock": "Den förra PIN-koden:", + "sim_enter_new_pin": "Den nya PIN-koden:", + "sim_confirm_new_pin": "Bekräfta ny PIN-kod:", + "sim_setup_wrong_pin_last_attempt": "Fel PIN-kod. Du har

1 försök kvar.
", + "sim_setup_wrong_pin": "Fel PIN-kod. Du har

$ATTEMPTS försök kvar.
", + "sim_wrong_pin_confirmation": "Fel PIN-kod.", + "sim_cme_error": "SIM-kort

CME error:$CMECODE
", + "sim_puk_blocked": "SIM-kortet är låst.

Var god kontakta operatör.
", + "sim_setup_enter_puk": "SIM-kortet är låst.

För att låsa upp det, skriv in PUK-koden:
", + "sim_setup_wrong_puk": "Fel PUK-kod.

Du har $ATTEMPTS försök kvar.
", + "sim_setup_wrong_puk_last_attempt": "Fel PUK-kod.

Du har 1 försök kvar.
", + "sim_setup_wrong_puk_last_attempt_warning": "Om koden är fel den här gången

kommer SIM-kortet låsas och du kommer

behöva kontakta operatören.
", "app_desktop_press_to_unlock": "Tryck Lås upp följt av #", "app_desktop_unread_messages": "Olästa meddelanden", "app_desktop_missed_calls": "Missade samtal", diff --git a/module-apps/Application.cpp b/module-apps/Application.cpp index dba1757669342b8ffe41c921a997a7da5fe2f7dd..f42bd897105186ed795f8faeef7f0fda58fc546b 100644 --- a/module-apps/Application.cpp +++ b/module-apps/Application.cpp @@ -49,6 +49,8 @@ #include #include #include +#include +#include #include #include #include @@ -104,7 +106,7 @@ namespace app keyTranslator{std::make_unique()}, startInBackground{startInBackground}, callbackStorage{std::make_unique()}, topBarManager{std::make_unique()}, settings(std::make_unique()), phoneMode{mode}, phoneLockSubject(this), - lockPolicyHandler(this) + lockPolicyHandler(this), simLockSubject(this) { topBarManager->enableIndicators({gui::top_bar::Indicator::Time}); using TimeMode = gui::top_bar::TimeConfiguration::TimeMode; @@ -792,6 +794,15 @@ namespace app return std::make_unique(app, std::move(presenter)); }); break; + case ID::SimLock: + case ID::SimInfo: + windowsFactory.attach(window::sim_unlock_window, [](Application *app, const std::string &name) { + return std::make_unique(app, window::sim_unlock_window); + }); + windowsFactory.attach(window::sim_info_window, [](Application *app, const std::string &name) { + return std::make_unique(app, window::sim_info_window); + }); + break; } } } @@ -817,6 +828,14 @@ namespace app gui::popup::resolveWindowName(id), std::make_unique(popupParams->getLock(), popupParams->getPhoneLockInputTypeAction())); } + else if (id == ID::SimLock || id == ID::SimInfo) { + auto popupParams = static_cast(params); + + switchWindow(gui::popup::resolveWindowName(id), + std::make_unique(popupParams->getLock(), + popupParams->getSimInputTypeAction(), + popupParams->getErrorCode())); + } else { switchWindow(gui::popup::resolveWindowName(id)); } @@ -952,4 +971,9 @@ namespace app { return lockPolicyHandler; } + + auto Application::getSimLockSubject() noexcept -> locks::SimLockSubject & + { + return simLockSubject; + } } /* namespace app */ diff --git a/module-apps/Application.hpp b/module-apps/Application.hpp index e0937693c618aaffb8f1169e28d967be82176e49..aa2d721617165917d48bc8d9dc292c9af43d4386 100644 --- a/module-apps/Application.hpp +++ b/module-apps/Application.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "WindowsFactory.hpp" #include "WindowsStack.hpp" @@ -402,9 +403,11 @@ namespace app locks::PhoneLockSubject phoneLockSubject; locks::LockPolicyHandler lockPolicyHandler; + locks::SimLockSubject simLockSubject; public: [[nodiscard]] auto getPhoneLockSubject() noexcept -> locks::PhoneLockSubject &; + [[nodiscard]] auto getSimLockSubject() noexcept -> locks::SimLockSubject &; [[nodiscard]] bool isPhoneLockEnabled() const noexcept; diff --git a/module-apps/application-desktop/ApplicationDesktop.cpp b/module-apps/application-desktop/ApplicationDesktop.cpp index 351b728e4cb3bc48e1416a899a377c68859d1fa9..7aee6fb3081ebc903a457a9e7feb926638e37985 100644 --- a/module-apps/application-desktop/ApplicationDesktop.cpp +++ b/module-apps/application-desktop/ApplicationDesktop.cpp @@ -6,7 +6,6 @@ #include "MessageType.hpp" #include "windows/DesktopMainWindow.hpp" #include "windows/MenuWindow.hpp" -#include "locks/windows/PinLockWindow.hpp" #include "windows/DeadBatteryWindow.hpp" #include "windows/LogoWindow.hpp" #include "windows/ChargingBatteryWindow.hpp" @@ -28,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -46,7 +44,7 @@ namespace app sys::phone_modes::PhoneMode mode, StartInBackground startInBackground) : Application(std::move(name), std::move(parent), mode, startInBackground), AsyncCallbackReceiver(this), - lockHandler(this), dbNotificationHandler(this) + dbNotificationHandler(this) { using namespace gui::top_bar; topBarManager->enableIndicators({Indicator::Signal, Indicator::Time, Indicator::Battery, Indicator::SimCard}); @@ -54,48 +52,6 @@ namespace app std::make_shared(SIMConfiguration::DisplayMode::OnlyInactiveState)); bus.channels.push_back(sys::BusChannel::ServiceDBNotifications); - addActionReceiver(app::manager::actions::RequestPin, [this](auto &&data) { - lockHandler.handlePasscodeRequest(locks::Lock::LockType::SimPin, std::move(data)); - return actionHandled(); - }); - - addActionReceiver(app::manager::actions::RequestPuk, [this](auto &&data) { - lockHandler.handlePasscodeRequest(locks::Lock::LockType::SimPuk, std::move(data)); - return actionHandled(); - }); - - addActionReceiver(app::manager::actions::RequestPinChange, [this](auto &&data) { - lockHandler.handlePinChangeRequest(std::move(data)); - return actionHandled(); - }); - - addActionReceiver(app::manager::actions::RequestPinDisable, [this](auto &&data) { - lockHandler.handlePinEnableRequest(std::forward(data), - cellular::api::SimLockState::Disabled); - return actionHandled(); - }); - - addActionReceiver(app::manager::actions::RequestPinEnable, [this](auto &&data) { - lockHandler.handlePinEnableRequest(std::forward(data), - cellular::api::SimLockState::Enabled); - return actionHandled(); - }); - - addActionReceiver(app::manager::actions::BlockSim, [this](auto &&data) { - lockHandler.handleSimBlocked(std::move(data)); - return actionHandled(); - }); - - addActionReceiver(app::manager::actions::UnlockSim, [this](auto &&data) { - lockHandler.handleUnlockSim(std::move(data)); - return actionHandled(); - }); - - addActionReceiver(app::manager::actions::DisplayCMEError, [this](auto &&data) { - lockHandler.handleCMEError(std::move(data)); - return actionHandled(); - }); - addActionReceiver(app::manager::actions::ShowMMIResponse, [this](auto &&data) { switchWindow(app::window::name::desktop_mmi_pull, std::move(data)); return actionHandled(); @@ -192,15 +148,6 @@ namespace app auto ApplicationDesktop::handle(cellular::StateChange *msg) -> bool { assert(msg); - if (msg->request == cellular::service::State::ST::URCReady) { - if (need_sim_select && !lockHandler.isScreenLocked()) { - manager::Controller::sendAction(this, manager::actions::SelectSimCard); - return true; - } - else if (need_sim_select == false) { - bus.sendUnicast(std::make_shared(), ServiceCellular::serviceName); - } - } if (msg->request == cellular::service::State::ST::ModemFatalFailure) { switchWindow(app::window::name::desktop_reboot); } @@ -242,68 +189,6 @@ namespace app return sys::msgHandled(); }); - auto createPinChangedSuccessfullyDialog = - [](app::ApplicationDesktop *app) -> std::unique_ptr { - return std::make_unique( - gui::DialogMetadata{utils::translate("app_desktop_sim_change_pin"), - "success_icon_W_G", - utils::translate("app_desktop_sim_pin_changed_successfully"), - "", - [app]() { - app->switchWindow(app::window::name::desktop_main_window); - return true; - }}); - }; - - connect(typeid(cellular::msg::request::sim::ChangePin::Response), - [&](sys::Message *request) -> sys::MessagePointer { - auto response = dynamic_cast(request); - if (response->retCode) { - auto metaData = createPinChangedSuccessfullyDialog(this); - switchWindow( - gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData)); - } - else { - lockHandler.handlePinChangeRequestFailed(); - } - return sys::MessageNone{}; - }); - - connect(typeid(cellular::msg::request::sim::UnblockWithPuk::Response), - [&](sys::Message *request) -> sys::MessagePointer { - auto response = dynamic_cast(request); - if (response->retCode) { - auto metaData = createPinChangedSuccessfullyDialog(this); - switchWindow( - gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData)); - } - return sys::MessageNone{}; - }); - - connect(typeid(cellular::msg::request::sim::SetPinLock::Response), - [&](sys::Message *request) -> sys::MessagePointer { - auto response = dynamic_cast(request); - if (response->retCode) { - auto metaData = std::make_unique( - gui::DialogMetadata{"", - "success_icon_W_G", - response->lock == cellular::api::SimLockState::Disabled - ? utils::translate("app_desktop_sim_card_unlocked") - : utils::translate("app_desktop_sim_card_locked"), - "", - [this]() { - switchWindow(app::window::name::desktop_main_window); - return true; - }}); - switchWindow( - gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData)); - } - else { - lockHandler.handlePinEnableRequestFailed(response->lock); - } - return sys::MessageNone{}; - }); - connect(typeid(db::NotificationMessage), [&](sys::Message *request) { auto notificationMessage = static_cast(request); dbNotificationHandler.handle(notificationMessage); @@ -314,20 +199,6 @@ namespace app std::make_shared(updateos::UpdateMessageType::UpdateCheckForUpdateOnce); bus.sendUnicast(msgToSend, service::name::service_desktop); - auto selectedSim = magic_enum::enum_cast( - settings->getValue(settings::SystemProperties::activeSim, settings::SettingsScope::Global)); - if (selectedSim.has_value()) { - Store::GSM::get()->selected = selectedSim.value(); - } - else { - Store::GSM::get()->selected = Store::GSM::SIM::NONE; - } - - settings->registerValueChange( - settings::SystemProperties::activeSim, - [this](const std::string &value) { activeSimChanged(value); }, - settings::SettingsScope::Global); - settings->registerValueChange( settings::SystemProperties::osCurrentVersion, [this](const std::string &value) { osCurrentVersionChanged(value); }, @@ -354,9 +225,6 @@ namespace app windowsFactory.attach(desktop_main_window, [](Application *app, const std::string &name) { return std::make_unique(app); }); - windowsFactory.attach(desktop_pin_lock, [&](Application *app, const std::string newname) { - return std::make_unique(app, desktop_pin_lock); - }); windowsFactory.attach(desktop_menu, [this](Application *app, const std::string newname) { return std::make_unique(app, dbNotificationHandler); }); @@ -395,8 +263,11 @@ namespace app return std::make_unique(app, name); }); - attachPopups( - {gui::popup::ID::Volume, gui::popup::ID::Tethering, gui::popup::ID::PhoneModes, gui::popup::ID::PhoneLock}); + attachPopups({gui::popup::ID::Volume, + gui::popup::ID::Tethering, + gui::popup::ID::PhoneModes, + gui::popup::ID::PhoneLock, + gui::popup::ID::SimLock}); } void ApplicationDesktop::destroyUserInterface() @@ -412,21 +283,6 @@ namespace app return false; } - void ApplicationDesktop::activeSimChanged(std::string value) - { - auto sim = magic_enum::enum_cast(value); - if (sim.has_value()) { - Store::GSM::get()->selected = sim.value(); - } - else { - Store::GSM::get()->selected = Store::GSM::SIM::NONE; - } - - if (Store::GSM::SIM::NONE == sim) { - need_sim_select = true; - } - } - void ApplicationDesktop::handleLowBatteryNotification(manager::actions::ActionParamsPtr &&data) { auto lowBatteryState = static_cast(data.get()); diff --git a/module-apps/application-desktop/ApplicationDesktop.hpp b/module-apps/application-desktop/ApplicationDesktop.hpp index 6bfdea345282620cc2c5c115dfe6082486b85fcb..28c32816358710b815abb734bdeea50e1dd77f9a 100644 --- a/module-apps/application-desktop/ApplicationDesktop.hpp +++ b/module-apps/application-desktop/ApplicationDesktop.hpp @@ -4,7 +4,6 @@ #pragma once #include "windows/Names.hpp" -#include "locks/handlers/PinLockHandler.hpp" #include "widgets/DBNotificationsHandler.hpp" #include "Constants.hpp" #include @@ -26,10 +25,6 @@ namespace app class ApplicationDesktop : public Application, public AsyncCallbackReceiver { public: - bool need_sim_select = false; - - gui::PinLockHandler lockHandler; - explicit ApplicationDesktop(std::string name = name_desktop, std::string parent = {}, sys::phone_modes::PhoneMode mode = sys::phone_modes::PhoneMode::Connected, @@ -63,7 +58,6 @@ namespace app private: bool refreshMenuWindow(); - void activeSimChanged(std::string value); void handleLowBatteryNotification(manager::actions::ActionParamsPtr &&data); void osUpdateVersionChanged(const std::string &value); void osCurrentVersionChanged(const std::string &value); @@ -78,17 +72,9 @@ namespace app { return {{manager::actions::Launch, manager::actions::AutoLock, - manager::actions::RequestPin, - manager::actions::RequestPuk, - manager::actions::RequestPinChange, - manager::actions::RequestPinDisable, - manager::actions::RequestPinEnable, - manager::actions::UnlockSim, - manager::actions::BlockSim, manager::actions::ShowMMIResponse, manager::actions::ShowMMIPush, manager::actions::ShowMMIResult, - manager::actions::DisplayCMEError, manager::actions::DisplayLowBatteryScreen, manager::actions::SystemBrownout, manager::actions::DisplayLogoAtExit, diff --git a/module-apps/application-desktop/windows/DesktopMainWindow.cpp b/module-apps/application-desktop/windows/DesktopMainWindow.cpp index 06e6b7e0944f66f7f5d9a2a346a4c78d9da626be..14092a423ed9f84b3a360805234f012339bff5c4 100644 --- a/module-apps/application-desktop/windows/DesktopMainWindow.cpp +++ b/module-apps/application-desktop/windows/DesktopMainWindow.cpp @@ -92,10 +92,6 @@ namespace gui void DesktopMainWindow::setVisibleState() { - auto app = getAppDesktop(); - - app->lockHandler.unlockScreen(); - setActiveState(); if (osUpdateVer == osCurrentVer && osUpdateVer != updateos::initSysVer && @@ -106,10 +102,6 @@ namespace gui getAppDesktop()->setOsUpdateVersion(updateos::initSysVer); } - if (app->need_sim_select && Store::GSM::get()->sim == Store::GSM::SIM::SIM_UNKNOWN) { - app::manager::Controller::sendAction(application, app::manager::actions::SelectSimCard); - } - application->bus.sendUnicast(std::make_shared(), service::name::service_time); } diff --git a/module-apps/application-desktop/windows/PostUpdateWindow.cpp b/module-apps/application-desktop/windows/PostUpdateWindow.cpp index a01497886107a1414ba6b418bde8087f5d13bb6a..32d595110834407f291f1c74a34f2dc078a39411 100644 --- a/module-apps/application-desktop/windows/PostUpdateWindow.cpp +++ b/module-apps/application-desktop/windows/PostUpdateWindow.cpp @@ -28,7 +28,7 @@ void PostUpdateWindow::onBeforeShow(ShowMode mode, SwitchData *data) currentOsVersion = item->getCurrentOsVersion(); auto info = utils::translate("app_desktop_update_success"); utils::findAndReplaceAll(info, "$VERSION", currentOsVersion); - infoText->setText(info); + infoIcon->text->setText(info); } } setVisibleState(); @@ -36,7 +36,6 @@ void PostUpdateWindow::onBeforeShow(ShowMode mode, SwitchData *data) void PostUpdateWindow::setVisibleState() { - successImage->setVisible(true); bottomBar->setActive(BottomBar::Side::CENTER, true); } @@ -67,31 +66,23 @@ top_bar::Configuration PostUpdateWindow::configureTopBar(top_bar::Configuration void PostUpdateWindow::buildInterface() { - namespace post_update_style = style::window::pin_lock; AppWindow::buildInterface(); setTitle(utils::translate("app_desktop_update_muditaos")); bottomBar->setText(BottomBar::Side::CENTER, utils::translate("common_ok")); - successImage = - new gui::Image(this, post_update_style::image::x, post_update_style::image::y, 0, 0, "circle_success"); - infoText = new Text(this, - post_update_style::primary_text::x, - post_update_style::primary_text::y, - post_update_style::primary_text::w, - post_update_style::primary_text::h); - infoText->setAlignment(Alignment::Horizontal::Center); + infoIcon = new gui::Icon(this, + style::window::default_left_margin, + style::header::height, + style::window::default_body_width, + style::window::default_body_height, + "circle_success", + ""); + infoIcon->setAlignment(Alignment::Horizontal::Center); } void PostUpdateWindow::destroyInterface() { erase(); - invalidate(); -} - -void PostUpdateWindow::invalidate() noexcept -{ - successImage = nullptr; - infoText = nullptr; } diff --git a/module-apps/application-desktop/windows/PostUpdateWindow.hpp b/module-apps/application-desktop/windows/PostUpdateWindow.hpp index 09b64939fa372a9634c2c34cc18046d0fb5056d3..7a0fa3c48f55b18b1fe8be68f7c3f03ff53cfd10 100644 --- a/module-apps/application-desktop/windows/PostUpdateWindow.hpp +++ b/module-apps/application-desktop/windows/PostUpdateWindow.hpp @@ -5,18 +5,15 @@ #include #include -#include +#include namespace gui { class PostUpdateWindow : public AppWindow { - gui::Image *successImage = nullptr; - gui::Text *infoText = nullptr; + Icon *infoIcon = nullptr; void setVisibleState(); - void invalidate() noexcept; - std::string currentOsVersion; public: diff --git a/module-apps/application-onboarding/windows/OnBoardingSimSelectWindow.cpp b/module-apps/application-onboarding/windows/OnBoardingSimSelectWindow.cpp index 43cc9d0afed7bcb102a23e7b1b47baea7c682c93..719de00bc8293ce1ab0ce3dad606f988696ebf79 100644 --- a/module-apps/application-onboarding/windows/OnBoardingSimSelectWindow.cpp +++ b/module-apps/application-onboarding/windows/OnBoardingSimSelectWindow.cpp @@ -51,7 +51,7 @@ namespace gui options.emplace_back(std::make_unique( "SIM1", [=](const gui::Item &item) { - application->getPhoneLockSubject().setPhoneLock(); + application->getSimLockSubject().setSim(cellular::api::SimSlot::SIM1); return true; }, nullptr, @@ -61,7 +61,7 @@ namespace gui options.emplace_back(std::make_unique( "SIM2", [=](const gui::Item &item) { - application->getPhoneLockSubject().setPhoneLock(); + application->getSimLockSubject().setSim(cellular::api::SimSlot::SIM2); return true; }, nullptr, diff --git a/module-apps/application-settings-new/ApplicationSettings.cpp b/module-apps/application-settings-new/ApplicationSettings.cpp index 683629ec99f5c1a8e092df1429d283b6ecd48568..261cfc41929d3d11dae970422b501669c9b3443b 100644 --- a/module-apps/application-settings-new/ApplicationSettings.cpp +++ b/module-apps/application-settings-new/ApplicationSettings.cpp @@ -59,8 +59,6 @@ #include #include -#include -#include #include #include #include @@ -82,7 +80,6 @@ #include #include #include -#include #include @@ -433,9 +430,6 @@ namespace app windowsFactory.attach(gui::window::name::security, [](Application *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); - windowsFactory.attach(app::window::name::desktop_pin_lock, [&](Application *app, const std::string newname) { - return std::make_unique(app, app::window::name::desktop_pin_lock); - }); windowsFactory.attach(gui::window::name::dialog_confirm, [](Application *app, const std::string &name) { return std::make_unique(app, gui::window::name::dialog_confirm); }); @@ -514,8 +508,12 @@ namespace app [](Application *app, const std::string &name) { return std::make_unique(app); }); - attachPopups( - {gui::popup::ID::Volume, gui::popup::ID::Tethering, gui::popup::ID::PhoneModes, gui::popup::ID::PhoneLock}); + + attachPopups({gui::popup::ID::Volume, + gui::popup::ID::Tethering, + gui::popup::ID::PhoneModes, + gui::popup::ID::PhoneLock, + gui::popup::ID::SimLock}); } void ApplicationSettingsNew::destroyUserInterface() @@ -529,7 +527,7 @@ namespace app void ApplicationSettingsNew::setSim(Store::GSM::SIM sim) { auto arg = (sim == Store::GSM::SIM::SIM2) ? cellular::api::SimSlot::SIM2 : cellular::api::SimSlot::SIM1; - bus.sendUnicast(arg); + getSimLockSubject().setSim(arg); } Store::GSM::SIM ApplicationSettingsNew::getSim() diff --git a/module-apps/application-settings-new/windows/PINSettingsWindow.cpp b/module-apps/application-settings-new/windows/PINSettingsWindow.cpp index fe25716506471e86d172e246f235b03ffb6c4950..2cffe53f5bd7e301d13f6aa37c3853f77ff67b2c 100644 --- a/module-apps/application-settings-new/windows/PINSettingsWindow.cpp +++ b/module-apps/application-settings-new/windows/PINSettingsWindow.cpp @@ -8,7 +8,7 @@ #include "OptionSetting.hpp" #include -#include +#include #include namespace gui @@ -56,11 +56,7 @@ namespace gui optionList.emplace_back(std::make_unique( utils::translate("app_settings_network_pin_change_code"), [=](Item & /*item*/) { - using namespace app::manager::actions; - auto params = std::make_unique(Store::GSM::get()->selected, - PasscodeParams::numOfAttemptsForEnteringPIN, - PasscodeParams::pinName); - app::manager::Controller::sendAction(application, RequestPinChange, std::move(params)); + application->getSimLockSubject().changeSimPin(); return true; }, nullptr, @@ -75,14 +71,11 @@ namespace gui { currentState = !currentState; refreshOptionsList(); - using namespace app::manager::actions; - auto params = std::make_unique( - Store::GSM::get()->selected, PasscodeParams::numOfAttemptsForEnteringPIN, PasscodeParams::pinName); if (!currentState) { - app::manager::Controller::sendAction(application, RequestPinDisable, std::move(params)); + application->getSimLockSubject().disableSimPin(); } else { - app::manager::Controller::sendAction(application, RequestPinEnable, std::move(params)); + application->getSimLockSubject().enableSimPin(); } } } // namespace gui diff --git a/module-apps/application-settings-new/windows/SecurityMainWindow.cpp b/module-apps/application-settings-new/windows/SecurityMainWindow.cpp index 1bae16d6947398623ada4ab7e4d31afd1a3acbd4..4387e6eddb819063d9b497d6049f748a7845e283 100644 --- a/module-apps/application-settings-new/windows/SecurityMainWindow.cpp +++ b/module-apps/application-settings-new/windows/SecurityMainWindow.cpp @@ -44,33 +44,6 @@ namespace gui nullptr, isPhoneLockEnabled ? option::SettingRightItem::On : option::SettingRightItem::Off)); - optionList.emplace_back(std::make_unique( - utils::translate("app_settings_security_usb_passcode"), - [=](Item &item) { - auto lock = std::make_unique( - Store::GSM::SIM::NONE, locks::Lock::LockState::InputRequired, locks::Lock::LockType::Screen); - lock->onActivatedCallback = [this](locks::Lock::LockType type, const std::vector &data) { - securitySettings->setUSBSecurity(!securitySettings->isUSBSecured()); - application->returnToPreviousWindow(); - }; - application->switchWindow( - app::window::name::desktop_pin_lock, - gui::ShowMode::GUI_SHOW_INIT, - std::make_unique(*lock, locks::PhoneLockInputTypeAction::Change)); - return true; - }, - [=](Item &item) { - if (item.focus) { - this->setBottomBarText(utils::translate(style::strings::common::Switch), BottomBar::Side::CENTER); - } - else { - this->setBottomBarText(utils::translate(style::strings::common::select), BottomBar::Side::CENTER); - } - return true; - }, - nullptr, - securitySettings->isUSBSecured() ? option::SettingRightItem::On : option::SettingRightItem::Off)); - if (isPhoneLockEnabled) { optionList.emplace_back(std::make_unique( utils::translate("app_settings_security_change_phone_lock"), diff --git a/module-apps/application-settings/ApplicationSettings.cpp b/module-apps/application-settings/ApplicationSettings.cpp index fa45bd8f213154085babaea59c1dea4f08107df5..bb4086ed3d663999a86f595acb62dcfd16c055a4 100644 --- a/module-apps/application-settings/ApplicationSettings.cpp +++ b/module-apps/application-settings/ApplicationSettings.cpp @@ -20,10 +20,7 @@ #include "ApplicationSettings.hpp" -#include "service-cellular/ServiceCellular.hpp" -#include #include "windows/SettingsMainWindow.hpp" -#include "windows/SimSelectWindow.hpp" #include "windows/CellularPassthroughWindow.hpp" #include @@ -45,13 +42,7 @@ namespace app sys::phone_modes::PhoneMode mode, StartInBackground startInBackground) : Application(name, parent, mode, startInBackground) - { - bus.channels.push_back(sys::BusChannel::AntennaNotifications); - addActionReceiver(manager::actions::SelectSimCard, [this](auto &&data) { - switchWindow(app::sim_select); - return actionHandled(); - }); - } + {} ApplicationSettings::~ApplicationSettings() {} @@ -116,10 +107,6 @@ namespace app return std::make_unique( app, utils::translate("app_settings_title_main"), mainWindowOptions(app)); }); - - windowsFactory.attach(app::sim_select, [this](Application *app, const std::string &name) { - return std::make_unique(app, name, simSelectWindow(app, this)); - }); windowsFactory.attach("Languages", [](Application *app, const std::string &name) { return std::make_unique(app); }); @@ -162,12 +149,6 @@ namespace app void ApplicationSettings::destroyUserInterface() {} - void ApplicationSettings::setSim(Store::GSM::SIM sim) - { - auto arg = (sim == Store::GSM::SIM::SIM2) ? cellular::api::SimSlot::SIM2 : cellular::api::SimSlot::SIM1; - bus.sendUnicast(arg); - } - void ApplicationSettings::timeDateChanged(std::string value) { auto newTimeDateFormat = utils::getNumericValue(value); diff --git a/module-apps/application-settings/ApplicationSettings.hpp b/module-apps/application-settings/ApplicationSettings.hpp index 7479c7d0c8db0adaaf6486ada52f807f32eeea3e..d457cd1bf4b5b008ed5cc03abb72138c860437ec 100644 --- a/module-apps/application-settings/ApplicationSettings.hpp +++ b/module-apps/application-settings/ApplicationSettings.hpp @@ -10,18 +10,9 @@ namespace app { - inline constexpr auto name_settings = "ApplicationSettings"; - inline constexpr auto sim_select = "SimSelect"; - - class SimSetter - { - public: - virtual ~SimSetter() = default; - virtual void setSim(Store::GSM::SIM sim) = 0; - }; - class ApplicationSettings : public app::Application, public SimSetter + class ApplicationSettings : public app::Application { public: ApplicationSettings(std::string name = name_settings, @@ -41,11 +32,9 @@ namespace app void createUserInterface() override; void destroyUserInterface() override; bsp::Board board = bsp::Board::none; - void setSim(Store::GSM::SIM sim) override; void timeDateChanged(std::string value); private: - unsigned int lockPassHash; bool europeanDateTimeFormat = false; // true europe format, false american format }; @@ -53,7 +42,7 @@ namespace app { static auto GetManifest() -> manager::ApplicationManifest { - return {{manager::actions::Launch, manager::actions::SelectSimCard, manager::actions::PhoneModeChanged}}; + return {{manager::actions::Launch, manager::actions::PhoneModeChanged}}; } }; } /* namespace app */ diff --git a/module-apps/application-settings/CMakeLists.txt b/module-apps/application-settings/CMakeLists.txt index 664ea09bacbde836900dfcc8c19aa3854628482c..2f7edafebc7fd1b36733dcc44352cd1e0c6cd3f3 100644 --- a/module-apps/application-settings/CMakeLists.txt +++ b/module-apps/application-settings/CMakeLists.txt @@ -21,7 +21,6 @@ target_sources( ${PROJECT_NAME} windows/BtScanWindow.cpp windows/UITestWindow.cpp windows/Info.cpp - windows/SimSelectWindow.cpp windows/DateTimeWindow.cpp windows/CellularPassthroughWindow.cpp windows/FotaWindow.cpp diff --git a/module-apps/application-settings/windows/SettingsMainWindow.cpp b/module-apps/application-settings/windows/SettingsMainWindow.cpp index c6b25b67474883f9707d682fa4a3cb26f37b5ea8..4105888525afccb4650d0365cd9a334148f1ac8e 100644 --- a/module-apps/application-settings/windows/SettingsMainWindow.cpp +++ b/module-apps/application-settings/windows/SettingsMainWindow.cpp @@ -33,7 +33,6 @@ std::list mainWindowOptions(app::Application *app) addMenu("UI TEST", "TEST_UI"); addMenu(i18("app_settings_bt"), "Bluetooth"); addMenu(i18("app_settings_language"), "Languages"); - addMenu("SIM SELECT", app::sim_select); addMenu(i18("app_settings_date_and_time"), "DateTime"); if (dynamic_cast(app)->board == bsp::Board::T4) { addMenu(i18("app_settings_cellular_passthrough"), gui::window::cellular_passthrough::window_name); diff --git a/module-apps/application-settings/windows/SimSelectWindow.cpp b/module-apps/application-settings/windows/SimSelectWindow.cpp deleted file mode 100644 index 38b6e1f0d529584f56a02e088496b3f96fc96948..0000000000000000000000000000000000000000 --- a/module-apps/application-settings/windows/SimSelectWindow.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "SimSelectWindow.hpp" -#include "Info.hpp" -#include "SettingsMainWindow.hpp" -#include -#include "log/log.hpp" -#include -#include -#include -#include -#include -#include - -std::list simSelectWindow(app::Application *app, app::SimSetter *setter) -{ - std::list l; - l.emplace_back(gui::Option{"SIM 1", - [=](gui::Item &item) { - setter->setSim(Store::GSM::SIM::SIM1); - return true; - }, - gui::option::Arrow::Disabled}); - l.emplace_back(gui::Option{"SIM 2", - [=](gui::Item &item) { - setter->setSim(Store::GSM::SIM::SIM2); - return true; - }, - gui::option::Arrow::Disabled}); - return l; -} diff --git a/module-apps/application-settings/windows/SimSelectWindow.hpp b/module-apps/application-settings/windows/SimSelectWindow.hpp deleted file mode 100644 index f314ff12e76e08fb243948f29438b63643524816..0000000000000000000000000000000000000000 --- a/module-apps/application-settings/windows/SimSelectWindow.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#pragma once - -#include -namespace app -{ - class Application; - class SimSetter; -} // namespace app - -std::list simSelectWindow(app::Application *app, app::SimSetter *setter); \ No newline at end of file diff --git a/module-apps/locks/CMakeLists.txt b/module-apps/locks/CMakeLists.txt index b885965c40d970c00991e81482083f384781a44a..7a1ae895977721bc65dfa0b917de3b29916cb905 100644 --- a/module-apps/locks/CMakeLists.txt +++ b/module-apps/locks/CMakeLists.txt @@ -14,16 +14,15 @@ include_directories( ${PROJECT_NAME} target_sources( ${PROJECT_NAME} PRIVATE - "${CMAKE_CURRENT_LIST_DIR}/handlers/PinLockHandler.cpp" "${CMAKE_CURRENT_LIST_DIR}/handlers/PhoneLockHandler.cpp" "${CMAKE_CURRENT_LIST_DIR}/handlers/PhoneLockSubject.cpp" + "${CMAKE_CURRENT_LIST_DIR}/handlers/SimLockHandler.cpp" + "${CMAKE_CURRENT_LIST_DIR}/handlers/SimLockSubject.cpp" "${CMAKE_CURRENT_LIST_DIR}/handlers/LockPolicyHandler.cpp" - "${CMAKE_CURRENT_LIST_DIR}/windows/LockWindow.cpp" - "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockBaseWindow.cpp" - "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockWindow.cpp" + "${CMAKE_CURRENT_LIST_DIR}/windows/LockInputWindow.cpp" "${CMAKE_CURRENT_LIST_DIR}/widgets/Lock.cpp" - "${CMAKE_CURRENT_LIST_DIR}/widgets/PukLockBox.cpp" - "${CMAKE_CURRENT_LIST_DIR}/widgets/PhoneLockBaseBox.cpp" + "${CMAKE_CURRENT_LIST_DIR}/widgets/LockBoxConstantSize.cpp" + "${CMAKE_CURRENT_LIST_DIR}/widgets/LockBoxAlternatingSize.cpp" "${CMAKE_CURRENT_LIST_DIR}/widgets/PhoneLockBox.cpp" "${CMAKE_CURRENT_LIST_DIR}/widgets/SimLockBox.cpp" @@ -31,18 +30,18 @@ target_sources( ${PROJECT_NAME} "${CMAKE_CURRENT_LIST_DIR}/data/LockData.hpp" "${CMAKE_CURRENT_LIST_DIR}/data/LockStyle.hpp" "${CMAKE_CURRENT_LIST_DIR}/data/PhoneLockMessages.hpp" - "${CMAKE_CURRENT_LIST_DIR}/handlers/PinLockHandler.hpp" + "${CMAKE_CURRENT_LIST_DIR}/data/SimLockMessages.hpp" "${CMAKE_CURRENT_LIST_DIR}/handlers/PhoneLockHandler.hpp" "${CMAKE_CURRENT_LIST_DIR}/handlers/PhoneLockSubject.hpp" "${CMAKE_CURRENT_LIST_DIR}/handlers/LockPolicyHandler.hpp" - "${CMAKE_CURRENT_LIST_DIR}/windows/LockWindow.hpp" - "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockBaseWindow.hpp" - "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockWindow.hpp" + "${CMAKE_CURRENT_LIST_DIR}/handlers/SimLockHandler.hpp" + "${CMAKE_CURRENT_LIST_DIR}/handlers/SimLockSubject.hpp" + "${CMAKE_CURRENT_LIST_DIR}/windows/LockInputWindow.hpp" "${CMAKE_CURRENT_LIST_DIR}/widgets/LockHash.hpp" "${CMAKE_CURRENT_LIST_DIR}/widgets/Lock.hpp" "${CMAKE_CURRENT_LIST_DIR}/widgets/LockBox.hpp" - "${CMAKE_CURRENT_LIST_DIR}/widgets/PukLockBox.hpp" - "${CMAKE_CURRENT_LIST_DIR}/widgets/PhoneLockBaseBox.hpp" + "${CMAKE_CURRENT_LIST_DIR}/widgets/LockBoxConstantSize.hpp" + "${CMAKE_CURRENT_LIST_DIR}/widgets/LockBoxAlternatingSize.hpp" "${CMAKE_CURRENT_LIST_DIR}/widgets/PhoneLockBox.hpp" "${CMAKE_CURRENT_LIST_DIR}/widgets/SimLockBox.hpp" ) diff --git a/module-apps/locks/data/LockData.hpp b/module-apps/locks/data/LockData.hpp index aeb8807feee4751d600329067a58ad0a74125045..5ada1f4f2636726ec730184e278c31407a3707b6 100644 --- a/module-apps/locks/data/LockData.hpp +++ b/module-apps/locks/data/LockData.hpp @@ -4,12 +4,13 @@ #pragma once #include -#include #include "gui/SwitchData.hpp" #include "locks/widgets/Lock.hpp" namespace locks { + using LockInput = const std::vector &; + enum class PhoneLockInputTypeAction { Unlock, @@ -20,6 +21,17 @@ namespace locks Set }; + enum class SimInputTypeAction + { + UnlockWithPin, + UnlockWithPuk, + ChangePin, + EnablePin, + DisablePin, + Blocked, + Error, + }; + // class template that stores information that was sent along with switch message class LockData : public gui::SwitchData { @@ -45,4 +57,26 @@ namespace locks } }; + class SimLockData : public LockData + { + SimInputTypeAction simInputTypeAction; + unsigned int errorCode; + + public: + explicit SimLockData(Lock lock, SimInputTypeAction simInputTypeAction, unsigned int errorCode) + : LockData(std::move(lock)), simInputTypeAction(simInputTypeAction), errorCode(errorCode) + { + description = "SimLockPhoneData"; + } + + [[nodiscard]] auto getSimInputTypeAction() const noexcept + { + return simInputTypeAction; + } + + [[nodiscard]] auto getErrorCode() const noexcept + { + return errorCode; + } + }; } // namespace locks diff --git a/module-apps/locks/data/LockStyle.hpp b/module-apps/locks/data/LockStyle.hpp index 87621ed69f925215fe2db1747341dc839291a7f2..90d39b68b9fe86e2e747a7c9e98b114574a7eca3 100644 --- a/module-apps/locks/data/LockStyle.hpp +++ b/module-apps/locks/data/LockStyle.hpp @@ -1,42 +1,33 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once #include "gui/widgets/Style.hpp" -namespace style::window::pin_lock +namespace style::window::lock_input { namespace image { - constexpr inline auto x = 177; - constexpr inline auto y = 132; + constexpr inline auto wh = 128; + constexpr inline auto image_top_margin = 30; + constexpr inline auto image_bottom_margin = 33; } // namespace image - namespace pin_label + namespace input_box { - constexpr inline auto x = 85; - constexpr inline auto y = 400; - constexpr inline auto w = style::window_width - 2 * x; - - constexpr inline auto size = 60; - constexpr inline auto margin = 10; + constexpr inline auto w = style::window::default_body_width; + constexpr inline auto h = 60; + constexpr inline auto label_margin = 10; + constexpr inline auto top_margin = 30; } // namespace pin_label - namespace title - { - constexpr inline auto x = 0; - constexpr inline auto y = 60; - constexpr inline auto w = style::window_width; - constexpr inline auto h = 50; - } // namespace title - namespace ice { constexpr inline auto x = style::window::default_left_margin; - constexpr inline auto y = title::y; + constexpr inline auto y = 60; constexpr inline auto w = 60; - constexpr inline auto h = title::h; + constexpr inline auto h = 50; constexpr inline auto margin = 3; @@ -49,31 +40,13 @@ namespace style::window::pin_lock namespace primary_text { - constexpr inline auto x = style::window::default_left_margin; - constexpr inline auto y = 294; - constexpr inline auto w = style::window_width - 2 * x; constexpr inline auto h = 60; } // namespace primary_text namespace secondary_text { - constexpr inline auto x = style::window::default_left_margin; - constexpr inline auto y = primary_text::y + primary_text::h + 30; - constexpr inline auto w = style::window_width - 2 * x; - constexpr inline auto h = 90; + constexpr inline auto top_margin = 30; + constexpr inline auto h = 90; } // namespace secondary_text -} // namespace style::window::pin_lock - -namespace style::window::screen_pin_lock -{ - namespace pin_label - { - constexpr inline auto y = 248; - } // namespace pin_label - - namespace primary_text - { - constexpr inline auto y = 160; - } // namespace primary_text -} // namespace style::window::screen_pin_lock +} // namespace style::window::lock_input diff --git a/module-apps/locks/data/SimLockMessages.hpp b/module-apps/locks/data/SimLockMessages.hpp new file mode 100644 index 0000000000000000000000000000000000000000..616b7512385bbc35970f9c0430d692b6670eae81 --- /dev/null +++ b/module-apps/locks/data/SimLockMessages.hpp @@ -0,0 +1,50 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include +#include + +namespace locks +{ + class UnLockSimInput : public sys::DataMessage + { + private: + std::vector inputData; + + public: + explicit UnLockSimInput(std::vector inputData) : DataMessage{}, inputData(std::move(inputData)) + {} + + [[nodiscard]] auto getInputData() const noexcept + { + return inputData; + } + }; + + class SetSim : public sys::DataMessage + { + private: + cellular::api::SimSlot simSlot; + + public: + explicit SetSim(cellular::api::SimSlot simSlot) : DataMessage{}, simSlot(simSlot) + {} + + [[nodiscard]] auto getSimSlot() const noexcept + { + return simSlot; + } + }; + + class ChangeSimPin : public sys::DataMessage + {}; + + class EnableSimPin : public sys::DataMessage + {}; + + class DisableSimPin : public sys::DataMessage + {}; + +} // namespace locks diff --git a/module-apps/locks/handlers/PhoneLockHandler.cpp b/module-apps/locks/handlers/PhoneLockHandler.cpp index 67beed3beaa85c7b9549f533b2f50e8bb287024a..543a450d37311d1377cc282720676fd25435dba5 100644 --- a/module-apps/locks/handlers/PhoneLockHandler.cpp +++ b/module-apps/locks/handlers/PhoneLockHandler.cpp @@ -1,5 +1,5 @@ -//// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -//// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "PhoneLockHandler.hpp" @@ -234,7 +234,7 @@ namespace locks phoneInputRequiredAction(); } - sys::MessagePointer PhoneLockHandler::verifyPhoneLockInput(const std::vector &inputData) + sys::MessagePointer PhoneLockHandler::verifyPhoneLockInput(LockInput inputData) { if (checkPhoneLockInputTypeAction(PhoneLockInputTypeAction::Enable) || checkPhoneLockInputTypeAction(PhoneLockInputTypeAction::Change) || @@ -246,7 +246,7 @@ namespace locks } } - sys::MessagePointer PhoneLockHandler::verifyPhoneUnlockInput(const std::vector &inputData) + sys::MessagePointer PhoneLockHandler::verifyPhoneUnlockInput(LockInput inputData) { const uint32_t hash = getHash(inputData); lock.attemptsLeft--; @@ -269,7 +269,7 @@ namespace locks return sys::msgHandled(); } - sys::MessagePointer PhoneLockHandler::verifyPhoneLockChangeInput(const std::vector &inputData) + sys::MessagePointer PhoneLockHandler::verifyPhoneLockChangeInput(LockInput inputData) { if (lock.isState(Lock::LockState::NewInputRequired) || lock.isState(Lock::LockState::NewInputInvalid)) { storedInputData = inputData; diff --git a/module-apps/locks/handlers/PhoneLockHandler.hpp b/module-apps/locks/handlers/PhoneLockHandler.hpp index 4d54e8d2b53bfec9a806758a925f7b0a4610e0ce..f2ea94b3ce835d59c37749ca5cff8430acebf6e8 100644 --- a/module-apps/locks/handlers/PhoneLockHandler.hpp +++ b/module-apps/locks/handlers/PhoneLockHandler.hpp @@ -49,8 +49,8 @@ namespace locks void checkNewPhoneLock(); void resolvePhoneLockAction(); - sys::MessagePointer verifyPhoneUnlockInput(const std::vector &inputData); - sys::MessagePointer verifyPhoneLockChangeInput(const std::vector &inputData); + sys::MessagePointer verifyPhoneUnlockInput(LockInput inputData); + sys::MessagePointer verifyPhoneLockChangeInput(LockInput inputData); public: explicit PhoneLockHandler(sys::Service *owner, std::shared_ptr settings); @@ -63,7 +63,7 @@ namespace locks sys::MessagePointer handleChangePhoneLock(); sys::MessagePointer handleSetPhoneLock(); sys::MessagePointer handleSkipSetPhoneLock(); - sys::MessagePointer verifyPhoneLockInput(const std::vector &inputData); + sys::MessagePointer verifyPhoneLockInput(LockInput inputData); void enablePhoneLock(bool _phoneLockEnabled); void setPhoneLockHash(const std::string &value); diff --git a/module-apps/locks/handlers/PhoneLockSubject.cpp b/module-apps/locks/handlers/PhoneLockSubject.cpp index 5dfb6e25c14650a9c5346a9a5cbaf53105324b5b..053458dc4b2821f4c83544d87fbdad43931167f6 100644 --- a/module-apps/locks/handlers/PhoneLockSubject.cpp +++ b/module-apps/locks/handlers/PhoneLockSubject.cpp @@ -1,5 +1,5 @@ -//// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -//// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "PhoneLockSubject.hpp" @@ -50,7 +50,7 @@ namespace locks owner->bus.sendUnicast(std::make_shared(), app::manager::ApplicationManager::ServiceName); } - void PhoneLockSubject::verifyInput(const std::vector &inputData) + void PhoneLockSubject::verifyInput(LockInput inputData) { owner->bus.sendUnicast(std::make_shared(inputData), app::manager::ApplicationManager::ServiceName); diff --git a/module-apps/locks/handlers/PhoneLockSubject.hpp b/module-apps/locks/handlers/PhoneLockSubject.hpp index db735706e253e46ef56d209653b2f4c134527626..12d5d2e17bf5506ca07db8d2029f558ba1c5e344 100644 --- a/module-apps/locks/handlers/PhoneLockSubject.hpp +++ b/module-apps/locks/handlers/PhoneLockSubject.hpp @@ -3,6 +3,7 @@ #pragma once +#include #include namespace locks @@ -22,7 +23,7 @@ namespace locks void changePhoneLock(); void setPhoneLock(); void skipSetPhoneLock(); - void verifyInput(const std::vector &inputData); + void verifyInput(LockInput inputData); }; } // namespace locks diff --git a/module-apps/locks/handlers/PinLockHandler.cpp b/module-apps/locks/handlers/PinLockHandler.cpp deleted file mode 100644 index 271f30d757ed920655097c802845d0b5fc859981..0000000000000000000000000000000000000000 --- a/module-apps/locks/handlers/PinLockHandler.cpp +++ /dev/null @@ -1,314 +0,0 @@ -//// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -//// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "locks/data/LockData.hpp" -#include "PinLockHandler.hpp" -#include "locks/widgets/LockHash.hpp" -#include "application-desktop/ApplicationDesktop.hpp" -#include "application-desktop/windows/Names.hpp" -#include -#include -#include - -#include -#include - -namespace gui -{ - namespace - { - constexpr unsigned int default_screen_pin_size = 4; - constexpr unsigned int screen_nopin_size = 0; - constexpr unsigned int default_attempts = 4; - constexpr unsigned int blocked_sim_attempts = 0; - constexpr unsigned int sim_max_passcode_size = 8; - constexpr unsigned int sim_min_passcode_size = 4; - - constexpr inline auto serviceCellular = "ServiceCellular"; - } // namespace - - PinLockHandler::PinLockHandler(app::ApplicationDesktop *app) - : app(app), - screenLock(Store::GSM::SIM::NONE, Lock::LockState::InputRequired, Lock::LockType::Screen, default_attempts), - simLock(Store::GSM::SIM::NONE, Lock::LockState::Unlocked, Lock::LockType::SimPin, default_attempts) - { - simLock.setInputSizeBounds(sim_min_passcode_size, sim_max_passcode_size); - screenLock.setInputSizeBounds(default_screen_pin_size, default_screen_pin_size); - screenLock.setAutoActivate(true); - } - - void PinLockHandler::handlePasscodeParams(Lock::LockType type, - Lock::LockState state, - app::manager::actions::ActionParamsPtr &&data) - { - auto passcodeData = static_cast(data.get()); - if (simLock.isSim(passcodeData->getSim()) && simLock.isType(type) && simLock.isState(state) && - simLock.getAttemptsLeft() > passcodeData->getAttempts()) { - simLock.lockState = Lock::LockState::InputInvalid; - } - else { - simLock.lockState = state; - simLock.sim = passcodeData->getSim(); - simLock.lockType = type; - } - simLock.lockName = passcodeData->getPasscodeName(); - simLock.attemptsLeft = passcodeData->getAttempts(); - } - - void PinLockHandler::handlePasscodeRequest(Lock::LockType type, app::manager::actions::ActionParamsPtr &&data) - { - LOG_DEBUG("Handling on of PasscodeRequest actions"); - promptSimLockWindow = true; - handlePasscodeParams(type, Lock::LockState::InputRequired, std::move(data)); - if (!getStrongestLock().isType(Lock::LockType::Screen)) { - unlock(); - } - } - - void PinLockHandler::handlePinChangeRequest(app::manager::actions::ActionParamsPtr &&data) - { - LOG_DEBUG("Handling RequestPinChange action"); - handlePasscodeParams(Lock::LockType::SimPin, Lock::LockState::InputRequired, std::move(data)); - promptSimLockWindow = true; - auto onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) { - handlePasscodeChange(data); - }; - switchToPinLockWindow(onActivatedCallback); - } - - void PinLockHandler::handlePinEnableRequest(app::manager::actions::ActionParamsPtr &&data, - cellular::api::SimLockState simCardLock) - { - using namespace cellular::msg; - using namespace cellular::api; - LOG_DEBUG("Handling PinEnableRequest action, simCardLock = %d", static_cast(simCardLock)); - handlePasscodeParams(Lock::LockType::SimPin, Lock::LockState::InputRequired, std::move(data)); - promptSimLockWindow = true; - auto onActivatedCallback = [this, simCardLock](Lock::LockType, const cellular::api::SimCode &data) { - app->bus.sendUnicast(simCardLock, data); - }; - switchToPinLockWindow(onActivatedCallback); - } - - void PinLockHandler::handlePinEnableRequestFailed(cellular::api::SimLockState simCardLock) - { - LOG_DEBUG("Handling PinEnableRequestFailed action, simCardLock = %d, simLock.value = %u", - static_cast(simCardLock), - simLock.attemptsLeft); - using namespace app::manager::actions; - if (simLock.attemptsLeft > 0) { - --simLock.attemptsLeft; - } - else { - LOG_ERROR("Number of attempts left is equal to zero before decrementation!"); - } - if (simLock.attemptsLeft > 0) { - simLock.lockState = Lock::LockState::InputInvalid; - auto onActivatedCallback = [this, simCardLock](Lock::LockType type, const cellular::api::SimCode &data) { - auto params = std::make_unique( - Store::GSM::get()->selected, simLock.attemptsLeft, PasscodeParams::pinName); - handlePinEnableRequest(std::move(params), simCardLock); - }; - switchToPinLockWindow(Lock::LockState::InputInvalid, onActivatedCallback); - } - else { - auto params = std::make_unique( - Store::GSM::get()->selected, PasscodeParams::numOfAttemptsForEnteringPUK, PasscodeParams::pukName); - handlePasscodeRequest(gui::Lock::LockType::SimPuk, std::move(params)); - } - } - - void PinLockHandler::handlePinChangeRequestFailed() - { - LOG_DEBUG("Handling PinChangeRequestFailed action, simLock.value = %u", simLock.attemptsLeft); - using namespace app::manager::actions; - if (simLock.attemptsLeft > 0) { - --simLock.attemptsLeft; - } - else { - LOG_ERROR("Number of attempts left is equal to zero before decrementation!"); - } - if (simLock.attemptsLeft > 0) { - simLock.lockState = Lock::LockState::InputInvalid; - auto onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) { - auto params = std::make_unique( - Store::GSM::get()->selected, simLock.attemptsLeft, PasscodeParams::pinName); - handlePinChangeRequest(std::move(params)); - }; - switchToPinLockWindow(Lock::LockState::InputInvalid, onActivatedCallback); - } - else { - auto params = std::make_unique( - Store::GSM::get()->selected, PasscodeParams::numOfAttemptsForEnteringPUK, PasscodeParams::pukName); - handlePasscodeRequest(gui::Lock::LockType::SimPuk, std::move(params)); - } - } - - void PinLockHandler::handleSimBlocked(app::manager::actions::ActionParamsPtr &&data) - { - LOG_DEBUG("Handling BlockSim action"); - auto params = static_cast(data.get()); - promptSimLockWindow = true; - simLock.sim = params->getSim(); - simLock.lockState = gui::Lock::LockState::Blocked; - simLock.lockType = gui::Lock::LockType::SimPin; - simLock.attemptsLeft = blocked_sim_attempts; - unlock(); - } - - void PinLockHandler::handleUnlockSim(app::manager::actions::ActionParamsPtr &&data) - { - LOG_DEBUG("Handling UnlockSim action"); - promptSimLockWindow = false; - if (!simLock.isState(Lock::LockState::Unlocked)) { - simLock.lockState = Lock::LockState::Unlocked; - unlock(); - } - } - - void PinLockHandler::handleCMEError(app::manager::actions::ActionParamsPtr &&data) const - { - LOG_DEBUG("Handling DisplayCMEError action"); - auto params = static_cast(data.get()); - auto lock = std::make_unique( - params->getSim(), Lock::LockState::ErrorOccurred, Lock::LockType::SimPin, params->getCMECode()); - lock->onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) { - app->switchWindow(app::window::name::desktop_main_window); - }; - app->switchWindow( - app::window::name::desktop_pin_lock, gui::ShowMode::GUI_SHOW_INIT, std::make_unique(*lock)); - } - - void PinLockHandler::switchToPinLockWindow( - std::function onLockActivatedCallback) - { - auto lock = std::make_unique(getStrongestLock()); - if (lock->isState(Lock::LockState::InputInvalid)) { - getStrongestLock().consumeState(); - lock->onActivatedCallback = [this, onLockActivatedCallback](Lock::LockType, - const cellular::api::SimCode &) { - switchToPinLockWindow(onLockActivatedCallback); - }; - } - else if (lock->isState(gui::Lock::LockState::Blocked)) { - lock->onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) { - setSimLockHandled(); - app->switchWindow(app::window::name::desktop_main_window); - }; - } - else if (lock->isState(gui::Lock::LockState::Unlocked)) { - setSimLockHandled(); - app->switchWindow(app::window::name::desktop_main_window); - return; - } - else { - lock->onActivatedCallback = onLockActivatedCallback; - } - app->switchWindow( - app::window::name::desktop_pin_lock, gui::ShowMode::GUI_SHOW_INIT, std::make_unique(*lock)); - } - - void PinLockHandler::switchToPinLockWindow( - Lock::LockState state, - std::function onLockActivatedCallback) - { - auto lock = std::make_unique(getStrongestLock()); - lock->lockState = state; - lock->onActivatedCallback = onLockActivatedCallback; - app->switchWindow( - app::window::name::desktop_pin_lock, gui::ShowMode::GUI_SHOW_INIT, std::make_unique(*lock)); - } - - void PinLockHandler::handlePasscode(Lock::LockType type, const cellular::api::SimCode &passcode) - { - if (type == Lock::LockType::SimPin) { - setSimLockHandled(); - app->bus.sendUnicast(passcode); - } - else if (type == Lock::LockType::SimPuk) { - handlePasscodeChange(passcode); - } - } - - void PinLockHandler::handlePasscodeChange(const cellular::api::SimCode &passcode) - { - auto onActivatedCallback = [this, passcode](Lock::LockType, const cellular::api::SimCode &pin) { - handleNewPasscodeUnconfirmed(passcode, pin); - }; - switchToPinLockWindow(Lock::LockState::NewInputRequired, onActivatedCallback); - } - - void PinLockHandler::handleNewPasscodeUnconfirmed(const cellular::api::SimCode &passcode, - const cellular::api::SimCode &pin) - { - auto onActivatedCallback = [this, passcode, pin](Lock::LockType type, - const cellular::api::SimCode &pinConfirmed) { - if (pin == pinConfirmed) { - handleNewPasscodeConfirmed(type, passcode, pin); - } - else { - handleNewPasscodeInvalid(passcode); - } - }; - switchToPinLockWindow(Lock::LockState::NewInputConfirmRequired, onActivatedCallback); - } - - void PinLockHandler::handleNewPasscodeConfirmed(Lock::LockType type, - const cellular::api::SimCode &passcode, - const cellular::api::SimCode &pin) - { - using namespace cellular::msg; - if (type == Lock::LockType::SimPin) { - app->bus.sendUnicast(passcode, pin); - } - else if (type == Lock::LockType::SimPuk) { - app->bus.sendUnicast(passcode, pin); - } - } - - void PinLockHandler::handleNewPasscodeInvalid(const cellular::api::SimCode &passcode) - { - auto onActivatedCallback = [this, passcode](Lock::LockType type, const cellular::api::SimCode &pin) { - handlePasscodeChange(passcode); - }; - switchToPinLockWindow(Lock::LockState::NewInputInvalid, onActivatedCallback); - } - void PinLockHandler::unlock() - { - auto onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) { - handlePasscode(type, data); - }; - switchToPinLockWindow(onActivatedCallback); - } - - auto PinLockHandler::getStrongestLock() noexcept -> gui::Lock & - { - if (!screenLock.isState(Lock::LockState::Unlocked)) { - return screenLock; - } - else if (promptSimLockWindow && !simLock.isState(Lock::LockState::Unlocked)) { - return simLock; - } - return screenLock; - } - - void PinLockHandler::lockScreen() - { - screenLock.lockState = Lock::LockState::InputRequired; - } - - void PinLockHandler::unlockScreen() - { - if (getStrongestLock().isType(Lock::LockType::Screen)) { - screenLock.lockState = gui::Lock::LockState::Unlocked; - } - } - - void PinLockHandler::setSimLockHandled() noexcept - { - if (!getStrongestLock().isType(Lock::LockType::Screen)) { - promptSimLockWindow = false; - } - } - -} // namespace gui diff --git a/module-apps/locks/handlers/PinLockHandler.hpp b/module-apps/locks/handlers/PinLockHandler.hpp deleted file mode 100644 index 0efbf1b6d88db771e9dbd1ed70b16b5b63097f06..0000000000000000000000000000000000000000 --- a/module-apps/locks/handlers/PinLockHandler.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#pragma once - -#include "locks/widgets/Lock.hpp" - -#include -#include -#include - -namespace app -{ - class ApplicationDesktop; -} - -namespace gui -{ - using namespace locks; - - class PinLockHandler - { - app::ApplicationDesktop *app = nullptr; - Lock screenLock; - Lock simLock; - bool promptSimLockWindow = true; - - void handlePasscode(Lock::LockType type, const cellular::api::SimCode &passcode); - void handlePasscodeChange(const cellular::api::SimCode &passcode); - void handleNewPasscodeUnconfirmed(const cellular::api::SimCode &passcode, const cellular::api::SimCode &pin); - void handleNewPasscodeConfirmed(Lock::LockType type, - const cellular::api::SimCode &passcode, - const cellular::api::SimCode &pin); - void handleNewPasscodeInvalid(const cellular::api::SimCode &passcode); - void handlePasscodeParams(Lock::LockType type, - Lock::LockState state, - app::manager::actions::ActionParamsPtr &&data); - void switchToPinLockWindow( - std::function onLockActivatedCallback); - void switchToPinLockWindow( - Lock::LockState type, - std::function onLockActivatedCallback); - - auto getStrongestLock() noexcept -> gui::Lock &; - void unlock(); - void setSimLockHandled() noexcept; - - public: - PinLockHandler(app::ApplicationDesktop *app); - - void handlePasscodeRequest(Lock::LockType type, app::manager::actions::ActionParamsPtr &&data); - void handlePinChangeRequest(app::manager::actions::ActionParamsPtr &&data); - void handlePinEnableRequest(app::manager::actions::ActionParamsPtr &&data, - cellular::api::SimLockState simCardLock); - void handlePinEnableRequestFailed(cellular::api::SimLockState simCardLock); - void handleSimBlocked(app::manager::actions::ActionParamsPtr &&data); - void handleUnlockSim(app::manager::actions::ActionParamsPtr &&data); - void handleCMEError(app::manager::actions::ActionParamsPtr &&data) const; - void handlePinChangeRequestFailed(); - - [[nodiscard]] auto isScreenLocked() const noexcept -> bool - { - return !screenLock.isState(Lock::LockState::Unlocked); - } - [[nodiscard]] auto isScreenBlocked() const noexcept -> bool - { - return screenLock.isState(Lock::LockState::Blocked); - } - void lockScreen(); - void unlockScreen(); - }; -} // namespace gui diff --git a/module-apps/locks/handlers/SimLockHandler.cpp b/module-apps/locks/handlers/SimLockHandler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..62308a6d7f7132fab7040927a6c52b3a228e1be2 --- /dev/null +++ b/module-apps/locks/handlers/SimLockHandler.cpp @@ -0,0 +1,354 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "SimLockHandler.hpp" + +#include +#include +#include +#include + +#include +#include +#include + +namespace locks +{ + constexpr unsigned int default_attempts = 4; + constexpr unsigned int max_input_size = 8; + constexpr unsigned int min_input_size = 4; + + SimLockHandler::SimLockHandler(sys::Service *owner) + : owner(owner), lock(Lock::LockState::Unlocked, default_attempts) + { + lock.setInputSizeBounds(min_input_size, max_input_size); + } + + void SimLockHandler::clearStoredInputs() + { + storedFirstInput.clear(); + storedSecondInput.clear(); + } + + void SimLockHandler::setSimInputTypeAction(SimInputTypeAction _simInputTypeAction) + { + if (simInputTypeAction != _simInputTypeAction) { + simInputTypeAction = _simInputTypeAction; + lock.lockState = Lock::LockState::Unlocked; + } + } + + void SimLockHandler::simInputRequiredAction() + { + app::manager::Controller::sendAction( + owner, + app::manager::actions::ShowPopup, + std::make_unique(gui::popup::ID::SimLock, lock, simInputTypeAction)); + } + + void SimLockHandler::simErrorAction(unsigned int errorCode) + { + app::manager::Controller::sendAction(owner, + app::manager::actions::ShowPopup, + std::make_unique( + gui::popup::ID::SimLock, lock, simInputTypeAction, errorCode)); + } + + void SimLockHandler::simUnlockAction() + { + app::manager::Controller::sendAction(owner, + app::manager::actions::AbortPopup, + std::make_unique(gui::popup::ID::SimLock)); + } + + void SimLockHandler::simInfoAction() + { + app::manager::Controller::sendAction( + owner, + app::manager::actions::ShowPopup, + std::make_unique(gui::popup::ID::SimInfo, lock, simInputTypeAction)); + } + + void SimLockHandler::getSettingsSimSelect(const std::string &settingsSim) + { + auto selectedSim = magic_enum::enum_cast(settingsSim); + Store::GSM::get()->selected = selectedSim.value(); + + if ((selectedSim.value() == Store::GSM::SIM::SIM1 || selectedSim.value() == Store::GSM::SIM::SIM2)) { + setSim(static_cast(selectedSim.value())); + } + else { + Store::GSM::get()->selected = Store::GSM::SIM::NONE; + } + } + + void SimLockHandler::setSim(cellular::api::SimSlot simSlot) + { + owner->bus.sendUnicast(simSlot); + } + + sys::MessagePointer SimLockHandler::handleSimPinRequest(unsigned int attempts) + { + setSimInputTypeAction(SimInputTypeAction::UnlockWithPin); + lock.attemptsLeft = attempts; + lock.lockName = utils::enumToString(Store::GSM::get()->selected); + + if (simUnlockBlockOnLockedPhone) { + return sys::msgNotHandled(); + } + + if (lock.isState(Lock::LockState::Unlocked)) { + lock.lockState = Lock::LockState::InputRequired; + } + else if (lock.isState(Lock::LockState::InputRequired)) { + lock.lockState = Lock::LockState::InputInvalid; + } + + simInputRequiredAction(); + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::handleSimPukRequest(unsigned int attempts) + { + setSimInputTypeAction(SimInputTypeAction::UnlockWithPuk); + lock.attemptsLeft = attempts; + lock.lockName = utils::enumToString(Store::GSM::get()->selected); + + if (simUnlockBlockOnLockedPhone) { + return sys::msgNotHandled(); + } + + clearStoredInputs(); + + if (lock.isState(Lock::LockState::Unlocked)) { + lock.lockState = Lock::LockState::InputRequired; + } + else if (lock.isState(Lock::LockState::InputRequired) || + lock.isState(Lock::LockState::NewInputConfirmRequired)) { + lock.lockState = Lock::LockState::InputInvalid; + } + + simInputRequiredAction(); + + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::handleSimUnlockedMessage() + { + lock.lockState = Lock::LockState::Unlocked; + + if (simInputTypeAction == SimInputTypeAction::UnlockWithPuk || + simInputTypeAction == SimInputTypeAction::ChangePin) { + simInfoAction(); + } + + simUnlockAction(); + + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::handleSimChangedMessage() + { + lock.lockState = Lock::LockState::Unlocked; + simInfoAction(); + simUnlockAction(); + + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::handleSimAvailabilityMessage() + { + lock.lockState = Lock::LockState::Unlocked; + simInfoAction(); + simUnlockAction(); + + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::handleSimPinChangeRequest() + { + setSimInputTypeAction(SimInputTypeAction::ChangePin); + + lock.lockName = utils::enumToString(Store::GSM::get()->selected); + lock.lockState = Lock::LockState::InputRequired; + simInputRequiredAction(); + + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::handleSimPinChangeFailedRequest() + { + clearStoredInputs(); + + lock.lockName = utils::enumToString(Store::GSM::get()->selected); + lock.lockState = Lock::LockState::InputInvalid; + simInputRequiredAction(); + + return sys::MessagePointer(); + } + + sys::MessagePointer SimLockHandler::handleSimEnableRequest() + { + setSimInputTypeAction(SimInputTypeAction::EnablePin); + + lock.lockName = utils::enumToString(Store::GSM::get()->selected); + lock.lockState = Lock::LockState::InputRequired; + simInputRequiredAction(); + + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::handleSimDisableRequest() + { + setSimInputTypeAction(SimInputTypeAction::DisablePin); + + lock.lockName = utils::enumToString(Store::GSM::get()->selected); + lock.lockState = Lock::LockState::InputRequired; + simInputRequiredAction(); + + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::handleSimBlockedRequest() + { + setSimInputTypeAction(SimInputTypeAction::Blocked); + + if (simUnlockBlockOnLockedPhone) { + return sys::msgNotHandled(); + } + + lock.lockName = utils::enumToString(Store::GSM::get()->selected); + lock.lockState = Lock::LockState::Blocked; + simInputRequiredAction(); + + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::handleCMEErrorRequest(unsigned int errorCode) + { + setSimInputTypeAction(SimInputTypeAction::Error); + + if (simUnlockBlockOnLockedPhone) { + storedErrorCode = errorCode; + return sys::msgNotHandled(); + } + + lock.lockName = utils::enumToString(Store::GSM::get()->selected); + lock.lockState = Lock::LockState::ErrorOccurred; + simErrorAction(errorCode); + + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::processLockWithNewInput(LockInput inputData) + { + if (lock.isState(Lock::LockState::InputRequired) || (lock.isState(Lock::LockState::InputInvalid))) { + + storedFirstInput = inputData; + lock.lockState = Lock::LockState::NewInputRequired; + simInputRequiredAction(); + } + else if (lock.isState(Lock::LockState::NewInputRequired) || lock.isState(Lock::LockState::NewInputInvalid)) { + + storedSecondInput = inputData; + lock.lockState = Lock::LockState::NewInputConfirmRequired; + simInputRequiredAction(); + } + else if (lock.isState(Lock::LockState::NewInputConfirmRequired)) { + + if (storedSecondInput == inputData) { + return resolveNewInputAction(storedFirstInput, inputData); + } + + lock.lockState = Lock::LockState::NewInputInvalid; + simInputRequiredAction(); + } + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::verifySimLockInput(LockInput inputData) + { + switch (simInputTypeAction) { + case SimInputTypeAction::UnlockWithPin: + return unlockSimWithPin(inputData); + case SimInputTypeAction::UnlockWithPuk: + return processLockWithNewInput(inputData); + case SimInputTypeAction::ChangePin: + return processLockWithNewInput(inputData); + case SimInputTypeAction::EnablePin: + return enableSimPin(inputData); + case SimInputTypeAction::DisablePin: + return disableSimPin(inputData); + default: + return sys::msgNotHandled(); + } + } + + void SimLockHandler::setSimUnlockBlockOnLockedPhone() + { + simUnlockBlockOnLockedPhone = true; + } + + sys::MessagePointer SimLockHandler::releaseSimUnlockBlockOnLockedPhone() + { + if (simUnlockBlockOnLockedPhone) { + simUnlockBlockOnLockedPhone = false; + if (simInputTypeAction == SimInputTypeAction::UnlockWithPin) { + return handleSimPinRequest(lock.getAttemptsLeft()); + } + else if (simInputTypeAction == SimInputTypeAction::UnlockWithPuk) { + return handleSimPukRequest(lock.getAttemptsLeft()); + } + else if (simInputTypeAction == SimInputTypeAction::Blocked) { + return handleSimBlockedRequest(); + } + else if (simInputTypeAction == SimInputTypeAction::Error) { + return handleCMEErrorRequest(storedErrorCode); + } + } + return sys::msgNotHandled(); + } + + sys::MessagePointer SimLockHandler::resolveNewInputAction(LockInput firstInputData, LockInput secondInputData) + { + if (simInputTypeAction == SimInputTypeAction::UnlockWithPuk) { + return unlockSimWithPuk(firstInputData, secondInputData); + } + else if (simInputTypeAction == SimInputTypeAction::ChangePin) { + return changeSimPin(firstInputData, secondInputData); + } + return sys::msgNotHandled(); + } + + sys::MessagePointer SimLockHandler::unlockSimWithPin(LockInput pinInputData) + { + owner->bus.sendUnicast(pinInputData); + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::unlockSimWithPuk(LockInput pukInputData, LockInput newPinInputData) + { + owner->bus.sendUnicast(pukInputData, newPinInputData); + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::changeSimPin(LockInput oldPinInputData, LockInput newPinInputData) + { + owner->bus.sendUnicast(oldPinInputData, newPinInputData); + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::enableSimPin(LockInput pinInputData) + { + owner->bus.sendUnicast(cellular::api::SimLockState::Enabled, + pinInputData); + return sys::msgHandled(); + } + + sys::MessagePointer SimLockHandler::disableSimPin(LockInput pinInputData) + { + owner->bus.sendUnicast(cellular::api::SimLockState::Disabled, + pinInputData); + return sys::msgHandled(); + } +} // namespace locks diff --git a/module-apps/locks/handlers/SimLockHandler.hpp b/module-apps/locks/handlers/SimLockHandler.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9558f6627530af51bebd2d14611559ba5b84fe95 --- /dev/null +++ b/module-apps/locks/handlers/SimLockHandler.hpp @@ -0,0 +1,68 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include +#include +#include + +#include + +namespace locks +{ + using StoredLockInput = std::vector; + + class SimLockHandler + { + private: + sys::Service *owner; + Lock lock; + + SimInputTypeAction simInputTypeAction = SimInputTypeAction::UnlockWithPin; + unsigned int storedErrorCode = 0; + bool simUnlockBlockOnLockedPhone = false; + StoredLockInput storedFirstInput; + StoredLockInput storedSecondInput; + + void clearStoredInputs(); + void setSimInputTypeAction(SimInputTypeAction _simInputTypeAction); + + void simInputRequiredAction(); + void simErrorAction(unsigned int errorCode); + void simUnlockAction(); + void simInfoAction(); + + sys::MessagePointer unlockSimWithPin(LockInput pinInputData); + sys::MessagePointer processLockWithNewInput(LockInput inputData); + sys::MessagePointer resolveNewInputAction(LockInput firstInputData, LockInput secondInputData); + sys::MessagePointer unlockSimWithPuk(LockInput pukInputData, LockInput newPinInputData); + sys::MessagePointer changeSimPin(LockInput oldPinInputData, LockInput newPinInputData); + sys::MessagePointer enableSimPin(LockInput pinInputData); + sys::MessagePointer disableSimPin(LockInput pinInputData); + + public: + explicit SimLockHandler(sys::Service *owner); + + void setSimUnlockBlockOnLockedPhone(); + sys::MessagePointer releaseSimUnlockBlockOnLockedPhone(); + + sys::MessagePointer verifySimLockInput(LockInput inputData); + + sys::MessagePointer handleSimPinRequest(unsigned int attempts); + sys::MessagePointer handleSimPukRequest(unsigned int attempts); + sys::MessagePointer handleSimPinChangeRequest(); + sys::MessagePointer handleSimPinChangeFailedRequest(); + sys::MessagePointer handleSimEnableRequest(); + sys::MessagePointer handleSimDisableRequest(); + sys::MessagePointer handleSimBlockedRequest(); + sys::MessagePointer handleCMEErrorRequest(unsigned int errorCode); + sys::MessagePointer handleSimUnlockedMessage(); + sys::MessagePointer handleSimChangedMessage(); + sys::MessagePointer handleSimAvailabilityMessage(); + + void getSettingsSimSelect(const std::string &settingsSim); + void setSim(cellular::api::SimSlot simSlot); + }; + +} // namespace locks diff --git a/module-apps/locks/handlers/SimLockSubject.cpp b/module-apps/locks/handlers/SimLockSubject.cpp new file mode 100644 index 0000000000000000000000000000000000000000..04186ad872deb990104dc2a97f107f2d6b06a2f6 --- /dev/null +++ b/module-apps/locks/handlers/SimLockSubject.cpp @@ -0,0 +1,43 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "SimLockSubject.hpp" + +#include +#include + +namespace locks +{ + SimLockSubject::SimLockSubject(sys::Service *owner) : owner{owner} + { + if (owner == nullptr) { + throw std::invalid_argument{"Subject's owner is invalid"}; + } + } + + void SimLockSubject::setSim(cellular::api::SimSlot simSlot) + { + owner->bus.sendUnicast(std::make_shared(simSlot), app::manager::ApplicationManager::ServiceName); + } + + void SimLockSubject::changeSimPin() + { + owner->bus.sendUnicast(std::make_shared(), app::manager::ApplicationManager::ServiceName); + } + + void SimLockSubject::enableSimPin() + { + owner->bus.sendUnicast(std::make_shared(), app::manager::ApplicationManager::ServiceName); + } + + void SimLockSubject::disableSimPin() + { + owner->bus.sendUnicast(std::make_shared(), app::manager::ApplicationManager::ServiceName); + } + + void SimLockSubject::verifyInput(LockInput inputData) + { + owner->bus.sendUnicast(std::make_shared(inputData), + app::manager::ApplicationManager::ServiceName); + } +} // namespace locks diff --git a/module-apps/locks/handlers/SimLockSubject.hpp b/module-apps/locks/handlers/SimLockSubject.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4df339a5c4618e52eafaf82001b1feb91c276e48 --- /dev/null +++ b/module-apps/locks/handlers/SimLockSubject.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include + +#include +#include + +namespace locks +{ + class SimLockSubject + { + private: + sys::Service *owner; + + public: + explicit SimLockSubject(sys::Service *owner); + + void setSim(cellular::api::SimSlot simSlot); + void changeSimPin(); + void enableSimPin(); + void disableSimPin(); + void verifyInput(LockInput inputData); + }; + +} // namespace locks diff --git a/module-apps/locks/widgets/Lock.cpp b/module-apps/locks/widgets/Lock.cpp index 7bbff68d58caf81fc93596193bf44f6d4496c774..55520a4b0db91fda91c01253b05800a42979d6c3 100644 --- a/module-apps/locks/widgets/Lock.cpp +++ b/module-apps/locks/widgets/Lock.cpp @@ -24,9 +24,6 @@ namespace locks if (maxInputSize > inputValue.size()) { inputValue.push_back(c); } - if (canVerify() && autoActivate && onActivatedCallback != nullptr) { - onActivatedCallback(lockType, inputValue); - } } void Lock::popChar() @@ -41,13 +38,4 @@ namespace locks inputValue.clear(); } - void Lock::activate() - { - if (!onActivatedCallback) { - LOG_ERROR("Passcode verification callback null"); - return; - } - onActivatedCallback(lockType, inputValue); - clearAttempt(); - } } // namespace locks diff --git a/module-apps/locks/widgets/Lock.hpp b/module-apps/locks/widgets/Lock.hpp index 344da7a3736bf2e6f620c58f44a6c772a850b672..4a7255fa3cab33ab533d5db5617a1ce4e909bb20 100644 --- a/module-apps/locks/widgets/Lock.hpp +++ b/module-apps/locks/widgets/Lock.hpp @@ -7,26 +7,14 @@ #include #include -#include - -namespace gui -{ - class PinLockHandler; -} // namespace gui - namespace locks { class PhoneLockHandler; + class SimLockHandler; class Lock { public: - enum class LockType - { - SimPin, - SimPuk, - Screen - }; enum class LockState { @@ -44,10 +32,6 @@ namespace locks { return lockState; } - [[nodiscard]] LockType getLockType() const noexcept - { - return lockType; - } [[nodiscard]] unsigned int getMaxInputSize() const noexcept { return maxInputSize; @@ -73,26 +57,14 @@ namespace locks { return attemptsLeft; } - [[nodiscard]] bool isSim(Store::GSM::SIM _sim) const noexcept - { - return sim == _sim; - } [[nodiscard]] bool isState(LockState state) const noexcept { return lockState == state; } - [[nodiscard]] bool isType(LockType type) const noexcept - { - return lockType == type; - } [[nodiscard]] const std::string &getLockName() const noexcept { return lockName; } - [[nodiscard]] Store::GSM::SIM getSim() const noexcept - { - return sim; - } void putNextChar(unsigned int c); /// removes a last character passed to Lock via putNextChar. The last character can not be popped @@ -102,37 +74,23 @@ namespace locks /// consumes LockState::InputInvalid state and LockState::NewInputInvalid void consumeState() noexcept; /// calls - void activate(); - Lock(Store::GSM::SIM sim, LockState state, LockType type, unsigned int attemptsLeft = unlimitedNumOfAttempts) - : sim{sim}, lockState{state}, lockType{type}, attemptsLeft{attemptsLeft} - {} - - Lock(LockState state, unsigned int attemptsLeft = unlimitedNumOfAttempts) + explicit Lock(LockState state, unsigned int attemptsLeft = unlimitedNumOfAttempts) : lockState{state}, attemptsLeft{attemptsLeft} {} - std::function &)> onActivatedCallback = nullptr; - private: std::string lockName; - Store::GSM::SIM sim = Store::GSM::SIM::NONE; LockState lockState = LockState::Unlocked; - LockType lockType = LockType::Screen; unsigned int attemptsLeft = 0; std::vector inputValue; unsigned int maxInputSize = defaultInputSize; unsigned int minInputSize = defaultInputSize; - bool autoActivate = false; static constexpr unsigned int defaultInputSize = 4; static constexpr unsigned int unlimitedNumOfAttempts = std::numeric_limits::max(); - void setAutoActivate(bool _autoActivate) - { - autoActivate = _autoActivate; - } void setInputSizeBounds(unsigned int _minInputSize, unsigned int _maxInputSize) { minInputSize = _minInputSize; @@ -140,7 +98,7 @@ namespace locks } friend class PhoneLockHandler; - friend class gui::PinLockHandler; + friend class SimLockHandler; }; } // namespace lock diff --git a/module-apps/locks/widgets/LockBox.hpp b/module-apps/locks/widgets/LockBox.hpp index 44cb620e64b0a1bb9d03ac71a5e1471f95bc4ff0..8ffedae6162d0e8bc5af17b1c7559570ecc1c9e6 100644 --- a/module-apps/locks/widgets/LockBox.hpp +++ b/module-apps/locks/widgets/LockBox.hpp @@ -21,7 +21,6 @@ namespace gui { InvalidInput, NewInputConfirmFailed, - UnhandledError }; virtual void popChar(unsigned int charNum) = 0; @@ -31,6 +30,7 @@ namespace gui virtual void setVisibleStateInputRequired(InputActionType type) = 0; virtual void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) = 0; virtual void setVisibleStateBlocked() = 0; + virtual void setVisibleStateError(unsigned int errorCode) = 0; virtual void buildLockBox(unsigned int inputSize) = 0; virtual ~LockBox() = default; diff --git a/module-apps/locks/widgets/LockBoxAlternatingSize.cpp b/module-apps/locks/widgets/LockBoxAlternatingSize.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0d71434dafc39e7ad30a32d64d3f28a44a3d4ab3 --- /dev/null +++ b/module-apps/locks/widgets/LockBoxAlternatingSize.cpp @@ -0,0 +1,47 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "Lock.hpp" +#include "LockBoxAlternatingSize.hpp" + +#include +#include + +namespace gui +{ + void LockBoxAlternatingSize::buildLockBox(unsigned int pinSize) + { + buildPinLabels(0); + } + + void LockBoxAlternatingSize::clear() + { + lockWindow->pinLabelsBox->erase(); + buildPinLabels(0); + } + + void LockBoxAlternatingSize::popChar(unsigned int charNum) + { + buildPinLabels(charNum); + } + + void LockBoxAlternatingSize::putChar(unsigned int charNum) + { + buildPinLabels(charNum + 1); + } + + void LockBoxAlternatingSize::buildPinLabels(unsigned int pinSize) + { + if (lockWindow->pinLabelsBox) { + lockWindow->pinLabelsBox->erase(); + } + + auto itemBuilder = []() { + auto label = new gui::Image("dot_12px_hard_alpha_W_G"); + return label; + }; + + lockWindow->buildPinLabels(itemBuilder, pinSize); + lockWindow->pinLabelsBox->setEdges(RectangleEdge::Bottom); + } +} // namespace gui diff --git a/module-apps/locks/widgets/LockBoxAlternatingSize.hpp b/module-apps/locks/widgets/LockBoxAlternatingSize.hpp new file mode 100644 index 0000000000000000000000000000000000000000..cc077d1bae1b4f8de7934f4895ec2d26f4c7d435 --- /dev/null +++ b/module-apps/locks/widgets/LockBoxAlternatingSize.hpp @@ -0,0 +1,30 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include "LockBox.hpp" + +#include +#include + +namespace gui +{ + class LockBoxAlternatingSize : public LockBox + { + public: + void buildLockBox(unsigned int pinSize) override; + void clear() final; + void popChar(unsigned int charNum) final; + void putChar(unsigned int charNum) final; + + protected: + explicit LockBoxAlternatingSize(LockInputWindow *lockBaseWindow) : lockWindow(lockBaseWindow) + {} + + void buildPinLabels(unsigned int pinSize); + + private: + LockInputWindow *lockWindow; + }; +} // namespace gui diff --git a/module-apps/locks/widgets/PhoneLockBaseBox.cpp b/module-apps/locks/widgets/LockBoxConstantSize.cpp similarity index 55% rename from module-apps/locks/widgets/PhoneLockBaseBox.cpp rename to module-apps/locks/widgets/LockBoxConstantSize.cpp index b55c2f29169d93d5ec3748c4cee840d519e9033c..7206f84edca59263bc0ba3825643adb7e4385adb 100644 --- a/module-apps/locks/widgets/PhoneLockBaseBox.cpp +++ b/module-apps/locks/widgets/LockBoxConstantSize.cpp @@ -1,74 +1,72 @@ // Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md -#include "locks/data/LockStyle.hpp" -#include "locks/windows/PinLockBaseWindow.hpp" #include "Lock.hpp" -#include "PhoneLockBaseBox.hpp" +#include "LockBoxConstantSize.hpp" -namespace label_style = style::window::pin_lock::pin_label; +#include +#include namespace gui { - void PhoneLockBaseBox::buildLockBox(unsigned int pinSize) + void LockBoxConstantSize::buildLockBox(unsigned int pinSize) { buildPinLabels(pinSize); } - void PhoneLockBaseBox::clear() + void LockBoxConstantSize::clear() { for (unsigned i = 0; i < inputLabels.size(); i++) { popChar(i); } } - void PhoneLockBaseBox::popChar(unsigned int charNum) + void LockBoxConstantSize::popChar(unsigned int charNum) { if (charNum < inputLabels.size()) { inputLabels[charNum]->setVisibleState(false); } } - void PhoneLockBaseBox::putChar(unsigned int charNum) + void LockBoxConstantSize::putChar(unsigned int charNum) { if (charNum < inputLabels.size()) { inputLabels[charNum]->setVisibleState(true); } } - void PhoneLockBaseBox::buildPinLabels(unsigned int pinSize) + void LockBoxConstantSize::buildPinLabels(unsigned int pinSize) { - constexpr auto pinLabelWidth = style::window::default_body_width; + using namespace style::window::lock_input; + inputLabels.clear(); if (pinSize == 0) { return; } - unsigned int singleLabelWidth = label_style::size; - unsigned int maxNoMarginsLabelsWidth = pinLabelWidth - pinSize * 2 * label_style::margin; + unsigned int singleLabelWidth = input_box::h; + unsigned int maxNoMarginsLabelsWidth = input_box::w - pinSize * 2 * input_box::label_margin; if (pinSize * singleLabelWidth > maxNoMarginsLabelsWidth) { singleLabelWidth = maxNoMarginsLabelsWidth / pinSize; } auto itemBuilder = [this, singleLabelWidth]() { - auto label = new InputLabel(nullptr, singleLabelWidth, label_style::size); + auto label = new InputLabel(nullptr, singleLabelWidth, input_box::h); label->setEdges(RectangleEdge::Bottom); - label->setMargins(Margins(label_style::margin, 0, label_style::margin, 0)); + label->setMargins(Margins(input_box::label_margin, 0, input_box::label_margin, 0)); inputLabels.push_back(label); return label; }; - lockWindow->buildPinLabels( - itemBuilder, pinSize, style::window::default_left_margin, label_style::y, pinLabelWidth); - lockWindow->pinLabelsBox->setEdges(RectangleEdge::None); + lockWindow->buildPinLabels(itemBuilder, pinSize); } - PhoneLockBaseBox::InputLabel::InputLabel(Item *parent, uint32_t w, uint32_t h) : HBox(parent, 0, 0, w, h) + LockBoxConstantSize::InputLabel::InputLabel(Item *parent, uint32_t w, uint32_t h) : HBox(parent, 0, 0, w, h) {} - void PhoneLockBaseBox::InputLabel::setVisibleState(bool isImageVisible) + void LockBoxConstantSize::InputLabel::setVisibleState(bool isImageVisible) { if (isImageVisible && image == nullptr) { image = new gui::Image("dot_12px_hard_alpha_W_G"); diff --git a/module-apps/locks/widgets/PhoneLockBaseBox.hpp b/module-apps/locks/widgets/LockBoxConstantSize.hpp similarity index 61% rename from module-apps/locks/widgets/PhoneLockBaseBox.hpp rename to module-apps/locks/widgets/LockBoxConstantSize.hpp index a888080422e00fae01b7ca42a41e5bd9228eb90c..d910ad438c72c97f94208e6b28720cecbb43c253 100644 --- a/module-apps/locks/widgets/PhoneLockBaseBox.hpp +++ b/module-apps/locks/widgets/LockBoxConstantSize.hpp @@ -3,32 +3,28 @@ #pragma once -#include "Image.hpp" #include "LockBox.hpp" -#include "locks/windows/LockWindow.hpp" + +#include +#include namespace gui { - class PhoneLockBaseBox : public LockBox + class LockBoxConstantSize : public LockBox { public: - explicit PhoneLockBaseBox(LockWindow *lockBaseWindow) : lockWindow(lockBaseWindow) - {} - void buildLockBox(unsigned int pinSize) override; void clear() final; void popChar(unsigned int charNum) final; void putChar(unsigned int charNum) final; - private: - void buildPinLabels(unsigned int pinSize); - void setVisibleStateBlocked() override - {} - void setVisibleStateInputRequired(InputActionType type) override - {} - void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) override + protected: + explicit LockBoxConstantSize(LockInputWindow *lockBaseWindow) : lockWindow(lockBaseWindow) {} + void buildPinLabels(unsigned int pinSize); + + private: struct InputLabel : public HBox { InputLabel(Item *parent, uint32_t w, uint32_t h); @@ -37,7 +33,7 @@ namespace gui gui::Image *image = nullptr; }; - LockWindow *lockWindow; + LockInputWindow *lockWindow; std::vector inputLabels; }; } // namespace gui diff --git a/module-apps/locks/widgets/LockHash.hpp b/module-apps/locks/widgets/LockHash.hpp index 44c5789bbdb7fa43f0dc93cf6762d9c404607c75..20218a5d37e50920e600c3e748839e71336aa7de 100644 --- a/module-apps/locks/widgets/LockHash.hpp +++ b/module-apps/locks/widgets/LockHash.hpp @@ -3,6 +3,8 @@ #pragma once +#include + #include #include #include @@ -20,7 +22,7 @@ template <> struct std::hash> } }; -static inline uint32_t getHash(const std::vector &input) +static inline uint32_t getHash(locks::LockInput input) { static std::hash> hashEngine; return hashEngine(input); diff --git a/module-apps/locks/widgets/PhoneLockBox.cpp b/module-apps/locks/widgets/PhoneLockBox.cpp index 7ca0cc766e294a33872dc5edb65b9bbe6aa0531f..b8eb58e10632b82e32765e99d58a295b6cfd77e5 100644 --- a/module-apps/locks/widgets/PhoneLockBox.cpp +++ b/module-apps/locks/widgets/PhoneLockBox.cpp @@ -10,26 +10,7 @@ namespace gui void PhoneLockBox::buildLockBox(unsigned int pinSize) { - LockWindow->buildImages("pin_lock", "pin_lock_info"); - PhoneLockBaseBox::buildLockBox(pinSize); - } - - top_bar::Configuration PhoneLockBox::configureTopBarLocked() - { - top_bar::Configuration appConfiguration; - appConfiguration.disable(top_bar::Indicator::Time); - appConfiguration.enable(top_bar::Indicator::Lock); - - return appConfiguration; - } - - top_bar::Configuration PhoneLockBox::configureTopBarUnLocked() - { - top_bar::Configuration appConfiguration; - appConfiguration.enable(top_bar::Indicator::Time); - appConfiguration.disable(top_bar::Indicator::Lock); - - return appConfiguration; + LockBoxConstantSize::buildLockBox(pinSize); } void PhoneLockBox::applyLockActionText(locks::PhoneLockInputTypeAction phoneLockInputTypeAction) @@ -37,7 +18,6 @@ namespace gui switch (phoneLockInputTypeAction) { case locks::PhoneLockInputTypeAction::Unlock: LockWindow->setTitleBar(false, false); - LockWindow->configureTopBar(configureTopBarLocked()); textForInputRequired = "phone_lock_unlock"; textForInvalidInput = "phone_lock_unlock_invalid"; leftBottomBarState = false; @@ -47,8 +27,7 @@ namespace gui case locks::PhoneLockInputTypeAction::ConfirmCurrent: case locks::PhoneLockInputTypeAction::Change: LockWindow->setTitleBar(true, false); - LockWindow->setText("phone_lock_configure", LockWindow::TextType::Title); - LockWindow->configureTopBar(configureTopBarUnLocked()); + LockWindow->setText("phone_lock_configure", LockInputWindow::TextType::Title); textForInputRequired = "phone_lock_current"; textForInvalidInput = "phone_lock_invalid"; @@ -58,8 +37,7 @@ namespace gui break; case locks::PhoneLockInputTypeAction::Set: LockWindow->setTitleBar(true, false); - LockWindow->setText("phone_lock_configure", LockWindow::TextType::Title); - LockWindow->configureTopBar(configureTopBarUnLocked()); + LockWindow->setText("phone_lock_configure", LockInputWindow::TextType::Title); textForInputRequired = "phone_lock_current"; textForInvalidInput = "phone_lock_invalid_retry"; @@ -74,30 +52,35 @@ namespace gui void PhoneLockBox::setVisibleStateBlocked() { - LockWindow->setText("phone_lock_blocked", LockWindow::TextType::Primary); - LockWindow->setImagesVisible(false, true); + LockWindow->setText("phone_lock_blocked", LockInputWindow::TextType::Primary); + LockWindow->setImage("info_icon_W_G"); LockWindow->setBottomBarWidgetsActive(false, true, false); } + void PhoneLockBox::setVisibleStateError(unsigned int errorCode) + { + LOG_ERROR("No use case for UnhandledError"); + } + void PhoneLockBox::setVisibleStateInputRequired(InputActionType type) { LockWindow->pinLabelsBox->setVisible(true); switch (type) { case LockBox::InputActionType::ProvideInput: { - LockWindow->setText(textForInputRequired, PinLockBaseWindow::TextType::Primary); + LockWindow->setText(textForInputRequired, LockInputWindow::TextType::Primary); break; } case LockBox::InputActionType::ProvideNewInput: { - LockWindow->setText(textForProvideNewInput, PinLockBaseWindow::TextType::Primary); + LockWindow->setText(textForProvideNewInput, LockInputWindow::TextType::Primary); break; } case LockBox::InputActionType::ConfirmNewInput: - LockWindow->setText(textForConfirmNewInput, PinLockBaseWindow::TextType::Primary); + LockWindow->setText(textForConfirmNewInput, LockInputWindow::TextType::Primary); break; } - LockWindow->setImagesVisible(true, false); + LockWindow->setImage("unlock_icon_W_G"); LockWindow->setBottomBarWidgetsActive(leftBottomBarState, false, true); } @@ -106,28 +89,26 @@ namespace gui switch (type) { case LockBox::InputErrorType::InvalidInput: if (value == 1) { - LockWindow->setText("phone_lock_unlock_last_attempt", LockWindow::TextType::Primary); + LockWindow->setText("phone_lock_unlock_last_attempt", LockInputWindow::TextType::Primary); LockWindow->setText("phone_lock_unlock_last_attempt_warning", - LockWindow::TextType::Secondary, - {{LockWindow->getToken(LockWindow::Token::Mins), timeToUnlock}}); + LockInputWindow::TextType::Secondary, + {{LockWindow->getToken(LockInputWindow::Token::Mins), timeToUnlock}}); } else { - LockWindow->setText(textForInvalidInput, - LockWindow::TextType::Primary, - {{LockWindow->getToken(LockWindow::Token::Attempts), static_cast(value)}}); + LockWindow->setText( + textForInvalidInput, + LockInputWindow::TextType::Primary, + {{LockWindow->getToken(LockInputWindow::Token::Attempts), static_cast(value)}}); } break; case LockBox::InputErrorType::NewInputConfirmFailed: LockWindow->setText(textForInvalidInput, - LockWindow::TextType::Primary, - {{LockWindow->getToken(LockWindow::Token::Attempts), static_cast(value)}}); - break; - case LockBox::InputErrorType::UnhandledError: - LOG_ERROR("No use case for UnhandledError"); + LockInputWindow::TextType::Primary, + {{LockWindow->getToken(LockInputWindow::Token::Attempts), static_cast(value)}}); break; } - LockWindow->setImagesVisible(false, true); + LockWindow->setImage("info_icon_W_G"); LockWindow->setBottomBarWidgetsActive(false, true, true); } } // namespace gui diff --git a/module-apps/locks/widgets/PhoneLockBox.hpp b/module-apps/locks/widgets/PhoneLockBox.hpp index 3479477b18066d4ad1c69ca3137337a3dfeb865a..93c707f00418769cda0e41e6afee640bb80cebf2 100644 --- a/module-apps/locks/widgets/PhoneLockBox.hpp +++ b/module-apps/locks/widgets/PhoneLockBox.hpp @@ -4,18 +4,18 @@ #pragma once #include "locks/data/LockData.hpp" -#include "locks/windows/PinLockBaseWindow.hpp" -#include "PhoneLockBaseBox.hpp" +#include "locks/windows/LockInputWindow.hpp" +#include "LockBoxConstantSize.hpp" namespace gui { - class PhoneLockBox : public PhoneLockBaseBox + class PhoneLockBox : public LockBoxConstantSize { public: explicit PhoneLockBox( - PinLockBaseWindow *LockBaseWindow, + LockInputWindow *LockBaseWindow, locks::PhoneLockInputTypeAction phoneLockInputTypeAction = locks::PhoneLockInputTypeAction::Unlock) - : PhoneLockBaseBox(LockBaseWindow), LockWindow(LockBaseWindow) + : LockBoxConstantSize(LockBaseWindow), LockWindow(LockBaseWindow) { applyLockActionText(phoneLockInputTypeAction); } @@ -23,14 +23,12 @@ namespace gui private: void buildLockBox(unsigned int pinSize) final; void setVisibleStateBlocked() final; + void setVisibleStateError(unsigned int errorCode) final; void setVisibleStateInputRequired(InputActionType type) final; void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) final; void applyLockActionText(locks::PhoneLockInputTypeAction phoneLockInputTypeAction); - [[nodiscard]] top_bar::Configuration configureTopBarLocked(); - [[nodiscard]] top_bar::Configuration configureTopBarUnLocked(); - - PinLockBaseWindow *LockWindow; + LockInputWindow *LockWindow; std::string textForInputRequired; std::string textForInvalidInput; std::string textForProvideNewInput; diff --git a/module-apps/locks/widgets/PukLockBox.cpp b/module-apps/locks/widgets/PukLockBox.cpp deleted file mode 100644 index 7b87107427ff43cf7da3011b6704d0d9b483db11..0000000000000000000000000000000000000000 --- a/module-apps/locks/widgets/PukLockBox.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "PukLockBox.hpp" - -#include "locks/data/LockStyle.hpp" -#include "locks/windows/PinLockBaseWindow.hpp" -#include "Lock.hpp" -#include "gui/widgets/Image.hpp" -#include -#include - -namespace label_style = style::window::pin_lock::pin_label; -namespace gui -{ - void PukLockBox::popChar(unsigned int charNum) - { - rebuildInputLabels(charNum); - } - void PukLockBox::putChar(unsigned int charNum) - { - rebuildInputLabels(++charNum); - } - void PukLockBox::buildLockBox(unsigned int inputSize) - { - LockWindow->buildImages("pin_lock", "pin_lock_info"); - buildInputLabels(0); - } - void PukLockBox::buildInputLabels(unsigned int inputSize) - { - auto itemBuilder = []() { - auto label = new gui::Image("dot_12px_hard_alpha_W_G"); - return label; - }; - - LockWindow->buildPinLabels(itemBuilder, inputSize, label_style::x, label_style::y, label_style::w); - LockWindow->pinLabelsBox->setEdges(RectangleEdge::Bottom); - } - - void PukLockBox::rebuildInputLabels(unsigned int inputSize) - { - LockWindow->pinLabelsBox->erase(); - buildInputLabels(inputSize); - } - - void PukLockBox::setVisibleStateInputRequired(InputActionType type) - { - LockWindow->pinLabelsBox->setVisible(true); - switch (type) { - case LockBox::InputActionType::ProvideInput: { - LockWindow->setText("app_desktop_sim_setup_enter_puk", PinLockBaseWindow::TextType::Primary); - break; - } - case LockBox::InputActionType::ProvideNewInput: { - LockWindow->setText("app_desktop_sim_enter_new_pin", PinLockBaseWindow::TextType::Primary); - break; - } - case LockBox::InputActionType::ConfirmNewInput: - LockWindow->setText("app_desktop_sim_confirm_new_pin", PinLockBaseWindow::TextType::Primary); - break; - } - - LockWindow->setImagesVisible(true, false); - LockWindow->setBottomBarWidgetsActive(false, false, true); - } - void PukLockBox::setVisibleStateInputInvalid(InputErrorType type, unsigned int value) - { - switch (type) { - case LockBox::InputErrorType::InvalidInput: - if (value > 1) { - LockWindow->setText( - "app_desktop_sim_setup_wrong_puk", - PinLockBaseWindow::TextType::Primary, - {{LockWindow->getToken(PinLockBaseWindow::Token::Attempts), static_cast(value)}}); - } - else { - LockWindow->setText("app_desktop_sim_setup_wrong_puk_last_attempt", - PinLockBaseWindow::TextType::Primary); - LockWindow->setText("app_desktop_sim_setup_wrong_puk_last_attempt_warning", - PinLockBaseWindow::TextType::Secondary); - } - break; - case LockBox::InputErrorType::NewInputConfirmFailed: { - LockWindow->setText("app_desktop_sim_wrong_pin_confirmation", PinLockBaseWindow::TextType::Primary); - break; - } - case LockBox::InputErrorType::UnhandledError: - LOG_ERROR("No use case for UnhandledError in PukLockBox"); - break; - } - LockWindow->setImagesVisible(false, true); - LockWindow->setBottomBarWidgetsActive(false, true, false); - } - void PukLockBox::setVisibleStateBlocked() - { - LockWindow->setText("app_desktop_sim_puk_blocked", PinLockBaseWindow::TextType::Primary); - LockWindow->setImagesVisible(false, true); - LockWindow->setBottomBarWidgetsActive(true, false, false); - } - - void PukLockBox::clear() - { - rebuildInputLabels(0); - } -} // namespace gui diff --git a/module-apps/locks/widgets/PukLockBox.hpp b/module-apps/locks/widgets/PukLockBox.hpp deleted file mode 100644 index f71c346c8f142b3a98dbbbd282fded8999775e87..0000000000000000000000000000000000000000 --- a/module-apps/locks/widgets/PukLockBox.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#pragma once - -#include "LockBox.hpp" - -namespace gui -{ - class PinLockBaseWindow; -} - -namespace gui -{ - class PukLockBox : public LockBox - { - public: - explicit PukLockBox(PinLockBaseWindow *LockBaseWindow) : LockWindow(LockBaseWindow) - {} - - private: - PinLockBaseWindow *LockWindow; - void popChar(unsigned int charNum) final; - void putChar(unsigned int charNum) final; - void clear() final; - - void setVisibleStateInputRequired(InputActionType type) final; - void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) final; - void setVisibleStateBlocked() final; - - void buildLockBox(unsigned int inputSize) final; - void buildInputLabels(unsigned int inputSize); - void rebuildInputLabels(unsigned int inputSize); - }; -} // namespace gui diff --git a/module-apps/locks/widgets/SimLockBox.cpp b/module-apps/locks/widgets/SimLockBox.cpp index 669024143aabd8e60dedd05e4b55de328b328a73..6281b4db83e2421edc133b7a021c0b72160d428b 100644 --- a/module-apps/locks/widgets/SimLockBox.cpp +++ b/module-apps/locks/widgets/SimLockBox.cpp @@ -2,47 +2,46 @@ // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "SimLockBox.hpp" - -#include "locks/data/LockStyle.hpp" -#include "locks/windows/PinLockBaseWindow.hpp" -#include "Lock.hpp" -#include -#include - -namespace label_style = style::window::pin_lock::pin_label; +#include "locks/windows/LockInputWindow.hpp" namespace gui { - - void SimLockBox::popChar(unsigned int charNum) + void SimLockBox::buildLockBox(unsigned int pinSize) { - rebuildInputLabels(charNum); - } - void SimLockBox::putChar(unsigned int charNum) - { - rebuildInputLabels(++charNum); + LockBoxAlternatingSize::buildLockBox(pinSize); } - void SimLockBox::buildLockBox(unsigned int inputSize) + void SimLockBox::applyLockActionText(locks::SimInputTypeAction simInputTypeAction) { - LockWindow->buildImages("pin_lock", "pin_lock_info"); - buildInputLabels(0); - } - void SimLockBox::buildInputLabels(unsigned int inputSize) - { - auto itemBuilder = []() { - auto label = new gui::Image("dot_12px_hard_alpha_W_G"); - return label; - }; - - LockWindow->buildPinLabels(itemBuilder, inputSize, label_style::x, label_style::y, label_style::w); - LockWindow->pinLabelsBox->setEdges(RectangleEdge::Bottom); - } + LockWindow->setText("sim_header_setup", + LockInputWindow::TextType::Title, + {{LockWindow->getToken(LockInputWindow::Token::Sim), LockWindow->lock->getLockName()}}); + LockWindow->setTitleBar(true, true); - void SimLockBox::rebuildInputLabels(unsigned int inputSize) - { - LockWindow->pinLabelsBox->erase(); - buildInputLabels(inputSize); + switch (simInputTypeAction) { + case locks::SimInputTypeAction::UnlockWithPin: + textForInputRequired = "sim_enter_pin_unlock"; + textForInvalidInput = "sim_setup_wrong_pin"; + textForInvalidInputLastAttempt = "sim_setup_wrong_pin_last_attempt"; + textForInvalidInputLastAttemptWarning = ""; + break; + case locks::SimInputTypeAction::UnlockWithPuk: + textForInputRequired = "sim_setup_enter_puk"; + textForInvalidInput = "sim_setup_wrong_puk"; + textForInvalidInputLastAttempt = "sim_setup_wrong_puk_last_attempt"; + textForInvalidInputLastAttemptWarning = "sim_setup_wrong_puk_last_attempt_warning"; + break; + case locks::SimInputTypeAction::ChangePin: + case locks::SimInputTypeAction::EnablePin: + case locks::SimInputTypeAction::DisablePin: + textForInputRequired = "sim_enter_enter_current"; + textForInvalidInput = "sim_wrong_pin_confirmation"; + textForInvalidInputLastAttempt = ""; + textForInvalidInputLastAttemptWarning = ""; + break; + default: + break; + } } void SimLockBox::setVisibleStateInputRequired(InputActionType type) @@ -51,59 +50,59 @@ namespace gui switch (type) { case LockBox::InputActionType::ProvideInput: { LockWindow->setText( - "app_desktop_sim_enter_pin_unlock", - PinLockBaseWindow::TextType::Primary, - {{LockWindow->getToken(PinLockBaseWindow::Token::PinType), LockWindow->lock->getLockName()}}); + textForInputRequired, + LockInputWindow::TextType::Primary, + {{LockWindow->getToken(LockInputWindow::Token::PinType), LockWindow->lock->getLockName()}}); break; } case LockBox::InputActionType::ProvideNewInput: - LockWindow->setText("app_desktop_sim_enter_new_pin", PinLockBaseWindow::TextType::Primary); + LockWindow->setText("sim_enter_new_pin", LockInputWindow::TextType::Primary); break; case LockBox::InputActionType::ConfirmNewInput: - LockWindow->setText("app_desktop_sim_confirm_new_pin", PinLockBaseWindow::TextType::Primary); + LockWindow->setText("sim_confirm_new_pin", LockInputWindow::TextType::Primary); break; } - LockWindow->setImagesVisible(true, false); + LockWindow->setImage("sim_card_W_G"); LockWindow->setBottomBarWidgetsActive(false, false, true); } + void SimLockBox::setVisibleStateInputInvalid(InputErrorType type, unsigned int value) { switch (type) { case LockBox::InputErrorType::InvalidInput: if (value == 1) { - LockWindow->setText("app_desktop_sim_setup_wrong_pin_last_attempt", - PinLockBaseWindow::TextType::Primary); + LockWindow->setText(textForInvalidInputLastAttempt, LockInputWindow::TextType::Primary); + LockWindow->setText(textForInvalidInputLastAttemptWarning, LockInputWindow::TextType::Secondary); } else { LockWindow->setText( - "app_desktop_sim_setup_wrong_pin", - PinLockBaseWindow::TextType::Primary, - {{LockWindow->getToken(PinLockBaseWindow::Token::Attempts), static_cast(value)}}); + textForInvalidInput, + LockInputWindow::TextType::Primary, + {{LockWindow->getToken(LockInputWindow::Token::Attempts), static_cast(value)}}); } break; case LockBox::InputErrorType::NewInputConfirmFailed: - LockWindow->setText("app_desktop_sim_wrong_pin_confirmation", PinLockBaseWindow::TextType::Primary); - break; - case LockBox::InputErrorType::UnhandledError: { - LockWindow->setText("app_desktop_sim_cme_error", - PinLockBaseWindow::TextType::Primary, - {{LockWindow->getToken(PinLockBaseWindow::Token::CmeCode), static_cast(value)}}); + LockWindow->setText("sim_wrong_pin_confirmation", LockInputWindow::TextType::Primary); break; } - } - LockWindow->setImagesVisible(false, true); + LockWindow->setImage("info_icon_W_G"); LockWindow->setBottomBarWidgetsActive(false, true, true); } + void SimLockBox::setVisibleStateBlocked() { - LockWindow->setText("app_desktop_sim_puk_blocked", PinLockBaseWindow::TextType::Primary); - LockWindow->setImagesVisible(false, true); - LockWindow->setBottomBarWidgetsActive(false, true, true); + LockWindow->setText("sim_puk_blocked", LockInputWindow::TextType::Primary); + LockWindow->setImage("sim_card_W_G"); + LockWindow->setBottomBarWidgetsActive(false, false, true); } - void SimLockBox::clear() + void SimLockBox::setVisibleStateError(unsigned int errorCode) { - rebuildInputLabels(0); + LockWindow->setText("sim_cme_error", + LockInputWindow::TextType::Primary, + {{LockWindow->getToken(LockInputWindow::Token::CmeCode), static_cast(errorCode)}}); + LockWindow->setImage("info_icon_W_G"); + LockWindow->setBottomBarWidgetsActive(false, false, true); } } // namespace gui diff --git a/module-apps/locks/widgets/SimLockBox.hpp b/module-apps/locks/widgets/SimLockBox.hpp index bf6bd19c2c1d19d155c79e11d434c239b2610d20..c0acdd391031a457dce889f9abfde86ec23543a6 100644 --- a/module-apps/locks/widgets/SimLockBox.hpp +++ b/module-apps/locks/widgets/SimLockBox.hpp @@ -3,33 +3,38 @@ #pragma once -#include "LockBox.hpp" +#include "LockBoxAlternatingSize.hpp" +#include namespace gui { - class PinLockBaseWindow; + class LockInputWindow; } namespace gui { - class SimLockBox : public LockBox + class SimLockBox : public LockBoxAlternatingSize { public: - SimLockBox(PinLockBaseWindow *LockBaseWindow) : LockWindow(LockBaseWindow) - {} + explicit SimLockBox(LockInputWindow *LockBaseWindow, + locks::SimInputTypeAction simLockInputTypeAction = locks::SimInputTypeAction::UnlockWithPin) + : LockBoxAlternatingSize(LockBaseWindow), LockWindow(LockBaseWindow) + { + applyLockActionText(simLockInputTypeAction); + } private: - PinLockBaseWindow *LockWindow; - void popChar(unsigned int charNum) final; - void putChar(unsigned int charNum) final; - void clear() final; - + void buildLockBox(unsigned int pinSize) final; void setVisibleStateInputRequired(InputActionType type) final; void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) final; void setVisibleStateBlocked() final; + void setVisibleStateError(unsigned int errorCode) final; + void applyLockActionText(locks::SimInputTypeAction simLockInputTypeAction); - void buildLockBox(unsigned int inputSize) final; - void buildInputLabels(unsigned int inputSize); - void rebuildInputLabels(unsigned int inputSize); + LockInputWindow *LockWindow; + std::string textForInputRequired; + std::string textForInvalidInput; + std::string textForInvalidInputLastAttempt; + std::string textForInvalidInputLastAttemptWarning; }; } // namespace gui diff --git a/module-apps/locks/windows/LockInputWindow.cpp b/module-apps/locks/windows/LockInputWindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b9095091f2d34ef3aca0dc9fa09dfaee13cda93b --- /dev/null +++ b/module-apps/locks/windows/LockInputWindow.cpp @@ -0,0 +1,247 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "LockInputWindow.hpp" + +#include +#include + +#include +#include +#include + +namespace lock_style = style::window::lock_input; + +namespace gui +{ + void LockInputWindow::build() + { + buildBody(); + buildImage(); + buildInfoTexts(); + buildPinBody(); + buildIceBox(); + buildBottomBar(); + + body->resizeItems(); + } + + void LockInputWindow::buildBody() + { + body = new VBox(this, + style::window::default_left_margin, + style::header::height, + style::window::default_body_width, + style::window::default_body_height); + body->setEdges(RectangleEdge::None); + } + + void LockInputWindow::buildImage() + { + using namespace style::window::lock_input; + + infoImage = new gui::ImageBox(body, 0, 0, 0, 0, new gui::Image("")); + infoImage->setMinimumSize(image::wh, image::wh); + infoImage->setMargins(Margins(0, image::image_top_margin, 0, image::image_bottom_margin)); + infoImage->showImage(false); + } + + void LockInputWindow::buildInfoTexts() + { + using namespace style::window::lock_input; + + primaryText = new Text(body, 0, 0, 0, 0); + primaryText->setMinimumSize(style::window::default_body_width, primary_text::h); + primaryText->setFont(style::window::font::medium); + primaryText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top)); + + secondaryText = new Text(body, 0, 0, 0, secondary_text::h); + secondaryText->setMinimumSize(style::window::default_body_width, secondary_text::h); + secondaryText->setMargins(Margins(0, secondary_text::top_margin, 0, 0)); + secondaryText->setFont(style::window::font::medium); + secondaryText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top)); + } + + void LockInputWindow::buildBottomBar() + { + bottomBar->setText(BottomBar::Side::LEFT, utils::translate(style::strings::common::skip)); + bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::confirm)); + bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back)); + setBottomBarWidgetsActive(false, false, false); + } + + void LockInputWindow::buildIceBox() + { + using namespace style::window::lock_input; + + iceBox = new gui::HBox(this, ice::x, ice::y, ice::w, ice::h); + iceBox->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); + iceBox->setEdges(RectangleEdge::None); + iceBox->setVisible(false); + + auto arrow = new gui::Image("left_label_arrow"); + arrow->activeItem = false; + arrow->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); + arrow->setMargins(Margins(0, 0, ice::margin, 0)); + iceBox->addWidget(arrow); + + auto iceText = new gui::Text(nullptr, 0, 0, ice::text::w, ice::h); + iceText->activeItem = false; + iceText->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); + iceText->setFont(style::window::font::verysmall); + iceText->setText(utils::translate("app_desktop_emergency")); + iceBox->addWidget(iceText); + } + + void LockInputWindow::buildPinBody() + { + pinLabelsBox = new gui::HBox(body, 0, 0, 0, 0); + pinLabelsBox->setMinimumSize(lock_style::input_box::w, lock_style::input_box::h); + pinLabelsBox->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center)); + pinLabelsBox->setMargins(Margins(0, lock_style::input_box::top_margin, 0, 0)); + pinLabelsBox->setEdges(RectangleEdge::None); + } + + void LockInputWindow::buildPinLabels(const std::function &itemBuilder, unsigned int pinSize) + { + if (pinSize == 0) { + return; + } + + for (uint32_t i = 0; i < pinSize; i++) { + auto label = itemBuilder(); + label->setFilled(false); + label->setBorderColor(gui::ColorFullBlack); + label->setPenWidth(2); + label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center)); + label->setVisible(true); + label->activeItem = false; + pinLabelsBox->addWidget(label); + } + } + + top_bar::Configuration LockInputWindow::configureTopBar(top_bar::Configuration appConfiguration) + { + appConfiguration.disable(top_bar::Indicator::NetworkAccessTechnology); + appConfiguration.enable(top_bar::Indicator::Time); + appConfiguration.enable(top_bar::Indicator::PhoneMode); + appConfiguration.enable(top_bar::Indicator::Battery); + appConfiguration.enable(top_bar::Indicator::Signal); + appConfiguration.enable(top_bar::Indicator::SimCard); + return appConfiguration; + } + + void LockInputWindow::restore() noexcept + { + infoImage->showImage(false); + primaryText->setVisible(false); + secondaryText->setVisible(false); + pinLabelsBox->setVisible(false); + } + + void LockInputWindow::setImage(const UTF8 &imageName) + { + infoImage->setImage(imageName); + infoImage->showImage(true); + } + + void LockInputWindow::setBottomBarWidgetsActive(bool left, bool center, bool right) + { + bottomBar->setActive(BottomBar::Side::LEFT, left); + bottomBar->setActive(BottomBar::Side::CENTER, center); + bottomBar->setActive(BottomBar::Side::RIGHT, right); + } + + void LockInputWindow::setText(const std::string &value, TextType type, text::RichTextParser::TokenMap tokens) + { + switch (type) { + case TextType::Title: { + title->setVisible(true); + if (!tokens.empty()) { + TextFormat format(FontManager::getInstance().getFont(style::window::font::medium)); + title->setText( + text::RichTextParser().parse(utils::translate(value), &format, std::move(tokens))->getText()); + } + else { + title->setText(utils::translate(value)); + } + break; + } + case TextType::Primary: + primaryText->setVisible(true); + primaryText->setRichText(utils::translate(value), std::move(tokens)); + break; + case TextType::Secondary: + secondaryText->setVisible(true); + secondaryText->setRichText(utils::translate(value), std::move(tokens)); + break; + } + } + + void LockInputWindow::setTitleBar(bool titleVisible, bool iceVisible) + { + title->setVisible(titleVisible); + iceBox->setVisible(iceVisible); + } + + auto LockInputWindow::getToken(LockInputWindow::Token token) const -> std::string + { + if (token == Token::PinType) { + return "$PINTYPE"; + } + else if (token == Token::Sim) { + return "$SIM"; + } + else if (token == Token::Attempts) { + return "$ATTEMPTS"; + } + else if (token == Token::Mins) { + return "$MINUTES"; + } + else if (token == Token::CmeCode) { + return "$CMECODE"; + } + return std::string{}; + } + + void LockInputWindow::setVisibleState() + { + restore(); + switch (lock->getState()) { + case locks::Lock::LockState::InputRequired: + lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideInput); + break; + case locks::Lock::LockState::InputInvalid: + lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::InvalidInput, lock->getAttemptsLeft()); + break; + case locks::Lock::LockState::Blocked: + lockBox->setVisibleStateBlocked(); + break; + case locks::Lock::LockState::NewInputRequired: + lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideNewInput); + break; + case locks::Lock::LockState::NewInputConfirmRequired: + lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ConfirmNewInput); + break; + case locks::Lock::LockState::NewInputInvalid: + lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::NewInputConfirmFailed, + lock->getAttemptsLeft()); + break; + default: + break; + } + } + + auto LockInputWindow::isInInputState() const noexcept -> bool + { + return lock && (lock->isState(locks::Lock::LockState::InputRequired) || + lock->isState(locks::Lock::LockState::NewInputRequired) || + lock->isState(locks::Lock::LockState::NewInputConfirmRequired)); + } + + auto LockInputWindow::isInInvalidInputState() const noexcept -> bool + { + return lock && (lock->isState(locks::Lock::LockState::InputInvalid) || + lock->isState(locks::Lock::LockState::NewInputInvalid)); + } +} // namespace gui diff --git a/module-apps/locks/windows/LockInputWindow.hpp b/module-apps/locks/windows/LockInputWindow.hpp new file mode 100644 index 0000000000000000000000000000000000000000..11d70ad932c2d108dc249c7ba967aa95ffd2ceb8 --- /dev/null +++ b/module-apps/locks/windows/LockInputWindow.hpp @@ -0,0 +1,80 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include + +#include +#include +#include +#include + +namespace locks +{ + class Lock; +} + +namespace gui +{ + class LockInputWindow : public AppWindow + { + public: + enum class TextType + { + Title, + Primary, + Secondary + }; + + enum class Token + { + Sim, + Attempts, + Mins, + CmeCode, + PinType + }; + + void buildPinLabels(const std::function &itemBuilder, unsigned int pinSize); + void setText(const std::string &value, + TextType type, + text::RichTextParser::TokenMap tokens = text::RichTextParser::TokenMap{}); + void setTitleBar(bool titleVisible, bool iceVisible); + void setImage(const UTF8 &imageName); + void setBottomBarWidgetsActive(bool left, bool center, bool right); + + [[nodiscard]] auto getToken(Token token) const -> std::string; + top_bar::Configuration configureTopBar(top_bar::Configuration appConfiguration) override; + + std::unique_ptr lock = nullptr; + gui::HBox *pinLabelsBox = nullptr; + + protected: + LockInputWindow(app::Application *app, std::string name) : AppWindow(app, std::move(name)) + {} + + void build(); + void restore() noexcept; + + virtual void setVisibleState(); + std::unique_ptr lockBox = nullptr; + + [[nodiscard]] auto isInInputState() const noexcept -> bool; + [[nodiscard]] auto isInInvalidInputState() const noexcept -> bool; + + private: + gui::VBox *body = nullptr; + gui::HBox *iceBox = nullptr; + gui::ImageBox *infoImage = nullptr; + gui::Text *primaryText = nullptr; + gui::Text *secondaryText = nullptr; + + void buildBody(); + void buildImage(); + void buildInfoTexts(); + void buildPinBody(); + void buildBottomBar(); + void buildIceBox(); + }; +} // namespace gui diff --git a/module-apps/locks/windows/LockWindow.cpp b/module-apps/locks/windows/LockWindow.cpp deleted file mode 100644 index 42fee3499fd5854e853637de7aca1cc07733928c..0000000000000000000000000000000000000000 --- a/module-apps/locks/windows/LockWindow.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "locks/data/LockStyle.hpp" -#include "locks/widgets/Lock.hpp" -#include "FontManager.hpp" -#include -#include "LockWindow.hpp" - -namespace lock_style = style::window::pin_lock; - -namespace gui -{ - void LockWindow::build() - { - buildBottomBar(); - buildTitleBar(); - buildInfoTexts(); - } - - void LockWindow::buildInfoTexts() - { - using namespace style::window::pin_lock; - - primaryText = new Text(this, primary_text::x, primary_text::y, primary_text::w, primary_text::h); - primaryText->setFont(style::window::font::medium); - primaryText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top)); - - secondaryText = new Text(this, secondary_text::x, secondary_text::y, secondary_text::w, secondary_text::h); - secondaryText->setFont(style::window::font::medium); - secondaryText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top)); - } - - void LockWindow::buildPinLabels(const std::function &itemBuilder, - unsigned int pinSize, - unsigned int offsetX, - unsigned int offsetY, - unsigned int boxWidth) - { - pinLabelsBox = new gui::HBox(this, offsetX, offsetY, boxWidth, lock_style::pin_label::size); - pinLabelsBox->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center)); - - if (pinSize == 0) { - return; - } - - for (uint32_t i = 0; i < pinSize; i++) { - auto label = itemBuilder(); - label->setFilled(false); - label->setBorderColor(gui::ColorFullBlack); - label->setPenWidth(2); - label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center)); - label->setVisible(true); - label->activeItem = false; - pinLabelsBox->addWidget(label); - } - } - - void LockWindow::restore() noexcept - { - primaryText->setVisible(false); - secondaryText->setVisible(false); - pinLabelsBox->setVisible(false); - } - - void LockWindow::setBottomBarWidgetsActive(bool left, bool center, bool right) - { - bottomBar->setActive(BottomBar::Side::LEFT, left); - bottomBar->setActive(BottomBar::Side::CENTER, center); - bottomBar->setActive(BottomBar::Side::RIGHT, right); - } - - void LockWindow::setText(const std::string &value, TextType type, text::RichTextParser::TokenMap tokens) - { - switch (type) { - case TextType::Title: { - title->setVisible(true); - if (!tokens.empty()) { - TextFormat format(FontManager::getInstance().getFont(style::window::font::medium)); - title->setText( - text::RichTextParser().parse(utils::translate(value), &format, std::move(tokens))->getText()); - } - else { - title->setText(utils::translate(value)); - } - break; - } - case TextType::Primary: - primaryText->setVisible(true); - primaryText->setRichText(utils::translate(value), std::move(tokens)); - break; - case TextType::Secondary: - secondaryText->setVisible(true); - secondaryText->setRichText(utils::translate(value), std::move(tokens)); - break; - } - } - - void LockWindow::setTitleBar(bool isVisible) - { - title->setVisible(isVisible); - } - - void LockWindow::buildBottomBar() - { - bottomBar->setText(BottomBar::Side::LEFT, utils::translate(style::strings::common::skip)); - bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::confirm)); - bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back)); - } - -} // namespace gui diff --git a/module-apps/locks/windows/LockWindow.hpp b/module-apps/locks/windows/LockWindow.hpp deleted file mode 100644 index c6b920420ab19ef8419afc2cef94b0f98d299d4f..0000000000000000000000000000000000000000 --- a/module-apps/locks/windows/LockWindow.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#pragma once - -#include "AppWindow.hpp" -#include "RichTextParser.hpp" -#include "Text.hpp" - -namespace locks -{ - class Lock; -} - -namespace gui -{ - class LockWindow : public AppWindow - { - public: - enum class TextType - { - Title, - Primary, - Secondary - }; - - enum class Token - { - Sim, - Attempts, - Mins, - CmeCode, - PinType - }; - - LockWindow(app::Application *app, std::string name) : AppWindow(app, std::move(name)) - {} - void build(); - void buildInfoTexts(); - void buildPinLabels(const std::function &itemBuilder, - unsigned int pinSize, - unsigned int offsetX, - unsigned int offsetY, - unsigned int boxWidth); - virtual void restore() noexcept; - void setBottomBarWidgetsActive(bool left, bool center, bool right); - void setText(const std::string &value, - TextType type, - text::RichTextParser::TokenMap tokens = text::RichTextParser::TokenMap{}); - void setTitleBar(bool isVisible); - - std::unique_ptr lock = nullptr; - gui::HBox *pinLabelsBox = nullptr; - gui::Text *primaryText = nullptr; - gui::Text *secondaryText = nullptr; - - protected: - virtual void buildBottomBar(); - virtual void buildTitleBar() = 0; - }; -} // namespace gui diff --git a/module-apps/locks/windows/PinLockBaseWindow.cpp b/module-apps/locks/windows/PinLockBaseWindow.cpp deleted file mode 100644 index 57ec124580ec1d50f9ca3ddad7362554d10d03a6..0000000000000000000000000000000000000000 --- a/module-apps/locks/windows/PinLockBaseWindow.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "locks/data/LockStyle.hpp" -#include "locks/widgets/Lock.hpp" -#include -#include "PinLockBaseWindow.hpp" -#include - -namespace lock_style = style::window::pin_lock; - -namespace gui -{ - void PinLockBaseWindow::buildImages(const std::string &lockImg, const std::string &infoImg) - { - lockImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, lockImg); - infoImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, infoImg); - } - - auto PinLockBaseWindow::getToken(Token token) const -> std::string - { - if (token == Token::PinType) { - return "$PINTYPE"; - } - else if (token == Token::Sim) { - return "$SIM"; - } - else if (token == Token::Attempts) { - return "$ATTEMPTS"; - } - else if (token == Token::Mins) { - return "$MINUTES"; - } - else if (token == Token::CmeCode) { - return "$CMECODE"; - } - return std::string{}; - } - - top_bar::Configuration PinLockBaseWindow::configureTopBar(top_bar::Configuration appConfiguration) - { - appConfiguration.disable(top_bar::Indicator::NetworkAccessTechnology); - appConfiguration.enable(top_bar::Indicator::PhoneMode); - appConfiguration.enable(top_bar::Indicator::Battery); - appConfiguration.enable(top_bar::Indicator::Signal); - appConfiguration.enable(top_bar::Indicator::SimCard); - return appConfiguration; - } - - void PinLockBaseWindow::restore() noexcept - { - LockWindow::restore(); - lockImage->setVisible(false); - infoImage->setVisible(false); - } - - void PinLockBaseWindow::setImagesVisible(bool lockImg, bool infoImg) - { - lockImage->setVisible(lockImg); - infoImage->setVisible(infoImg); - } - - void PinLockBaseWindow::setTitleBar(bool isVisible, bool isIceActive) - { - iceBox->setVisible(isIceActive); - LockWindow::setTitleBar(isVisible); - } - - void PinLockBaseWindow::buildBottomBar() - { - LockWindow::buildBottomBar(); - setBottomBarWidgetsActive(false, false, false); - } - - void PinLockBaseWindow::buildTitleBar() - { - using namespace style::window::pin_lock; - - iceBox = new gui::HBox(this, ice::x, ice::y, ice::w, ice::h); - iceBox->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); - iceBox->setEdges(RectangleEdge::None); - iceBox->setVisible(false); - - auto arrow = new gui::Image("left_label_arrow"); - arrow->activeItem = false; - arrow->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); - arrow->setMargins(Margins(0, 0, ice::margin, 0)); - iceBox->addWidget(arrow); - - auto iceText = new gui::Text(nullptr, 0, 0, ice::text::w, ice::h); - iceText->activeItem = false; - iceText->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); - iceText->setFont(style::window::font::verysmall); - iceText->setText(utils::translate("app_desktop_emergency")); - iceBox->addWidget(iceText); - } - -} // namespace gui diff --git a/module-apps/locks/windows/PinLockBaseWindow.hpp b/module-apps/locks/windows/PinLockBaseWindow.hpp deleted file mode 100644 index 527e18759a7954d1bd434fb5d782330c48224d90..0000000000000000000000000000000000000000 --- a/module-apps/locks/windows/PinLockBaseWindow.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#pragma once - -#include "LockWindow.hpp" - -namespace gui -{ - class Image; - class PinLockBaseWindow : public LockWindow - { - public: - PinLockBaseWindow(app::Application *app, std::string name) : LockWindow(app, name) - {} - - top_bar::Configuration configureTopBar(top_bar::Configuration appConfiguration) override; - - void buildImages(const std::string &lockImg, const std::string &infoImg); - [[nodiscard]] auto getToken(Token token) const -> std::string; - void restore() noexcept override; - void setImagesVisible(bool lockImg, bool infoImg); - void setTitleBar(bool isVisible, bool isIceActive); - - gui::HBox *iceBox = nullptr; - gui::Image *infoImage = nullptr; - gui::Image *lockImage = nullptr; - - private: - void buildBottomBar() override; - void buildTitleBar() override; - }; -} // namespace gui diff --git a/module-apps/locks/windows/PinLockWindow.cpp b/module-apps/locks/windows/PinLockWindow.cpp deleted file mode 100644 index 45975196875562a78735437b99ee5740509501cb..0000000000000000000000000000000000000000 --- a/module-apps/locks/windows/PinLockWindow.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -// application manager -#include "InputEvent.hpp" -#include "service-appmgr/Controller.hpp" - -// module-gui -#include "gui/widgets/BottomBar.hpp" -#include "PinLockWindow.hpp" - -#include "application-desktop/ApplicationDesktop.hpp" -#include "locks/data/LockData.hpp" -#include "locks/widgets/PhoneLockBox.hpp" -#include "locks/widgets/SimLockBox.hpp" -#include "locks/widgets/PukLockBox.hpp" -#include - -namespace gui -{ - - PinLockWindow::PinLockWindow(app::Application *app, const std::string &window_name) - : PinLockBaseWindow(app, window_name), this_window_name(window_name) - { - buildInterface(); - } - - void PinLockWindow::rebuild() - { - // find which widget has focus - destroyInterface(); - buildInterface(); - // set state - focusItem = nullptr; - } - void PinLockWindow::buildInterface() - { - AppWindow::buildInterface(); - PinLockBaseWindow::build(); - } - - void PinLockWindow::destroyInterface() - { - erase(); - } - - void PinLockWindow::setVisibleState() - { - restore(); - if (lock->isState(Lock::LockState::InputRequired)) { - lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideInput); - } - else if (lock->isState(Lock::LockState::InputInvalid)) { - lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::InvalidInput, lock->getAttemptsLeft()); - } - else if (lock->isState(Lock::LockState::Blocked)) { - lockBox->setVisibleStateBlocked(); - } - else if (lock->isState(Lock::LockState::NewInputRequired)) { - lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideNewInput); - } - else if (lock->isState(Lock::LockState::NewInputConfirmRequired)) { - lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ConfirmNewInput); - } - else if (lock->isState(Lock::LockState::NewInputInvalid)) { - lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::NewInputConfirmFailed, - lock->getAttemptsLeft()); - } - else if (lock->isState(Lock::LockState::ErrorOccurred)) { - lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::UnhandledError, lock->getAttemptsLeft()); - } - application->refreshWindow(RefreshModes::GUI_REFRESH_FAST); - } - - void PinLockWindow::onBeforeShow(ShowMode mode, SwitchData *data) - { - if (auto lockData = dynamic_cast(data)) { - rebuild(); - lock = std::make_unique(lockData->getLock()); - - buildPinLockBox(); - lockBox->buildLockBox(lock->getMaxInputSize()); - - if (lock->isState(Lock::LockState::InputRequired)) { - currentPasscodeType = LockBox::InputActionType::ProvideInput; - } - else if (lock->isState(Lock::LockState::NewInputRequired)) { - currentPasscodeType = LockBox::InputActionType::ProvideNewInput; - } - setVisibleState(); - } - } - - bool PinLockWindow::onInput(const InputEvent &inputEvent) - { - if (!inputEvent.isShortRelease()) { - return AppWindow::onInput(inputEvent); - } - // accept only LF, enter, RF, #, and numeric values; - if (inputEvent.is(KeyCode::KEY_LEFT) && iceBox->visible) { - app::manager::Controller::sendAction(application, app::manager::actions::EmergencyDial); - return true; - } - else if (inputEvent.is(KeyCode::KEY_RF) && bottomBar->isActive(BottomBar::Side::RIGHT)) { - if (usesNumericKeys()) { - lock->clearAttempt(); - } - else if (lock->isState(Lock::LockState::InputInvalid)) { - lock->consumeState(); - } - application->returnToPreviousWindow(); - return true; - } - else if (inputEvent.is(KeyCode::KEY_PND)) { - if (usesNumericKeys()) { - lock->popChar(); - lockBox->popChar(lock->getCharCount()); - bottomBar->setActive(BottomBar::Side::CENTER, lock->canVerify()); - return true; - } - } - else if (inputEvent.isDigit()) { - if (usesNumericKeys() && lock->canPut()) { - lockBox->putChar(lock->getCharCount()); - lock->putNextChar(inputEvent.numericValue()); - bottomBar->setActive(BottomBar::Side::CENTER, lock->canVerify()); - return true; - } - } - else if (inputEvent.is(KeyCode::KEY_ENTER) && bottomBar->isActive(BottomBar::Side::CENTER)) { - lock->activate(); - bottomBar->setActive(BottomBar::Side::CENTER, false); - return true; - } - // check if any of the lower inheritance onInput methods catch the event - return AppWindow::onInput(inputEvent); - } - - void PinLockWindow::buildPinLockBox() - { - auto lockType = lock->getLockType(); - if (lockType == Lock::LockType::Screen) { - lockBox = std::make_unique(this); - } - else if (lockType == Lock::LockType::SimPuk) { - lockBox = std::make_unique(this); - setTitleBar(true, true); - setText("app_desktop_header_sim_setup", - TextType::Title, - {{getToken(Token::Sim), utils::enumToString(lock->getSim())}}); - } - else if (lockType == Lock::LockType::SimPin) { - lockBox = std::make_unique(this); - setTitleBar(true, false); - setText("app_desktop_header_sim_setup", - TextType::Title, - {{getToken(Token::Sim), utils::enumToString(lock->getSim())}}); - } - assert(lockBox != nullptr); - } - - auto PinLockWindow::usesNumericKeys() const noexcept -> bool - { - return lock && - (lock->isState(Lock::LockState::InputRequired) || lock->isState(Lock::LockState::NewInputRequired) || - lock->isState(Lock::LockState::NewInputConfirmRequired)); - } -} /* namespace gui */ diff --git a/module-apps/locks/windows/PinLockWindow.hpp b/module-apps/locks/windows/PinLockWindow.hpp deleted file mode 100644 index 4e164da3cf014166cd2b670860f8a4869254e02d..0000000000000000000000000000000000000000 --- a/module-apps/locks/windows/PinLockWindow.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#pragma once - -#include "AppWindow.hpp" -#include "gui/widgets/Label.hpp" -#include "gui/widgets/Image.hpp" -#include "gui/widgets/BottomBar.hpp" -#include "locks/widgets/Lock.hpp" -#include "locks/widgets/LockBox.hpp" -#include "PinLockBaseWindow.hpp" - -namespace gui -{ - class PinLockWindow : public PinLockBaseWindow - { - const std::string this_window_name; - std::string lockTimeoutApplication = ""; - std::unique_ptr lockBox = nullptr; - LockBox::InputActionType currentPasscodeType = LockBox::InputActionType::ProvideInput; - - // method hides or show widgets and sets bars according to provided state - void setVisibleState(); - void buildPinLockBox(); - auto usesNumericKeys() const noexcept -> bool; - - public: - PinLockWindow(app::Application *app, const std::string &window_name); - void onBeforeShow(ShowMode mode, SwitchData *data) override; - bool onInput(const InputEvent &inputEvent) override; - - void rebuild() override; - void buildInterface() override; - void destroyInterface() override; - }; - -} /* namespace gui */ diff --git a/module-apps/popups/CMakeLists.txt b/module-apps/popups/CMakeLists.txt index e4b00abd51192732ecc729195bcb3aed7f876218..4b82f9f3298b975ab36614c566c583821bf312b3 100644 --- a/module-apps/popups/CMakeLists.txt +++ b/module-apps/popups/CMakeLists.txt @@ -27,6 +27,8 @@ target_sources( ${PROJECT_NAME} "${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockedWindow.cpp" "${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockInputWindow.cpp" "${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockChangeInfoWindow.cpp" + "${CMAKE_CURRENT_LIST_DIR}/lock-popups/SimLockInputWindow.cpp" + "${CMAKE_CURRENT_LIST_DIR}/lock-popups/SimInfoWindow.cpp" PRIVATE "${CMAKE_CURRENT_LIST_DIR}/Popups.hpp" @@ -43,4 +45,6 @@ target_sources( ${PROJECT_NAME} "${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockedWindow.hpp" "${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockInputWindow.hpp" "${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockChangeInfoWindow.hpp" + "${CMAKE_CURRENT_LIST_DIR}/lock-popups/SimLockInputWindow.hpp" + "${CMAKE_CURRENT_LIST_DIR}/lock-popups/SimInfoWindow.hpp" ) diff --git a/module-apps/popups/Popups.cpp b/module-apps/popups/Popups.cpp index f317bad0ff616fc5c65e6dc98f3f41a9830b4362..43f88a167397b44b9b6ca8a82c07bb39b2a319db 100644 --- a/module-apps/popups/Popups.cpp +++ b/module-apps/popups/Popups.cpp @@ -24,7 +24,12 @@ namespace gui::popup return gui::popup::window::phone_lock_input_window; case ID::PhoneLockChangeInfo: return gui::popup::window::phone_lock_change_info_window; + case ID::SimLock: + return gui::popup::window::sim_unlock_window; + case ID::SimInfo: + return gui::popup::window::sim_info_window; } + return {}; } } // namespace gui::popup diff --git a/module-apps/popups/Popups.hpp b/module-apps/popups/Popups.hpp index d01c7a0e4c77a03d650a24bf6dc93163bd4a9768..2da155c292e397fd4e89a7c174d12d818b110afa 100644 --- a/module-apps/popups/Popups.hpp +++ b/module-apps/popups/Popups.hpp @@ -19,6 +19,8 @@ namespace gui PhoneLock, PhoneLockInput, PhoneLockChangeInfo, + SimLock, + SimInfo, }; namespace window @@ -33,6 +35,8 @@ namespace gui inline constexpr auto phone_lock_input_window = "PhoneLockInputPopup"; inline constexpr auto phone_lock_change_info_window = "PhoneLockChangeInfoPopup"; inline constexpr auto power_off_window = "PowerOffPopup"; + inline constexpr auto sim_unlock_window = "SimUnlockPopup"; + inline constexpr auto sim_info_window = "SimInfoPopup"; } // namespace window diff --git a/module-apps/popups/data/PopupRequestParams.hpp b/module-apps/popups/data/PopupRequestParams.hpp index 5544691dfd1e34c994b162594d1d0715e4d4b0b9..f7064e4e5de5e212e4ab253bb4d6a49dbfc87273 100644 --- a/module-apps/popups/data/PopupRequestParams.hpp +++ b/module-apps/popups/data/PopupRequestParams.hpp @@ -53,6 +53,38 @@ namespace gui locks::PhoneLockInputTypeAction phoneLockInputTypeAction; }; + class SimUnlockInputRequestParams : public PopupRequestParams + { + public: + SimUnlockInputRequestParams(gui::popup::ID popupId, + locks::Lock lock, + locks::SimInputTypeAction simInputTypeAction, + unsigned int errorCode = 0) + : PopupRequestParams{popupId}, lock{std::move(lock)}, simInputTypeAction(simInputTypeAction), + errorCode(errorCode) + {} + + [[nodiscard]] auto getLock() const noexcept + { + return lock; + } + + [[nodiscard]] auto getSimInputTypeAction() const noexcept + { + return simInputTypeAction; + } + + [[nodiscard]] auto getErrorCode() const noexcept + { + return errorCode; + } + + private: + locks::Lock lock; + locks::SimInputTypeAction simInputTypeAction; + unsigned int errorCode; + }; + class PhoneModePopupRequestParams : public PopupRequestParams { public: diff --git a/module-apps/popups/lock-popups/PhoneLockChangeInfoWindow.cpp b/module-apps/popups/lock-popups/PhoneLockChangeInfoWindow.cpp index eff924fa376644611212de874c03d8971ff36aa3..638bb827186d8fe3f4d9681d9ce5d365cd541a8c 100644 --- a/module-apps/popups/lock-popups/PhoneLockChangeInfoWindow.cpp +++ b/module-apps/popups/lock-popups/PhoneLockChangeInfoWindow.cpp @@ -33,11 +33,11 @@ void PhoneLockChangeInfoWindow::onBeforeShow(ShowMode mode, SwitchData *data) switch (infoData->getPhoneLockInputTypeAction()) { case locks::PhoneLockInputTypeAction::Disable: - infoText->setRichText(utils::translate("phone_lock_disabled")); + infoIcon->text->setRichText(utils::translate("phone_lock_disabled")); break; case locks::PhoneLockInputTypeAction::Enable: case locks::PhoneLockInputTypeAction::Change: - infoText->setRichText(utils::translate("phone_lock_changed_successfully")); + infoIcon->text->setRichText(utils::translate("phone_lock_changed_successfully")); break; default: break; @@ -47,17 +47,16 @@ void PhoneLockChangeInfoWindow::onBeforeShow(ShowMode mode, SwitchData *data) void PhoneLockChangeInfoWindow::buildInterface() { - namespace lock_style = style::window::pin_lock; AppWindow::buildInterface(); setTitle(utils::translate("phone_lock_configure")); - infoImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, "success_icon_W_G"); - infoText = new Text(this, - lock_style::primary_text::x, - lock_style::primary_text::y, - lock_style::primary_text::w, - lock_style::primary_text::h); - - infoText->setAlignment(Alignment::Horizontal::Center); + infoIcon = new gui::Icon(this, + style::window::default_left_margin, + style::header::height, + style::window::default_body_width, + style::window::default_body_height, + "success_icon_W_G", + ""); + infoIcon->setAlignment(Alignment::Horizontal::Center); } diff --git a/module-apps/popups/lock-popups/PhoneLockChangeInfoWindow.hpp b/module-apps/popups/lock-popups/PhoneLockChangeInfoWindow.hpp index 47cd571271ea0d9f4ed0c13b92f82f8c7766391f..b0d2e8d199d7f5e003f28cdc856d4e4003f4fc20 100644 --- a/module-apps/popups/lock-popups/PhoneLockChangeInfoWindow.hpp +++ b/module-apps/popups/lock-popups/PhoneLockChangeInfoWindow.hpp @@ -5,14 +5,13 @@ #include #include -#include +#include namespace gui { class PhoneLockChangeInfoWindow : public WindowWithTimer { - gui::Image *infoImage = nullptr; - gui::Text *infoText = nullptr; + Icon *infoIcon = nullptr; public: PhoneLockChangeInfoWindow(app::Application *app, const std::string &name); diff --git a/module-apps/popups/lock-popups/PhoneLockInputWindow.cpp b/module-apps/popups/lock-popups/PhoneLockInputWindow.cpp index 39e4eacc2217e7eac1adba00b1eedda4fb190a88..3dda6cf2046078fd5fdc1c39e96536df80ba7eb1 100644 --- a/module-apps/popups/lock-popups/PhoneLockInputWindow.cpp +++ b/module-apps/popups/lock-popups/PhoneLockInputWindow.cpp @@ -11,7 +11,7 @@ namespace gui { PhoneLockInputWindow::PhoneLockInputWindow(app::Application *app, const std::string &window_name) - : PinLockBaseWindow(app, window_name) + : LockInputWindow(app, window_name) { buildInterface(); } @@ -24,7 +24,7 @@ namespace gui void PhoneLockInputWindow::buildInterface() { AppWindow::buildInterface(); - LockWindow::build(); + LockInputWindow::build(); } void PhoneLockInputWindow::destroyInterface() @@ -32,28 +32,17 @@ namespace gui erase(); } - void PhoneLockInputWindow::setVisibleState() + top_bar::Configuration PhoneLockInputWindow::configureTopBar(top_bar::Configuration appConfiguration) { - restore(); - if (lock->isState(locks::Lock::LockState::InputRequired)) { - lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideInput); + if (phoneLockInputTypeAction == locks::PhoneLockInputTypeAction::Unlock) { + appConfiguration.enable(top_bar::Indicator::Lock); + appConfiguration.disable(top_bar::Indicator::Time); } - else if (lock->isState(locks::Lock::LockState::InputInvalid)) { - lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::InvalidInput, lock->getAttemptsLeft()); - } - else if (lock->isState(locks::Lock::LockState::Blocked)) { - lockBox->setVisibleStateBlocked(); - } - else if (lock->isState(locks::Lock::LockState::NewInputRequired)) { - lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideNewInput); - } - else if (lock->isState(locks::Lock::LockState::NewInputConfirmRequired)) { - lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ConfirmNewInput); - } - else if (lock->isState(locks::Lock::LockState::NewInputInvalid)) { - lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::NewInputConfirmFailed, - lock->getAttemptsLeft()); + else { + appConfiguration.enable(top_bar::Indicator::Time); + appConfiguration.disable(top_bar::Indicator::Lock); } + return appConfiguration; } void PhoneLockInputWindow::onBeforeShow(ShowMode mode, SwitchData *data) @@ -134,12 +123,4 @@ namespace gui // check if any of the lower inheritance onInput methods catch the event return AppWindow::onInput(inputEvent); } - - auto PhoneLockInputWindow::isInInputState() const noexcept -> bool - { - return lock && (lock->isState(locks::Lock::LockState::InputRequired) || - lock->isState(locks::Lock::LockState::NewInputRequired) || - lock->isState(locks::Lock::LockState::NewInputConfirmRequired)); - } - } /* namespace gui */ diff --git a/module-apps/popups/lock-popups/PhoneLockInputWindow.hpp b/module-apps/popups/lock-popups/PhoneLockInputWindow.hpp index 295ddb06a35d930e4ff52bfef0a08f4505610c29..d19384dadef9cdc472b755affe7e8ae9a1f053a7 100644 --- a/module-apps/popups/lock-popups/PhoneLockInputWindow.hpp +++ b/module-apps/popups/lock-popups/PhoneLockInputWindow.hpp @@ -6,18 +6,14 @@ #include #include #include -#include +#include namespace gui { - class PhoneLockInputWindow : public PinLockBaseWindow + class PhoneLockInputWindow : public LockInputWindow { - std::unique_ptr lockBox = nullptr; locks::PhoneLockInputTypeAction phoneLockInputTypeAction = locks::PhoneLockInputTypeAction::Unlock; - void setVisibleState(); - [[nodiscard]] auto isInInputState() const noexcept -> bool; - public: PhoneLockInputWindow(app::Application *app, const std::string &window_name); void onBeforeShow(ShowMode mode, SwitchData *data) override; @@ -26,6 +22,7 @@ namespace gui void rebuild() override; void buildInterface() override; void destroyInterface() override; + top_bar::Configuration configureTopBar(top_bar::Configuration appConfiguration) override; }; } /* namespace gui */ diff --git a/module-apps/popups/lock-popups/PhoneLockedInfoWindow.cpp b/module-apps/popups/lock-popups/PhoneLockedInfoWindow.cpp index 3ab8bc9a19fa74cdf9733c8047548b2f7f13c5be..895afdd378bdccca52085a267afc9dca8ef64917 100644 --- a/module-apps/popups/lock-popups/PhoneLockedInfoWindow.cpp +++ b/module-apps/popups/lock-popups/PhoneLockedInfoWindow.cpp @@ -18,13 +18,6 @@ PhoneLockedInfoWindow::PhoneLockedInfoWindow(app::Application *app, const std::s void PhoneLockedInfoWindow::onBeforeShow(ShowMode mode, SwitchData *data) { - setVisibleState(); -} - -void PhoneLockedInfoWindow::setVisibleState() -{ - lockImage->setVisible(true); - bottomBar->setActive(BottomBar::Side::LEFT, true); bottomBar->setActive(BottomBar::Side::CENTER, false); bottomBar->setActive(BottomBar::Side::RIGHT, true); @@ -56,19 +49,18 @@ top_bar::Configuration PhoneLockedInfoWindow::configureTopBar(top_bar::Configura void PhoneLockedInfoWindow::buildInterface() { - namespace lock_style = style::window::pin_lock; + namespace lock_style = style::window::lock_input; AppWindow::buildInterface(); bottomBar->setText(BottomBar::Side::LEFT, utils::translate("app_desktop_emergency")); bottomBar->setText(BottomBar::Side::RIGHT, utils::translate("common_back")); - lockImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, "pin_lock"); - infoText = new Text(this, - lock_style::primary_text::x, - lock_style::primary_text::y, - lock_style::primary_text::w, - lock_style::primary_text::h); - - infoText->setRichText(utils::translate("app_desktop_press_to_unlock")); - infoText->setAlignment(Alignment::Horizontal::Center); + infoIcon = new gui::Icon(this, + style::window::default_left_margin, + style::header::height, + style::window::default_body_width, + style::window::default_body_height, + "unlock_icon_W_G", + utils::translate("app_desktop_press_to_unlock")); + infoIcon->setAlignment(Alignment::Horizontal::Center); } diff --git a/module-apps/popups/lock-popups/PhoneLockedInfoWindow.hpp b/module-apps/popups/lock-popups/PhoneLockedInfoWindow.hpp index 70bb6a49dda484d863d0dd4a1244253126bd8c03..a0b7c5bd2c8ae6f75609cfaaa29dd8eecb87b0e2 100644 --- a/module-apps/popups/lock-popups/PhoneLockedInfoWindow.hpp +++ b/module-apps/popups/lock-popups/PhoneLockedInfoWindow.hpp @@ -5,16 +5,13 @@ #include #include -#include +#include namespace gui { class PhoneLockedInfoWindow : public AppWindow { - gui::Image *lockImage = nullptr; - gui::Text *infoText = nullptr; - - void setVisibleState(); + Icon *infoIcon = nullptr; public: PhoneLockedInfoWindow(app::Application *app, const std::string &name); diff --git a/module-apps/popups/lock-popups/SimInfoWindow.cpp b/module-apps/popups/lock-popups/SimInfoWindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2cbf64092df779ecc530fbc1c484cffd0370befb --- /dev/null +++ b/module-apps/popups/lock-popups/SimInfoWindow.cpp @@ -0,0 +1,67 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "SimInfoWindow.hpp" +#include +#include +#include + +using namespace gui; + +SimInfoWindow::SimInfoWindow(app::Application *app, const std::string &name) : WindowWithTimer(app, name) +{ + buildInterface(); +} + +top_bar::Configuration SimInfoWindow::configureTopBar(top_bar::Configuration appConfiguration) +{ + appConfiguration.enable(top_bar::Indicator::NetworkAccessTechnology); + appConfiguration.enable(top_bar::Indicator::Time); + appConfiguration.enable(top_bar::Indicator::PhoneMode); + appConfiguration.enable(top_bar::Indicator::Battery); + appConfiguration.enable(top_bar::Indicator::Signal); + appConfiguration.enable(top_bar::Indicator::SimCard); + return appConfiguration; +} + +void SimInfoWindow::onBeforeShow(ShowMode mode, SwitchData *data) +{ + WindowWithTimer::onBeforeShow(mode, data); + + if (auto infoData = dynamic_cast(data)) { + + switch (infoData->getSimInputTypeAction()) { + case locks::SimInputTypeAction::UnlockWithPuk: + case locks::SimInputTypeAction::ChangePin: + setTitle(utils::translate("sim_change_pin")); + infoIcon->text->setRichText(utils::translate("sim_pin_changed_successfully")); + break; + case locks::SimInputTypeAction::EnablePin: + setTitle(""); + infoIcon->text->setRichText(utils::translate("sim_card_pin_enabled")); + break; + case locks::SimInputTypeAction::DisablePin: + setTitle(""); + infoIcon->text->setRichText(utils::translate("sim_card_pin_disabled")); + break; + default: + break; + } + } +} + +void SimInfoWindow::buildInterface() +{ + AppWindow::buildInterface(); + + setTitle(utils::translate("sim_change_pin")); + + infoIcon = new gui::Icon(this, + style::window::default_left_margin, + style::header::height, + style::window::default_body_width, + style::window::default_body_height, + "success_icon_W_G", + utils::translate("sim_pin_changed_successfully")); + infoIcon->setAlignment(Alignment::Horizontal::Center); +} diff --git a/module-apps/popups/lock-popups/SimInfoWindow.hpp b/module-apps/popups/lock-popups/SimInfoWindow.hpp new file mode 100644 index 0000000000000000000000000000000000000000..477d989ab441416078f9cd6eef3f3aa443bf6c8d --- /dev/null +++ b/module-apps/popups/lock-popups/SimInfoWindow.hpp @@ -0,0 +1,23 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include +#include +#include + +namespace gui +{ + class SimInfoWindow : public WindowWithTimer + { + Icon *infoIcon = nullptr; + + public: + SimInfoWindow(app::Application *app, const std::string &name); + + void buildInterface() override; + void onBeforeShow(ShowMode mode, SwitchData *data) override; + top_bar::Configuration configureTopBar(top_bar::Configuration appConfiguration) override; + }; +} /* namespace gui */ diff --git a/module-apps/popups/lock-popups/SimLockInputWindow.cpp b/module-apps/popups/lock-popups/SimLockInputWindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a2491eb7d7e2fc457000758fcca0fa37eb2ec4a0 --- /dev/null +++ b/module-apps/popups/lock-popups/SimLockInputWindow.cpp @@ -0,0 +1,123 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "SimLockInputWindow.hpp" + +#include +#include +#include + +#include +#include + +namespace gui +{ + SimLockInputWindow::SimLockInputWindow(app::Application *app, const std::string &window_name) + : LockInputWindow(app, window_name) + { + buildInterface(); + } + + void SimLockInputWindow::rebuild() + { + destroyInterface(); + buildInterface(); + } + void SimLockInputWindow::buildInterface() + { + AppWindow::buildInterface(); + LockInputWindow::build(); + } + + void SimLockInputWindow::destroyInterface() + { + erase(); + } + + void SimLockInputWindow::setVisibleState() + { + LockInputWindow::setVisibleState(); + + if (lock->isState(locks::Lock::LockState::ErrorOccurred)) { + lockBox->setVisibleStateError(errorCode); + } + } + + top_bar::Configuration SimLockInputWindow::configureTopBar(top_bar::Configuration appConfiguration) + { + appConfiguration.disable(top_bar::Indicator::NetworkAccessTechnology); + appConfiguration.enable(top_bar::Indicator::Time); + appConfiguration.enable(top_bar::Indicator::PhoneMode); + appConfiguration.enable(top_bar::Indicator::Battery); + appConfiguration.enable(top_bar::Indicator::Signal); + appConfiguration.enable(top_bar::Indicator::SimCard); + return appConfiguration; + } + + void SimLockInputWindow::onBeforeShow(ShowMode mode, SwitchData *data) + { + if (auto SimLockData = dynamic_cast(data)) { + lock = std::make_unique(SimLockData->getLock()); + simLockInputTypeAction = SimLockData->getSimInputTypeAction(); + errorCode = SimLockData->getErrorCode(); + } + + // Lock need to exist in that window flow + assert(lock); + + rebuild(); + lockBox = std::make_unique(this, simLockInputTypeAction); + lockBox->buildLockBox(lock->getMaxInputSize()); + + setVisibleState(); + } + + bool SimLockInputWindow::onInput(const InputEvent &inputEvent) + { + if (!inputEvent.isShortRelease()) { + return AppWindow::onInput(inputEvent); + } + else if (inputEvent.is(KeyCode::KEY_RF) && bottomBar->isActive(BottomBar::Side::RIGHT)) { + if (isInInputState()) { + lock->clearAttempt(); + } + else if (lock->isState(locks::Lock::LockState::InputInvalid)) { + lock->consumeState(); + } + application->returnToPreviousWindow(); + return true; + } + else if (inputEvent.is(KeyCode::KEY_PND)) { + if (isInInputState()) { + lock->popChar(); + lockBox->popChar(lock->getCharCount()); + bottomBar->setActive(BottomBar::Side::CENTER, lock->canVerify()); + return true; + } + } + else if (inputEvent.isDigit()) { + if (isInInputState() && lock->canPut()) { + lockBox->putChar(lock->getCharCount()); + lock->putNextChar(inputEvent.numericValue()); + + bottomBar->setActive(BottomBar::Side::CENTER, lock->canVerify()); + return true; + } + } + else if (inputEvent.is(KeyCode::KEY_ENTER) && bottomBar->isActive(BottomBar::Side::CENTER)) { + if (isInInputState()) { + application->getSimLockSubject().verifyInput(lock->getInput()); + } + else if (isInInvalidInputState()) { + lock->consumeState(); + lock->clearAttempt(); + setVisibleState(); + } + return true; + } + + // check if any of the lower inheritance onInput methods catch the event + return AppWindow::onInput(inputEvent); + } + +} /* namespace gui */ diff --git a/module-apps/popups/lock-popups/SimLockInputWindow.hpp b/module-apps/popups/lock-popups/SimLockInputWindow.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d3abe6bc48f646245be3679e6c1cfa0f4537ea9a --- /dev/null +++ b/module-apps/popups/lock-popups/SimLockInputWindow.hpp @@ -0,0 +1,32 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include +#include +#include +#include + +namespace gui +{ + class SimLockInputWindow : public LockInputWindow + { + private: + locks::SimInputTypeAction simLockInputTypeAction = locks::SimInputTypeAction::UnlockWithPin; + unsigned int errorCode = 0; + + void setVisibleState() override; + + public: + SimLockInputWindow(app::Application *app, const std::string &window_name); + void onBeforeShow(ShowMode mode, SwitchData *data) override; + bool onInput(const InputEvent &inputEvent) override; + + void rebuild() override; + void buildInterface() override; + void destroyInterface() override; + top_bar::Configuration configureTopBar(top_bar::Configuration appConfiguration) override; + }; + +} /* namespace gui */ diff --git a/module-gui/gui/widgets/Icon.cpp b/module-gui/gui/widgets/Icon.cpp index e8c70c4ba75d13958a6aafcb68aeb8fb78b81c7c..5fe7f6d0b10f61cafb866a29e4ce63153ee7f118 100644 --- a/module-gui/gui/widgets/Icon.cpp +++ b/module-gui/gui/widgets/Icon.cpp @@ -22,7 +22,7 @@ Icon::Icon(Item *parent, setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); image = new Image(this, imageName); - image->setMargins(Margins(0, 0, 0, icon::image_bottom_margin)); + image->setMargins(Margins(0, icon::image_top_margin, 0, icon::image_bottom_margin)); text = new Text(this, 0, 0, 0, 0); text->setMaximumSize(w, h); diff --git a/module-gui/gui/widgets/ImageBox.cpp b/module-gui/gui/widgets/ImageBox.cpp index 2c88f07a9c4073bc876418f7d81ec22fc299bc3d..7d328e4c75535f598231f9a32358af5a61278a86 100644 --- a/module-gui/gui/widgets/ImageBox.cpp +++ b/module-gui/gui/widgets/ImageBox.cpp @@ -18,3 +18,8 @@ void ImageBox::showImage(bool show) { image->setVisible(show); } + +void ImageBox::setImage(const UTF8 &name) +{ + image->set(name); +} diff --git a/module-gui/gui/widgets/ImageBox.hpp b/module-gui/gui/widgets/ImageBox.hpp index 3bf72ab63b1cac9bcba9d05cc79460640ba5e65e..e7bd4959b1517e9eacdd013e0f9041c38a69d0e7 100644 --- a/module-gui/gui/widgets/ImageBox.hpp +++ b/module-gui/gui/widgets/ImageBox.hpp @@ -17,6 +17,7 @@ namespace gui ~ImageBox() override = default; void showImage(bool show); + void setImage(const UTF8 &name); private: Image *image; diff --git a/module-services/service-appmgr/CMakeLists.txt b/module-services/service-appmgr/CMakeLists.txt index 939152744cbb992b0f1c171ece6a97d4e11cb5b7..0e08a9ea52163d45fa16140b9db563f742cfdfae 100644 --- a/module-services/service-appmgr/CMakeLists.txt +++ b/module-services/service-appmgr/CMakeLists.txt @@ -4,7 +4,6 @@ message( "${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}" ) set(SOURCES ApplicationManifest.cpp Controller.cpp - data/SimActionsParams.cpp data/MmiActionsParams.cpp data/NotificationsChangedActionsParams.cpp model/ApplicationManager.cpp diff --git a/module-services/service-appmgr/data/SimActionsParams.cpp b/module-services/service-appmgr/data/SimActionsParams.cpp deleted file mode 100644 index c4a42be39142e2c4c8cd3b9a4f9c49f9cf821a6e..0000000000000000000000000000000000000000 --- a/module-services/service-appmgr/data/SimActionsParams.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include - -using namespace app::manager::actions; - -PasscodeParams::PasscodeParams(Store::GSM::SIM _sim, unsigned int _attempts, std::string _passcodeName) - : sim{_sim}, attempts{_attempts}, passcodeName{std::move(_passcodeName)} -{} - -Store::GSM::SIM PasscodeParams::getSim() const noexcept -{ - return sim; -} -unsigned int PasscodeParams::getAttempts() const noexcept -{ - return attempts; -} -const std::string &PasscodeParams::getPasscodeName() const noexcept -{ - return passcodeName; -} - -SimStateParams::SimStateParams(Store::GSM::SIM _sim) : sim{_sim} -{} - -Store::GSM::SIM SimStateParams::getSim() const noexcept -{ - return sim; -} - -UnhandledCMEParams::UnhandledCMEParams(Store::GSM::SIM _sim, unsigned int _cmeCode) : sim{_sim}, cmeCode{_cmeCode} -{} - -Store::GSM::SIM UnhandledCMEParams::getSim() const noexcept -{ - return sim; -} -unsigned int UnhandledCMEParams::getCMECode() const noexcept -{ - return cmeCode; -} diff --git a/module-services/service-appmgr/model/ApplicationManager.cpp b/module-services/service-appmgr/model/ApplicationManager.cpp index e8ab53050a29d1025aabc0329527bdf65e3e6e4d..5a714f499c88ba56bf2631359fed51bc670717c7 100644 --- a/module-services/service-appmgr/model/ApplicationManager.cpp +++ b/module-services/service-appmgr/model/ApplicationManager.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include "module-services/service-appmgr/service-appmgr/messages/ApplicationStatus.hpp" @@ -138,7 +139,7 @@ namespace app::manager actionsRegistry{[this](ActionEntry &action) { return handleAction(action); }}, notificationProvider(this), settings(std::make_unique()), phoneModeObserver(std::make_unique()), - phoneLockHandler(locks::PhoneLockHandler(this, settings)) + phoneLockHandler(locks::PhoneLockHandler(this, settings)), simLockHandler(this) { autoLockTimer = sys::TimerFactory::createSingleShotTimer( this, autoLockTimerName, sys::timer::InfiniteTimeout, [this](sys::Timer &) { onPhoneLocked(); }); @@ -425,6 +426,8 @@ namespace app::manager handleDBResponse(response); return sys::msgHandled(); }); + + // PhoneLock connects connect(typeid(locks::LockPhone), [&](sys::Message *request) -> sys::MessagePointer { return phoneLockHandler.handleLockRequest(); }); connect(typeid(locks::UnlockPhone), @@ -433,7 +436,7 @@ namespace app::manager return phoneLockHandler.handleUnlockCancelRequest(); }); connect(typeid(locks::UnLockPhoneInput), [&](sys::Message *request) -> sys::MessagePointer { - auto data = dynamic_cast(request); + auto data = static_cast(request); return phoneLockHandler.verifyPhoneLockInput(data->getInputData()); }); connect(typeid(locks::EnablePhoneLock), @@ -443,7 +446,7 @@ namespace app::manager }); connect(typeid(locks::UnlockedPhone), [&](sys::Message *request) -> sys::MessagePointer { autoLockTimer.start(); - return sys::msgHandled(); + return simLockHandler.releaseSimUnlockBlockOnLockedPhone(); }); connect(typeid(locks::ChangePhoneLock), [&](sys::Message *request) -> sys::MessagePointer { return phoneLockHandler.handleChangePhoneLock(); }); @@ -461,6 +464,112 @@ namespace app::manager return handleAutoLockSetRequest(req); }); + // SimLock connects + connect(typeid(cellular::msg::notification::SimNeedPin), [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + if (phoneLockHandler.isPhoneLocked()) { + simLockHandler.setSimUnlockBlockOnLockedPhone(); + } + return simLockHandler.handleSimPinRequest(data->attempts); + }); + connect(typeid(cellular::msg::request::sim::PinUnlock::Response), + [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + if (data->retCode) { + return simLockHandler.handleSimUnlockedMessage(); + } + return sys::msgNotHandled(); + }); + connect(typeid(locks::UnLockSimInput), [&](sys::Message *request) -> sys::MessagePointer { + auto msg = static_cast(request); + return simLockHandler.verifySimLockInput(msg->getInputData()); + }); + connect(typeid(cellular::msg::notification::SimNeedPuk), [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + if (phoneLockHandler.isPhoneLocked()) { + simLockHandler.setSimUnlockBlockOnLockedPhone(); + } + return simLockHandler.handleSimPukRequest(data->attempts); + }); + connect(typeid(cellular::msg::request::sim::UnblockWithPuk::Response), + [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + if (data->retCode) { + return simLockHandler.handleSimUnlockedMessage(); + } + return sys::msgNotHandled(); + }); + connect(typeid(locks::ChangeSimPin), [&](sys::Message *request) -> sys::MessagePointer { + return simLockHandler.handleSimPinChangeRequest(); + }); + connect(typeid(cellular::msg::request::sim::ChangePin::Response), + [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + if (data->retCode) { + return simLockHandler.handleSimChangedMessage(); + } + else { + return simLockHandler.handleSimPinChangeFailedRequest(); + } + }); + connect(typeid(locks::EnableSimPin), + [&](sys::Message *request) -> sys::MessagePointer { return simLockHandler.handleSimEnableRequest(); }); + connect(typeid(locks::DisableSimPin), + [&](sys::Message *request) -> sys::MessagePointer { return simLockHandler.handleSimDisableRequest(); }); + connect(typeid(cellular::msg::request::sim::SetPinLock::Response), + [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + if (data->retCode) { + return simLockHandler.handleSimAvailabilityMessage(); + } + else { + if (data->lock == cellular::api::SimLockState::Enabled) { + return simLockHandler.handleSimEnableRequest(); + } + else { + return simLockHandler.handleSimDisableRequest(); + } + } + }); + connect(typeid(cellular::msg::notification::SimBlocked), [&](sys::Message *request) -> sys::MessagePointer { + if (phoneLockHandler.isPhoneLocked()) { + simLockHandler.setSimUnlockBlockOnLockedPhone(); + } + return simLockHandler.handleSimBlockedRequest(); + }); + connect(typeid(cellular::msg::notification::UnhandledCME), [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + if (phoneLockHandler.isPhoneLocked()) { + simLockHandler.setSimUnlockBlockOnLockedPhone(); + } + return simLockHandler.handleCMEErrorRequest(data->code); + }); + connect(typeid(locks::SetSim), [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + simLockHandler.setSim(data->getSimSlot()); + return sys::msgHandled(); + }); + connect(typeid(cellular::msg::request::sim::SetActiveSim::Response), + [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + if (data->retCode) { + settings->setValue(::settings::SystemProperties::activeSim, + utils::enumToString(Store::GSM::get()->selected), + ::settings::SettingsScope::Global); + return sys::msgHandled(); + } + return sys::msgNotHandled(); + }); + connect(typeid(cellular::StateChange), [&](sys::Message *request) -> sys::MessagePointer { + auto data = static_cast(request); + if (data->request == cellular::service::State::ST::URCReady) { + simLockHandler.getSettingsSimSelect( + settings->getValue(settings::SystemProperties::activeSim, settings::SettingsScope::Global)); + return sys::msgHandled(); + } + return sys::msgNotHandled(); + }); + connect(typeid(sdesktop::developerMode::DeveloperModeRequest), [&](sys::Message *request) -> sys::MessagePointer { return handleDeveloperModeRequest(request); }); @@ -480,33 +589,6 @@ namespace app::manager connect(typeid(sys::TetheringQuestionAbort), convertibleToActionHandler); connect(typeid(sys::TetheringPhoneModeChangeProhibitedMessage), convertibleToActionHandler); connect(typeid(VolumeChanged), convertibleToActionHandler); - - /* Notifications from sys::BusChannel::ServiceCellularNotifications */ - connect(typeid(cellular::msg::notification::SimReady), [&](sys::Message *request) { - auto msg = static_cast(request); - handleSimReady(msg); - return sys::MessageNone{}; - }); - connect(typeid(cellular::msg::notification::SimNeedPin), [&](sys::Message *request) { - auto msg = static_cast(request); - handleSimNeedPin(msg); - return sys::MessageNone{}; - }); - connect(typeid(cellular::msg::notification::SimNeedPuk), [&](sys::Message *request) { - auto msg = static_cast(request); - handleSimNeedPuk(msg); - return sys::MessageNone{}; - }); - connect(typeid(cellular::msg::notification::SimBlocked), [&](sys::Message *request) { - auto msg = static_cast(request); - handleSimBlocked(msg); - return sys::MessageNone{}; - }); - connect(typeid(cellular::msg::notification::UnhandledCME), [&](sys::Message *request) { - auto msg = static_cast(request); - handleUnhandledCME(msg); - return sys::MessageNone{}; - }); } sys::ReturnCodes ApplicationManager::SwitchPowerModeHandler(const sys::ServicePowerMode mode) @@ -654,55 +736,6 @@ namespace app::manager actionsRegistry.enqueue(std::move(entry)); } - void ApplicationManager::handleSimReady(cellular::msg::notification::SimReady *msg) - { - if (msg->ready) { - auto action = std::make_unique( - msg->sender, - app::manager::actions::UnlockSim, - std::make_unique(Store::GSM::get()->selected)); - handleActionRequest(action.get()); - } - } - - void ApplicationManager::handleSimNeedPin(cellular::msg::notification::SimNeedPin *msg) - { - auto action = std::make_unique( - msg->sender, - app::manager::actions::RequestPin, - std::make_unique( - Store::GSM::get()->selected, msg->attempts, std::string())); - handleActionRequest(action.get()); - } - - void ApplicationManager::handleSimNeedPuk(cellular::msg::notification::SimNeedPuk *msg) - { - auto action = std::make_unique( - msg->sender, - app::manager::actions::RequestPuk, - std::make_unique( - Store::GSM::get()->selected, msg->attempts, std::string())); - handleActionRequest(action.get()); - } - - void ApplicationManager::handleSimBlocked(cellular::msg::notification::SimBlocked *msg) - { - auto action = std::make_unique( - msg->sender, - app::manager::actions::BlockSim, - std::make_unique(Store::GSM::get()->selected)); - handleActionRequest(action.get()); - } - - void ApplicationManager::handleUnhandledCME(cellular::msg::notification::UnhandledCME *msg) - { - auto action = std::make_unique( - msg->sender, - app::manager::actions::DisplayCMEError, - std::make_unique(Store::GSM::get()->selected, msg->code)); - handleActionRequest(action.get()); - } - void ApplicationManager::handlePhoneModeChanged(sys::phone_modes::PhoneMode phoneMode) { for (const auto app : getRunningApplications()) { diff --git a/module-services/service-appmgr/service-appmgr/Actions.hpp b/module-services/service-appmgr/service-appmgr/Actions.hpp index 76b8881822b896cfe7a6ba4bd986714476f8061c..de7099cd629e9607cfa98620104144f29b997005 100644 --- a/module-services/service-appmgr/service-appmgr/Actions.hpp +++ b/module-services/service-appmgr/service-appmgr/Actions.hpp @@ -39,21 +39,12 @@ namespace app::manager EditContact, ShowContactDetails, ShowSpecialInput, - SelectSimCard, ShowAlarm, ShowReminder, - RequestPin, - RequestPuk, - RequestPinChange, - RequestPinDisable, - RequestPinEnable, - UnlockSim, - BlockSim, ShowMMIResult, ShowMMIResponse, ShowMMIPush, SmsRejectNoSim, - DisplayCMEError, DisplayLowBatteryScreen, SystemBrownout, DisplayLogoAtExit, diff --git a/module-services/service-appmgr/service-appmgr/data/SimActionsParams.hpp b/module-services/service-appmgr/service-appmgr/data/SimActionsParams.hpp deleted file mode 100644 index aab59902868550d83c06e8c68f5b374e6788ce57..0000000000000000000000000000000000000000 --- a/module-services/service-appmgr/service-appmgr/data/SimActionsParams.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#pragma once - -#include -#include - -namespace app::manager::actions -{ - /** Action parameters for - * RequestPinAction - * RequestPukAction - * ChangePinAction - */ - class PasscodeParams : public ActionParams - { - Store::GSM::SIM sim; - unsigned int attempts; - /// passcodeName stands for PIN1/PIN2 or PUK1/PUK2 type - std::string passcodeName; - - public: - PasscodeParams(Store::GSM::SIM _sim, unsigned int _attempts, std::string _passcodeName); - - [[nodiscard]] Store::GSM::SIM getSim() const noexcept; - [[nodiscard]] unsigned int getAttempts() const noexcept; - [[nodiscard]] const std::string &getPasscodeName() const noexcept; - - static constexpr auto numOfAttemptsForEnteringPIN = 3u; - static constexpr auto numOfAttemptsForEnteringPUK = 10u; - - static constexpr auto pinName = "PIN"; - static constexpr auto pukName = "PUK"; - }; - - /** Action parameters for - * SimUnlockedAction - * SimBlockedAction - */ - class SimStateParams : public ActionParams - { - Store::GSM::SIM sim; - - public: - explicit SimStateParams(Store::GSM::SIM _sim); - - [[nodiscard]] Store::GSM::SIM getSim() const noexcept; - }; - - /** Action parameters for - * UnhandledCMEError - */ - class UnhandledCMEParams : public ActionParams - { - Store::GSM::SIM sim; - unsigned int cmeCode; - - public: - UnhandledCMEParams(Store::GSM::SIM _sim, unsigned int _cmeCode); - - [[nodiscard]] Store::GSM::SIM getSim() const noexcept; - [[nodiscard]] unsigned int getCMECode() const noexcept; - }; -} // namespace app::manager::actions diff --git a/module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp b/module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp index 3b43d26ca3c3647366a353f2f41b7eeb57518fb8..b3a770b14c6e93ef83ad043385125800532ef9b4 100644 --- a/module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp +++ b/module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp @@ -32,7 +32,7 @@ #include #include -#include +#include namespace app { @@ -151,11 +151,6 @@ namespace app::manager auto handleDBResponse(db::QueryResponse *msg) -> bool; auto handlePowerSavingModeInit() -> bool; auto handleMessageAsAction(sys::Message *request) -> std::shared_ptr; - void handleSimReady(cellular::msg::notification::SimReady *msg); - void handleSimNeedPin(cellular::msg::notification::SimNeedPin *msg); - void handleSimNeedPuk(cellular::msg::notification::SimNeedPuk *msg); - void handleSimBlocked(cellular::msg::notification::SimBlocked *msg); - void handleUnhandledCME(cellular::msg::notification::UnhandledCME *msg); auto handleDeveloperModeRequest(sys::Message *request) -> sys::MessagePointer; /// handles dom request by passing this request to application which should provide the dom auto handleDOMRequest(sys::Message *request) -> std::shared_ptr; @@ -192,6 +187,7 @@ namespace app::manager std::unique_ptr phoneModeObserver; locks::PhoneLockHandler phoneLockHandler; + locks::SimLockHandler simLockHandler; void displayLanguageChanged(std::string value); void lockTimeChanged(std::string value); diff --git a/module-services/service-cellular/service-cellular/CellularMessage.hpp b/module-services/service-cellular/service-cellular/CellularMessage.hpp index fa2cea55b2922de1ce12b5c9df9c2b9eb336f5eb..f9393086eca68ec1ca83c00927dcdd48f27483d6 100644 --- a/module-services/service-cellular/service-cellular/CellularMessage.hpp +++ b/module-services/service-cellular/service-cellular/CellularMessage.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include diff --git a/module-services/service-desktop/service-desktop/DesktopMessages.hpp b/module-services/service-desktop/service-desktop/DesktopMessages.hpp index 107147c20eecf8286f57f447b2bc4cd939841ab8..a74f2d52982bef7cdd02261449dd4eee70da1390 100644 --- a/module-services/service-desktop/service-desktop/DesktopMessages.hpp +++ b/module-services/service-desktop/service-desktop/DesktopMessages.hpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include