package androidx.profileinstaller;

import K1.c;
import L1.e;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.util.Log;
import java.io.File;

/* JADX INFO: loaded from: classes.dex */
public class ProfileInstallReceiver extends BroadcastReceiver {
    @Override // android.content.BroadcastReceiver
    public final void onReceive(Context context, Intent intent) {
        Bundle extras;
        if (intent == null) {
            return;
        }
        String action = intent.getAction();
        if ("androidx.profileinstaller.action.INSTALL_PROFILE".equals(action)) {
            e.t(context, new c(0), new K4.c(18, this), true);
            return;
        }
        if ("androidx.profileinstaller.action.SKIP_FILE".equals(action)) {
            Bundle extras2 = intent.getExtras();
            if (extras2 != null) {
                String string = extras2.getString("EXTRA_SKIP_FILE_OPERATION");
                if (!"WRITE_SKIP_FILE".equals(string)) {
                    if ("DELETE_SKIP_FILE".equals(string)) {
                        new File(context.getFilesDir(), "profileinstaller_profileWrittenFor_lastUpdateTime.dat").delete();
                        Log.d("ProfileInstaller", "RESULT_DELETE_SKIP_FILE_SUCCESS");
                        setResultCode(11);
                        return;
                    }
                    return;
                }
                K4.c cVar = new K4.c(18, this);
                try {
                    e.e(context.getPackageManager().getPackageInfo(context.getApplicationContext().getPackageName(), 0), context.getFilesDir());
                    cVar.f(10, null);
                    return;
                } catch (PackageManager.NameNotFoundException e8) {
                    cVar.f(7, e8);
                    return;
                }
            }
            return;
        }
        if ("androidx.profileinstaller.action.SAVE_PROFILE".equals(action)) {
            K4.c cVar2 = new K4.c(18, this);
            if (Build.VERSION.SDK_INT < 24) {
                cVar2.f(13, null);
                return;
            } else {
                Process.sendSignal(Process.myPid(), 10);
                cVar2.f(12, null);
                return;
            }
        }
        if (!"androidx.profileinstaller.action.BENCHMARK_OPERATION".equals(action) || (extras = intent.getExtras()) == null) {
            return;
        }
        String string2 = extras.getString("EXTRA_BENCHMARK_OPERATION");
        K4.c cVar3 = new K4.c(18, this);
        if (!"DROP_SHADER_CACHE".equals(string2)) {
            cVar3.f(16, null);
            return;
        }
        int i = Build.VERSION.SDK_INT;
        if (e.c(i >= 34 ? context.createDeviceProtectedStorageContext().getCacheDir() : i >= 24 ? context.createDeviceProtectedStorageContext().getCodeCacheDir() : i == 23 ? context.getCodeCacheDir() : context.getCacheDir())) {
            cVar3.f(14, null);
        } else {
            cVar3.f(15, null);
        }
    }
}
