package Ġuk . co . ri bot . android boilerplate . runner Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroid . app . Key guard Manager Ċ import Ġandroid . os . Power Manager Ċ import Ġandroid . support . test . runner . Android JUnit Runner Ċ Ċ import Ġandroid . content . Context . KEY GU ARD _ SERVICE Ċ import Ġandroid . content . Context . POWER _ SERVICE Ċ import Ġandroid . os . Power Manager . AC Q UIRE _ CA USE S _ WAKE UP Ċ import Ġandroid . os . Power Manager . FULL _ WAKE _ LOCK Ċ import Ġandroid . os . Power Manager . ON _ AFTER _ RELEASE Ċ Ċ /** Ċ Ġ* ĠExtension Ġof ĠAndroid JUnit Runner Ġthat Ġadds Ġsome Ġfunctionality Ġto Ġun block Ġthe Ġdevice Ġscreen Ċ Ġ* Ġbefore Ġstarting Ġthe Ġtests . Ċ Ġ*/ Ċ open Ġclass ĠUn lock Device Android JUnit Runner Ġ: ĠAndroid JUnit Runner () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Wake Lock : ĠPower Manager . Wake Lock ĊĊĠĠĠ Ġoverride Ġfun ĠonStart () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġapplication Ġ= Ġtarget Context . application Context Ġas ĠApplication ĊĠĠĠĠĠĠĠ Ġval Ġsimple Name Ġ= ĠUn lock Device Android JUnit Runner :: class . java . simple Name ĊĊĠĠĠĠĠĠĠ Ġ// ĠUn lock Ġthe Ġdevice Ġso Ġthat Ġthe Ġtests Ġcan Ġinput Ġkey stro kes . ĊĠĠĠĠĠĠĠ Ġ( application . getSystem Service ( KEY GU ARD _ SERVICE ) Ġas ĠKey guard Manager ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. new Key guard Lock ( simple Name ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. disable Key guard () ĊĊĠĠĠĠĠĠĠ Ġ// ĠW ake Ġup Ġthe Ġscreen . ĊĠĠĠĠĠĠĠ Ġval Ġpower Manager Ġ= Ġapplication . getSystem Service ( POWER _ SERVICE ) Ġas ĠPower Manager ĊĠĠĠĠĠĠĠ Ġm Wake Lock Ġ= Ġpower Manager . new Wake Lock ( FULL _ WAKE _ LOCK Ġor ĠAC Q UIRE _ CA USE S _ WAKE UP Ġor ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠON _ AFTER _ RELEASE , Ġsimple Name ) ĊĠĠĠĠĠĠĠ Ġm Wake Lock . acquire () ĊĠĠĠĠĠĠĠ Ġsuper . onStart () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy () ĊĠĠĠĠĠĠĠ Ġm Wake Lock . release () ĊĠĠĠ Ġ} Ċ } Ċ