package androidx.profileinstaller;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Process;
import androidx.profileinstaller.f;
import defpackage.kr;
import java.io.File;

/* JADX INFO: loaded from: classes.dex */
public class ProfileInstallReceiver extends BroadcastReceiver {

    public class a implements f.d {
        public a() {
        }

        @Override // androidx.profileinstaller.f.d
        public final void a(int i, Object obj) {
            ((f.b) f.b).a(i, obj);
            ProfileInstallReceiver.this.setResultCode(i);
        }
    }

    @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)) {
            f.b(context, new kr(1), new a(), 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)) {
                        a aVar = new a();
                        new File(context.getFilesDir(), "profileinstaller_profileWrittenFor_lastUpdateTime.dat").delete();
                        aVar.a(11, null);
                        return;
                    }
                    return;
                }
                a aVar2 = new a();
                try {
                    f.a(context.getPackageManager().getPackageInfo(context.getApplicationContext().getPackageName(), 0), context.getFilesDir());
                    aVar2.a(10, null);
                    return;
                } catch (PackageManager.NameNotFoundException e) {
                    aVar2.a(7, e);
                    return;
                }
            }
            return;
        }
        if ("androidx.profileinstaller.action.SAVE_PROFILE".equals(action)) {
            a aVar3 = new a();
            Process.sendSignal(Process.myPid(), 10);
            aVar3.a(12, null);
        } else {
            if (!"androidx.profileinstaller.action.BENCHMARK_OPERATION".equals(action) || (extras = intent.getExtras()) == null) {
                return;
            }
            String string2 = extras.getString("EXTRA_BENCHMARK_OPERATION");
            a aVar4 = new a();
            if (!"DROP_SHADER_CACHE".equals(string2)) {
                aVar4.a(16, null);
            } else if (androidx.profileinstaller.a.a(context.createDeviceProtectedStorageContext().getCodeCacheDir())) {
                aVar4.a(14, null);
            } else {
                aVar4.a(15, null);
            }
        }
    }
}
