Code styling

This commit is contained in:
Juha Heinanen
2026-06-24 20:09:47 +03:00
parent eb5a236170
commit b02bc7a521

View File

@ -176,7 +176,8 @@ class BaresipService: Service() {
val vibratorManager = getSystemService(VIBRATOR_MANAGER_SERVICE) as
VibratorManager
vibratorManager.defaultVibrator
} else {
}
else {
@Suppress("DEPRECATION")
getSystemService(VIBRATOR_SERVICE) as Vibrator
}
@ -253,9 +254,9 @@ class BaresipService: Service() {
if ("android.net.wifi.WIFI_AP_STATE_CHANGED" == action) {
val state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0)
if (WifiManager.WIFI_STATE_ENABLED == state % 10) {
if (hotSpotIsEnabled) {
if (hotSpotIsEnabled)
Log.d(TAG, "HotSpot is still enabled")
} else {
else {
Log.d(TAG, "HotSpot is enabled")
hotSpotIsEnabled = true
Timer().schedule(1000) {
@ -273,15 +274,16 @@ class BaresipService: Service() {
Timer().schedule(2000) {
updateNetwork()
}
} else {
Log.w(TAG, "Could not get hotspot addresses")
}
else
Log.w(TAG, "Could not get hotspot addresses")
}
}
} else {
if (!hotSpotIsEnabled) {
}
else {
if (!hotSpotIsEnabled)
Log.d(TAG, "HotSpot is still disabled")
} else {
else {
Log.d(TAG, "HotSpot is disabled")
hotSpotIsEnabled = false
if (hotSpotAddresses.isNotEmpty()) {
@ -348,34 +350,33 @@ class BaresipService: Service() {
}
}
BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED -> {
val state = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE,
BluetoothHeadset.STATE_AUDIO_DISCONNECTED)
val state = intent.getIntExtra(
BluetoothHeadset.EXTRA_STATE,
BluetoothHeadset.STATE_AUDIO_DISCONNECTED
)
when (state) {
BluetoothHeadset.STATE_AUDIO_CONNECTED -> {
BluetoothHeadset.STATE_AUDIO_CONNECTED ->
Log.d(TAG, "Bluetooth headset audio is connected")
}
BluetoothHeadset.STATE_AUDIO_DISCONNECTED -> {
BluetoothHeadset.STATE_AUDIO_DISCONNECTED ->
Log.d(TAG, "Bluetooth headset audio is disconnected")
}
}
}
AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED -> {
val state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE,
AudioManager.SCO_AUDIO_STATE_DISCONNECTED)
val state = intent.getIntExtra(
AudioManager.EXTRA_SCO_AUDIO_STATE,
AudioManager.SCO_AUDIO_STATE_DISCONNECTED
)
when (state) {
AudioManager.SCO_AUDIO_STATE_CONNECTING -> {
AudioManager.SCO_AUDIO_STATE_CONNECTING ->
Log.d(TAG, "Bluetooth headset SCO is connecting")
}
AudioManager.SCO_AUDIO_STATE_CONNECTED -> {
AudioManager.SCO_AUDIO_STATE_CONNECTED ->
Log.d(TAG, "Bluetooth headset SCO is connected")
}
AudioManager.SCO_AUDIO_STATE_DISCONNECTED -> {
Log.d(TAG, "Bluetooth headset SCO is disconnected")
resetCallVolume()
}
AudioManager.SCO_AUDIO_STATE_ERROR -> {
AudioManager.SCO_AUDIO_STATE_ERROR ->
Log.d(TAG, "Bluetooth headset SCO state ERROR")
}
}
}
}
@ -395,13 +396,13 @@ class BaresipService: Service() {
bluetoothReceiverRegistered = true
telephonyManager = getSystemService(TELEPHONY_SERVICE) as TelephonyManager
if (VERSION.SDK_INT >= 31) {
if (VERSION.SDK_INT >= 31)
telephonyCallback = object : TelephonyCallback(), TelephonyCallback.ServiceStateListener {
override fun onServiceStateChanged(serviceState: ServiceState) {
updateMobileStatusFromServiceState(serviceState.state)
}
}
} else {
else {
@Suppress("DEPRECATION")
phoneStateListener = object : PhoneStateListener() {
@Deprecated("Deprecated in Java")
@ -414,9 +415,10 @@ class BaresipService: Service() {
proximityWakeLock = pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
"com.tutpro.baresip:proximity_wakelock")
wifiLock = if (VERSION.SDK_INT < 29)
wifiLock = if (VERSION.SDK_INT < 29) {
@Suppress("DEPRECATION")
wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "Baresip")
}
else
wm.createWifiLock(WifiManager.WIFI_MODE_FULL_LOW_LATENCY, "Baresip")
wifiLock.setReferenceCounted(false)
@ -466,7 +468,8 @@ class BaresipService: Service() {
if (intent == null) {
action = "Start"
Log.d(TAG, "Received onStartCommand with null intent")
} else {
}
else {
// Utils.dumpIntent(intent)
action = intent.action!!
Log.d(TAG, "Received onStartCommand action $action")
@ -540,9 +543,9 @@ class BaresipService: Service() {
Contact.contactsUpdate()
val history = CallHistory.get()
if (history.isEmpty()) {
if (history.isEmpty())
CallHistoryNew.restore()
} else {
else
for (old in history) {
val new = CallHistoryNew(old.aor, old.peerUri, old.direction)
new.stopTime = old.stopTime
@ -550,7 +553,6 @@ class BaresipService: Service() {
new.recording = old.recording
new.add()
}
}
Blocked.restore()
BlockRule.restore()
@ -610,17 +612,14 @@ class BaresipService: Service() {
toast(getString(R.string.no_aec), Toast.LENGTH_LONG)
}
"Notification Dismissed" -> {
"Notification Dismissed" ->
updateStatusNotification()
}
"Start Content Observer" -> {
"Start Content Observer" ->
registerAndroidContactsObserver()
}
"Stop Content Observer" -> {
"Stop Content Observer" ->
unRegisterAndroidContactsObserver()
}
"Call Answer" -> {
val callp = intent!!.getLongExtra("callp", 0L)
@ -639,9 +638,9 @@ class BaresipService: Service() {
nm.cancel(CALL_NOTIFICATION_ID)
stopRinging()
stopMediaPlayer()
if (call == null) {
if (call == null)
Log.w(TAG, "onStartCommand did not find call $callp")
} else {
else {
val peerUri = call.peerUri
val aor = call.ua.account.aor
Log.d(TAG, "Aor $aor rejected incoming call $callp from $peerUri")
@ -733,18 +732,16 @@ class BaresipService: Service() {
msg.direction = MESSAGE_UP_FAIL
msg.responseReason = getString(R.string.message_failed)
}
else {
else
ua.account.unreadMessages = Message.unreadMessages(aor)
}
}
}
}
nm.cancel(MESSAGE_NOTIFICATION_ID)
}
"Update Notification" -> {
"Update Notification" ->
updateStatusNotification()
}
"Start Call" -> {
val uap = intent!!.getLongExtra("uap", 0L)
@ -766,9 +763,8 @@ class BaresipService: Service() {
}
}
else -> {
else ->
Log.e(TAG, "Unknown start action $action")
}
}
return START_STICKY