Skip to content

Commit

Permalink
Temporary workaround for broken cellular network callback when Wi-Fi …
Browse files Browse the repository at this point in the history
…is enabled
  • Loading branch information
CasperVerswijvelt committed Dec 12, 2021
1 parent 3f7492f commit 42d0a9a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class InternetTileService : TileService() {
private var wifiConnected = false
private var sharedPreferences: SharedPreferences? = null

private val runCycleInternet = Runnable { cycleInternet() }
private val runCycleInternet = Runnable {
cycleInternet()
syncTile()
}
private val cellularChangeCallback = object : NetworkChangeCallback {
override fun handleChange(type: NetworkChangeType?) {
syncTile()
Expand Down Expand Up @@ -110,10 +113,8 @@ class InternetTileService : TileService() {

} else {

cycleInternet()
runCycleInternet.run()
}

syncTile()
}

private fun cycleInternet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class MobileDataTileService : TileService() {

private var sharedPreferences: SharedPreferences? = null

private val runToggleInternet = Runnable { toggleMobileData() }
private val runToggleMobileData = Runnable {
toggleMobileData()
syncTile()
}
private val networkChangeCallback = object : NetworkChangeCallback {
override fun handleChange(type: NetworkChangeType?) {
syncTile()
Expand Down Expand Up @@ -82,14 +85,12 @@ class MobileDataTileService : TileService() {
) == true
) {

unlockAndRun(runToggleInternet)
unlockAndRun(runToggleMobileData)

} else {

toggleMobileData()
runToggleMobileData.run()
}

syncTile()
}

private fun toggleMobileData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ class WifiTileService : TileService() {
private var wifiConnected = false
private var sharedPreferences: SharedPreferences? = null

private val runToggleInternet = Runnable { toggleInternet() }
private val runToggleInternet = Runnable {
toggleInternet()
syncTile()
}
private val networkChangeCallback = object : NetworkChangeCallback {
override fun handleChange(type: NetworkChangeType?) {
when (type) {
Expand Down Expand Up @@ -91,10 +94,8 @@ class WifiTileService : TileService() {

} else {

toggleInternet()
runToggleInternet.run()
}

syncTile()
}

private fun toggleInternet() {
Expand Down

0 comments on commit 42d0a9a

Please sign in to comment.