@@ -340,15 +340,25 @@ public static void startPushService() {
340340 editorCA .commit ();
341341 ConnectionsManager .getInstance (UserConfig .selectedAccount ).setPushConnectionEnabled (true );
342342 }
343+ int pendingIntentFlags ;
344+ if (Build .VERSION .SDK_INT >= 34 ) {
345+ pendingIntentFlags = PendingIntent .FLAG_IMMUTABLE ;
346+ } else {
347+ pendingIntentFlags = PendingIntent .FLAG_MUTABLE ;
348+ }
343349 if (enabled ) {
344350 Log .d ("TFOSS" , "Trying to start push service every minute" );
345351 // Telegram-FOSS: unconditionally enable push service
346352 AlarmManager am = (AlarmManager ) applicationContext .getSystemService (Context .ALARM_SERVICE );
347353 Intent i = new Intent (applicationContext , NotificationsService .class );
348- pendingIntent = PendingIntent .getBroadcast (applicationContext , 0 , i , PendingIntent .FLAG_MUTABLE );
354+ try {
355+ pendingIntent = PendingIntent .getBroadcast (applicationContext , 0 , i , pendingIntentFlags );
349356
350357 am .cancel (pendingIntent );
351358 am .setRepeating (AlarmManager .RTC_WAKEUP , System .currentTimeMillis (), 60000 , pendingIntent );
359+ } catch (Throwable ignore ) {
360+ Log .d ("Fork Client" , "Failed to set intent" );
361+ }
352362 try {
353363 Log .d ("TFOSS" , "Starting push service..." );
354364 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
@@ -361,13 +371,16 @@ public static void startPushService() {
361371 }
362372 } else {
363373 applicationContext .stopService (new Intent (applicationContext , NotificationsService .class ));
364-
374+ try {
365375 PendingIntent pintent = PendingIntent .getService (applicationContext , 0 , new Intent (applicationContext , NotificationsService .class ), PendingIntent .FLAG_MUTABLE );
366376 AlarmManager alarm = (AlarmManager )applicationContext .getSystemService (Context .ALARM_SERVICE );
367377 alarm .cancel (pintent );
368- if (pendingIntent != null ) {
369- alarm .cancel (pendingIntent );
370- }
378+ if (pendingIntent != null ) {
379+ alarm .cancel (pendingIntent );
380+ }
381+ } catch (Throwable ignore ) {
382+ Log .d ("Fork Client" , "Failed to set intent" );
383+ }
371384 }
372385 }
373386
0 commit comments