From a99d8c8f14858a815c045cd5d8132b7ef70a817e Mon Sep 17 00:00:00 2001 From: CactiChameleon9 <51231053+CactiChameleon9@users.noreply.github.com> Date: Sat, 31 Aug 2024 17:36:41 +0100 Subject: [PATCH] Remove useless, broken info from notification --- .../com/mridang/speedo/TrafficService.java | 47 ++----------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/com/mridang/speedo/TrafficService.java b/app/src/main/java/com/mridang/speedo/TrafficService.java index c01dfce..1420e90 100644 --- a/app/src/main/java/com/mridang/speedo/TrafficService.java +++ b/app/src/main/java/com/mridang/speedo/TrafficService.java @@ -65,14 +65,6 @@ public class TrafficService extends Service { * The instance of the manager of the notification services */ private static NotificationManager mgrNotifications; - /** - * The instance of the manager of the wireless services - */ - private static WifiManager mgrWireless; - /** - * The instance of the manager of the telephony services - */ - private static TelephonyManager mgrTelephony; /** * The instance of the notification builder to rebuild the notification */ @@ -112,17 +104,17 @@ public class TrafficService extends Service { notBuilder.setOngoing(true); notBuilder.setWhen(0); notBuilder.setOnlyAlertOnce(true); - notBuilder.setPriority(Integer.MAX_VALUE); + notBuilder.setSilent(true); + notBuilder.setPriority(2); notBuilder.setCategory(NotificationCompat.CATEGORY_SERVICE); notBuilder.setLocalOnly(true); notBuilder.setColor(Color.TRANSPARENT); + notBuilder.setContentTitle(getString(R.string.app_name)); visibilityPublic(settings.getBoolean("lockscreen", true)); Log.d("HardwareService", "Setting up the service manager and the broadcast receiver"); mgrConnectivity = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); mgrNotifications = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - mgrWireless = (WifiManager) getSystemService(Context.WIFI_SERVICE); - mgrTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); hndNotifier = new NotificationHandler(getApplicationContext()); if (settings.getBoolean("enabled", true)) { @@ -188,40 +180,9 @@ public class TrafficService extends Service { NetworkInfo nifNetwork = mgrConnectivity.getActiveNetworkInfo(); if (nifNetwork != null && nifNetwork.isConnectedOrConnecting()) { - Log.d("TrafficService", "Network connected; showing the notification"); - if (nifNetwork.getType() == ConnectivityManager.TYPE_WIFI) { - - Log.d("TrafficService", "Connected to a wireless network"); - WifiInfo wifInfo = mgrWireless.getConnectionInfo(); - if (wifInfo != null && !wifInfo.getSSID().trim().isEmpty()) { - - Log.d("TrafficService", wifInfo.getSSID()); - notBuilder.setContentTitle(getString(R.string.wireless)); - notBuilder.setContentText(wifInfo.getSSID().replaceAll("^\"|\"$", "")); - showNotification(); - } else { - - Log.d("TrafficService", "Unknown network without SSID"); - hideNotification(); - } - } else { - - Log.d("TrafficService", "Connected to a cellular network"); - if (!mgrTelephony.getNetworkOperatorName().trim().isEmpty()) { - - Log.d("TrafficService", mgrTelephony.getNetworkOperatorName()); - notBuilder.setContentTitle(getString(R.string.cellular)); - notBuilder.setContentText(mgrTelephony.getNetworkOperatorName()); - showNotification(); - } else { - - Log.d("TrafficService", "Unknown network without IMSI"); - hideNotification(); - } - } + showNotification(); } else { - Log.d("TrafficService", "Network disconnected; hiding the notification"); hideNotification(); }