/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 2 0 ĠD uck Duck Go Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . duck duck go . app . https upgrade Ċ Ċ import Ġandroidx . annotation . Worker Thread Ċ import Ġcom . duck duck go . app . global . store . Binary DataStore Ċ import Ġcom . duck duck go . app . https upgrade . model . Https B loom Filter Spec . Companion . HTTPS _ BINARY _ FILE Ċ import Ġcom . duck duck go . app . https upgrade . store . Https B loom Filter Spec Dao Ċ import Ġcom . duck duck go . app . https upgrade . store . Https Embedded Data Pers ister Ċ import Ġcom . duck duck go . app . https upgrade . store . Https Data Pers ister Ċ import Ġtim ber . log . Tim ber Ċ import Ġjavax . inject . Inject Ċ Ċ interface ĠHttp s B loom Filter Factory Ġ{ ĊĠĠĠ Ġfun Ġcreate (): ĠB loom Filter ? Ċ } Ċ Ċ class ĠHttp s B loom Filter Factory Impl Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġdao : ĠHttp s B loom Filter Spec Dao , ĊĠĠĠ Ġprivate Ġval Ġbinary DataStore : ĠBinary DataStore , ĊĠĠĠ Ġprivate Ġval Ġhttps Embedded Data Pers ister : ĠHttp s Embedded Data Pers ister , ĊĠĠĠ Ġprivate Ġval Ġhttps Data Pers ister : ĠHttp s Data Pers ister Ċ ) Ġ: ĠHttp s B loom Filter Factory Ġ{ ĊĊĠĠĠ Ġ@ Worker Thread ĊĠĠĠ Ġoverride Ġfun Ġcreate (): ĠB loom Filter ? Ġ{ ĊĊĠĠĠĠĠĠĠ Ġif Ġ( https Embedded Data Pers ister . should Persist Embedded Data ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTim ber . d (" Https Ġupdate Ġdata Ġnot Ġfound , Ġloading Ġembedded Ġdata ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhttps Embedded Data Pers ister . persist Embedded Data () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġspecification Ġ= Ġdao . get () ĊĠĠĠĠĠĠĠ Ġval Ġdata Path Ġ= Ġbinary DataStore . data FilePath ( HTTPS _ BINARY _ FILE ) ĊĠĠĠĠĠĠĠ Ġif Ġ( data Path Ġ== Ġnull Ġ|| Ġspecification Ġ== Ġnull Ġ|| Ġ! https Data Pers ister . is Pers isted ( specification )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTim ber . d (" Https Ġupdate Ġdata Ġnot Ġavailable ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġnull ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Timestamp Ġ= ĠSystem . currentTimeMillis () ĊĠĠĠĠĠĠĠ ĠTim ber . d (" Found Ġhttps Ġdata Ġat Ġ$ data Path , Ġbuilding Ġfilter ") ĊĠĠĠĠĠĠĠ Ġval Ġb loom Filter Ġ= ĠB loom Filter ( data Path , Ġspecification . bit Count , Ġspecification . total Entries ) ĊĠĠĠĠĠĠĠ ĠTim ber . v (" Loading Ġtook Ġ${ System . currentTimeMillis () Ġ- Ġinitial Timestamp } ms ") ĊĊĠĠĠĠĠĠĠ Ġreturn Ġb loom Filter ĊĠĠĠ Ġ} Ċ } Ċ