正在查看: Petal Maps v4.7.0.310001 应用的 NavFloatingWindowService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Petal Maps v4.7.0.310001 应用的 NavFloatingWindowService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.huawei.maps.app.navigation.service;
import android.app.ActivityOptions;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import androidx.annotation.Nullable;
import com.huawei.hms.navi.navibase.model.NaviInfo;
import com.huawei.maps.app.common.utils.BaseMapAppLifecycle;
import com.huawei.maps.app.common.utils.BaseMapApplication;
import com.huawei.maps.app.navigation.service.NavFloatingWindowService;
import com.huawei.maps.app.navigation.ui.layout.NavFloatingWindowLayout;
import com.huawei.maps.app.petalmaps.PetalMapsActivity;
import com.huawei.maps.app.routeplan.ui.bean.TicketErrorInfo;
import com.huawei.secure.android.common.activity.SafeService;
import com.huawei.secure.android.common.intent.IntentUtils;
import com.huawei.secure.android.common.intent.SafeIntent;
import defpackage.a06;
import defpackage.n73;
import defpackage.t73;
public class NavFloatingWindowService extends SafeService {
public WindowManager b;
public boolean c;
public WindowManager.LayoutParams d;
public NavFloatingWindowLayout e;
public NaviInfo f;
public String g;
public int h;
public boolean i;
public class a implements View.OnTouchListener {
public int a;
public int b;
public int c;
public int d;
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
hm4.f("NavFloatingWindowService", "floating window touch.");
int action = motionEvent.getAction();
if (action == 0) {
this.a = (int) motionEvent.getRawX();
this.c = (int) motionEvent.getRawX();
this.b = (int) motionEvent.getRawY();
this.d = (int) motionEvent.getRawY();
return false;
}
if (action == 1) {
int rawX = ((int) motionEvent.getRawX()) - this.c;
int rawY = ((int) motionEvent.getRawY()) - this.d;
if (Math.abs(rawX) < 6 && Math.abs(rawY) < 6) {
NavFloatingWindowService.this.g();
return false;
}
NavFloatingWindowService.this.h++;
xr4.Q().H2(NavFloatingWindowService.this.h);
return false;
}
if (action != 2) {
return false;
}
int rawX2 = (int) motionEvent.getRawX();
int rawY2 = (int) motionEvent.getRawY();
int i = rawX2 - this.a;
int i2 = rawY2 - this.b;
this.a = rawX2;
this.b = rawY2;
NavFloatingWindowService.this.d.x += i;
NavFloatingWindowService.this.d.y += i2;
NavFloatingWindowService.this.b.updateViewLayout(view, NavFloatingWindowService.this.d);
return false;
}
public a() {
}
}
public class b extends Binder {
public b() {
}
public NavFloatingWindowService a() {
return NavFloatingWindowService.this;
}
}
public final void g() {
hm4.p("NavFloatingWindowService", "click floating window, back to foreground.");
SafeIntent safeIntent = new SafeIntent(new Intent(o41.c(), (Class<?>) PetalMapsActivity.class));
safeIntent.setFlags(268435456);
ActivityOptions makeBasic = ActivityOptions.makeBasic();
if (Build.VERSION.SDK_INT >= 34) {
makeBasic.setPendingIntentBackgroundActivityStartMode(1);
}
try {
PendingIntent.getActivity(o41.c(), 0, safeIntent, 201326592, makeBasic.toBundle()).send();
} catch (PendingIntent.CanceledException unused) {
hm4.z("NavFloatingWindowService", "pendingIntent start activity failed,start with intent.");
IntentUtils.safeStartActivity(o41.c(), safeIntent);
}
pn5.W();
}
public void h() {
hm4.p("NavFloatingWindowService", "closeFloatingWindow enter");
if (this.i) {
t73.b().a();
pn5.X();
return;
}
NavFloatingWindowLayout navFloatingWindowLayout = this.e;
if (navFloatingWindowLayout == null) {
return;
}
if (navFloatingWindowLayout.isShown()) {
this.b.removeViewImmediate(this.e);
}
if (this.c && !this.e.b()) {
pn5.X();
this.h = 0;
}
this.c = false;
}
public final void i() {
t73.b().c(this.b);
}
public final void j() {
final BaseMapApplication b2 = o41.b();
b2.getMapAppLifeCycle().setCallBack("FLOATING_WINDOW", new BaseMapAppLifecycle.AppRunSituationCallBack() {
public final void situation() {
NavFloatingWindowService.this.k(b2);
}
});
}
public final void k(BaseMapApplication baseMapApplication) {
boolean isAppBackground = baseMapApplication.isAppBackground();
boolean b2 = c06.b();
boolean canDrawOverlays = Settings.canDrawOverlays(o41.c());
String h0 = p19.F().h0();
hm4.p("NavFloatingWindowService", "change to background, isAppBackground = " + isAppBackground + ", isNavigation = " + b2 + ",canDrawOverlays=" + canDrawOverlays + ", suspendedNavigationSwitch = " + h0);
if (!isAppBackground || !b2 || !canDrawOverlays || !"Y".equals(h0)) {
hm4.p("NavFloatingWindowService", "change to foreground, close floating window");
h();
return;
}
hm4.p("NavFloatingWindowService", "change to background, show floating window");
String D = p19.F().D();
hm4.p("NavFloatingWindowService", "initObserver type = " + D);
if (TextUtils.equals(D, TicketErrorInfo.TICKET_ERROR_TYPE_NO_DATA) && a06.k()) {
this.i = true;
i();
return;
}
this.i = false;
if (this.e == null) {
NavFloatingWindowLayout navFloatingWindowLayout = new NavFloatingWindowLayout(o41.c());
this.e = navFloatingWindowLayout;
navFloatingWindowLayout.setOnTouchListener(new a());
String str = this.g;
if (str != null) {
this.e.g(str);
} else {
this.e.i(this.f);
}
}
if (this.d == null) {
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
this.d = layoutParams;
layoutParams.type = 2038;
layoutParams.format = 1;
layoutParams.flags = 40;
layoutParams.gravity = 8388659;
layoutParams.y = (ct3.l(o41.c()) * 2) / 3;
this.d.x = ct3.m(o41.c()) - ct3.b(o41.c(), 206);
WindowManager.LayoutParams layoutParams2 = this.d;
layoutParams2.height = -2;
layoutParams2.width = ct3.b(o41.c(), 190);
}
this.e.h();
this.b.addView(this.e, this.d);
this.c = true;
}
public void l(String str) {
if (this.i) {
n73.b().g(str);
return;
}
NavFloatingWindowLayout navFloatingWindowLayout = this.e;
if (navFloatingWindowLayout != null) {
navFloatingWindowLayout.g(str);
} else {
this.g = str;
}
}
public void m(NaviInfo naviInfo) {
NavFloatingWindowLayout navFloatingWindowLayout = this.e;
if (navFloatingWindowLayout == null || !this.c) {
this.f = naviInfo;
n73.b().d(this.f);
} else {
navFloatingWindowLayout.i(naviInfo);
hm4.p("NavFloatingWindowService", "updateFloatingWindow success");
}
}
@Nullable
public IBinder onBind(Intent intent) {
return new b();
}
public void onCreate() {
hm4.p("NavFloatingWindowService", "nav floating window service create.");
super.onCreate();
this.b = (WindowManager) getSystemService("window");
j();
}
public void onDestroy() {
super.onDestroy();
o41.b().getMapAppLifeCycle().removeCallBack("FLOATING_WINDOW");
}
public boolean onUnbind(Intent intent) {
if (this.i) {
t73.b().a();
}
if (this.c && this.e.isShown()) {
this.b.removeViewImmediate(this.e);
}
this.c = false;
return super.onUnbind(intent);
}
}