From aee60e4d914a5df46c725860ca9a819c31779236 Mon Sep 17 00:00:00 2001 From: Oizaro <45825534+Oizaro@users.noreply.github.com> Date: Mon, 7 Sep 2020 04:53:54 +0200 Subject: [PATCH] Test notifications for API 21 and above --- .../microg/gms/common/ForegroundServiceContext.java | 12 ++---------- .../src/main/java/org/microg/gms/gcm/McsService.java | 12 ++---------- .../src/main/res/values-it/strings.xml | 2 +- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/play-services-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java b/play-services-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java index 58655cef..d8e1fe3b 100644 --- a/play-services-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java +++ b/play-services-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java @@ -2,8 +2,6 @@ package org.microg.gms.common; import android.app.ActivityManager; import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.ComponentName; @@ -61,24 +59,18 @@ public class ForegroundServiceContext extends ContextWrapper { } public static void completeForegroundService(Service service, Intent intent, String tag) { - if (intent.getBooleanExtra(EXTRA_FOREGROUND, false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (intent.getBooleanExtra(EXTRA_FOREGROUND, false)) { Log.d(tag, "Started in foreground mode."); service.startForeground(tag.hashCode(), buildForegroundNotification(service)); } } - @RequiresApi(api = Build.VERSION_CODES.O) private static Notification buildForegroundNotification(Context context) { - NotificationChannel channel = new NotificationChannel("foreground-service", context.getResources().getString(R.string.notification_service_name), NotificationManager.IMPORTANCE_MIN); - channel.setShowBadge(false); - channel.setLockscreenVisibility(0); - channel.setVibrationPattern(new long[0]); Intent mIntent = new Intent(); mIntent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS); mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mIntent, 0); - context.getSystemService(NotificationManager.class).createNotificationChannel(channel); - return new Notification.Builder(context, channel.getId()) + return new Notification.Builder(context) .setOngoing(true) .setContentIntent(pendingIntent) .setContentTitle(context.getResources().getString(R.string.notification_service_title)) diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java index 9a459d00..56c17d41 100644 --- a/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java +++ b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java @@ -18,8 +18,6 @@ package org.microg.gms.gcm; import android.app.AlarmManager; import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.ComponentName; @@ -40,7 +38,6 @@ import android.os.SystemClock; import android.os.UserHandle; import android.util.Log; -import androidx.annotation.RequiresApi; import androidx.legacy.content.WakefulBroadcastReceiver; import com.mgoogle.android.gms.R; @@ -318,14 +315,9 @@ public class McsService extends Service implements Handler.Callback { return START_REDELIVER_INTENT; } - @RequiresApi(api = Build.VERSION_CODES.O) private Notification buildForegroundNotification() { - NotificationChannel channel = new NotificationChannel("foreground-service", getString(R.string.notification_service_name), NotificationManager.IMPORTANCE_LOW); - channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET); - channel.setShowBadge(false); - getSystemService(NotificationManager.class).createNotificationChannel(channel); - return new Notification.Builder(this, channel.getId()) - .setOngoing(true) + return new Notification.Builder(this) + .setCategory(Notification.CATEGORY_MESSAGE) .setContentTitle(this.getResources().getString(R.string.notification_service_title)) .setSmallIcon(android.R.drawable.stat_notify_sync) .build(); diff --git a/play-services-core/src/main/res/values-it/strings.xml b/play-services-core/src/main/res/values-it/strings.xml index 7f8a6a86..333584af 100755 --- a/play-services-core/src/main/res/values-it/strings.xml +++ b/play-services-core/src/main/res/values-it/strings.xml @@ -82,7 +82,7 @@ Questo potrĂ  richiedere un paio di minuti" Ultima registrazione: %1$s Ottimizzazione batteria attivata - Hai attivato l'\opzione Messaggistica Cloud Google ma i Servizi Vanced microG risultano al momento limitati dall\'ottimizzazione energetica di sistema. Se desideri ricevere le notifiche push, escludi i microG da questa ottimizzazione. + Hai attivato l\'opzione Messaggistica Cloud Google ma i Servizi Vanced microG risultano al momento limitati dall\'ottimizzazione energetica di sistema. Se desideri ricevere le notifiche push, escludi i microG da questa ottimizzazione. Ignore ottimizzazione Preferenze account