/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 2 0 Ġpan pf Ġ< pan p fp an pf @ outlook . com > Ċ Ġ* Ċ Ġ* Ġ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 . Ċ Ġ*/ Ċ Ċ @ file : Suppress (" NOTH ING _ TO _ INLINE ") Ċ Ċ package Ġcom . github . pan pf . tools 4 a . network . k tx Ċ Ċ import Ġandroid . Manifest Ċ import Ġandroid . content . Context Ċ import Ġandroid . net . Connectivity Manager Ċ import Ġandroid . net . Network Ċ import Ġandroid . os . Build Ċ import Ġandroidx . annotation . Requires Api Ċ import Ġandroidx . annotation . Requires Permission Ċ import Ġcom . github . pan pf . tools 4 a . network . Network Capabilities Compat Ċ import Ġcom . github . pan pf . tools 4 a . network . Network x Ċ Ċ /** Ċ Ġ* ĠGet Ġthe Ġcurrently Ġactive Ġnetwork Ċ Ġ* Ċ Ġ* Ġ@ receiver Ġ[ Connectivity Manager ]. ĠNetwork Ġconnection Ġmanager Ċ Ġ* Ġ@ return Ġ[ Network ]. ĠDescribe Ġnetwork Ġrelated Ġinformation Ċ Ġ*/ Ċ @ Requires Api ( api Ġ= ĠBuild . VERSION _ CODES . LO L LI POP ) Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠConnect ivity Manager . active Network Compat (): ĠNetwork ? Ġ= ĠNetwork x . active Network ( this ) Ċ Ċ /** Ċ Ġ* ĠGet Ġthe Ġcurrently Ġactive Ġnetwork Ċ Ġ* Ċ Ġ* Ġ@ receiver Ġ[ Context ]. ĠApp Ġcontext Ċ Ġ* Ġ@ return Ġ[ Network ]. ĠDescribe Ġnetwork Ġrelated Ġinformation Ċ Ġ*/ Ċ @ Requires Api ( api Ġ= ĠBuild . VERSION _ CODES . LO L LI POP ) Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . active Network (): ĠNetwork ? Ġ= ĠNetwork x . active Network ( this ) Ċ Ċ /** Ċ Ġ* ĠReturn ĠNetwork Capabilities Compat , Ġprovides ĠNetwork Capabilities Ġsupport Ġfor Ġversions Ġbelow ĠL Ċ Ġ* Ċ Ġ* Ġ@ receiver Ġ[ Context ]. ĠApp Ġcontext Ċ Ġ* Ġ@ return Ġ[ Network Capabilities Compat ]. ĠProvides ĠNetwork Capabilities Ġsupport Ġfor Ġversions Ġbelow ĠL Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . network Capabilities Compat (): ĠNetwork Capabilities Compat Ġ= ĠNetwork x . network Capabilities Compat ( this ) ĊĊ Ċ /** Ċ Ġ* ĠReturn Ġtrue Ġif Ġany Ġtype Ġof Ġnetwork Ġis Ġcurrently Ġconnected Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . is Network Connected (): ĠBoolean Ġ= ĠNetwork x . isConnected ( this ) Ċ Ċ /** Ċ Ġ* ĠIndicates Ġthat Ġcurrently Ġconnected Ġnetwork Ġhas Ġwi - fi Ġtransport Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . is Wifi Network Connected (): ĠBoolean Ġ= ĠNetwork x . is Wifi Connected ( this ) Ċ Ċ /** Ċ Ġ* ĠIndicates Ġthat Ġcurrently Ġconnected Ġnetwork Ġhas Ġcell ular Ġtransport Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . is Cell ular Network Connected (): ĠBoolean Ġ= ĠNetwork x . is Cell ular Connected ( this ) ĊĊ Ċ /** Ċ Ġ* ĠIndicates Ġthat Ġcurrently Ġconnected Ġnetwork Ġis Ġun meter ed . Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . is Network Not Meter ed (): ĠBoolean Ġ= ĠNetwork x . isNot Meter ed ( this ) Ċ Ċ /** Ċ Ġ* ĠIndicates Ġthat Ġcurrently Ġconnected Ġnetwork Ġis Ġmeter ed . Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . is Network Meter ed (): ĠBoolean Ġ= ĠNetwork x . is Meter ed ( this ) Ċ Ċ /** Ċ Ġ* ĠIndicates Ġthat Ġcurrently Ġconnected Ġnetwork Ġis Ġnot Ġro aming . Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . is Network Not Roaming (): ĠBoolean Ġ= ĠNetwork x . isNot Roaming ( this ) Ċ Ċ /** Ċ Ġ* ĠIndicates Ġthat Ġcurrently Ġconnected Ġnetwork Ġis Ġro aming . Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . is Network Roaming (): ĠBoolean Ġ= ĠNetwork x . is Roaming ( this ) ĊĊ Ċ /** Ċ Ġ* ĠReturns Ġthe Ġnames Ġof Ġthe Ġcurrent Ġnetwork Ġall Ġtransport , Ċ Ġ* Ġfor Ġexample : Ġ' CELL ULAR & WIFI & BL U ETO OTH & ETHER NET & VPN & WIFI _ AW ARE & LOW PAN & TEST ' Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . get Network Transport Names (): ĠString ? Ġ= ĠNetwork x . get Transport Names ( this ) Ċ Ċ /** Ċ Ġ* ĠReturns Ġthe Ġnames Ġof Ġthe Ġcurrent Ġnetwork Ġall Ġcapability , Ċ Ġ* Ġfor Ġexample : Ġ' INTER NET & TR UST ED & NOT _ METER ED & NOT _ VPN & VALID ATED & ...' Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ NETWORK _ STATE ) Ċ inline Ġfun ĠContext . get Network Capability Names (): ĠString ? Ġ= ĠNetwork x . get Capability Names ( this ) Ċ Ċ /** Ċ Ġ* ĠGet Ġthe Ġstatus Ġof ĠWi - Fi Ċ Ġ* Ċ Ġ* Ġ@ return ĠThe Ġvalue Ġis Ġone Ġof ĠW IFI _ STATE _ ENABLED , ĠW IFI _ STATE _ EN AB LING , ĠW IFI _ STATE _ DISABLED , ĠW IFI _ STATE _ DIS AB LING , ĠW IFI _ STATE _ UNKNOWN Ġin ĠW ifi Manager . Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ WIFI _ STATE ) Ċ inline Ġfun ĠContext . get Wifi State (): ĠInt Ġ= ĠNetwork x . get Wifi State ( this ) Ċ Ċ /** Ċ Ġ* ĠReturn Ġtrue Ġif ĠWi - Fi Ġis Ġturned Ġon Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ WIFI _ STATE ) Ċ inline Ġfun ĠContext . is Wifi Enabled (): ĠBoolean Ġ= ĠNetwork x . is Wifi Enabled ( this ) Ċ Ċ /** Ċ Ġ* ĠTurn ĠWi - Fi Ġon Ġor Ġoff Ċ Ġ*/ Ċ @ Suppress (" Deprecated Callable Add Replace With ") Ċ @ Deprecated (" Starting Ġwith ĠBuild . VERSION _ CODES # Q , Ġapplications Ġare Ġnot Ġallowed Ġto Ġenable / disable ĠWi - Fi .") Ċ @ Requires Permission ( any Of Ġ= Ġ[( Manifest . permission . ACCESS _ WIFI _ STATE ), Ġ( Manifest . permission . CHANGE _ WIFI _ STATE )]) Ċ inline Ġfun ĠContext . set Wifi Enabled ( enable : ĠBoolean ): ĠBoolean Ġ= ĠNetwork x . set Wifi Enabled ( this , Ġenable ) Ċ Ċ /** Ċ Ġ* ĠReturn Ġwi - fi Ġgateway Ċ Ġ*/ Ċ @ Requires Permission ( Manifest . permission . ACCESS _ WIFI _ STATE ) Ċ inline Ġfun ĠContext . get Wifi Gateway (): ĠString ? Ġ= ĠNetwork x . get Wifi Gateway ( this )