0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-11-27 21:53:00 +00:00

Fix notification cancel

This commit is contained in:
Oizaro 2020-09-17 15:21:41 +02:00
parent cd9f3bf270
commit 6f10a7336d
2 changed files with 6 additions and 6 deletions

View file

@ -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))

View file

@ -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;