package Ġat . spec ure . worker Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroidx . work . Backoff Policy Ċ import Ġandroidx . work . Constraints Ċ import Ġandroidx . work . Data Ċ import Ġandroidx . work . Existing Work Policy Ċ import Ġandroidx . work . Network Type Ċ import Ġandroidx . work . One Time Work Request Ċ import Ġandroidx . work . Work Manager Ċ import Ġat . spec ure . worker . request . Send Data Worker Ċ import Ġat . spec ure . worker . request . Settings Worker Ċ import Ġat . spec ure . worker . request . Signal Measurement Chunk Worker Ċ import Ġat . spec ure . worker . request . Signal Measurement Info Worker Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ private Ġconst Ġval ĠWAIT ING _ TIME _ B ETWEEN _ REQUEST Ġ= Ġ 1 0 L Ċ private Ġconst Ġval ĠSET T INGS _ REQUEST _ WORK _ NAME Ġ= Ġ" SETTINGS _ REQUEST _ WORK _ NAME " Ċ private Ġconst Ġval ĠDEL AY ED _ SUB MISSION _ WORK _ NAME Ġ= Ġ" DELAY ED _ SUB MISSION _ WORK _ NAME " Ċ private Ġconst Ġval ĠSERVER _ MEAS UREMENT _ INFO Ġ= Ġ" SERVER _ MEAS UREMENT _ INFO " Ċ private Ġconst Ġval ĠSIGNAL _ MEAS UREMENT _ CHUNK Ġ= Ġ" SIGNAL _ MEAS UREMENT _ CHUNK " Ċ Ċ const Ġval ĠKEY _ TEST _ UUID Ġ= Ġ" key _ test _ uuid " Ċ Ċ object ĠWork Launcher Ġ{ ĊĊĠĠĠ Ġfun Ġenqueue Settings Request ( context : ĠContext ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġwork Request Ġ= ĠOne Time Work Request . Builder ( Settings Worker :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Constraints ( get Worker Constraints ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Tag ( SETTINGS _ REQUEST _ WORK _ NAME ). set Backoff Criteria ( Backoff Policy . LINEAR , ĠWAIT ING _ TIME _ B ETWEEN _ REQUEST , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ ĠWork Manager . getInstance ( context ). enqueue Unique Work ( SETTINGS _ REQUEST _ WORK _ NAME , ĠExisting Work Policy . REPLACE , Ġwork Request ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġenqueue Delayed Data Save Request ( context : ĠContext , Ġtest UUID : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinput Data Ġ= ĠData . Builder (). putString ( KEY _ TEST _ UUID , Ġtest UUID ). build () ĊĊĠĠĠĠĠĠĠ Ġval Ġwork Request Ġ= ĠOne Time Work Request . Builder ( Send Data Worker :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set InputData ( input Data ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Constraints ( get Worker Constraints ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Tag ( DELAY ED _ SUB MISSION _ WORK _ NAME ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Backoff Criteria ( Backoff Policy . EXP ON ENTIAL , ĠWAIT ING _ TIME _ B ETWEEN _ REQUEST , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ ĠWork Manager . getInstance ( context ). enqueue Unique Work ( DELAY ED _ SUB MISSION _ WORK _ NAME , ĠExisting Work Policy . REPLACE , Ġwork Request ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġenqueue Signal Measurement Info Request ( context : ĠContext , Ġmeasurement Id : ĠString ) Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠOne Time Work Request . Builder ( Signal Measurement Info Worker :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set InputData ( Signal Measurement Info Worker . getData ( measurement Id )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Constraints ( get Worker Constraints ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Backoff Criteria ( Backoff Policy . EXP ON ENTIAL , ĠWAIT ING _ TIME _ B ETWEEN _ REQUEST , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ ĠWork Manager . getInstance ( context ). enqueue Unique Work ( SERVER _ MEAS UREMENT _ INFO , ĠExisting Work Policy . REPLACE , Ġrequest ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġenqueue Signal Measurement Chunk Request ( context : ĠContext , Ġchunk Id : ĠString ) Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠOne Time Work Request . Builder ( Signal Measurement Chunk Worker :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set InputData ( Signal Measurement Chunk Worker . getData ( chunk Id )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Constraints ( get Worker Constraints ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Backoff Criteria ( Backoff Policy . EXP ON ENTIAL , ĠWAIT ING _ TIME _ B ETWEEN _ REQUEST , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ ĠWork Manager . getInstance ( context ). enqueue Unique Work ( SIGNAL _ MEAS UREMENT _ CHUNK , ĠExisting Work Policy . REPLACE , Ġrequest ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Worker Constraints () Ġ= ĠConstraints . Builder () ĊĠĠĠĠĠĠĠ Ġ. set Required Network Type ( Network Type . CONNECTED ) ĊĠĠĠĠĠĠĠ Ġ. build () Ċ }