Remove useless, broken info from notification

This commit is contained in:
CactiChameleon9 2024-08-31 17:36:41 +01:00
parent 6b1ab1500b
commit a99d8c8f14

View File

@ -65,14 +65,6 @@ public class TrafficService extends Service {
* The instance of the manager of the notification services * The instance of the manager of the notification services
*/ */
private static NotificationManager mgrNotifications; 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 * The instance of the notification builder to rebuild the notification
*/ */
@ -112,17 +104,17 @@ public class TrafficService extends Service {
notBuilder.setOngoing(true); notBuilder.setOngoing(true);
notBuilder.setWhen(0); notBuilder.setWhen(0);
notBuilder.setOnlyAlertOnce(true); notBuilder.setOnlyAlertOnce(true);
notBuilder.setPriority(Integer.MAX_VALUE); notBuilder.setSilent(true);
notBuilder.setPriority(2);
notBuilder.setCategory(NotificationCompat.CATEGORY_SERVICE); notBuilder.setCategory(NotificationCompat.CATEGORY_SERVICE);
notBuilder.setLocalOnly(true); notBuilder.setLocalOnly(true);
notBuilder.setColor(Color.TRANSPARENT); notBuilder.setColor(Color.TRANSPARENT);
notBuilder.setContentTitle(getString(R.string.app_name));
visibilityPublic(settings.getBoolean("lockscreen", true)); visibilityPublic(settings.getBoolean("lockscreen", true));
Log.d("HardwareService", "Setting up the service manager and the broadcast receiver"); Log.d("HardwareService", "Setting up the service manager and the broadcast receiver");
mgrConnectivity = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); mgrConnectivity = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mgrNotifications = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mgrNotifications = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mgrWireless = (WifiManager) getSystemService(Context.WIFI_SERVICE);
mgrTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
hndNotifier = new NotificationHandler(getApplicationContext()); hndNotifier = new NotificationHandler(getApplicationContext());
if (settings.getBoolean("enabled", true)) { if (settings.getBoolean("enabled", true)) {
@ -188,40 +180,9 @@ public class TrafficService extends Service {
NetworkInfo nifNetwork = mgrConnectivity.getActiveNetworkInfo(); NetworkInfo nifNetwork = mgrConnectivity.getActiveNetworkInfo();
if (nifNetwork != null && nifNetwork.isConnectedOrConnecting()) { if (nifNetwork != null && nifNetwork.isConnectedOrConnecting()) {
Log.d("TrafficService", "Network connected; showing the notification"); Log.d("TrafficService", "Network connected; showing the notification");
if (nifNetwork.getType() == ConnectivityManager.TYPE_WIFI) { showNotification();
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();
}
}
} else { } else {
Log.d("TrafficService", "Network disconnected; hiding the notification"); Log.d("TrafficService", "Network disconnected; hiding the notification");
hideNotification(); hideNotification();
} }