导航菜单

页面标题

页面副标题

CAARD v1.1.19 - FlutterLocationService.java 源代码

正在查看: CAARD v1.1.19 应用的 FlutterLocationService.java JAVA 源代码文件

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


package com.lyokone.location;

import android.app.Activity;
import android.app.Service;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;
import cc.g;
import cc.l;
import j9.NotificationOptions;
import java.util.Map;
import kotlin.Metadata;
import ob.o;
import ob.u;
import ob.y;
import pa.j;
import pa.n;
import pb.k0;

@Metadata(d1 = {"\u0000\u0080\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0015\n\u0002\b\b\u0018\u0000 =2\u00020\u00012\u00020\u0002:\u0002=>B\u0005¢\u0006\u0002\u0010\u0003J\u001c\u0010 \u001a\u0010\u0012\u0004\u0012\u00020\"\u0012\u0004\u0012\u00020#\u0018\u00010!2\u0006\u0010$\u001a\u00020%J\u0006\u0010&\u001a\u00020\u000bJ\u0006\u0010'\u001a\u00020(J\u0006\u0010)\u001a\u00020(J\u0006\u0010*\u001a\u00020\u000bJ\u0012\u0010+\u001a\u00020,2\b\u0010-\u001a\u0004\u0018\u00010.H\u0016J\b\u0010/\u001a\u00020(H\u0016J\b\u00100\u001a\u00020(H\u0016J-\u00101\u001a\u00020\u000b2\u0006\u00102\u001a\u0002032\u000e\u00104\u001a\n\u0012\u0006\b\u0001\u0012\u00020\"052\u0006\u00106\u001a\u000207H\u0016¢\u0006\u0002\u00108J\u0012\u00109\u001a\u00020\u000b2\b\u0010-\u001a\u0004\u0018\u00010.H\u0016J\u0006\u0010:\u001a\u00020(J\u0010\u0010;\u001a\u00020(2\b\u0010\u0004\u001a\u0004\u0018\u00010\u0005J\b\u0010<\u001a\u00020\u000bH\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\b\u001a\u00060\tR\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\"\u0010\u000e\u001a\u0004\u0018\u00010\r2\b\u0010\f\u001a\u0004\u0018\u00010\r@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u000f\u0010\u0010R\u0013\u0010\u0011\u001a\u0004\u0018\u00010\u00128F¢\u0006\u0006\u001a\u0004\b\u0013\u0010\u0014R\u0013\u0010\u0015\u001a\u0004\u0018\u00010\u00028F¢\u0006\u0006\u001a\u0004\b\u0016\u0010\u0017R\u001c\u0010\u0018\u001a\u0004\u0018\u00010\u0019X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001a\u0010\u001b\"\u0004\b\u001c\u0010\u001dR\u0011\u0010\u001e\u001a\u00020\u00028F¢\u0006\u0006\u001a\u0004\b\u001f\u0010\u0017¨\u0006?"}, d2 = {"Lcom/lyokone/location/FlutterLocationService;", "Landroid/app/Service;", "Lio/flutter/plugin/common/PluginRegistry$RequestPermissionsResultListener;", "()V", "activity", "Landroid/app/Activity;", "backgroundNotification", "Lcom/lyokone/location/BackgroundNotification;", "binder", "Lcom/lyokone/location/FlutterLocationService$LocalBinder;", "isForeground", "", "<set-?>", "Lcom/lyokone/location/FlutterLocation;", "location", "getLocation", "()Lcom/lyokone/location/FlutterLocation;", "locationActivityResultListener", "Lio/flutter/plugin/common/PluginRegistry$ActivityResultListener;", "getLocationActivityResultListener", "()Lio/flutter/plugin/common/PluginRegistry$ActivityResultListener;", "locationRequestPermissionsResultListener", "getLocationRequestPermissionsResultListener", "()Lio/flutter/plugin/common/PluginRegistry$RequestPermissionsResultListener;", "result", "Lio/flutter/plugin/common/MethodChannel$Result;", "getResult", "()Lio/flutter/plugin/common/MethodChannel$Result;", "setResult", "(Lio/flutter/plugin/common/MethodChannel$Result;)V", "serviceRequestPermissionsResultListener", "getServiceRequestPermissionsResultListener", "changeNotificationOptions", "", "", "", "options", "Lcom/lyokone/location/NotificationOptions;", "checkBackgroundPermissions", "disableBackgroundMode", "", "enableBackgroundMode", "isInForegroundMode", "onBind", "Landroid/os/IBinder;", "intent", "Landroid/content/Intent;", "onCreate", "onDestroy", "onRequestPermissionsResult", "requestCode", "", "permissions", "", "grantResults", "", "(I[Ljava/lang/String;[I)Z", "onUnbind", "requestBackgroundPermissions", "setActivity", "shouldShowRequestBackgroundPermissionRationale", "Companion", "LocalBinder", "location_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public final class FlutterLocationService extends Service implements n {

    public static final a f7582m = new a(null);

    private final LocalBinder f7583a = new LocalBinder();

    private boolean f7584b;

    private Activity f7585c;

    private j9.a f7586d;

    private com.lyokone.location.a f7587e;

    private j.d f7588f;

    @Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\b\u0086\u0004\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0006\u0010\u0003\u001a\u00020\u0004¨\u0006\u0005"}, d2 = {"Lcom/lyokone/location/FlutterLocationService$LocalBinder;", "Landroid/os/Binder;", "(Lcom/lyokone/location/FlutterLocationService;)V", "getService", "Lcom/lyokone/location/FlutterLocationService;", "location_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
    public final class LocalBinder extends Binder {
        public LocalBinder() {
        }

        public final FlutterLocationService getF7589a() {
            return FlutterLocationService.this;
        }
    }

    @Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0006X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000¨\u0006\t"}, d2 = {"Lcom/lyokone/location/FlutterLocationService$Companion;", "", "()V", "CHANNEL_ID", "", "ONGOING_NOTIFICATION_ID", "", "REQUEST_PERMISSIONS_REQUEST_CODE", "TAG", "location_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
    public static final class a {
        private a() {
        }

        public a(g gVar) {
            this();
        }
    }

    private final boolean m() {
        if (Build.VERSION.SDK_INT < 29) {
            return false;
        }
        Activity activity = this.f7585c;
        if (activity != null) {
            return androidx.core.app.b.f(activity, "android.permission.ACCESS_BACKGROUND_LOCATION");
        }
        throw new ActivityNotFoundException();
    }

    public final Map<String, Object> a(NotificationOptions notificationOptions) {
        l.f(notificationOptions, "options");
        j9.a aVar = this.f7586d;
        if (aVar != null) {
            aVar.f(notificationOptions, this.f7584b);
        }
        if (this.f7584b) {
            return k0.l(new o[]{u.a("channelId", "flutter_location_channel_01"), u.a("notificationId", 75418)});
        }
        return null;
    }

    public final boolean b() {
        if (Build.VERSION.SDK_INT >= 29) {
            Activity activity = this.f7585c;
            if (activity != null) {
                return androidx.core.content.a.checkSelfPermission(activity, "android.permission.ACCESS_BACKGROUND_LOCATION") == 0;
            }
            throw new ActivityNotFoundException();
        }
        com.lyokone.location.a aVar = this.f7587e;
        if (aVar != null) {
            return aVar.h();
        }
        return false;
    }

    public final void c() {
        Log.d("FlutterLocationService", "Stop service in foreground.");
        stopForeground(1);
        this.f7584b = false;
    }

    public final void d() {
        if (this.f7584b) {
            Log.d("FlutterLocationService", "Service already in foreground mode.");
            return;
        }
        Log.d("FlutterLocationService", "Start service in foreground mode.");
        j9.a aVar = this.f7586d;
        l.c(aVar);
        startForeground(75418, aVar.a());
        this.f7584b = true;
    }

    public final com.lyokone.location.a getF7587e() {
        return this.f7587e;
    }

    public final pa.l f() {
        return this.f7587e;
    }

    public final n g() {
        return this.f7587e;
    }

    public final n h() {
        return this;
    }

    public final boolean getF7584b() {
        return this.f7584b;
    }

    public final void j() {
        y yVar = null;
        if (Build.VERSION.SDK_INT >= 29) {
            Activity activity = this.f7585c;
            if (activity != null) {
                androidx.core.app.b.e(activity, new String[]{"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_BACKGROUND_LOCATION"}, 641);
                yVar = y.a;
            }
            if (yVar == null) {
                throw new ActivityNotFoundException();
            }
            return;
        }
        com.lyokone.location.a aVar = this.f7587e;
        if (aVar != null) {
            aVar.f7603t = this.f7588f;
        }
        if (aVar != null) {
            aVar.q();
        }
        this.f7588f = null;
    }

    public final void k(Activity activity) {
        this.f7585c = activity;
        com.lyokone.location.a aVar = this.f7587e;
        if (aVar != null) {
            aVar.t(activity);
        }
    }

    public final void l(j.d dVar) {
        this.f7588f = dVar;
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.d("FlutterLocationService", "Binding to location service.");
        return this.f7583a;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("FlutterLocationService", "Creating service.");
        this.f7587e = new com.lyokone.location.a(getApplicationContext(), null);
        Context applicationContext = getApplicationContext();
        l.e(applicationContext, "getApplicationContext(...)");
        this.f7586d = new j9.a(applicationContext, "flutter_location_channel_01", 75418);
    }

    @Override
    public void onDestroy() {
        Log.d("FlutterLocationService", "Destroying service.");
        this.f7587e = null;
        this.f7586d = null;
        super.onDestroy();
    }

    @Override
    public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        j.d dVar;
        String str;
        String str2;
        l.f(permissions, "permissions");
        l.f(grantResults, "grantResults");
        if (Build.VERSION.SDK_INT >= 29 && requestCode == 641 && permissions.length == 2 && l.a(permissions[0], "android.permission.ACCESS_FINE_LOCATION") && l.a(permissions[1], "android.permission.ACCESS_BACKGROUND_LOCATION")) {
            if (grantResults[0] == 0 && grantResults[1] == 0) {
                d();
                j.d dVar2 = this.f7588f;
                if (dVar2 != null) {
                    dVar2.a(1);
                }
            } else if (m()) {
                dVar = this.f7588f;
                if (dVar != null) {
                    str = "PERMISSION_DENIED";
                    str2 = "Background location permission denied";
                    dVar.b(str, str2, null);
                }
            } else {
                dVar = this.f7588f;
                if (dVar != null) {
                    str = "PERMISSION_DENIED_NEVER_ASK";
                    str2 = "Background location permission denied forever - please open app settings";
                    dVar.b(str, str2, null);
                }
            }
            this.f7588f = null;
        }
        return false;
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.d("FlutterLocationService", "Unbinding from location service.");
        return super.onUnbind(intent);
    }
}