package Ġcom . sensor berg . notifications . sdk . internal . work Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroidx . work . Worker Ċ import Ġandroidx . work . Worker Parameters Ċ import Ġcom . sensor berg . notifications . sdk . internal . Sdk Enable Handler Ċ import Ġcom . sensor berg . notifications . sdk . internal . backend . Backend Ċ import Ġcom . sensor berg . notifications . sdk . internal . log Result Ċ import Ġcom . sensor berg . notifications . sdk . internal . log Start Ċ import Ġcom . sensor berg . notifications . sdk . internal . model . Action Conversion Ċ import Ġcom . sensor berg . notifications . sdk . internal . model . Action History Ċ import Ġcom . sensor berg . notifications . sdk . internal . storage . Action Dao Ċ import Ġcom . sensor berg . notifications . sdk . internal . Notification Sdk Component Ċ import Ġorg . k oin . core . inject Ċ import Ġtim ber . log . Tim ber Ċ import Ġjava . util . concurrent . Ex ch anger Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ internal Ġclass ĠUpload Work ( context : ĠContext , Ġworker Params : ĠWorker Parameters ) Ġ: ĠWorker ( context , Ġworker Params ), ĠNotification Sdk Component Ġ{ ĊĊ ĉ private Ġval Ġsdk Enable Handler : ĠS dk Enable Handler Ġby Ġinject () Ċ ĉ private Ġval Ġdao : ĠAction Dao Ġby Ġinject () Ċ ĉ private Ġval Ġbackend : ĠBackend Ġby Ġinject () Ċ ĉ private Ġval Ġbackend Execution Ġ= ĠEx ch anger < Result >() ĊĊ ĉ override Ġfun Ġdo Work (): ĠResult Ġ{ Ċĉ ĉ if Ġ(! sdk Enable Handler . isEnabled ()) Ġreturn ĠResult . failure () Ċĉ ĉ log Start () ĊĊĉ ĉ val Ġactions : ĠList < Action History > Ġ= Ġdao . getAction History () Ċĉ ĉ val Ġconversions : ĠList < Action Conversion > Ġ= Ġdao . getAction Conversion () Ċĉ ĉ if Ġ( actions . isEmpty () Ġ&& Ġconversions . isEmpty ()) Ġ{ Ċĉĉ ĉ Tim ber . d (" Nothing Ġto Ġupload ") Ċĉĉ ĉ return ĠResult . success () Ċĉ ĉ } ĊĊĉ ĉ Tim ber . d (" Executing Ġupload Ġwork Ġfor Ġ${ actions . size } Ġactions Ġtriggered Ġand Ġ${ conversions . size } Ġconversion Ġdata ") ĊĊĉ ĉ backend . publish History ( actions , Ġconversions ) Ġ{ Ċĉĉ ĉ val Ġresult Ġ= Ġif Ġ( it ) ĠResult . success () Ġelse ĠResult . retry () Ċĉĉ ĉ backend Execution . exchange ( result ) Ċĉ ĉ } ĊĊĉ ĉ return Ġlog Result ( try Ġ{ Ċĉĉ ĉ val Ġresult Ġ= Ġbackend Execution . exchange ( null , Ġ 3 0 , ĠTimeUnit . SECONDS ) Ċĉĉ ĉ if Ġ( result Ġ== ĠResult . success ()) Ġ{ Ċĉĉĉ ĉ dao . clear Action History ( actions ) Ċĉĉĉ ĉ dao . clear Action Conversion ( conversions ) Ċĉĉ ĉ } Ċĉĉ ĉ Tim ber . d (" Upload Ġwork Ġexecution Ġ$ result ") Ċĉĉ ĉ result Ċĉ ĉ } Ġcatch Ġ( e : ĠException ) Ġ{ Ċĉĉ ĉ Tim ber . w ( e , Ġ" Upload Ġwork Ġexecution Ġfailed ") Ċĉĉ ĉ Result . retry () Ċĉ ĉ }) Ċ ĉ } Ċ }