Skip to content

Commit 3432ea1

Browse files
committed
Analysis: Suppress connectivity manager & network info deprecated warns
Warning Messages: - "'CONNECTIVITY_ACTION: String' is deprecated. Deprecated in Java" - "'getter for type: Int' is deprecated. Deprecated in Java" - "'TYPE_WIFI: Int' is deprecated. Deprecated in Java" - "'TYPE_MOBILE: Int' is deprecated. Deprecated in Java" - "'getter for activeNetworkInfo: NetworkInfo?' is deprecated. Deprecated in Java" - "'getter for isConnected: Boolean' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. For more info see: - Compiler Warnings as Errors - WordPress Module - Connectivity Manager & Network Info #17230 (Issue): #17230
1 parent a58a9a4 commit 3432ea1

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

WordPress/src/main/java/org/wordpress/android/AppInitializer.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ class AppInitializer @Inject constructor(
768768
* 1. the app starts (but it's not opened by a service or a broadcast receiver, i.e. an activity is resumed)
769769
* 2. the app was in background and is now foreground
770770
*/
771+
@Suppress("DEPRECATION")
771772
fun onAppComesFromBackground() {
772773
readerTracker.setupTrackers()
773774
AppLog.i(T.UTILS, "App comes from background")

WordPress/src/main/java/org/wordpress/android/support/ZendeskHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ private fun buildZendeskTags(
475475
* could prove useful for the Happiness Engineers while debugging the users' issues.
476476
*/
477477
private fun getNetworkInformation(context: Context): String {
478-
val networkType = when (NetworkUtils.getActiveNetworkInfo(context)?.type) {
478+
@Suppress("DEPRECATION") val networkType = when (NetworkUtils.getActiveNetworkInfo(context)?.type) {
479479
ConnectivityManager.TYPE_WIFI -> ZendeskConstants.networkWifi
480480
ConnectivityManager.TYPE_MOBILE -> ZendeskConstants.networkWWAN
481481
else -> ZendeskConstants.unknownValue

WordPress/src/main/java/org/wordpress/android/viewmodel/helpers/ConnectionStatusLiveData.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import android.content.IntentFilter
77
import android.net.ConnectivityManager
88
import androidx.lifecycle.LiveData
99
import org.wordpress.android.util.distinct
10-
import org.wordpress.android.viewmodel.helpers.ConnectionStatus.AVAILABLE
11-
import org.wordpress.android.viewmodel.helpers.ConnectionStatus.UNAVAILABLE
12-
import org.wordpress.android.viewmodel.helpers.ConnectionStatusLiveData.Factory
1310
import javax.inject.Inject
1411

1512
enum class ConnectionStatus {
@@ -26,6 +23,7 @@ enum class ConnectionStatus {
2623
* IMPORTANT: It needs to be observed for the changes to be posted.
2724
*/
2825
class ConnectionStatusLiveData private constructor(private val context: Context) : LiveData<ConnectionStatus>() {
26+
@Suppress("DEPRECATION")
2927
override fun onActive() {
3028
super.onActive()
3129
val intentFilter = IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)
@@ -37,12 +35,16 @@ class ConnectionStatusLiveData private constructor(private val context: Context)
3735
context.unregisterReceiver(networkReceiver)
3836
}
3937

40-
private val networkReceiver = object : BroadcastReceiver() {
38+
@Suppress("DEPRECATION") private val networkReceiver = object : BroadcastReceiver() {
4139
override fun onReceive(context: Context, intent: Intent) {
4240
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager?
4341
val networkInfo = connectivityManager?.activeNetworkInfo
4442

45-
val nextValue: ConnectionStatus = if (networkInfo?.isConnected == true) AVAILABLE else UNAVAILABLE
43+
val nextValue: ConnectionStatus = if (networkInfo?.isConnected == true){
44+
ConnectionStatus.AVAILABLE
45+
} else {
46+
ConnectionStatus.UNAVAILABLE
47+
}
4648
postValue(nextValue)
4749
}
4850
}

0 commit comments

Comments
 (0)