@@ -218,6 +218,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
218218
219219 private lateinit var sharedPreferencesLogs: SharedPreferences
220220 private lateinit var sharedPreferences: SharedPreferences
221+ private var wasConnectedForLive: Boolean = false
221222 private val packetLogKey = " packet_log"
222223 private val _packetLogsFlow = MutableStateFlow <Set <String >>(emptySet())
223224 val packetLogsFlow: StateFlow <Set <String >> get() = _packetLogsFlow
@@ -289,6 +290,12 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
289290 getSharedPreferences(" settings" , MODE_PRIVATE ).getString(" name" , " AirPods Pro" )
290291 ? : " AirPods"
291292 )
293+ if (sharedPreferences.getBoolean(" show_live_update_notification" , true )) {
294+ LiveUpdateNotification .showCaseOpenReminder(
295+ this @AirPodsService.applicationContext,
296+ batteryNotification.getBattery()
297+ )
298+ }
292299 if (socket.isConnected) return
293300 val leftLevel = bleManager.getMostRecentStatus()?.leftBattery ? : 0
294301 val rightLevel = bleManager.getMostRecentStatus()?.rightBattery ? : 0
@@ -308,6 +315,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
308315 sendBatteryBroadcast()
309316 } else {
310317 Log .d(TAG , " Lid closed" )
318+ LiveUpdateNotification .resetCaseOpenReminderOnLidClose()
311319 }
312320 }
313321
@@ -913,10 +921,19 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
913921 override fun onControlCommandReceived (controlCommand : ByteArray ) {
914922 val command = AACPManager .ControlCommand .fromByteArray(controlCommand)
915923 if (command.identifier == AACPManager .Companion .ControlCommandIdentifiers .LISTENING_MODE .value) {
916- ancNotification.setStatus(byteArrayOf( command.value.takeIf { it.isNotEmpty() }
917- ?.get( 0 ) ? : 0x00 .toByte() ))
924+ val newMode = command.value.takeIf { it.isNotEmpty() }?.get( 0 ) ? : 0x00 .toByte()
925+ ancNotification.setStatus(byteArrayOf(newMode ))
918926 sendANCBroadcast()
919927 updateNoiseControlWidget()
928+ if (sharedPreferences.getBoolean(" show_live_update_notification" , true )) {
929+ val name = sharedPreferences.getString(" name" , " AirPods Pro" ) ? : " AirPods"
930+ LiveUpdateNotification .headsUpOnListeningModeChange(
931+ this @AirPodsService.applicationContext,
932+ name,
933+ batteryNotification.getBattery(),
934+ newMode
935+ )
936+ }
920937 }
921938 }
922939
@@ -1664,6 +1681,15 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
16641681 otherDeviceName : String? = null
16651682 ) {
16661683 Log .d(TAG , " Showing island window" )
1684+ if (sharedPreferences.getBoolean(" show_live_update_notification" , true )) {
1685+ val name = sharedPreferences.getString(" name" , " AirPods Pro" ) ? : " AirPods"
1686+ LiveUpdateNotification .show(
1687+ service.applicationContext,
1688+ name,
1689+ batteryNotification.getBattery(),
1690+ headsUp = true
1691+ )
1692+ }
16671693 if (! sharedPreferences.getBoolean(" show_island_popup" , true )) {
16681694 return
16691695 }
@@ -2038,7 +2064,12 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
20382064
20392065 if (connected && (config.bleOnlyMode || socket.isConnected)) {
20402066 if (liveEnabled && batteryList != null ) {
2041- LiveUpdateNotification .update(this , resolvedName, batteryList)
2067+ if (! wasConnectedForLive) {
2068+ LiveUpdateNotification .show(this , resolvedName, batteryList, headsUp = true )
2069+ wasConnectedForLive = true
2070+ } else {
2071+ LiveUpdateNotification .update(this , resolvedName, batteryList)
2072+ }
20422073 LiveUpdateNotification .checkLowBattery(this , batteryList)
20432074 notificationManager.cancel(1 )
20442075 notificationManager.cancel(2 )
@@ -2096,6 +2127,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
20962127 notificationManager.cancel(2 )
20972128 LiveUpdateNotification .cancelAll(this )
20982129 LiveUpdateNotification .resetState()
2130+ wasConnectedForLive = false
20992131 } else if (! config.bleOnlyMode && ! socket.isConnected) {
21002132 showSocketConnectionFailureNotification(" Socket created, but not connected. Check logs" )
21012133 }
0 commit comments