resources/src/main/java/org/robolectric/res/android/ConfigDescription.java
private static void applyVersionForCompatibility(ResTable_config config) {
    if (config == null) {
      return;
    }
    int min_sdk = 0;
    if (((config.uiMode & ResTable_config.MASK_UI_MODE_TYPE)
        == ResTable_config.UI_MODE_TYPE_VR_HEADSET) ||
        (config.colorMode & ResTable_config.MASK_WIDE_COLOR_GAMUT) != 0 ||
            (config.colorMode & ResTable_config.MASK_HDR) != 0) {
      min_sdk = SDK_O;
    } else if (isTruthy(config.screenLayout2 & ResTable_config.MASK_SCREENROUND)) {
      min_sdk = SDK_MNC;
    } else if (config.density == ResTable_config.DENSITY_ANY) {
      min_sdk = SDK_LOLLIPOP;
    } else if (config.smallestScreenWidthDp != ResTable_config.SCREENWIDTH_ANY
        || config.screenWidthDp != ResTable_config.SCREENWIDTH_ANY
        || config.screenHeightDp != ResTable_config.SCREENHEIGHT_ANY) {
      min_sdk = SDK_HONEYCOMB_MR2;
    } else if ((config.uiMode & ResTable_config.MASK_UI_MODE_TYPE)
        != ResTable_config.UI_MODE_TYPE_ANY
        ||  (config.uiMode & ResTable_config.MASK_UI_MODE_NIGHT)
        != ResTable_config.UI_MODE_NIGHT_ANY) {
      min_sdk = SDK_FROYO;
    } else if ((config.screenLayout & ResTable_config.MASK_SCREENSIZE)
        != ResTable_config.SCREENSIZE_ANY
        ||  (config.screenLayout & ResTable_config.MASK_SCREENLONG)
        != ResTable_config.SCREENLONG_ANY
        || config.density != ResTable_config.DENSITY_DEFAULT) {
      min_sdk = SDK_DONUT;
    }
    if (min_sdk > config.sdkVersion) {
      config.sdkVersion = min_sdk;
    }
  }
private static void applyVersionForCompatibility(ResTable_config config) {
    if (config == null) {
      return;
    }
    int min_sdk = 0;
    if (((config.uiMode & ResTable_config.MASK_UI_MODE_TYPE)
        == ResTable_config.UI_MODE_TYPE_VR_HEADSET) ||
        (config.colorMode & ResTable_config.MASK_WIDE_COLOR_GAMUT) != 0 ||
            (config.colorMode & ResTable_config.MASK_HDR) != 0) {
      min_sdk = SDK_O;
    } else if (isTruthy(config.screenLayout2 & ResTable_config.MASK_SCREENROUND)) {
      min_sdk = SDK_MNC;
    } else if (config.density == ResTable_config.DENSITY_ANY) {
      min_sdk = SDK_LOLLIPOP;
    } else if (config.smallestScreenWidthDp != ResTable_config.SCREENWIDTH_ANY
        || config.screenWidthDp != ResTable_config.SCREENWIDTH_ANY
        || config.screenHeightDp != ResTable_config.SCREENHEIGHT_ANY) {
      min_sdk = SDK_HONEYCOMB_MR2;
    } else if ((config.uiMode & ResTable_config.MASK_UI_MODE_TYPE)
        != ResTable_config.UI_MODE_TYPE_ANY
        ||  (config.uiMode & ResTable_config.MASK_UI_MODE_NIGHT)
        != ResTable_config.UI_MODE_NIGHT_ANY) {
      min_sdk = SDK_FROYO;
    } else if ((config.screenLayout & ResTable_config.MASK_SCREENSIZE)
        != ResTable_config.SCREENSIZE_ANY
        ||  (config.screenLayout & ResTable_config.MASK_SCREENLONG)
        != ResTable_config.SCREENLONG_ANY
        || config.density != ResTable_config.DENSITY_DEFAULT) {
      min_sdk = SDK_DONUT;
    }
    if (min_sdk > config.sdkVersion) {
      config.sdkVersion = min_sdk;
    }
  }
transliterated from https://android.googlesource.com/platform/frameworks/base/+/android-9.0.0_r12/tools/aapt/AaptConfig.cpp