package com.google.android.play.core.assetpacks; import com.google.android.gms.ads.RequestConfiguration; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; /* loaded from: classes2.dex */ final class p2 { /* renamed from: c, reason: collision with root package name */ private static final r3.h0 f5011c = new r3.h0("PackMetadataManager"); /* renamed from: a, reason: collision with root package name */ private final e0 f5012a; /* renamed from: b, reason: collision with root package name */ private final r2 f5013b; p2(e0 e0Var, r2 r2Var) { this.f5012a = e0Var; this.f5013b = r2Var; } final String a(String str) { if (!this.f5012a.f(str)) { return RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } r2 r2Var = this.f5013b; e0 e0Var = this.f5012a; int a10 = r2Var.a(); File w10 = e0Var.w(str, a10, e0Var.q(str)); try { if (!w10.exists()) { return String.valueOf(a10); } FileInputStream fileInputStream = new FileInputStream(w10); try { Properties properties = new Properties(); properties.load(fileInputStream); fileInputStream.close(); String property = properties.getProperty("moduleVersionTag"); return property == null ? String.valueOf(a10) : property; } finally { } } catch (IOException unused) { f5011c.b("Failed to read pack version tag for pack %s", str); return RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } } final void b(String str, int i10, long j10, String str2) { if (str2 == null || str2.isEmpty()) { str2 = String.valueOf(i10); } Properties properties = new Properties(); properties.put("moduleVersionTag", str2); File w10 = this.f5012a.w(str, i10, j10); w10.getParentFile().mkdirs(); w10.createNewFile(); FileOutputStream fileOutputStream = new FileOutputStream(w10); try { properties.store(fileOutputStream, (String) null); fileOutputStream.close(); } catch (Throwable th) { try { fileOutputStream.close(); } catch (Throwable th2) { th.addSuppressed(th2); } throw th; } } }