导航菜单

页面标题

页面副标题

Petal Maps v4.7.0.310001 - LocationShareService.java 源代码

正在查看: Petal Maps v4.7.0.310001 应用的 LocationShareService.java JAVA 源代码文件

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


package com.huawei.maps.locationshare.service;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import com.huawei.map.mapapi.model.BitmapDescriptorFactory;
import com.huawei.maps.app.routeplan.util.WorkerResult;
import com.huawei.maps.locationshare.R$drawable;
import com.huawei.maps.locationshare.R$string;
import com.huawei.maps.locationshare.service.LocationShareService;
import com.huawei.secure.android.common.activity.SafeService;
import com.huawei.secure.android.common.intent.SafeIntent;

public class LocationShareService extends SafeService {
    public static volatile SafeIntent e = null;
    public static volatile boolean f = false;
    public static final Object g = new Object();
    public static ServiceConnection h;
    public Notification b;
    public NotificationManager c;
    public Bitmap d;

    public class a implements ServiceConnection {
        public static void b(IBinder iBinder) {
            ((b) iBinder).a().f();
        }

        @Override
        public void onServiceConnected(ComponentName componentName, final IBinder iBinder) {
            hm4.p("LocationShareService", "LocationShareService bind");
            if (iBinder instanceof b) {
                try {
                    if (Build.VERSION.SDK_INT >= 31) {
                        rya.a.b(new WorkerResult() {
                            public final void doWork() {
                                LocationShareService.a.b(iBinder);
                            }
                        });
                    } else {
                        ((b) iBinder).a().f();
                    }
                } catch (Exception e) {
                    o05.c(e, true);
                    hm4.p("LocationShareService", "location share onServiceConnected fail");
                }
            }
        }

        @Override
        public void onServiceDisconnected(ComponentName componentName) {
            hm4.p("LocationShareService", "unbind");
        }
    }

    public class b extends Binder {
        public b() {
        }

        @NonNull
        public LocationShareService a() {
            return LocationShareService.this;
        }
    }

    public static ServiceConnection c() {
        return new a();
    }

    public static boolean e() {
        return f;
    }

    public static void g() {
        synchronized (g) {
            try {
                if (f) {
                    return;
                }
                e = new SafeIntent(new Intent((Context) o41.b(), (Class<?>) LocationShareService.class));
                if (e == null) {
                    f = false;
                    return;
                }
                h = c();
                o41.b().bindService(e, h, 1);
                f = true;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public static boolean h() {
        synchronized (g) {
            try {
                if (!f) {
                    return false;
                }
                if (h == null || e == null) {
                    f = false;
                    return false;
                }
                try {
                    o41.b().unbindService(h);
                } catch (IllegalArgumentException unused) {
                    hm4.h("LocationShareService", "unBindError");
                }
                o41.b().stopService(e);
                h = null;
                e = null;
                f = false;
                return true;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    private void i() {
        try {
            stopForeground(true);
            stopSelf();
        } catch (Exception unused) {
            hm4.p("LocationShareService", "stopNavService LocationShareService catch exception");
        }
    }

    public final Notification a() {
        if (this.c == null) {
            NotificationManager notificationManager = (NotificationManager) o41.b().getSystemService("notification");
            this.c = notificationManager;
            if (notificationManager != null) {
                NotificationChannel notificationChannel = new NotificationChannel("10000", o41.f(R$string.notification_channel_navigation), 2);
                notificationChannel.setSound(null, null);
                this.c.createNotificationChannel(notificationChannel);
            }
        }
        Uri parse = Uri.parse("petalmaps://showPage?page=shareLocationManager&fromType=4");
        Intent p = w59.a.p();
        if (p != null) {
            p.setFlags(268435456);
            p.setData(parse);
        } else {
            p = new SafeIntent(new Intent());
        }
        PendingIntent activity = PendingIntent.getActivity(o41.b(), 0, p, 201326592);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(o41.b(), "10000");
        builder.setContentText(o41.b().getString(R$string.notification_real_time_location_sharing)).setSmallIcon(R$drawable.appbg_color).setLargeIcon(b()).setOngoing(false).setSound((Uri) null).setContentIntent(activity).setWhen(System.currentTimeMillis());
        return builder.build();
    }

    public final Bitmap b() {
        Bitmap bitmap = this.d;
        if (bitmap != null) {
            return bitmap;
        }
        int i = R$drawable.appbg;
        this.d = BitmapDescriptorFactory.fromResource(i).getBitmap();
        hm4.p("LocationShareService", " getLargeIcon drawable is : " + i);
        StringBuilder sb = new StringBuilder();
        sb.append(" getLargeIcon is empty : ");
        boolean z = false;
        sb.append(this.d == null);
        hm4.p("LocationShareService", sb.toString());
        StringBuilder sb2 = new StringBuilder();
        sb2.append(" getLargeIcon is isRecycled : ");
        Bitmap bitmap2 = this.d;
        if (bitmap2 != null && bitmap2.isRecycled()) {
            z = true;
        }
        sb2.append(z);
        hm4.p("LocationShareService", sb2.toString());
        return this.d;
    }

    public void d() {
        if (this.b == null) {
            Notification a2 = a();
            this.b = a2;
            a2.flags |= 64;
        }
    }

    public void f() {
        d();
        if (Build.VERSION.SDK_INT >= 29) {
            startForeground(1001, this.b, -1);
        } else {
            startForeground(1001, this.b);
        }
    }

    @Nullable
    public IBinder onBind(Intent intent) {
        return new b();
    }

    public void onCreate() {
        super.onCreate();
        hm4.p("LocationShareService", "onCreate");
    }

    public void onDestroy() {
        super.onDestroy();
        hm4.p("LocationShareService", "onDestroy");
        Bitmap bitmap = this.d;
        if (bitmap != null) {
            bitmap.recycle();
            this.d = null;
        }
        NotificationManager notificationManager = this.c;
        if (notificationManager != null) {
            notificationManager.cancel(1001);
        }
        i();
    }
}