content: package androidx.core.net;
  
  import android.content.Intent;
  import android.net.ConnectivityManager;
  import android.net.NetworkInfo;
  import android.os.Build;
  import java.lang.annotation.Retention;
  import java.lang.annotation.RetentionPolicy;
  
  public final class ConnectivityManagerCompat {
      public static final int RESTRICT_BACKGROUND_STATUS_DISABLED = 1;
      public static final int RESTRICT_BACKGROUND_STATUS_ENABLED = 3;
      public static final int RESTRICT_BACKGROUND_STATUS_WHITELISTED = 2;
  
      static class Api16Impl {
          private Api16Impl() {
          }
  
          static boolean isActiveNetworkMetered(ConnectivityManager connectivityManager) {
              return connectivityManager.isActiveNetworkMetered();
          }
      }
  
      static class Api24Impl {
          private Api24Impl() {
          }
  
          static int getRestrictBackgroundStatus(ConnectivityManager connectivityManager) {
              return connectivityManager.getRestrictBackgroundStatus();
          }
      }
  
      @Retention(RetentionPolicy.SOURCE)
      public @interface RestrictBackgroundStatus {
      }
  
      private ConnectivityManagerCompat() {
      }
  
      public static NetworkInfo getNetworkInfoFromBroadcast(ConnectivityManager cm, Intent intent) {
          NetworkInfo networkInfo = (NetworkInfo) intent.getParcelableExtra("networkInfo");
          if (networkInfo != null) {
              return cm.getNetworkInfo(networkInfo.getType());
          }
          return null;
      }
  
      public static int getRestrictBackgroundStatus(ConnectivityManager cm) {
          if (Build.VERSION.SDK_INT >= 24) {
              return Api24Impl.getRestrictBackgroundStatus(cm);
          }
          return 3;
      }
  
      public static boolean isActiveNetworkMetered(ConnectivityManager cm) {
          if (Build.VERSION.SDK_INT >= 16) {
              return Api16Impl.isActiveNetworkMetered(cm);
          }
          NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
          if (activeNetworkInfo == null) {
              return true;
          }
          switch (activeNetworkInfo.getType()) {
              case 0:
              case 2:
              case 3:
              case 4:
              case 5:
              case 6:
                  return true;
              case 1:
              case 7:
              case 9:
                  return false;
              default:
                  return true;
          }
      }
  }
  