package Ġio . re bble . co bble . datas ources Ċ Ċ import Ġandroid . content . Context Ċ import Ġio . re bble . co bble . util . has Notification Access Permission Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . channels . Broadcast Channel Ċ import Ġkotlinx . coroutines . channels . Channel Ċ import Ġkotlinx . coroutines . channels . Receive Channel Ċ import Ġkotlinx . coroutines . flow .* Ċ Ċ /** Ċ Ġ* ĠBus Ġthat Ġtriggers Ġwhenever Ġpermissions Ġchange Ċ Ġ*/ Ċ @ Opt In ( Experimental Cor outines Api :: class ) Ċ object ĠPermission Change Bus Ġ{ ĊĠĠĠ Ġprivate Ġval Ġpermission Change Channel Ġ= ĠBroadcast Channel < Unit >( Channel . CON FL ATED ) ĊĊĠĠĠ Ġfun Ġopen Subscription (): ĠReceive Channel < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġpermission Change Channel . open Subscription () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġtrigger () Ġ{ ĊĠĠĠĠĠĠĠ Ġpermission Change Channel . offer ( Unit ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun ĠPermission Change Bus . notification Permission Flow ( context : ĠContext ): ĠFlow < Boolean > Ġ{ ĊĠĠĠ Ġreturn Ġ( open Subscription (). consume As Flow (). onStart Ġ{ Ġemit ( Unit ) Ġ}) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġcontext . has Notification Access Permission () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. distinct Until Changed () Ċ }