package Ġcom . pr aver a . flutter _ foreground _ task Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroidx . annotation . NonNull Ċ import Ġcom . pr aver a . flutter _ foreground _ task . errors . ErrorCode s Ċ import Ġcom . pr aver a . flutter _ foreground _ task . service . Foreground Service Manager Ċ import Ġcom . pr aver a . flutter _ foreground _ task . utils . Screen Utils Ċ Ċ import Ġio . flutter . plugin . common . Binary Messenger Ċ import Ġio . flutter . plugin . common . MethodCall Ċ import Ġio . flutter . plugin . common . Method Channel Ċ Ċ /** ĠMethod Call Handler Impl Ġ*/ Ċ class ĠMethod Call Handler Impl : ĠMethod Channel . MethodCall Handler Ġ{ Ċ ĉ private Ġlateinit Ġvar Ġmethod Channel Ġ: ĠMethod Channel Ċ ĉ private Ġlateinit Ġvar Ġforeground Service Manager Ġ: ĠFore ground Service Manager ĊĊ ĉ private Ġvar Ġactivity : ĠActivity ? Ġ= Ġnull ĊĊ ĉ fun Ġstart Listening ( messenger : ĠBinary Messenger ) Ġ{ Ċĉ ĉ foreground Service Manager Ġ= ĠFore ground Service Manager () Ċĉ ĉ method Channel Ġ= ĠMethod Channel ( messenger , Ġ" flutter _ foreground _ task / method ") Ċĉ ĉ method Channel . set MethodCall Handler ( this ) Ċ ĉ } ĊĊ ĉ fun Ġstop Listening () Ġ{ Ċĉ ĉ if Ġ(:: method Channel . isInitialized ) Ċĉĉ ĉ method Channel . set MethodCall Handler ( null ) Ċ ĉ } ĊĊ ĉ fun Ġset Activity ( activity : ĠActivity ?) Ġ{ Ċĉ ĉ this . activity Ġ= Ġactivity Ċ ĉ } ĊĊ ĉ private Ġfun Ġhandle Error ( result : ĠMethod Channel . Result , ĠerrorCode : ĠError Codes ) Ġ{ Ċĉ ĉ result . error ( errorCode . toString (), Ġnull , Ġnull ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon MethodCall (@ NonNull Ġcall : ĠMethod Call , Ġ@ NonNull Ġresult : ĠMethod Channel . Result ) Ġ{ Ċĉ ĉ if Ġ( activity Ġ== Ġnull ) Ġ{ Ċĉĉ ĉ handleError ( result , ĠError Codes . ACTIVITY _ NOT _ REGISTER ED ) Ċĉĉ ĉ return Ċĉ ĉ } ĊĊĉ ĉ when Ġ( call . method ) Ġ{ Ċĉĉ ĉ " start Foreground Service " Ġ-> Ġforeground Service Manager . start ( activity !! , Ġcall ) Ċĉĉ ĉ " update Foreground Service " Ġ-> Ġforeground Service Manager . update ( activity !! , Ġcall ) Ċĉĉ ĉ " stop Foreground Service " Ġ-> Ġforeground Service Manager . stop ( activity !! ) Ċĉĉ ĉ " minimize App " Ġ-> ĠScreen Utils . minimize App ( activity !! ) Ċĉĉ ĉ " wake Up Screen " Ġ-> ĠScreen Utils . wake Up Screen ( activity !! ) Ċĉĉ ĉ else Ġ-> Ġresult . not Implemented () Ċĉ ĉ } Ċ ĉ } Ċ } Ċ