导航菜单

页面标题

页面副标题

Biko v2.0.23 - LocusActivity.java 源代码

正在查看: Biko v2.0.23 应用的 LocusActivity.java JAVA 源代码文件

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


package com.birjuvachhani.locus;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.lifecycle.Lifecycle;
import com.facebook.internal.AnalyticsEvents;
import com.facebook.internal.NativeProtocol;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.ResolvableApiException;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResponse;
import com.google.android.gms.location.SettingsClient;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import kotlin.Lazy;
import kotlin.LazyKt;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.ArraysKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;

@Metadata(d1 = {"\u0000p\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u0015\n\u0002\b\u000e\u0018\u0000 :2\u00020\u00012\u00020\u0002:\u0001:B\u0005¢\u0006\u0002\u0010\u0003J\b\u0010\u0010\u001a\u00020\u0011H\u0002J4\u0010\u0012\u001a\u00020\u00112\u0012\u0010\u0013\u001a\u000e\u0012\u0004\u0012\u00020\u0015\u0012\u0004\u0012\u00020\u00110\u00142\u0016\u0010\u0016\u001a\u0012\u0012\b\u0012\u00060\u0017j\u0002`\u0018\u0012\u0004\u0012\u00020\u00110\u0014H\u0002J\b\u0010\u0019\u001a\u00020\u0011H\u0002J\b\u0010\u001a\u001a\u00020\u001bH\u0002J\b\u0010\u001c\u001a\u00020\u0011H\u0002J\b\u0010\u001d\u001a\u00020\u001bH\u0002J\"\u0010\u001e\u001a\u00020\u00112\u0006\u0010\u001f\u001a\u00020 2\u0006\u0010!\u001a\u00020 2\b\u0010\"\u001a\u0004\u0018\u00010#H\u0014J\u0012\u0010$\u001a\u00020\u00112\b\u0010%\u001a\u0004\u0018\u00010&H\u0014J\b\u0010'\u001a\u00020\u0011H\u0014J\b\u0010(\u001a\u00020\u0011H\u0002J\b\u0010)\u001a\u00020\u0011H\u0002J\b\u0010*\u001a\u00020\u0011H\u0002J-\u0010+\u001a\u00020\u00112\u0006\u0010\u001f\u001a\u00020 2\u000e\u0010\u0006\u001a\n\u0012\u0006\b\u0001\u0012\u00020\b0\u00072\u0006\u0010,\u001a\u00020-H\u0016¢\u0006\u0002\u0010.J\b\u0010/\u001a\u00020\u0011H\u0002J\u0014\u00100\u001a\u00020\u00112\n\u00101\u001a\u00060\u0017j\u0002`\u0018H\u0002J\b\u00102\u001a\u00020\u0011H\u0002J\u0010\u00103\u001a\u00020\u00112\u0006\u00104\u001a\u00020\bH\u0002J\b\u00105\u001a\u00020\u0011H\u0002J\u0014\u00106\u001a\u00020\u00112\n\u00101\u001a\u00060\u0017j\u0002`\u0018H\u0002J\b\u00107\u001a\u00020\u0011H\u0002J\b\u00108\u001a\u00020\u0011H\u0002J\b\u00109\u001a\u00020\u0011H\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u0016\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\b0\u0007X\u0082\u000e¢\u0006\u0004\n\u0002\u0010\tR\u001b\u0010\n\u001a\u00020\u000b8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u000e\u0010\u000f\u001a\u0004\b\f\u0010\r¨\u0006;"}, d2 = {"Lcom/birjuvachhani/locus/LocusActivity;", "Landroidx/appcompat/app/AppCompatActivity;", "Landroidx/core/app/ActivityCompat$OnRequestPermissionsResultCallback;", "()V", "config", "Lcom/birjuvachhani/locus/Configuration;", NativeProtocol.RESULT_ARGS_PERMISSIONS, "", "", "[Ljava/lang/String;", "pref", "Landroid/content/SharedPreferences;", "getPref", "()Landroid/content/SharedPreferences;", "pref$delegate", "Lkotlin/Lazy;", "checkIfLocationSettingsAreEnabled", "", "checkSettings", "success", "Lkotlin/Function1;", "Lcom/google/android/gms/location/LocationSettingsResponse;", "failure", "Ljava/lang/Exception;", "Lkotlin/Exception;", "clearPermissionNotificationIfAny", "hasAllPermissions", "", "initPermissionModel", "needToShowRationale", "onActivityResult", "requestCode", "", "resultCode", "data", "Landroid/content/Intent;", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onPermissionDenied", "onPermissionGranted", "onPermissionPermanentlyDenied", "onRequestPermissionsResult", "grantResults", "", "(I[Ljava/lang/String;[I)V", "onResolutionDenied", "onResolutionNeeded", "exception", "openSettings", "postResult", AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_STATUS, "requestForPermissions", "resolveLocationSettings", "shouldProceedForLocation", "showPermanentlyDeniedDialog", "showPermissionRationale", "Companion", "locus_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class LocusActivity extends AppCompatActivity implements ActivityCompat.OnRequestPermissionsResultCallback {
    private static final int PERMISSION_REQUEST_CODE = 777;
    private static final String PREF_NAME = "locus_pref";
    private static final int REQUEST_CODE_LOCATION_SETTINGS = 545;
    private static final int SETTINGS_ACTIVITY_REQUEST_CODE = 659;
    private Configuration config = new Configuration(null, false, false, false, 15, null);

    private final Lazy pref = LazyKt.lazy(new Function0<SharedPreferences>() {
        {
            super(0);
        }

        public final SharedPreferences m2530invoke() {
            return LocusActivity.this.getSharedPreferences("locus_pref", 0);
        }
    });
    private String[] permissions = new String[0];

    private final SharedPreferences getPref() {
        Object value = this.pref.getValue();
        Intrinsics.checkNotNullExpressionValue(value, "<get-pref>(...)");
        return (SharedPreferences) value;
    }

    protected void onCreate(Bundle savedInstanceState) {
        Unit unit;
        Configuration configuration;
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_location_permission);
        Intent intent = getIntent();
        if (intent == null || (configuration = (Configuration) intent.getParcelableExtra(Constants.INTENT_EXTRA_CONFIGURATION)) == null) {
            unit = null;
        } else {
            this.config = configuration;
            unit = Unit.INSTANCE;
        }
        if (unit == null && LoggerKt.isLoggingEnabled()) {
            Log.e(getClass().getSimpleName(), "No config is sent to the permission activity");
        }
        Intent intent2 = getIntent();
        this.permissions = (!this.config.getEnableBackgroundUpdates() || (intent2 != null ? intent2.getBooleanExtra(Constants.INTENT_EXTRA_IS_SINGLE_UPDATE, false) : false)) ? PermissionUtilsKt.getLocationPermissions() : (String[]) ArraysKt.plus(PermissionUtilsKt.getLocationPermissions(), PermissionUtilsKt.getBackgroundPermission());
        initPermissionModel();
    }

    private final void requestForPermissions() {
        ActivityCompat.requestPermissions((Activity) this, this.permissions, PERMISSION_REQUEST_CODE);
    }

    private final boolean hasAllPermissions() {
        for (String str : this.permissions) {
            if (!PermissionUtilsKt.hasPermission((Context) this, str)) {
                return false;
            }
        }
        return true;
    }

    private final boolean needToShowRationale() {
        for (String str : this.permissions) {
            if (PermissionUtilsKt.shouldShowRationale((Activity) this, str)) {
                return true;
            }
        }
        return false;
    }

    private final void showPermissionRationale() {
        String string = getString(R.string.locus_rationale_title);
        Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.locus_rationale_title)");
        String string2 = getString(R.string.locus_rationale_message);
        Intrinsics.checkNotNullExpressionValue(string2, "getString(R.string.locus_rationale_message)");
        AlertDialog create = new AlertDialog.Builder((Context) this).setTitle(string).setMessage(string2).setPositiveButton(R.string.grant, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                LocusActivity.m2528showPermissionRationale$lambda2(LocusActivity.this, dialogInterface, i);
            }
        }).setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                LocusActivity.m2529showPermissionRationale$lambda3(LocusActivity.this, dialogInterface, i);
            }
        }).setCancelable(false).create();
        if (!(!isFinishing())) {
            create = null;
        }
        if (create != null) {
            create.show();
        }
    }

    public static final void m2528showPermissionRationale$lambda2(LocusActivity locusActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(locusActivity, "this$0");
        locusActivity.requestForPermissions();
        dialogInterface.dismiss();
    }

    public static final void m2529showPermissionRationale$lambda3(LocusActivity locusActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(locusActivity, "this$0");
        dialogInterface.dismiss();
        locusActivity.onPermissionDenied();
    }

    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        String[] locationPermissions;
        boolean z;
        Intrinsics.checkNotNullParameter(permissions, NativeProtocol.RESULT_ARGS_PERMISSIONS);
        Intrinsics.checkNotNullParameter(grantResults, "grantResults");
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (this.config.getEnableBackgroundUpdates() && this.config.getForceBackgroundUpdates()) {
            locationPermissions = (String[]) ArraysKt.plus(PermissionUtilsKt.getLocationPermissions(), PermissionUtilsKt.getBackgroundPermission());
        } else {
            locationPermissions = PermissionUtilsKt.getLocationPermissions();
        }
        if (requestCode == PERMISSION_REQUEST_CODE) {
            boolean z2 = true;
            if (grantResults.length == 0) {
                if (LoggerKt.isLoggingEnabled()) {
                    Log.d(getClass().getSimpleName(), "User interaction was cancelled.");
                    return;
                }
                return;
            }
            int length = grantResults.length;
            int i = 0;
            while (true) {
                if (i >= length) {
                    z = true;
                    break;
                }
                if (!(grantResults[i] == 0)) {
                    z = false;
                    break;
                }
                i++;
            }
            if (z) {
                onPermissionGranted();
                return;
            }
            int length2 = locationPermissions.length;
            int i2 = 0;
            while (true) {
                if (i2 >= length2) {
                    break;
                }
                if (!(grantResults[ArraysKt.indexOf(permissions, locationPermissions[i2])] == 0)) {
                    z2 = false;
                    break;
                }
                i2++;
            }
            if (z2) {
                onPermissionGranted();
            } else {
                onPermissionDenied();
            }
        }
    }

    private final void onPermissionGranted() {
        if (this.config.getShouldResolveRequest()) {
            checkIfLocationSettingsAreEnabled();
        } else {
            shouldProceedForLocation();
        }
    }

    private final void onPermissionDenied() {
        if (!needToShowRationale()) {
            showPermanentlyDeniedDialog();
            return;
        }
        if (LoggerKt.isLoggingEnabled()) {
            Log.d(getClass().getSimpleName(), "Sending permission denied");
        }
        postResult(Constants.DENIED);
    }

    private final void showPermanentlyDeniedDialog() {
        String string = getString(R.string.locus_permission_blocked_title);
        Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.locus_permission_blocked_title)");
        String string2 = getString(R.string.locus_permission_blocked_message);
        Intrinsics.checkNotNullExpressionValue(string2, "getString(R.string.locus…rmission_blocked_message)");
        AlertDialog create = new AlertDialog.Builder((Context) this).setTitle(string).setMessage(string2).setPositiveButton(R.string.open_settings, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                LocusActivity.m2526showPermanentlyDeniedDialog$lambda7(LocusActivity.this, dialogInterface, i);
            }
        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                LocusActivity.m2527showPermanentlyDeniedDialog$lambda8(LocusActivity.this, dialogInterface, i);
            }
        }).setCancelable(false).create();
        if (!(!isFinishing())) {
            create = null;
        }
        if (create != null) {
            create.show();
        }
    }

    public static final void m2526showPermanentlyDeniedDialog$lambda7(LocusActivity locusActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(locusActivity, "this$0");
        locusActivity.openSettings();
        dialogInterface.dismiss();
    }

    public static final void m2527showPermanentlyDeniedDialog$lambda8(LocusActivity locusActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(locusActivity, "this$0");
        dialogInterface.dismiss();
        locusActivity.onPermissionPermanentlyDenied();
    }

    private final void onPermissionPermanentlyDenied() {
        postResult(Constants.PERMANENTLY_DENIED);
    }

    private final void openSettings() {
        Intent intent = new Intent();
        intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
        intent.setData(Uri.fromParts("package", getPackageName(), null));
        startActivityForResult(intent, SETTINGS_ACTIVITY_REQUEST_CODE);
    }

    private final void checkIfLocationSettingsAreEnabled() {
        checkSettings(new Function1<LocationSettingsResponse, Unit>() {
            {
                super(1);
            }

            public Object invoke(Object obj) {
                invoke((LocationSettingsResponse) obj);
                return Unit.INSTANCE;
            }

            public final void invoke(LocationSettingsResponse locationSettingsResponse) {
                Intrinsics.checkNotNullParameter(locationSettingsResponse, "it");
                LocusActivity.this.shouldProceedForLocation();
            }
        }, new Function1<Exception, Unit>() {
            {
                super(1);
            }

            public Object invoke(Object obj) {
                invoke((Exception) obj);
                return Unit.INSTANCE;
            }

            public final void invoke(Exception exc) {
                Intrinsics.checkNotNullParameter(exc, "exception");
                if (exc instanceof ApiException) {
                    int statusCode = ((ApiException) exc).getStatusCode();
                    if (statusCode == 6) {
                        LocusActivity locusActivity = LocusActivity.this;
                        if (LoggerKt.isLoggingEnabled()) {
                            Log.d(locusActivity.getClass().getSimpleName(), "Location settings resolution is required");
                        }
                        LocusActivity.this.onResolutionNeeded(exc);
                        return;
                    }
                    if (statusCode == 8502) {
                        LocusActivity locusActivity2 = LocusActivity.this;
                        if (LoggerKt.isLoggingEnabled()) {
                            Log.d(locusActivity2.getClass().getSimpleName(), "cannot change settings, continue with current settings");
                        }
                        LocusActivity.this.shouldProceedForLocation();
                        return;
                    }
                    LocusActivity locusActivity3 = LocusActivity.this;
                    String str = "something went wrong while processing location settings resolution request: " + exc;
                    if (LoggerKt.isLoggingEnabled()) {
                        Log.d(locusActivity3.getClass().getSimpleName(), str);
                        return;
                    }
                    return;
                }
                LocusActivity locusActivity4 = LocusActivity.this;
                if (LoggerKt.isLoggingEnabled()) {
                    Log.d(locusActivity4.getClass().getSimpleName(), "Location settings resolution denied");
                }
                LocusActivity.this.onResolutionDenied();
            }
        });
    }

    private final void checkSettings(final Function1<? super LocationSettingsResponse, Unit> success, final Function1<? super Exception, Unit> failure) {
        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
        builder.addLocationRequest(this.config.getLocationRequest$locus_release());
        builder.setAlwaysShow(true);
        SettingsClient settingsClient = LocationServices.getSettingsClient((Activity) this);
        Intrinsics.checkNotNullExpressionValue(settingsClient, "getSettingsClient(this)");
        Task checkLocationSettings = settingsClient.checkLocationSettings(builder.build());
        Intrinsics.checkNotNullExpressionValue(checkLocationSettings, "client.checkLocationSettings(builder.build())");
        checkLocationSettings.addOnSuccessListener(new OnSuccessListener() {
            public final void onSuccess(Object obj) {
                LocusActivity.m2522checkSettings$lambda10(success, (LocationSettingsResponse) obj);
            }
        }).addOnFailureListener(new OnFailureListener() {
            public final void onFailure(Exception exc) {
                LocusActivity.m2523checkSettings$lambda11(failure, exc);
            }
        });
    }

    public static final void m2522checkSettings$lambda10(Function1 function1, LocationSettingsResponse locationSettingsResponse) {
        Intrinsics.checkNotNullParameter(function1, "$success");
        Intrinsics.checkNotNullExpressionValue(locationSettingsResponse, "it");
        function1.invoke(locationSettingsResponse);
    }

    public static final void m2523checkSettings$lambda11(Function1 function1, Exception exc) {
        Intrinsics.checkNotNullParameter(function1, "$failure");
        Intrinsics.checkNotNullParameter(exc, "exception");
        function1.invoke(exc);
    }

    public final void shouldProceedForLocation() {
        clearPermissionNotificationIfAny();
        postResult(Constants.GRANTED);
    }

    private final void clearPermissionNotificationIfAny() {
        Object systemService = getSystemService("notification");
        NotificationManager notificationManager = systemService instanceof NotificationManager ? (NotificationManager) systemService : null;
        if (notificationManager == null) {
            return;
        }
        notificationManager.cancel(Constants.PERMISSION_NOTIFICATION_ID);
    }

    public final void onResolutionNeeded(final Exception exception) {
        exception.printStackTrace();
        if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
            String string = getString(R.string.locus_location_resolution_title);
            Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.locus…ocation_resolution_title)");
            String string2 = getString(R.string.locus_location_resolution_message);
            Intrinsics.checkNotNullExpressionValue(string2, "getString(R.string.locus…ation_resolution_message)");
            new AlertDialog.Builder((Context) this).setTitle(string).setMessage(string2).setPositiveButton(R.string.enable, new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    LocusActivity.m2524onResolutionNeeded$lambda12(LocusActivity.this, exception, dialogInterface, i);
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    LocusActivity.m2525onResolutionNeeded$lambda13(LocusActivity.this, dialogInterface, i);
                }
            }).setCancelable(false).create().show();
        }
    }

    public static final void m2524onResolutionNeeded$lambda12(LocusActivity locusActivity, Exception exc, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(locusActivity, "this$0");
        Intrinsics.checkNotNullParameter(exc, "$exception");
        locusActivity.resolveLocationSettings(exc);
        dialogInterface.dismiss();
    }

    public static final void m2525onResolutionNeeded$lambda13(LocusActivity locusActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(locusActivity, "this$0");
        dialogInterface.dismiss();
        locusActivity.onResolutionDenied();
    }

    public final void onResolutionDenied() {
        postResult(Constants.RESOLUTION_FAILED);
    }

    private final void resolveLocationSettings(Exception exception) {
        ResolvableApiException resolvableApiException = exception instanceof ResolvableApiException ? (ResolvableApiException) exception : null;
        if (resolvableApiException == null) {
            return;
        }
        try {
            resolvableApiException.startResolutionForResult((Activity) this, REQUEST_CODE_LOCATION_SETTINGS);
        } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
        }
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE_LOCATION_SETTINGS) {
            if (resultCode == -1) {
                shouldProceedForLocation();
                return;
            } else {
                checkSettings(new Function1<LocationSettingsResponse, Unit>() {
                    {
                        super(1);
                    }

                    public Object invoke(Object obj) {
                        invoke((LocationSettingsResponse) obj);
                        return Unit.INSTANCE;
                    }

                    public final void invoke(LocationSettingsResponse locationSettingsResponse) {
                        Intrinsics.checkNotNullParameter(locationSettingsResponse, "it");
                        LocusActivity.this.shouldProceedForLocation();
                    }
                }, new Function1<Exception, Unit>() {
                    {
                        super(1);
                    }

                    public Object invoke(Object obj) {
                        invoke((Exception) obj);
                        return Unit.INSTANCE;
                    }

                    public final void invoke(Exception exc) {
                        Intrinsics.checkNotNullParameter(exc, "it");
                        LocusActivity.this.postResult(Constants.LOCATION_SETTINGS_DENIED);
                    }
                });
                return;
            }
        }
        if (requestCode != SETTINGS_ACTIVITY_REQUEST_CODE) {
            return;
        }
        if (hasAllPermissions()) {
            onPermissionGranted();
        } else {
            onPermissionPermanentlyDenied();
        }
    }

    public final void postResult(String status) {
        String str = "Posting permission result: " + getIntent();
        if (LoggerKt.isLoggingEnabled()) {
            Log.d(getClass().getSimpleName(), str);
        }
        LocusKt.getPermissionLiveData().postValue(status);
        LocusKt.isRequestingPermission().set(false);
        finish();
    }

    protected void onDestroy() {
        super.onDestroy();
        LocusKt.isRequestingPermission().set(false);
    }

    private final void initPermissionModel() {
        if (LoggerKt.isLoggingEnabled()) {
            Log.d(getClass().getSimpleName(), "Initializing permission model");
        }
        if (!hasAllPermissions()) {
            if (!needToShowRationale()) {
                requestForPermissions();
                return;
            }
            if (LoggerKt.isLoggingEnabled()) {
                Log.d(getClass().getSimpleName(), "should display rationale for location permission");
            }
            showPermissionRationale();
            return;
        }
        onPermissionGranted();
    }
}