mirror of
https://github.com/revanced/revanced-patches
synced 2025-02-19 09:26:49 +01:00
68 lines
1.9 KiB
Java
68 lines
1.9 KiB
Java
package fi.razerman.youtube;
|
|
|
|
import android.content.Context;
|
|
import android.net.ConnectivityManager;
|
|
import android.net.NetworkInfo;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class Connectivity {
|
|
public static NetworkInfo getNetworkInfo(Context context) {
|
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
return cm.getActiveNetworkInfo();
|
|
}
|
|
|
|
public static boolean isConnected(Context context) {
|
|
NetworkInfo info = getNetworkInfo(context);
|
|
return info != null && info.isConnected();
|
|
}
|
|
|
|
public static boolean isConnectedWifi(Context context) {
|
|
NetworkInfo info = getNetworkInfo(context);
|
|
return info != null && info.isConnected() && info.getType() == 1;
|
|
}
|
|
|
|
public static boolean isConnectedMobile(Context context) {
|
|
NetworkInfo info = getNetworkInfo(context);
|
|
return info != null && info.isConnected() && info.getType() == 0;
|
|
}
|
|
|
|
public static boolean isConnectedFast(Context context) {
|
|
NetworkInfo info = getNetworkInfo(context);
|
|
return info != null && info.isConnected() && isConnectionFast(info.getType(), info.getSubtype());
|
|
}
|
|
|
|
public static boolean isConnectionFast(int type, int subType) {
|
|
if (type == 1) {
|
|
return true;
|
|
}
|
|
if (type != 0) {
|
|
return false;
|
|
}
|
|
switch (subType) {
|
|
case 1:
|
|
return false;
|
|
case 2:
|
|
return false;
|
|
case 3:
|
|
case 5:
|
|
case 6:
|
|
case 8:
|
|
case 9:
|
|
case 10:
|
|
case 12:
|
|
case 13:
|
|
case 14:
|
|
case 15:
|
|
return true;
|
|
case 4:
|
|
return false;
|
|
case 7:
|
|
return false;
|
|
case 11:
|
|
return false;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
}
|