Skip to content

Commit

Permalink
fix app crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
kyujin-cho committed Feb 16, 2024
1 parent 32aa093 commit 7d62457
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ class SIM1IMSStatusQSTileService : IMSStatusQSTileService(0)
class SIM2IMSStatusQSTileService : IMSStatusQSTileService(1)

open class IMSStatusQSTileService(private val simSlotIndex: Int) : TileService() {
val TAG = "SIM${simSlotIndex}IMSStatusQSTileService"
private val TAG = "SIM${simSlotIndex}IMSStatusQSTileService"

private val moder: SubscriptionModer? get() {
val carrierModer = CarrierModer(this.applicationContext)

if (checkShizukuPermission(0) == ShizukuStatus.GRANTED && carrierModer.deviceSupportsIMS) {
val subscriptions = carrierModer.subscriptions
val sub = carrierModer.getActiveSubscriptionInfoForSimSlotIndex(this.simSlotIndex) ?: return null
return SubscriptionModer(sub.subscriptionId)
}
try {
if (checkShizukuPermission(0) == ShizukuStatus.GRANTED && carrierModer.deviceSupportsIMS) {
carrierModer.subscriptions
val sub = carrierModer.getActiveSubscriptionInfoForSimSlotIndex(this.simSlotIndex)
?: return null
return SubscriptionModer(sub.subscriptionId)
}
} catch (_: IllegalStateException) {}
return null
}
private val imsActivated: Boolean? get() {
Expand Down Expand Up @@ -59,14 +62,4 @@ open class IMSStatusQSTileService(private val simSlotIndex: Int) : TileService()
)
qsTile.updateTile()
}

// Called when your app can no longer update your tile.
override fun onStopListening() {
super.onStopListening()
}

// Called when the user removes your tile.
override fun onTileRemoved() {
super.onTileRemoved()
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/dev/bluehouse/enablevolte/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fun checkShizukuPermission(code: Int): ShizukuStatus {
}

val SubscriptionInfo.uniqueName: String
get() = "${this.displayName} (SIM ${this.simSlotIndex+1})"
get() = "${this.displayName} (SIM ${this.simSlotIndex + 1})"

fun getLatestAppVersion(handler: (String) -> Unit) {
"https://api.github.com/repos/kyujin-cho/pixel-volte-patch/releases"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ class SIM1VoLTEConfigToggleQSTileService : VoLTEConfigToggleQSTileService(0)
class SIM2VoLTEConfigToggleQSTileService : VoLTEConfigToggleQSTileService(1)

open class VoLTEConfigToggleQSTileService(private val simSlotIndex: Int) : TileService() {
val TAG = "SIM${simSlotIndex}VoLTEConfigToggleQSTileService"
private val TAG = "SIM${simSlotIndex}VoLTEConfigToggleQSTileService"

private val moder: SubscriptionModer? get() {
val carrierModer = CarrierModer(this.applicationContext)

if (checkShizukuPermission(0) == ShizukuStatus.GRANTED && carrierModer.deviceSupportsIMS) {
val subscriptions = carrierModer.subscriptions
val sub = carrierModer.getActiveSubscriptionInfoForSimSlotIndex(this.simSlotIndex) ?: return null
return SubscriptionModer(sub.subscriptionId)
}
try {
if (checkShizukuPermission(0) == ShizukuStatus.GRANTED && carrierModer.deviceSupportsIMS) {
carrierModer.subscriptions
val sub = carrierModer.getActiveSubscriptionInfoForSimSlotIndex(this.simSlotIndex)
?: return null
return SubscriptionModer(sub.subscriptionId)
}
} catch (_: IllegalStateException) {}
return null
}

private val volteEnabled: Boolean? get() {
/*
* true: VoLTE enabled
Expand Down Expand Up @@ -60,11 +64,6 @@ open class VoLTEConfigToggleQSTileService(private val simSlotIndex: Int) : TileS
qsTile.updateTile()
}

// Called when your app can no longer update your tile.
override fun onStopListening() {
super.onStopListening()
}

private fun toggleVoLTEStatus() {
val moder = this.moder ?: return
val volteEnabled = this.volteEnabled ?: return
Expand All @@ -84,9 +83,4 @@ open class VoLTEConfigToggleQSTileService(private val simSlotIndex: Int) : TileS
toggleVoLTEStatus()
}
}

// Called when the user removes your tile.
override fun onTileRemoved() {
super.onTileRemoved()
}
}
3 changes: 0 additions & 3 deletions app/src/main/java/dev/bluehouse/enablevolte/pages/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dev.bluehouse.enablevolte.pages

import android.app.StatusBarManager
import android.content.ComponentName
import android.content.Context
import android.graphics.drawable.Icon
import android.os.Build
import android.os.Build.VERSION
Expand All @@ -29,15 +28,13 @@ import dev.bluehouse.enablevolte.BooleanPropertyView
import dev.bluehouse.enablevolte.CarrierModer
import dev.bluehouse.enablevolte.ClickablePropertyView
import dev.bluehouse.enablevolte.HeaderText
import dev.bluehouse.enablevolte.IMSStatusQSTileService
import dev.bluehouse.enablevolte.InfiniteLoadingDialog
import dev.bluehouse.enablevolte.KeyValueEditView
import dev.bluehouse.enablevolte.R
import dev.bluehouse.enablevolte.ShizukuStatus
import dev.bluehouse.enablevolte.SubscriptionModer
import dev.bluehouse.enablevolte.UserAgentPropertyView
import dev.bluehouse.enablevolte.ValueType
import dev.bluehouse.enablevolte.VoLTEConfigToggleQSTileService
import dev.bluehouse.enablevolte.checkShizukuPermission
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down

0 comments on commit 7d62457

Please sign in to comment.