/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 8 Ġ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 . browser . default B rowsing Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . content . Intent . ACTION _ VIEW Ċ import Ġandroid . content . pm . PackageManager Ċ import Ġandroid . content . pm . Resolve Info Ċ import Ġandroid . net . Uri Ċ import Ġandroid . os . Build Ċ import Ġcom . duck duck go . app . browser . Build Config Ċ import Ġcom . duck duck go . app . global . install . App Install Store Ċ import Ġtim ber . log . Tim ber Ċ import Ġjavax . inject . Inject Ċ Ċ interface ĠDefault Browser Detector Ġ{ ĊĠĠĠ Ġfun Ġdevice Supports Default Browser Configuration (): ĠBoolean ĊĠĠĠ Ġfun Ġis Currently Configured As Default Browser (): ĠBoolean ĊĠĠĠ Ġfun Ġuser Decl ined To Set As Default Browser ( timestamp : ĠLong Ġ= ĠSystem . currentTimeMillis ()) Ċ } Ċ Ċ class ĠAndroid Default Browser Detector Ġ@ Inject Ġconstructor ( private Ġval Ġcontext : ĠContext , Ġprivate Ġval Ġapp Install Store : ĠApp Install Store ) Ġ: ĊĠĠĠ ĠDefault Browser Detector Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġdevice Supports Default Browser Configuration (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠBuild . VERSION . SDK _ INT Ġ>= ĠBuild . VERSION _ CODES . N ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġis Currently Configured As Default Browser (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( ACTION _ VIEW , ĠUri . parse (" https :// ")) ĊĠĠĠĠĠĠĠ Ġval Ġresolution Info : ĠResolve Info ? Ġ= Ġcontext . package Manager . resolve Activity ( intent , ĠPackage Manager . MATCH _ DEFAULT _ ONLY ) ĊĠĠĠĠĠĠĠ Ġval Ġdefault Already Ġ= Ġresolution Info ?. activity Info ?. packageName Ġ== ĠBuild Config . APPLICATION _ ID ĊĊĠĠĠĠĠĠĠ ĠTim ber . i (" Default Ġbrowser Ġidentified Ġas Ġ${ resolution Info ?. activity Info ?. packageName }") ĊĠĠĠĠĠĠĠ Ġreturn Ġdefault Already ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġuser Decl ined To Set As Default Browser ( timestamp : ĠLong ) Ġ{ ĊĠĠĠĠĠĠĠ Ġapp Install Store . record User Decl ined To SetDefault Browser ( timestamp ) ĊĠĠĠ Ġ} Ċ }