package com.squareup.leakcanary; import android.content.Context; import android.content.Intent; import androidx.core.content.ContextCompat; import com.squareup.leakcanary.internal.ForegroundService; import java.io.File; /* loaded from: classes.dex */ public abstract class AbstractAnalysisResultService extends ForegroundService { private static final String ANALYZED_HEAP_PATH_EXTRA = "analyzed_heap_path_extra"; public AbstractAnalysisResultService() { super(AbstractAnalysisResultService.class.getName(), R.string.leak_canary_notification_reporting); } public static void sendResultToListener(Context context, String str, HeapDump heapDump, AnalysisResult analysisResult) { try { Intent intent = new Intent(context, Class.forName(str)); File save = AnalyzedHeap.save(heapDump, analysisResult); if (save != null) { intent.putExtra(ANALYZED_HEAP_PATH_EXTRA, save.getAbsolutePath()); } ContextCompat.a(context, intent); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } protected void onAnalysisResultFailure(String str) { CanaryLog.d(str, new Object[0]); } @Override // com.squareup.leakcanary.internal.ForegroundService protected final void onHandleIntentInForeground(Intent intent) { if (intent == null) { CanaryLog.d("AbstractAnalysisResultService received a null intent, ignoring.", new Object[0]); return; } if (!intent.hasExtra(ANALYZED_HEAP_PATH_EXTRA)) { onAnalysisResultFailure(getString(R.string.leak_canary_result_failure_no_disk_space)); return; } AnalyzedHeap load = AnalyzedHeap.load(new File(intent.getStringExtra(ANALYZED_HEAP_PATH_EXTRA))); if (load == null) { onAnalysisResultFailure(getString(R.string.leak_canary_result_failure_no_file)); return; } try { onHeapAnalyzed(load); } finally { load.heapDump.heapDumpFile.delete(); load.selfFile.delete(); } } protected void onHeapAnalyzed(AnalyzedHeap analyzedHeap) { onHeapAnalyzed(analyzedHeap.heapDump, analyzedHeap.result); } @Deprecated protected void onHeapAnalyzed(HeapDump heapDump, AnalysisResult analysisResult) { } }