导航菜单

页面标题

页面副标题

Mitra Bukalapak v2.55.0 - BrazeGeofenceManager.java 源代码

正在查看: Mitra Bukalapak v2.55.0 应用的 BrazeGeofenceManager.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.braze.managers;

import android.app.PendingIntent;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import bo.app.ab;
import bo.app.bb;
import bo.app.cb;
import bo.app.db;
import bo.app.eb;
import bo.app.ez;
import bo.app.fb;
import bo.app.gb;
import bo.app.gc;
import bo.app.hc;
import bo.app.ic;
import bo.app.if;
import bo.app.jb;
import bo.app.jc;
import bo.app.kb;
import bo.app.kc;
import bo.app.lb;
import bo.app.mb;
import bo.app.mc;
import bo.app.mf;
import bo.app.mg;
import bo.app.nb;
import bo.app.nc;
import bo.app.o90;
import bo.app.ob;
import bo.app.oy;
import bo.app.pb;
import bo.app.pc;
import bo.app.qa;
import bo.app.qb;
import bo.app.qd;
import bo.app.ra;
import bo.app.rb;
import bo.app.sb;
import bo.app.sz;
import bo.app.tb;
import bo.app.ty;
import bo.app.ub;
import bo.app.uy;
import bo.app.vb;
import bo.app.xd;
import bo.app.ya;
import bo.app.za;
import com.braze.configuration.BrazeConfigurationProvider;
import com.braze.location.IBrazeGeofenceApi;
import com.braze.location.IBrazeLocationApi;
import com.braze.models.BrazeGeofence;
import com.braze.models.IBrazeLocation;
import com.braze.support.BrazeLogger;
import com.braze.support.DateTimeUtils;
import com.braze.support.PermissionUtils;
import com.braze.support.h;
import com.bukalapak.android.lib.api4.tungku.data.SingleKycIdentity;
import com.google.android.gms.common.GoogleApiAvailability;
import defpackage.C0187su0;
import defpackage.ex2;
import defpackage.gx2;
import defpackage.ku8;
import defpackage.lm9;
import defpackage.oq1;
import defpackage.ou0;
import defpackage.p64;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import kotlin.Metadata;
import org.json.JSONException;
import org.json.JSONObject;

@Metadata(d1 = {"\u0000 \u0001\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010!\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0012\n\u0002\u0010\b\n\u0002\b\u0007\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0007\u0018\u0000 q2\u00020\u00012\u00020\u0001:\u0001qB7\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010l\u001a\u00020k\u0012\u0006\u0010#\u001a\u00020\"\u0012\u0006\u0010(\u001a\u00020'\u0012\u0006\u0010+\u001a\u00020*\u0012\u0006\u0010n\u001a\u00020m¢\u0006\u0004\bo\u0010pJ\u0017\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0007¢\u0006\u0004\b\u0005\u0010\u0006J\u0017\u0010\t\u001a\u00020\b2\u0006\u0010\u0007\u001a\u00020\u0004H\u0007¢\u0006\u0004\b\t\u0010\nJ\u0019\u0010\r\u001a\u00020\b2\b\u0010\f\u001a\u0004\u0018\u00010\u000bH\u0007¢\u0006\u0004\b\r\u0010\u000eJ\u0017\u0010\u0011\u001a\u00020\b2\u0006\u0010\u0010\u001a\u00020\u000fH\u0016¢\u0006\u0004\b\u0011\u0010\u0012J\u0017\u0010\u0011\u001a\u00020\b2\u0006\u0010\u0013\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u0011\u0010\nJ\u0017\u0010\u0016\u001a\u00020\b2\u0006\u0010\u0015\u001a\u00020\u0014H\u0016¢\u0006\u0004\b\u0016\u0010\u0017J\u001d\u0010\u001b\u001a\u00020\b2\f\u0010\u001a\u001a\b\u0012\u0004\u0012\u00020\u00190\u0018H\u0016¢\u0006\u0004\b\u001b\u0010\u001cJ\u0019\u0010\u001d\u001a\u00020\b2\b\u0010\u0010\u001a\u0004\u0018\u00010\u000fH\u0016¢\u0006\u0004\b\u001d\u0010\u0012J\u000f\u0010\u001e\u001a\u00020\bH\u0007¢\u0006\u0004\b\u001e\u0010\u001fJ%\u0010 \u001a\u00020\b2\f\u0010\u001a\u001a\b\u0012\u0004\u0012\u00020\u00190\u00182\u0006\u0010\f\u001a\u00020\u000bH\u0007¢\u0006\u0004\b \u0010!R\u0017\u0010#\u001a\u00020\"8\u0006¢\u0006\f\n\u0004\b#\u0010$\u001a\u0004\b%\u0010&R\u0014\u0010(\u001a\u00020'8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b(\u0010)R\u0014\u0010+\u001a\u00020*8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b+\u0010,R \u0010.\u001a\u00020-8\u0006X\u0087\u0004¢\u0006\u0012\n\u0004\b.\u0010/\u0012\u0004\b2\u0010\u001f\u001a\u0004\b0\u00101R \u00104\u001a\u0002038\u0006X\u0087\u0004¢\u0006\u0012\n\u0004\b4\u00105\u0012\u0004\b8\u0010\u001f\u001a\u0004\b6\u00107R\u001c\u0010:\u001a\n 9*\u0004\u0018\u00010\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b:\u0010;R\u0014\u0010=\u001a\u00020<8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b=\u0010>R \u0010@\u001a\u00020?8\u0006X\u0087\u0004¢\u0006\u0012\n\u0004\b@\u0010A\u0012\u0004\bD\u0010\u001f\u001a\u0004\bB\u0010CR&\u0010F\u001a\b\u0012\u0004\u0012\u00020\u00190E8\u0006X\u0087\u0004¢\u0006\u0012\n\u0004\bF\u0010G\u0012\u0004\bJ\u0010\u001f\u001a\u0004\bH\u0010IR\"\u0010K\u001a\u0004\u0018\u00010\u000b8\u0006X\u0087\u0004¢\u0006\u0012\n\u0004\bK\u0010L\u0012\u0004\bO\u0010\u001f\u001a\u0004\bM\u0010NR(\u0010Q\u001a\u00020P8\u0006@\u0006X\u0087\u000e¢\u0006\u0018\n\u0004\bQ\u0010R\u0012\u0004\bW\u0010\u001f\u001a\u0004\bS\u0010T\"\u0004\bU\u0010VR*\u0010X\u001a\u0004\u0018\u00010\u000f8\u0006@\u0006X\u0087\u000e¢\u0006\u0018\n\u0004\bX\u0010Y\u0012\u0004\b]\u0010\u001f\u001a\u0004\bZ\u0010[\"\u0004\b\\\u0010\u0012R(\u0010^\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u0018\n\u0004\b^\u0010_\u0012\u0004\bb\u0010\u001f\u001a\u0004\b^\u0010`\"\u0004\ba\u0010\nR(\u0010d\u001a\u00020c8\u0006@\u0006X\u0087\u000e¢\u0006\u0018\n\u0004\bd\u0010e\u0012\u0004\bj\u0010\u001f\u001a\u0004\bf\u0010g\"\u0004\bh\u0010i¨\u0006r"}, d2 = {"Lcom/braze/managers/BrazeGeofenceManager;", SingleKycIdentity.EMPTY, "Landroid/content/Context;", "context", SingleKycIdentity.EMPTY, "isGeofencesEnabledFromEnvironment", "(Landroid/content/Context;)Z", "reRegisterGeofences", "Llm9;", "setUpGeofences", "(Z)V", "Landroid/app/PendingIntent;", "geofenceRequestIntent", "tearDownGeofences", "(Landroid/app/PendingIntent;)V", "Lcom/braze/models/IBrazeLocation;", "location", "requestGeofenceRefresh", "(Lcom/braze/models/IBrazeLocation;)V", "ignoreRateLimit", "Lbo/app/a90;", "serverConfig", "configureFromServerConfig", "(Lbo/app/a90;)V", SingleKycIdentity.EMPTY, "Lcom/braze/models/BrazeGeofence;", "geofenceList", "registerGeofences", "(Ljava/util/List;)V", "onLocationRequestComplete", "requestSingleLocationUpdateFromGooglePlay", "()V", "registerGeofencesWithGooglePlay", "(Ljava/util/List;Landroid/app/PendingIntent;)V", "Lbo/app/ez;", "brazeManager", "Lbo/app/ez;", "getBrazeManager", "()Lbo/app/ez;", "Lcom/braze/configuration/BrazeConfigurationProvider;", "configurationProvider", "Lcom/braze/configuration/BrazeConfigurationProvider;", "Lbo/app/o90;", "serverConfigStorageProvider", "Lbo/app/o90;", "Lbo/app/qa;", "brazeGeofenceApi", "Lbo/app/qa;", "getBrazeGeofenceApi", "()Lbo/app/qa;", "getBrazeGeofenceApi$annotations", "Lbo/app/qd;", "brazeLocationApi", "Lbo/app/qd;", "getBrazeLocationApi", "()Lbo/app/qd;", "getBrazeLocationApi$annotations", "kotlin.jvm.PlatformType", "applicationContext", "Landroid/content/Context;", "Ljava/util/concurrent/locks/ReentrantLock;", "geofenceListLock", "Ljava/util/concurrent/locks/ReentrantLock;", "Landroid/content/SharedPreferences;", "geofenceStorageSharedPreferences", "Landroid/content/SharedPreferences;", "getGeofenceStorageSharedPreferences", "()Landroid/content/SharedPreferences;", "getGeofenceStorageSharedPreferences$annotations", SingleKycIdentity.EMPTY, "brazeGeofences", "Ljava/util/List;", "getBrazeGeofences", "()Ljava/util/List;", "getBrazeGeofences$annotations", "geofenceTransitionPendingIntent", "Landroid/app/PendingIntent;", "getGeofenceTransitionPendingIntent", "()Landroid/app/PendingIntent;", "getGeofenceTransitionPendingIntent$annotations", "Lbo/app/pc;", "brazeGeofenceReEligibilityManager", "Lbo/app/pc;", "getBrazeGeofenceReEligibilityManager", "()Lbo/app/pc;", "setBrazeGeofenceReEligibilityManager", "(Lbo/app/pc;)V", "getBrazeGeofenceReEligibilityManager$annotations", "geofenceRequestLocation", "Lcom/braze/models/IBrazeLocation;", "getGeofenceRequestLocation", "()Lcom/braze/models/IBrazeLocation;", "setGeofenceRequestLocation", "getGeofenceRequestLocation$annotations", "isGeofencesEnabled", "Z", "()Z", "setGeofencesEnabled", "isGeofencesEnabled$annotations", SingleKycIdentity.EMPTY, "maxNumToRegister", "I", "getMaxNumToRegister", "()I", "setMaxNumToRegister", "(I)V", "getMaxNumToRegister$annotations", SingleKycIdentity.EMPTY, "apiKey", "Lbo/app/sz;", "internalIEventMessenger", "<init>", "(Landroid/content/Context;Ljava/lang/String;Lbo/app/ez;Lcom/braze/configuration/BrazeConfigurationProvider;Lbo/app/o90;Lbo/app/sz;)V", "Companion", "android-sdk-base_release"}, k = 1, mv = {1, 8, 0})
public final class BrazeGeofenceManager {

    public static final Companion INSTANCE = new Companion(null);
    private final Context applicationContext;
    private final qa brazeGeofenceApi;
    private pc brazeGeofenceReEligibilityManager;
    private final List<BrazeGeofence> brazeGeofences;
    private final qd brazeLocationApi;
    private final ez brazeManager;
    private final BrazeConfigurationProvider configurationProvider;
    private final ReentrantLock geofenceListLock;
    private IBrazeLocation geofenceRequestLocation;
    private final SharedPreferences geofenceStorageSharedPreferences;
    private final PendingIntent geofenceTransitionPendingIntent;
    private boolean isGeofencesEnabled;
    private int maxNumToRegister;
    private final o90 serverConfigStorageProvider;

    @Metadata(d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0087\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u001a\u0010\u001bJ\u0017\u0010\u0004\u001a\u00020\u00022\u0006\u0010\u0003\u001a\u00020\u0002H\u0007¢\u0006\u0004\b\u0004\u0010\u0005J\u0017\u0010\t\u001a\u00020\b2\u0006\u0010\u0007\u001a\u00020\u0006H\u0007¢\u0006\u0004\b\t\u0010\nJ\u0017\u0010\r\u001a\u00020\b2\u0006\u0010\f\u001a\u00020\u000bH\u0007¢\u0006\u0004\b\r\u0010\u000eJ\u0017\u0010\u0010\u001a\u00020\u000f2\u0006\u0010\f\u001a\u00020\u000bH\u0007¢\u0006\u0004\b\u0010\u0010\u0011J\u001d\u0010\u0016\u001a\b\u0012\u0004\u0012\u00020\u00150\u00142\u0006\u0010\u0013\u001a\u00020\u0012H\u0007¢\u0006\u0004\b\u0016\u0010\u0017R\u0014\u0010\u0018\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0018\u0010\u0019¨\u0006\u001c"}, d2 = {"Lcom/braze/managers/BrazeGeofenceManager$Companion;", SingleKycIdentity.EMPTY, SingleKycIdentity.EMPTY, "apiKey", "getGeofenceSharedPreferencesName", "(Ljava/lang/String;)Ljava/lang/String;", "Lcom/braze/configuration/BrazeConfigurationProvider;", "configurationProvider", SingleKycIdentity.EMPTY, "getGeofencesEnabledFromConfiguration", "(Lcom/braze/configuration/BrazeConfigurationProvider;)Z", "Lbo/app/o90;", "serverConfigStorageProvider", "getGeofencesEnabledFromServerConfig", "(Lbo/app/o90;)Z", SingleKycIdentity.EMPTY, "getMaxNumToRegister", "(Lbo/app/o90;)I", "Landroid/content/SharedPreferences;", "sharedPreferences", SingleKycIdentity.EMPTY, "Lcom/braze/models/BrazeGeofence;", "retrieveBrazeGeofencesFromLocalStorage", "(Landroid/content/SharedPreferences;)Ljava/util/List;", "GEOFENCE_STORAGE_SHARED_PREFS_LOCATION", "Ljava/lang/String;", "<init>", "()V", "android-sdk-base_release"}, k = 1, mv = {1, 8, 0})
    public static final class Companion {
        public Companion(oq1 oq1Var) {
            this();
        }

        public final String getGeofenceSharedPreferencesName(String apiKey) {
            p64.h(apiKey, "apiKey");
            return "com.appboy.managers.geofences.storage." + apiKey;
        }

        public final boolean getGeofencesEnabledFromConfiguration(BrazeConfigurationProvider configurationProvider) {
            p64.h(configurationProvider, "configurationProvider");
            return configurationProvider.isGeofencesEnabled();
        }

        public final boolean getGeofencesEnabledFromServerConfig(o90 serverConfigStorageProvider) {
            p64.h(serverConfigStorageProvider, "serverConfigStorageProvider");
            if (!serverConfigStorageProvider.w()) {
                BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.I, (Throwable) null, c.a, 2, (Object) null);
                return false;
            }
            if (serverConfigStorageProvider.v()) {
                BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.I, (Throwable) null, a.a, 2, (Object) null);
                return true;
            }
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, BrazeLogger.Priority.I, (Throwable) null, (ex2) b.a, 2, (Object) null);
            return false;
        }

        public final int getMaxNumToRegister(o90 serverConfigStorageProvider) {
            p64.h(serverConfigStorageProvider, "serverConfigStorageProvider");
            if (serverConfigStorageProvider.k() > 0) {
                return serverConfigStorageProvider.k();
            }
            return 20;
        }

        public final List<BrazeGeofence> retrieveBrazeGeofencesFromLocalStorage(SharedPreferences sharedPreferences) {
            boolean y;
            p64.h(sharedPreferences, "sharedPreferences");
            ArrayList arrayList = new ArrayList();
            Map<String, ?> all = sharedPreferences.getAll();
            if (all == null || all.isEmpty()) {
                BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, d.a, 3, (Object) null);
                return arrayList;
            }
            Set<String> keySet = all.keySet();
            if (keySet.isEmpty()) {
                BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, BrazeLogger.Priority.W, (Throwable) null, (ex2) e.a, 2, (Object) null);
                return arrayList;
            }
            for (String str : keySet) {
                String string = sharedPreferences.getString(str, null);
                if (string != null) {
                    try {
                        y = ku8.y(string);
                    } catch (JSONException e) {
                        BrazeLogger.INSTANCE.brazelog(this, BrazeLogger.Priority.E, e, (ex2<String>) new g(string));
                    } catch (Exception e2) {
                        BrazeLogger.INSTANCE.brazelog(this, BrazeLogger.Priority.E, e2, (ex2<String>) new h(string));
                    }
                    if (!y) {
                        arrayList.add(new BrazeGeofence(new JSONObject(string)));
                    }
                }
                BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, BrazeLogger.Priority.W, (Throwable) null, (ex2) new f(str), 2, (Object) null);
            }
            return arrayList;
        }

        private Companion() {
        }
    }

    public BrazeGeofenceManager(Context context, String str, ez ezVar, BrazeConfigurationProvider brazeConfigurationProvider, o90 o90Var, sz szVar) {
        p64.h(context, "context");
        p64.h(str, "apiKey");
        p64.h(ezVar, "brazeManager");
        p64.h(brazeConfigurationProvider, "configurationProvider");
        p64.h(o90Var, "serverConfigStorageProvider");
        p64.h(szVar, "internalIEventMessenger");
        this.brazeManager = ezVar;
        this.configurationProvider = brazeConfigurationProvider;
        this.serverConfigStorageProvider = o90Var;
        qa qaVar = new qa();
        this.brazeGeofenceApi = qaVar;
        this.brazeLocationApi = new qd(context, xd.c.a(brazeConfigurationProvider), brazeConfigurationProvider);
        this.applicationContext = context.getApplicationContext();
        this.geofenceListLock = new ReentrantLock();
        Companion companion = INSTANCE;
        boolean z = false;
        SharedPreferences sharedPreferences = context.getSharedPreferences(companion.getGeofenceSharedPreferencesName(str), 0);
        p64.g(sharedPreferences, "context.getSharedPrefere…ontext.MODE_PRIVATE\n    )");
        this.geofenceStorageSharedPreferences = sharedPreferences;
        this.brazeGeofences = C0187su0.S0(companion.retrieveBrazeGeofencesFromLocalStorage(sharedPreferences));
        this.geofenceTransitionPendingIntent = qaVar.a(context);
        this.brazeGeofenceReEligibilityManager = new pc(context, str, o90Var, szVar);
        if (companion.getGeofencesEnabledFromServerConfig(o90Var) && isGeofencesEnabledFromEnvironment(context) && qaVar.a()) {
            z = true;
        }
        this.isGeofencesEnabled = z;
        this.maxNumToRegister = companion.getMaxNumToRegister(o90Var);
        if (!qaVar.a()) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.I, (Throwable) null, ra.a, 2, (Object) null);
        }
        setUpGeofences(true);
    }

    public void configureFromServerConfig(bo.app.a90 r13) {
        throw new UnsupportedOperationException("Method not decompiled: com.braze.managers.BrazeGeofenceManager.configureFromServerConfig(bo.app.a90):void");
    }

    public final List<BrazeGeofence> getBrazeGeofences() {
        return this.brazeGeofences;
    }

    public final int getMaxNumToRegister() {
        return this.maxNumToRegister;
    }

    public final boolean getIsGeofencesEnabled() {
        return this.isGeofencesEnabled;
    }

    public final boolean isGeofencesEnabledFromEnvironment(Context context) {
        p64.h(context, "context");
        if (!INSTANCE.getGeofencesEnabledFromConfiguration(this.configurationProvider)) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, ya.a, 3, (Object) null);
            return false;
        }
        if (!PermissionUtils.hasPermission(context, "android.permission.ACCESS_FINE_LOCATION")) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, BrazeLogger.Priority.I, (Throwable) null, (ex2) za.a, 2, (Object) null);
            return false;
        }
        if (Build.VERSION.SDK_INT >= 29 && !PermissionUtils.hasPermission(context, "android.permission.ACCESS_BACKGROUND_LOCATION")) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, BrazeLogger.Priority.I, (Throwable) null, (ex2) ab.a, 2, (Object) null);
            return false;
        }
        p64.h(context, "context");
        int g = GoogleApiAvailability.m().g(context);
        if (g != 0) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) h.a, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new uy(g), 3, (Object) null);
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) bb.a, 3, (Object) null);
            return false;
        }
        BrazeLogger brazeLogger = BrazeLogger.INSTANCE;
        BrazeLogger.brazelog$default(brazeLogger, (Object) h.a, (BrazeLogger.Priority) null, (Throwable) null, (ex2) ty.a, 3, (Object) null);
        if (!this.brazeGeofenceApi.a()) {
            BrazeLogger.brazelog$default(brazeLogger, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) cb.a, 3, (Object) null);
            return false;
        }
        try {
            Class.forName("com.google.android.gms.location.LocationServices", false, BrazeGeofenceManager.class.getClassLoader());
            BrazeLogger.brazelog$default(brazeLogger, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) eb.a, 3, (Object) null);
            return true;
        } catch (Exception unused) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) db.a, 3, (Object) null);
            return false;
        }
    }

    public void onLocationRequestComplete(IBrazeLocation location) {
        if (location == null) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) gb.a, 3, (Object) null);
            return;
        }
        BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new fb(location), 3, (Object) null);
        requestGeofenceRefresh(location);
        this.brazeGeofenceReEligibilityManager.a(DateTimeUtils.nowInSeconds());
    }

    public void registerGeofences(List<BrazeGeofence> geofenceList) {
        List list;
        p64.h(geofenceList, "geofenceList");
        List S0 = C0187su0.S0(geofenceList);
        if (!this.isGeofencesEnabled) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, BrazeLogger.Priority.W, (Throwable) null, (ex2) jb.a, 2, (Object) null);
            return;
        }
        if (this.geofenceRequestLocation != null) {
            Iterator it = S0.iterator();
            while (it.hasNext()) {
                BrazeGeofence brazeGeofence = (BrazeGeofence) it.next();
                IBrazeLocation iBrazeLocation = this.geofenceRequestLocation;
                if (iBrazeLocation != null) {
                    double latitude = iBrazeLocation.getLatitude();
                    double longitude = iBrazeLocation.getLongitude();
                    double latitude2 = brazeGeofence.getLatitude();
                    double longitude2 = brazeGeofence.getLongitude();
                    double radians = Math.toRadians(latitude2 - latitude);
                    double radians2 = Math.toRadians(longitude2 - longitude);
                    double d = 2;
                    brazeGeofence.setDistanceFromGeofenceRefresh(Math.asin(Math.sqrt((Math.cos(Math.toRadians(latitude2)) * Math.cos(Math.toRadians(latitude)) * Math.pow(Math.sin(radians2 / d), 2.0d)) + Math.pow(Math.sin(radians / d), 2.0d))) * 1.2742E7d);
                    S0 = S0;
                    it = it;
                }
            }
            list = S0;
            ou0.v(list);
        } else {
            list = S0;
        }
        ReentrantLock reentrantLock = this.geofenceListLock;
        reentrantLock.lock();
        try {
            List list2 = list;
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new kb(list2), 3, (Object) null);
            SharedPreferences.Editor edit = this.geofenceStorageSharedPreferences.edit();
            edit.clear();
            this.brazeGeofences.clear();
            Iterator it2 = list2.iterator();
            int i = 0;
            while (true) {
                if (!it2.hasNext()) {
                    break;
                }
                BrazeGeofence brazeGeofence2 = (BrazeGeofence) it2.next();
                if (i == this.maxNumToRegister) {
                    BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new lb(this), 3, (Object) null);
                    break;
                }
                this.brazeGeofences.add(brazeGeofence2);
                BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new mb(brazeGeofence2), 3, (Object) null);
                edit.putString(brazeGeofence2.getId(), brazeGeofence2.forJsonPut().toString());
                i++;
            }
            edit.apply();
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new nb(this), 3, (Object) null);
            lm9 lm9Var = lm9.a;
            reentrantLock.unlock();
            pc pcVar = this.brazeGeofenceReEligibilityManager;
            pcVar.getClass();
            p64.h(list2, "brazeGeofenceList");
            LinkedHashSet linkedHashSet = new LinkedHashSet();
            Iterator it3 = list2.iterator();
            while (it3.hasNext()) {
                linkedHashSet.add(((BrazeGeofence) it3.next()).getId());
            }
            HashSet hashSet = new HashSet(pcVar.c.keySet());
            SharedPreferences.Editor edit2 = pcVar.b.edit();
            Iterator it4 = hashSet.iterator();
            while (it4.hasNext()) {
                String str = (String) it4.next();
                p64.g(str, "reEligibilityId");
                if (linkedHashSet.contains(pcVar.a(str))) {
                    BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) pcVar, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new nc(str), 3, (Object) null);
                } else {
                    BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) pcVar, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new mc(str), 3, (Object) null);
                    pcVar.c.remove(str);
                    edit2.remove(str);
                }
            }
            edit2.apply();
            setUpGeofences(true);
        } catch (Throwable th) {
            reentrantLock.unlock();
            throw th;
        }
    }

    public final void registerGeofencesWithGooglePlay(List<BrazeGeofence> geofenceList, PendingIntent geofenceRequestIntent) {
        p64.h(geofenceList, "geofenceList");
        p64.h(geofenceRequestIntent, "geofenceRequestIntent");
        qa qaVar = this.brazeGeofenceApi;
        Context context = this.applicationContext;
        p64.g(context, "applicationContext");
        qaVar.getClass();
        p64.h(context, "context");
        p64.h(geofenceList, "geofenceList");
        p64.h(geofenceRequestIntent, "geofenceRequestIntent");
        IBrazeGeofenceApi iBrazeGeofenceApi = qaVar.a;
        if (iBrazeGeofenceApi != null) {
            iBrazeGeofenceApi.registerGeofences(context, geofenceList, geofenceRequestIntent);
        }
    }

    public void requestGeofenceRefresh(IBrazeLocation location) {
        p64.h(location, "location");
        if (!this.isGeofencesEnabled) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) ob.a, 3, (Object) null);
            return;
        }
        this.geofenceRequestLocation = location;
        if (location != null) {
            mf mfVar = (mf) this.brazeManager;
            mfVar.getClass();
            p64.h(location, "location");
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) mfVar, (BrazeLogger.Priority) null, (Throwable) null, (ex2) if.a, 3, (Object) null);
            mfVar.a((mg) new oy(mfVar.f, mfVar.e.getBaseUrlForRequests(), location));
        }
    }

    public final void requestSingleLocationUpdateFromGooglePlay() {
        qd qdVar = this.brazeLocationApi;
        gx2<? super IBrazeLocation, lm9> qbVar = new qb<>(this);
        qdVar.getClass();
        p64.h(qbVar, "manualLocationUpdateCallback");
        IBrazeLocationApi iBrazeLocationApi = qdVar.a;
        if (iBrazeLocationApi != null) {
            iBrazeLocationApi.requestSingleLocationUpdate(qbVar);
        }
    }

    public final void setUpGeofences(boolean reRegisterGeofences) {
        if (!this.isGeofencesEnabled) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, rb.a, 3, (Object) null);
            return;
        }
        PendingIntent pendingIntent = this.geofenceTransitionPendingIntent;
        if (pendingIntent == null) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) sb.a, 3, (Object) null);
            return;
        }
        if (reRegisterGeofences) {
            ReentrantLock reentrantLock = this.geofenceListLock;
            reentrantLock.lock();
            try {
                registerGeofencesWithGooglePlay(this.brazeGeofences, pendingIntent);
                lm9 lm9Var = lm9.a;
            } finally {
                reentrantLock.unlock();
            }
        }
    }

    public final void tearDownGeofences(PendingIntent geofenceRequestIntent) {
        BrazeLogger brazeLogger = BrazeLogger.INSTANCE;
        BrazeLogger.brazelog$default(brazeLogger, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) tb.a, 3, (Object) null);
        if (geofenceRequestIntent != null) {
            BrazeLogger.brazelog$default(brazeLogger, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) ub.a, 3, (Object) null);
            qa qaVar = this.brazeGeofenceApi;
            Context context = this.applicationContext;
            p64.g(context, "applicationContext");
            qaVar.getClass();
            p64.h(context, "applicationContext");
            p64.h(geofenceRequestIntent, "intent");
            IBrazeGeofenceApi iBrazeGeofenceApi = qaVar.a;
            if (iBrazeGeofenceApi != null) {
                iBrazeGeofenceApi.teardownGeofences(context, geofenceRequestIntent);
            }
        }
        ReentrantLock reentrantLock = this.geofenceListLock;
        reentrantLock.lock();
        try {
            BrazeLogger.brazelog$default(brazeLogger, (Object) this, (BrazeLogger.Priority) null, (Throwable) null, (ex2) vb.a, 3, (Object) null);
            this.geofenceStorageSharedPreferences.edit().clear().apply();
            this.brazeGeofences.clear();
            lm9 lm9Var = lm9.a;
        } finally {
            reentrantLock.unlock();
        }
    }

    public void requestGeofenceRefresh(boolean ignoreRateLimit) {
        if (!this.isGeofencesEnabled) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, pb.a, 3, (Object) null);
            return;
        }
        pc pcVar = this.brazeGeofenceReEligibilityManager;
        long nowInSeconds = DateTimeUtils.nowInSeconds() - pcVar.e;
        if (!ignoreRateLimit && pcVar.g > nowInSeconds) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) pcVar, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new gc(nowInSeconds, pcVar), 3, (Object) null);
            return;
        }
        if (ignoreRateLimit) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) pcVar, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new hc(nowInSeconds), 3, (Object) null);
        } else {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) pcVar, (BrazeLogger.Priority) null, (Throwable) null, (ex2) new ic(nowInSeconds, pcVar), 3, (Object) null);
        }
        if (pcVar.d.compareAndSet(false, true)) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) pcVar, (BrazeLogger.Priority) null, (Throwable) null, (ex2) jc.a, 3, (Object) null);
            requestSingleLocationUpdateFromGooglePlay();
        } else {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, (Object) pcVar, (BrazeLogger.Priority) null, (Throwable) null, (ex2) kc.a, 3, (Object) null);
        }
    }
}