@Implementation(minSdk = P)
  protected static long nativeOpenXmlAsset(long ptr, int jcookie, @NonNull String asset_path)
      throws FileNotFoundException {
    ApkAssetsCookie cookie = JavaCookieToApkAssetsCookie(jcookie);
    String asset_path_utf8 = asset_path;
    if (asset_path_utf8 == null) {
      // This will throw NPE.
      return 0;
    }

    ATRACE_NAME(String.format("AssetManager::OpenXmlAsset(%s)", asset_path_utf8));

    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    Asset asset;
    if (cookie.intValue() != kInvalidCookie) {
      asset = assetmanager.OpenNonAsset(asset_path_utf8, cookie, Asset.AccessMode.ACCESS_RANDOM);
    } else {
      Ref<ApkAssetsCookie> cookieRef = new Ref<>(cookie);
      asset = assetmanager.OpenNonAsset(asset_path_utf8, Asset.AccessMode.ACCESS_RANDOM, cookieRef);
      cookie = cookieRef.get();
    }

    if (!isTruthy(asset)) {
      throw new FileNotFoundException(asset_path_utf8);
    }

    // May be nullptr.
    DynamicRefTable dynamic_ref_table = assetmanager.GetDynamicRefTableForCookie(cookie);

    ResXMLTree xml_tree = new ResXMLTree(dynamic_ref_table);
    int err = xml_tree.setTo(asset.getBuffer(true), (int) asset.getLength(), true);
    // asset.reset();

    if (err != NO_ERROR) {
      throw new FileNotFoundException("Corrupt XML binary file");
    }
    return NATIVE_RES_XML_TREES.register(xml_tree);
  }
@Implementation(minSdk = P)
  protected static long nativeOpenXmlAsset(long ptr, int jcookie, @NonNull String asset_path)
      throws FileNotFoundException {
    ApkAssetsCookie cookie = JavaCookieToApkAssetsCookie(jcookie);
    String asset_path_utf8 = asset_path;
    if (asset_path_utf8 == null) {
      
      return 0;
    }

    ATRACE_NAME(String.format("AssetManager::OpenXmlAsset(%s)", asset_path_utf8));

    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    Asset asset;
    if (cookie.intValue() != kInvalidCookie) {
      asset = assetmanager.OpenNonAsset(asset_path_utf8, cookie, Asset.AccessMode.ACCESS_RANDOM);
    } else {
      Ref<ApkAssetsCookie> cookieRef = new Ref<>(cookie);
      asset = assetmanager.OpenNonAsset(asset_path_utf8, Asset.AccessMode.ACCESS_RANDOM, cookieRef);
      cookie = cookieRef.get();
    }

    if (!isTruthy(asset)) {
      throw new FileNotFoundException(asset_path_utf8);
    }

    
    DynamicRefTable dynamic_ref_table = assetmanager.GetDynamicRefTableForCookie(cookie);

    ResXMLTree xml_tree = new ResXMLTree(dynamic_ref_table);
    int err = xml_tree.setTo(asset.getBuffer(true), (int) asset.getLength(), true);
    

    if (err != NO_ERROR) {
      throw new FileNotFoundException("Corrupt XML binary file");
    }
    return NATIVE_RES_XML_TREES.register(xml_tree);
  }
@ Implementation ( minSdk = P ) protected static long nativeOpenXmlAsset ( long ptr , int jcookie , @ NonNull String asset_path ) throws FileNotFoundException { ApkAssetsCookie cookie = JavaCookieToApkAssetsCookie ( jcookie ) ; String asset_path_utf8 = asset_path ; if ( asset_path_utf8 == null ) { // This will throw NPE. return 0 ; } ATRACE_NAME ( String . format ( "AssetManager::OpenXmlAsset(%s)" , asset_path_utf8 ) ) ; CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Asset asset ; if ( cookie . intValue ( ) != kInvalidCookie ) { asset = assetmanager . OpenNonAsset ( asset_path_utf8 , cookie , Asset . AccessMode . ACCESS_RANDOM ) ; } else { Ref < ApkAssetsCookie > cookieRef = new Ref <> ( cookie ) ; asset = assetmanager . OpenNonAsset ( asset_path_utf8 , Asset . AccessMode . ACCESS_RANDOM , cookieRef ) ; cookie = cookieRef . get ( ) ; } if ( ! isTruthy ( asset ) ) { throw new FileNotFoundException ( asset_path_utf8 ) ; } // May be nullptr. DynamicRefTable dynamic_ref_table = assetmanager . GetDynamicRefTableForCookie ( cookie ) ; ResXMLTree xml_tree = new ResXMLTree ( dynamic_ref_table ) ; int err = xml_tree . setTo ( asset . getBuffer ( true ) , ( int ) asset . getLength ( ) , true ) ; // asset.reset(); if ( err != NO_ERROR ) { throw new FileNotFoundException ( "Corrupt XML binary file" ) ; } return NATIVE_RES_XML_TREES . register ( xml_tree ) ; }
jstring asset_path) {
jstring asset_path ) {