导航菜单

页面标题

页面副标题

CAARD v1.1.19 - GeolocatorLocationService.java 源代码

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

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


package com.baseflow.geolocator;

import android.app.Activity;
import android.app.Service;
import android.content.Intent;
import android.location.Location;
import android.net.wifi.WifiManager;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.os.PowerManager;
import android.util.Log;
import com.baseflow.geolocator.GeolocatorLocationService;
import g2.o;
import g2.r;
import g2.s;
import g2.x;
import pa.c;

public class GeolocatorLocationService extends Service {

    private o f5316o;

    private final String f5308a = "GeolocatorLocationService:Wakelock";

    private final String f5309b = "GeolocatorLocationService:WifiLock";

    private final a f5310c = new a(this);

    private boolean f5311d = false;

    private int f5312e = 0;

    private int f5313f = 0;

    private Activity f5314m = null;

    private g2.k f5315n = null;

    private PowerManager.WakeLock f5317p = null;

    private WifiManager.WifiLock f5318q = null;

    private g2.b f5319r = null;

    class a extends Binder {

        private final GeolocatorLocationService f5320a;

        a(GeolocatorLocationService geolocatorLocationService) {
            this.f5320a = geolocatorLocationService;
        }

        public GeolocatorLocationService a() {
            return this.f5320a;
        }
    }

    private int i() {
        return Build.VERSION.SDK_INT < 29 ? 3 : 4;
    }

    public static void j(c.b bVar, Location location) {
        bVar.a(r.b(location));
    }

    public static void k(c.b bVar, f2.b bVar2) {
        bVar.b(bVar2.toString(), bVar2.g(), null);
    }

    private void l(g2.d dVar) {
        WifiManager wifiManager;
        PowerManager powerManager;
        m();
        if (dVar.f() && (powerManager = (PowerManager) getApplicationContext().getSystemService("power")) != null) {
            PowerManager.WakeLock newWakeLock = powerManager.newWakeLock(1, "GeolocatorLocationService:Wakelock");
            this.f5317p = newWakeLock;
            newWakeLock.setReferenceCounted(false);
            this.f5317p.acquire();
        }
        if (!dVar.g() || (wifiManager = (WifiManager) getApplicationContext().getSystemService("wifi")) == null) {
            return;
        }
        WifiManager.WifiLock createWifiLock = wifiManager.createWifiLock(i(), "GeolocatorLocationService:WifiLock");
        this.f5318q = createWifiLock;
        createWifiLock.setReferenceCounted(false);
        this.f5318q.acquire();
    }

    private void m() {
        PowerManager.WakeLock wakeLock = this.f5317p;
        if (wakeLock != null && wakeLock.isHeld()) {
            this.f5317p.release();
            this.f5317p = null;
        }
        WifiManager.WifiLock wifiLock = this.f5318q;
        if (wifiLock == null || !wifiLock.isHeld()) {
            return;
        }
        this.f5318q.release();
        this.f5318q = null;
    }

    public boolean c(boolean z10) {
        return z10 ? this.f5313f == 1 : this.f5312e == 0;
    }

    public void d(g2.d dVar) {
        g2.b bVar = this.f5319r;
        if (bVar != null) {
            bVar.f(dVar, this.f5311d);
            l(dVar);
        }
    }

    public void e() {
        if (this.f5311d) {
            Log.d("FlutterGeolocator", "Stop service in foreground.");
            stopForeground(1);
            m();
            this.f5311d = false;
            this.f5319r = null;
        }
    }

    public void f(g2.d dVar) {
        if (this.f5319r != null) {
            Log.d("FlutterGeolocator", "Service already in foreground mode.");
            d(dVar);
        } else {
            Log.d("FlutterGeolocator", "Start service in foreground mode.");
            g2.b bVar = new g2.b(getApplicationContext(), "geolocator_channel_01", 75415, dVar);
            this.f5319r = bVar;
            bVar.d(dVar.b());
            startForeground(75415, this.f5319r.a());
            this.f5311d = true;
        }
        l(dVar);
    }

    public void g() {
        this.f5312e++;
        Log.d("FlutterGeolocator", "Flutter engine connected. Connected engine count " + this.f5312e);
    }

    public void h() {
        this.f5312e--;
        Log.d("FlutterGeolocator", "Flutter engine disconnected. Connected engine count " + this.f5312e);
    }

    public void n(Activity activity) {
        this.f5314m = activity;
    }

    public void o(g2.k kVar) {
        this.f5315n = kVar;
    }

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

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("FlutterGeolocator", "Creating service.");
    }

    @Override
    public void onDestroy() {
        Log.d("FlutterGeolocator", "Destroying location service.");
        q();
        e();
        this.f5315n = null;
        this.f5319r = null;
        Log.d("FlutterGeolocator", "Destroyed location service.");
        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int i10, int i11) {
        return 1;
    }

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

    public void p(boolean z10, s sVar, final c.b bVar) {
        this.f5313f++;
        g2.k kVar = this.f5315n;
        if (kVar != null) {
            o a10 = kVar.a(getApplicationContext(), Boolean.TRUE.equals(Boolean.valueOf(z10)), sVar);
            this.f5316o = a10;
            this.f5315n.f(a10, this.f5314m, new x() {
                @Override
                public final void a(Location location) {
                    GeolocatorLocationService.j(c.b.this, location);
                }
            }, new f2.a() {
                @Override
                public final void a(f2.b bVar2) {
                    GeolocatorLocationService.k(c.b.this, bVar2);
                }
            });
        }
    }

    public void q() {
        g2.k kVar;
        this.f5313f--;
        Log.d("FlutterGeolocator", "Stopping location service.");
        o oVar = this.f5316o;
        if (oVar == null || (kVar = this.f5315n) == null) {
            return;
        }
        kVar.g(oVar);
    }
}