package com.squareup.leakcanary.internal; import android.app.IntentService; import android.app.Notification; import android.content.Intent; import android.os.IBinder; import android.os.SystemClock; import com.squareup.leakcanary.R; /* loaded from: classes.dex */ public abstract class ForegroundService extends IntentService { private final int notificationContentTitleResId; private final int notificationId; public ForegroundService(String str, int i) { super(str); this.notificationContentTitleResId = i; this.notificationId = (int) SystemClock.uptimeMillis(); } @Override // android.app.IntentService, android.app.Service public IBinder onBind(Intent intent) { return null; } @Override // android.app.IntentService, android.app.Service public void onCreate() { super.onCreate(); showForegroundNotification(100, 0, true, getString(R.string.leak_canary_notification_foreground_text)); } @Override // android.app.IntentService, android.app.Service public void onDestroy() { super.onDestroy(); stopForeground(true); } @Override // android.app.IntentService protected void onHandleIntent(Intent intent) { onHandleIntentInForeground(intent); } protected abstract void onHandleIntentInForeground(Intent intent); protected void showForegroundNotification(int i, int i2, boolean z, String str) { startForeground(this.notificationId, LeakCanaryInternals.buildNotification(this, new Notification.Builder(this).setContentTitle(getString(this.notificationContentTitleResId)).setContentText(str).setProgress(i, i2, z))); } }