diff --git a/play-services-core/src/main/java/org/microg/gms/auth/AuthManagerServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/auth/AuthManagerServiceImpl.java index 2205eb3f..33641b39 100644 --- a/play-services-core/src/main/java/org/microg/gms/auth/AuthManagerServiceImpl.java +++ b/play-services-core/src/main/java/org/microg/gms/auth/AuthManagerServiceImpl.java @@ -30,6 +30,7 @@ import android.util.Base64; import android.util.Log; import androidx.core.app.NotificationCompat; +import androidx.core.app.NotificationManagerCompat; import com.google.android.auth.IAuthManagerService; import com.mgoogle.android.gms.R; @@ -116,7 +117,7 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub { } catch (Exception e) { Log.w(TAG, "Can't decode consent data: ", e); } - if (notify) { + if (notify && NotificationManagerCompat.from(context.getApplicationContext()).areNotificationsEnabled()) { NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(packageName.hashCode(), new NotificationCompat.Builder(context) .setContentIntent(PendingIntent.getActivity(context, 0, i, 0)) diff --git a/play-services-core/src/main/java/org/microg/gms/common/StatusNotification.java b/play-services-core/src/main/java/org/microg/gms/common/StatusNotification.java index 966cb281..3dfa0a06 100644 --- a/play-services-core/src/main/java/org/microg/gms/common/StatusNotification.java +++ b/play-services-core/src/main/java/org/microg/gms/common/StatusNotification.java @@ -21,7 +21,8 @@ public class StatusNotification { private static boolean notificationExists = false; public static void Notify(Context context) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && NotificationManagerCompat.from(context.getApplicationContext()).areNotificationsEnabled()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M + && NotificationManagerCompat.from(context.getApplicationContext()).areNotificationsEnabled()) { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); boolean isChannelEnabled = true; @@ -29,9 +30,7 @@ public class StatusNotification { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && notificationChannelID != "") { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel notificationChannel = notificationManager.getNotificationChannel(notificationChannelID); - if (notificationChannel.getImportance() != NotificationManager.IMPORTANCE_NONE) { - isChannelEnabled = true; - } else { + if (notificationChannel.getImportance() == NotificationManager.IMPORTANCE_NONE) { isChannelEnabled = false; } } @@ -44,6 +43,7 @@ public class StatusNotification { } else { if (notificationExists) { ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).cancel(notificationID); + notificationChannelID = ""; notificationExists = false; } } @@ -79,7 +79,6 @@ public class StatusNotification { .setContentText(context.getResources().getString(R.string.notification_service_subcontent)); NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - manager.notify(notificationID, notification.build()); notificationExists = true;