- // Populate the notification according to the network type.
- if ((telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_NR) || (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_IWLAN) ||
- (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_UNKNOWN)) { // This is a secure network.
- // Only update the notification if the network status has changed.
- if (currentStatus != SECURE_NETWORK) {
- // Create a secure network notification builder.
- val secureNetworkNotificationBuilder = Notification.Builder(applicationContext, SECURE_NETWORK)
-
- // Set the notification to open Privacy Cell.
- secureNetworkNotificationBuilder.setContentIntent(privacyCellPendingIntent)
-
- // Set the notification text.
- secureNetworkNotificationBuilder.setContentText(getString(R.string.secure_network))
-
- // Set the notification icon.
- secureNetworkNotificationBuilder.setSmallIcon(R.drawable.secure_notification_enabled)
-
- // Set the color.
- secureNetworkNotificationBuilder.setColor(getColor(R.color.blue_icon))
-
- // Update the notification.
- notificationManager.notify(NOTIFICATION_ID, secureNetworkNotificationBuilder.build())
-
- // Store the new network status.
- currentStatus = SECURE_NETWORK
- }
- } else if ((telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_LTE) || (!consider3gAntiquated && (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_1xRTT ||
- (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_EVDO_0) || (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_EVDO_A) ||
- (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_EVDO_B) || (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_EHRPD) ||
- (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_UMTS) || (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_TD_SCDMA) ||
- (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_HSDPA) || (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_HSUPA) ||
- (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_HSPA) || (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_HSPAP)))) {
- // This is an insecure network.
- // Only update the notification if the network status has changed.
- if (currentStatus != INSECURE_NETWORK) {
- // Create an insecure network notification builder.
- val insecureNetworkNotificationBuilder = Notification.Builder(applicationContext, INSECURE_NETWORK)
-
- // Set the notification to open Privacy Cell.
- insecureNetworkNotificationBuilder.setContentIntent(privacyCellPendingIntent)
-
- // Set the notification text.
- insecureNetworkNotificationBuilder.setContentText(getString(R.string.insecure_network))
-
- // Set the notification icon.
- insecureNetworkNotificationBuilder.setSmallIcon(R.drawable.insecure_notification_enabled)
-
- // Set the color.
- insecureNetworkNotificationBuilder.setColor(getColor(R.color.yellow_notification_icon))
-
- // Update the notification.
- notificationManager.notify(NOTIFICATION_ID, insecureNetworkNotificationBuilder.build())
-
- // Store the new network status.
- currentStatus = INSECURE_NETWORK
- }
- } else { // This is an antiquated network.
- // Only update the notification if the network status has changed.
- if (currentStatus != ANTIQUATED_NETWORK) {
- // Create an antiquated network notification builder.
- val antiquatedNetworkNotificationBuilder = Notification.Builder(applicationContext, ANTIQUATED_NETWORK)
-
- // Set the notification to open Privacy Cell.
- antiquatedNetworkNotificationBuilder.setContentIntent(privacyCellPendingIntent)
-
- // Set the notification text.
- antiquatedNetworkNotificationBuilder.setContentText(getString(R.string.antiquated_network))
-
- // Set the notification icon.
- antiquatedNetworkNotificationBuilder.setSmallIcon(R.drawable.antiquated_notification_enabled)
-
- // Set the color.
- antiquatedNetworkNotificationBuilder.setColor(getColor(R.color.red_notification_icon))
-
- // Update the notification.
- notificationManager.notify(NOTIFICATION_ID, antiquatedNetworkNotificationBuilder.build())
-
- // Store the new network status.
- currentStatus = ANTIQUATED_NETWORK
- }
- }