package com.vungle.ads.internal.task; import android.content.Context; import android.os.Bundle; import com.vungle.ads.BuildConfig; import com.vungle.ads.ServiceLocator; import com.vungle.ads.internal.persistence.FilePreferences; import com.vungle.ads.internal.util.FileUtility; import com.vungle.ads.internal.util.Logger; import com.vungle.ads.internal.util.PathProvider; import csdk.gluads.Consts; import java.io.File; import java.io.IOException; import kotlin.Lazy; import kotlin.LazyKt__LazyJVMKt; import kotlin.LazyThreadSafetyMode; import kotlin.jvm.functions.Function0; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes4.dex */ public final class CleanupJob implements Job { private static final String AD_ID_KEY = "AD_ID_KEY"; public static final Companion Companion = new Companion(null); public static final String TAG = "CleanupJob"; private final Context context; private final PathProvider pathProvider; public final Context getContext() { return this.context; } public final PathProvider getPathProvider() { return this.pathProvider; } public CleanupJob(Context context, PathProvider pathProvider) { Intrinsics.checkNotNullParameter(context, "context"); Intrinsics.checkNotNullParameter(pathProvider, "pathProvider"); this.context = context; this.pathProvider = pathProvider; } @Override // com.vungle.ads.internal.task.Job public int onRunJob(Bundle bundle, JobRunner jobRunner) { File file; Intrinsics.checkNotNullParameter(bundle, "bundle"); Intrinsics.checkNotNullParameter(jobRunner, "jobRunner"); File downloadDir = this.pathProvider.getDownloadDir(); String string = bundle.getString(AD_ID_KEY); if (string == null || (file = this.pathProvider.getDownloadsDirForAd(string)) == null) { file = downloadDir; } Logger.Companion.d(TAG, "CleanupJob: Current directory snapshot"); try { if (Intrinsics.areEqual(file, downloadDir)) { checkIfSdkUpgraded(); FileUtility.deleteContents(file); return 0; } FileUtility.delete(file); return 0; } catch (IOException unused) { return 1; } } private final void dropV6Data() { Logger.Companion.d(TAG, "CleanupJob: drop old files data"); File file = new File(this.context.getNoBackupFilesDir(), "vungle_db"); if (file.exists()) { FileUtility.delete(file); FileUtility.delete(new File(file.getPath() + "-journal")); } else { this.context.deleteDatabase("vungle_db"); } String string = this.context.getSharedPreferences("com.vungle.sdk", 0).getString("cache_path", null); this.context.deleteSharedPreferences("com.vungle.sdk"); File noBackupFilesDir = this.context.getNoBackupFilesDir(); Intrinsics.checkNotNullExpressionValue(noBackupFilesDir, "{\n context.noBackupFilesDir\n }"); FileUtility.delete(new File(noBackupFilesDir, "vungle_settings")); if (string != null) { FileUtility.delete(new File(string)); } } private final void dropV700Data() { FileUtility.delete(new File(this.context.getApplicationInfo().dataDir, Consts.SDK_VUNGLE)); } private final void dropV730TempData() { try { FileUtility.delete(new File(this.pathProvider.getSharedPrefsDir(), "vungleSettings")); FileUtility.delete(new File(this.pathProvider.getSharedPrefsDir(), "failedTpatSet")); } catch (Exception e) { Logger.Companion.e(TAG, "Failed to delete temp data", e); } } private final void checkIfSdkUpgraded() { Lazy lazy; ServiceLocator.Companion companion = ServiceLocator.Companion; final Context context = this.context; lazy = LazyKt__LazyJVMKt.lazy(LazyThreadSafetyMode.SYNCHRONIZED, new Function0() { // from class: com.vungle.ads.internal.task.CleanupJob$checkIfSdkUpgraded$$inlined$inject$1 /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ { super(0); } /* JADX WARN: Type inference failed for: r0v2, types: [com.vungle.ads.internal.persistence.FilePreferences, java.lang.Object] */ @Override // kotlin.jvm.functions.Function0 public final FilePreferences invoke() { return ServiceLocator.Companion.getInstance(context).getService(FilePreferences.class); } }); int i = m3973checkIfSdkUpgraded$lambda3(lazy).getInt("VERSION_CODE", -1); if (i < 70401) { if (i < 70000) { dropV6Data(); } if (i < 70100) { dropV700Data(); } if (i < 70301) { dropV730TempData(); } m3973checkIfSdkUpgraded$lambda3(lazy).put("VERSION_CODE", BuildConfig.VERSION_CODE).apply(); } } /* renamed from: checkIfSdkUpgraded$lambda-3, reason: not valid java name */ private static final FilePreferences m3973checkIfSdkUpgraded$lambda3(Lazy lazy) { return (FilePreferences) lazy.getValue(); } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } public static /* synthetic */ JobInfo makeJobInfo$default(Companion companion, String str, int i, Object obj) { if ((i & 1) != 0) { str = null; } return companion.makeJobInfo(str); } public final JobInfo makeJobInfo(String str) { JobInfo priority = new JobInfo(CleanupJob.TAG).setPriority(0); Bundle bundle = new Bundle(); if (str != null) { bundle.putString(CleanupJob.AD_ID_KEY, str); } return priority.setExtras(bundle).setUpdateCurrent(str == null); } } }