导航菜单

页面标题

页面副标题

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

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

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


package com.huawei.maps.auto.navi.floatingwindow.service;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.RectF;
import android.os.Binder;
import android.os.IBinder;
import android.provider.Settings;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import com.huawei.hms.navi.navibase.model.NaviInfo;
import com.huawei.map.databus.MapDataBus;
import com.huawei.maps.auto.R$drawable;
import com.huawei.maps.auto.R$string;
import com.huawei.maps.auto.navi.floatingwindow.service.FloatingWindowService;
import com.huawei.maps.auto.navi.widget.NaviGuideLayout;
import com.huawei.secure.android.common.activity.SafeService;
import com.huawei.secure.android.common.intent.SafeIntent;
import defpackage.ls4;
import defpackage.x73;

public class FloatingWindowService extends SafeService {
    public static boolean o;
    public int b = ct3.b(o41.c(), 5.0f);
    public int c = ct3.b(o41.c(), 136.0f) + (this.b * 2);
    public int d = lt3.g().a() - this.b;
    public int e = ct3.b(o41.c(), 16.0f) - this.b;
    public int f;
    public WindowManager g;
    public WindowManager.LayoutParams h;
    public LinearLayout i;
    public NaviGuideLayout j;
    public NaviInfo k;
    public Bitmap l;
    public String m;
    public boolean n;

    public class a implements Runnable {
        public a() {
        }

        @Override
        public void run() {
            int[] iArr = new int[2];
            FloatingWindowService.this.i.getLocationOnScreen(iArr);
            FloatingWindowService floatingWindowService = FloatingWindowService.this;
            floatingWindowService.f = iArr[1] - floatingWindowService.e;
        }
    }

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

        public FloatingWindowService a() {
            return FloatingWindowService.this;
        }
    }

    public class c implements View.OnTouchListener {
        public int a;
        public int b;
        public boolean c;
        public boolean d;

        public final void a() {
            SafeService safeService = FloatingWindowService.this;
            safeService.startActivity(safeService.getPackageManager().getLaunchIntentForPackage(FloatingWindowService.this.getPackageName()));
        }

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            int action = motionEvent.getAction();
            if (action == 0) {
                this.c = false;
                this.a = (int) motionEvent.getRawX();
                this.b = (int) motionEvent.getRawY();
                int[] iArr = new int[2];
                FloatingWindowService.this.j.getLocationOnScreen(iArr);
                int width = FloatingWindowService.this.j.getWidth();
                int height = FloatingWindowService.this.j.getHeight();
                this.d = new RectF(iArr[0], iArr[1], r4 + width, r7 + height).contains(this.a, this.b);
            } else {
                if (action != 1) {
                    if (action != 2 || !this.d) {
                        return false;
                    }
                    int rawX = (int) motionEvent.getRawX();
                    int rawY = (int) motionEvent.getRawY();
                    int i = rawX - this.a;
                    int i2 = rawY - this.b;
                    if (i > 0 || i2 > 0) {
                        this.c = true;
                    }
                    this.a = rawX;
                    this.b = rawY;
                    if (x73.a().b()) {
                        int w = ct3.w(o41.c());
                        int u = ct3.u();
                        int i3 = FloatingWindowService.this.h.x + i <= 0 ? 0 : FloatingWindowService.this.h.x + i;
                        int i4 = FloatingWindowService.this.h.y + i2 > 0 ? FloatingWindowService.this.h.y + i2 : 0;
                        int width2 = w - FloatingWindowService.this.i.getWidth();
                        int t = ((u - FloatingWindowService.this.c) - FloatingWindowService.this.f) - ct3.t(o41.c());
                        if (i3 >= width2) {
                            i3 = width2;
                        }
                        if (i4 >= t) {
                            i4 = t;
                        }
                        FloatingWindowService.this.h.x = i3;
                        FloatingWindowService.this.h.y = i4;
                        FloatingWindowService.this.g.updateViewLayout(view, FloatingWindowService.this.h);
                    }
                    return true;
                }
                if (this.c) {
                    return true;
                }
                if (this.d) {
                    a();
                }
            }
            return false;
        }

        public c() {
        }
    }

    public static void p(boolean z) {
        o = z;
    }

    public final Notification j() {
        NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
        NotificationChannel notificationChannel = new NotificationChannel("notification_channel_id_01", "Foreground Service Notification", 2);
        notificationChannel.setDescription("Floating Window Service");
        if (notificationManager != null) {
            notificationManager.createNotificationChannel(notificationChannel);
        }
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "notification_channel_id_01");
        builder.setSmallIcon(R$drawable.appbg_color);
        builder.setContentTitle(o41.f(R$string.hwmap));
        builder.setContentText(o41.f(R$string.notification_navigation));
        builder.setWhen(System.currentTimeMillis());
        SafeIntent safeIntent = new SafeIntent(new Intent((Context) this, (Class<?>) MapDataBus.get().post("app_data_bus_receiver_get_main_activity", o41.b().getMapAppLifeCycle().getTopActivity())));
        safeIntent.setFlags(268435456);
        builder.setContentIntent(PendingIntent.getActivity(this, 0, safeIntent, 67108864));
        return builder.build();
    }

    public final void k() {
        if (Settings.canDrawOverlays(this)) {
            NaviGuideLayout naviGuideLayout = new NaviGuideLayout(getApplicationContext());
            this.j = naviGuideLayout;
            ls4.h(naviGuideLayout, this.n);
            LinearLayout linearLayout = new LinearLayout(this);
            this.i = linearLayout;
            linearLayout.setVisibility(8);
            this.i.setGravity(17);
            this.i.addView(this.j);
            this.i.setOnTouchListener(new c());
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.j.getLayoutParams();
            layoutParams.width = lt3.g().b();
            layoutParams.height = -2;
            int i = this.b;
            layoutParams.leftMargin = i;
            layoutParams.topMargin = i;
            layoutParams.rightMargin = i;
            layoutParams.bottomMargin = i;
            this.g = (WindowManager) getSystemService("window");
            WindowManager.LayoutParams layoutParams2 = new WindowManager.LayoutParams();
            this.h = layoutParams2;
            layoutParams2.type = 2038;
            layoutParams2.format = 1;
            layoutParams2.gravity = 51;
            layoutParams2.flags = 1576;
            layoutParams2.width = -2;
            layoutParams2.height = -2;
            layoutParams2.x = this.d;
            layoutParams2.y = this.e;
            this.g.addView(this.i, layoutParams2);
            this.i.post(new a());
        }
    }

    public final void l(int i) {
        boolean z;
        if (this.i != null) {
            hm4.p("FloatingWindowService", "setVisibility: " + i);
            if (i == 0) {
                WindowManager.LayoutParams layoutParams = this.h;
                int i2 = layoutParams.x;
                int i3 = this.d;
                boolean z2 = true;
                if (i2 != i3) {
                    layoutParams.x = i3;
                    z = true;
                } else {
                    z = false;
                }
                int i4 = layoutParams.y;
                int i5 = this.e;
                if (i4 != i5) {
                    layoutParams.y = i5;
                } else {
                    z2 = z;
                }
                if (z2) {
                    this.g.updateViewLayout(this.i, layoutParams);
                }
                r();
            }
            this.i.setVisibility(i);
        }
    }

    public void m(Bitmap bitmap) {
        NaviGuideLayout naviGuideLayout;
        this.l = bitmap;
        if (o && (naviGuideLayout = this.j) != null && naviGuideLayout.getVisibility() == 0) {
            this.j.setLaneInfo(bitmap);
        }
    }

    public void n(NaviInfo naviInfo) {
        NaviGuideLayout naviGuideLayout;
        this.k = naviInfo;
        this.m = null;
        if (o && (naviGuideLayout = this.j) != null && naviGuideLayout.getVisibility() == 0) {
            this.j.setNaviInfo(naviInfo);
        }
    }

    public void o(String str) {
        NaviGuideLayout naviGuideLayout;
        this.m = str;
        if (o && (naviGuideLayout = this.j) != null && naviGuideLayout.getVisibility() == 0) {
            this.j.setRerouteText(str);
        }
    }

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

    public void onConfigurationChanged(Configuration configuration) {
        if (this.n != o9a.f()) {
            this.n = o9a.f();
        }
        super/*android.app.Service*/.onConfigurationChanged(configuration);
    }

    public void onCreate() {
        super.onCreate();
        p(true);
        startForeground(1000, j());
    }

    public int onStartCommand(Intent intent, int i, int i2) {
        k();
        return 2;
    }

    public boolean onUnbind(Intent intent) {
        LinearLayout linearLayout = this.i;
        if (linearLayout != null) {
            this.g.removeView(linearLayout);
        }
        p(false);
        return super.onUnbind(intent);
    }

    public void q(final int i) {
        com.huawei.maps.app.common.utils.task.a.d(new Runnable() {
            @Override
            public final void run() {
                FloatingWindowService.this.l(i);
            }
        });
    }

    public final void r() {
        NaviGuideLayout naviGuideLayout;
        if (!o || (naviGuideLayout = this.j) == null) {
            return;
        }
        naviGuideLayout.setRerouteText(this.m);
        this.j.setNaviInfo(this.k);
        this.j.setLaneInfo(this.l);
    }
}