导航菜单

页面标题

页面副标题

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

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

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


package com.huawei.maps.hicar;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.huawei.hicarsdk.builder.ButtonBuilder;
import com.huawei.hicarsdk.builder.CardBuilder;
import com.huawei.hicarsdk.capability.display.CarDisplayInfo;
import com.huawei.hicarsdk.capability.lifecycle.CarServiceLifeCycleMgr;
import com.huawei.hicarsdk.capability.lifecycle.IHiCarLifeCycleMonitor;
import com.huawei.hicarsdk.capability.response.RequestCallBack;
import com.huawei.hicarsdk.constant.ConstantEx;
import com.huawei.hicarsdk.event.callback.EventCallBack;
import com.huawei.hicarsdk.job.CreateCardBack;
import com.huawei.hms.navi.navibase.model.Distance;
import com.huawei.hms.navi.navibase.model.LaneInfo;
import com.huawei.hms.navi.navibase.model.NaviInfo;
import com.huawei.maps.hicar.HiCarThemeHelper;
import com.huawei.maps.hicar.a;
import com.huawei.maps.hicar.listener.ICruiseAudioStataChangeListener;
import com.huawei.maps.hicar.listener.IHiCarListener;
import com.huawei.secure.android.common.intent.IntentUtils;
import com.huawei.secure.android.common.intent.SafeBundle;
import com.huawei.secure.android.common.intent.SafeIntent;
import defpackage.pz3;
import defpackage.sp5;
import defpackage.yl7;
import java.util.Locale;

public class a {
    public boolean a;
    public boolean b;
    public int c;
    public int d;
    public boolean e;
    public boolean f;
    public Bitmap g;
    public Activity h;
    public boolean i;
    public String j;
    public boolean k;
    public boolean l;
    public boolean m;
    public int n;
    public SafeBundle o;
    public SafeBundle p;
    public boolean q;
    public CardBuilder r;
    public boolean s;
    public IHiCarListener t;
    public ICruiseAudioStataChangeListener u;
    public boolean v;
    public Class w;
    public Runnable x;
    public Runnable y;

    public class C0000a implements RequestCallBack<pm0> {
        public C0000a() {
        }

        public void onResult(pm0 pm0Var) {
            hm4.p("HiCarHelper", "Get card window info back");
            if (pm0Var != null) {
                a.this.m = pm0Var.b();
                hm4.p("HiCarHelper", "cardWindowInfo support opr " + a.this.m);
            }
        }
    }

    public class b implements RequestCallBack<CarDisplayInfo> {
        public b() {
        }

        public void onResult(CarDisplayInfo carDisplayInfo) {
            if (carDisplayInfo == null) {
                return;
            }
            p79.k("hi_car_display_info", og3.a(carDisplayInfo), o41.c());
            a.this.c0(carDisplayInfo);
        }
    }

    public class c implements IHiCarLifeCycleMonitor {
        public c() {
        }

        public final void b() {
            if (com.huawei.maps.businessbase.manager.location.a.z()) {
                hm4.p("HiCarHelper", "send cruise state");
                a.this.I0();
            }
        }

        public void onHiCarStarted() {
            HiCarThemeHelper.f().l();
            hm4.p("HiCarHelper", " HiCar started");
            a.this.b0();
            fk2.f(new Runnable() {
                @Override
                public final void run() {
                    a.c.this.b();
                }
            });
        }

        public void onHiCarStopped() {
            hm4.p("HiCarHelper", " HiCar stopped");
            HiCarThemeHelper.f().p();
            a.this.K0();
        }
    }

    public class d implements Runnable {

        public class C0001a implements CreateCardBack {
            public C0001a() {
            }

            public final void c(int i) {
                a.this.c = i;
                a.this.q = false;
                a.this.c1();
                if (!a.this.e) {
                    a.this.F0(i);
                    a.this.c = -1;
                }
                hm4.p("HiCarHelper", "Map card id");
            }

            public void callBack(final int i) {
                fk2.b(new Runnable() {
                    @Override
                    public final void run() {
                        a.d.C0001a.this.c(i);
                    }
                });
            }

            public final void d() {
                a.this.q = false;
                hm4.h("HiCarHelper", "service not running");
            }

            public void remoteServiceNotRunning() {
                fk2.b(new Runnable() {
                    @Override
                    public final void run() {
                        a.d.C0001a.this.d();
                    }
                });
            }
        }

        public d() {
        }

        @Override
        public void run() {
            try {
                if (a.this.q) {
                    hm4.z("HiCarHelper", "Create normal card is running");
                    return;
                }
                a.this.q = true;
                wl0.c(o41.c(), a.this.K(), new C0001a());
            } catch (vl7 unused) {
                a.this.q = false;
                hm4.h("HiCarHelper", "service not running");
            }
        }
    }

    public class e implements Runnable {

        public class C0002a implements CreateCardBack {
            public C0002a() {
            }

            public void c(int i) {
                a.this.d = i;
                a.this.s = false;
                hm4.p("HiCarHelper", "Nva card id");
            }

            public void d() {
                a.this.s = false;
                hm4.h("HiCarHelper", "service not running");
            }

            public void callBack(final int i) {
                fk2.b(new Runnable() {
                    @Override
                    public final void run() {
                        a.e.C0002a.this.c(i);
                    }
                });
            }

            public void remoteServiceNotRunning() {
                fk2.b(new Runnable() {
                    @Override
                    public final void run() {
                        a.e.C0002a.this.d();
                    }
                });
            }
        }

        public e() {
        }

        @Override
        public void run() {
            try {
                if (a.this.s) {
                    hm4.z("HiCarHelper", "Create nav card is running");
                } else {
                    a.this.s = true;
                    wl0.c(o41.c(), a.this.r, new C0002a());
                }
            } catch (vl7 unused) {
                a.this.s = false;
                hm4.h("HiCarHelper", "service not running");
            }
        }
    }

    public static class f {
        public static final a a = new a();
    }

    public static class g implements HiCarThemeHelper.OnHiCarThemeChangedListener {
        @Override
        public void onHiCarThemeChanged() {
            a.V().c1();
        }
    }

    public static a V() {
        return f.a;
    }

    public static boolean j0(Context context) {
        Bundle bundle;
        try {
            PackageManager packageManager = context.getPackageManager();
            if (packageManager == null) {
                hm4.z("HiCarHelper", "get packageManager error");
                return false;
            }
            ApplicationInfo applicationInfo = packageManager.getApplicationInfo("com.huawei.hicar", 128);
            if (applicationInfo == null || (bundle = applicationInfo.metaData) == null) {
                hm4.z("HiCarHelper", "get application info error");
                return false;
            }
            if (!TextUtils.isEmpty(bundle.getString("com.huawei.hicar.map.supportCardWindow"))) {
                return true;
            }
            hm4.z("HiCarHelper", "no such meta data");
            return false;
        } catch (PackageManager.NameNotFoundException unused) {
            hm4.h("HiCarHelper", "get application info error");
            return false;
        } catch (RuntimeException unused2) {
            hm4.h("ContentValues", "isHiCarSupportCardWindow RuntimeException");
            return false;
        }
    }

    public static void x0() {
        HiCarThemeHelper.f().g(new g());
    }

    public final void A0(pn7 pn7Var) {
        hm4.p("HiCarHelper", " Unregister HiCar lifecycle back");
        K0();
    }

    public void B0(Intent intent) {
        long j;
        hm4.p("HiCarHelper", "newIntent");
        if (h0()) {
            String safeGetStringExtra = IntentUtils.safeGetStringExtra(new SafeIntent(intent), "action");
            if (tha.a(safeGetStringExtra)) {
                return;
            }
            if (com.huawei.maps.businessbase.manager.location.a.z()) {
                n0();
                j = 800;
            } else {
                j = 500;
            }
            safeGetStringExtra.hashCode();
            if (safeGetStringExtra.equals("go_to_work")) {
                fk2.c(new Runnable() {
                    @Override
                    public final void run() {
                        a.this.a0();
                    }
                }, j);
            } else if (safeGetStringExtra.equals("go_home")) {
                fk2.c(new Runnable() {
                    @Override
                    public final void run() {
                        a.this.Z();
                    }
                }, j);
            }
        }
    }

    public final void C0() {
        fk2.f(new Runnable() {
            @Override
            public final void run() {
                a.this.p0();
            }
        });
    }

    public boolean D0(Intent intent) {
        if (intent == null) {
            return false;
        }
        S0(intent);
        if (!h0()) {
            return false;
        }
        Intent T = V().T();
        T.putExtras(intent);
        T.setData(intent.getData());
        IntentUtils.safeStartActivity(o41.c(), T);
        return true;
    }

    public void E0() {
        CarDisplayInfo carDisplayInfo;
        hm4.p("HiCarHelper", " Register HiCar lifecycle");
        String f2 = p79.f("hi_car_display_info", "", o41.c());
        if (!tha.a(f2)) {
            try {
                carDisplayInfo = (CarDisplayInfo) new Gson().fromJson(f2, CarDisplayInfo.class);
            } catch (JsonSyntaxException e2) {
                hm4.f("HiCarHelper", "carDisplayInfo - " + e2.getLocalizedMessage());
                carDisplayInfo = null;
            }
            c0(carDisplayInfo);
        }
        CarServiceLifeCycleMgr.c().d(o41.b(), new c(), new RequestCallBack() {
            public final void onResult(Object obj) {
                hm4.p("HiCarHelper", " Register HiCar lifecycle back");
            }
        });
    }

    public final boolean F0(int i) {
        if (i == -1) {
            hm4.h("HiCarHelper", "Return remove card is -1");
            return false;
        }
        try {
            wl0.d(o41.c(), i);
            hm4.p("HiCarHelper", "Remove card");
            return true;
        } catch (vl7 unused) {
            hm4.h("HiCarHelper", "Service not running");
            return false;
        }
    }

    public void G(final Bundle bundle) {
        fk2.f(new Runnable() {
            @Override
            public final void run() {
                a.this.l0(bundle);
            }
        });
    }

    public void G0(NaviInfo naviInfo) {
        if (!i0()) {
            hm4.p("HiCarHelper", "Hi car not start");
            return;
        }
        if (naviInfo == null) {
            hm4.p("HiCarHelper", "Navi info is null");
            return;
        }
        this.o.putString("mapRequestMethod", "reportCruiseData");
        SafeBundle safeBundle = new SafeBundle();
        int i = 0;
        if (naviInfo.getSpeedInfo() != null) {
            try {
                i = Integer.valueOf(sp5.f(naviInfo.getSpeedInfo().getSpeedValue())).intValue();
            } catch (NumberFormatException e2) {
                hm4.p("HiCarHelper", e2.getMessage());
            }
            String g2 = sp5.g(naviInfo.getSpeedInfo().getSpeedUnit());
            safeBundle.putInt("currentRate", i);
            safeBundle.putString("unit", g2);
        } else {
            safeBundle.putInt("currentRate", 0);
            safeBundle.putString("unit", "");
            safeBundle.putInt("limitRate", 0);
        }
        this.p.putBundle("rate", safeBundle.getBundle());
        this.o.putBundle("reportData", this.p.getBundle());
        lo.a().b(o41.c(), 1004001001, this.o.getBundle(), new RequestCallBack() {
            public final void onResult(Object obj) {
                a.r0((Bundle) obj);
            }
        });
    }

    public final void H(SafeBundle safeBundle) {
        if (safeBundle == null) {
            hm4.h("HiCarHelper", "action bundle is null");
            return;
        }
        this.e = safeBundle.getBoolean("canCreateCard", false);
        hm4.p("HiCarHelper", "canCreateCard " + this.e);
        if (this.e) {
            if (c06.b()) {
                M(5, "", "", "", null);
                return;
            } else {
                J();
                return;
            }
        }
        if (F0(this.c)) {
            this.c = -1;
        }
        if (F0(this.d)) {
            this.d = -1;
        }
    }

    public void H0() {
        if (!i0()) {
            hm4.p("HiCarHelper", "Hi car not start");
        } else {
            this.o.putString("mapRequestMethod", "offCruiseMode");
            lo.a().b(o41.c(), 1004001001, this.o.getBundle(), new RequestCallBack() {
                public final void onResult(Object obj) {
                    a.this.s0((Bundle) obj);
                }
            });
        }
    }

    public final Bundle[] I() {
        int i;
        String f2;
        Intent T = T();
        T.putExtra("action", "go_home");
        Intent intent = new Intent(T);
        ButtonBuilder f3 = new ButtonBuilder(o41.c()).f(1);
        ConstantEx.ButtonStyle buttonStyle = ConstantEx.ButtonStyle.WIDGET;
        Bundle c2 = f3.g(buttonStyle).e(o41.f(R$string.notification_commute_home)).d(R$drawable.ic_map_home).b(intent).c();
        Intent T2 = T();
        T2.putExtra("action", "go_to_work");
        Bundle c3 = new ButtonBuilder(o41.c()).f(2).g(buttonStyle).e(o41.f(R$string.notification_commute_work)).d(R$drawable.ic_map_office).b(new Intent(T2)).c();
        SafeBundle safeBundle = new SafeBundle();
        safeBundle.putString("action", "cruise");
        if (com.huawei.maps.businessbase.manager.location.a.z()) {
            i = R$drawable.ic_map_electroniceye_on;
            f2 = o41.f(R$string.navi_exit_cruise);
        } else {
            i = o9a.f() ? R$drawable.ic_map_electroniceye_off : R$drawable.ic_map_electroniceye_off_light;
            f2 = o41.f(R$string.navi_cruise);
        }
        return new Bundle[]{c2, c3, new ButtonBuilder(o41.c()).f(3).g(buttonStyle).e(f2).d(i).a(safeBundle.getBundle()).c()};
    }

    public void I0() {
        if (!i0()) {
            hm4.p("HiCarHelper", "Hi car not start");
        } else {
            this.o.putString("mapRequestMethod", "onCruiseMode");
            lo.a().b(o41.c(), 1004001001, this.o.getBundle(), new RequestCallBack() {
                public final void onResult(Object obj) {
                    a.this.t0((Bundle) obj);
                }
            });
        }
    }

    public void J() {
        try {
            if (this.c == -1) {
                hm4.p("HiCarHelper", "createCard");
                fk2.d(this.x);
                fk2.c(this.x, 500L);
            } else {
                hm4.p("HiCarHelper", "updateCard");
                wl0.g(o41.c(), this.c, K());
            }
        } catch (vl7 unused) {
            hm4.h("HiCarHelper", "service not running");
        }
    }

    public void J0(int i) {
        if (!i0()) {
            hm4.p("HiCarHelper", "Hi car not start");
            return;
        }
        hm4.p("HiCarHelper", "Report cruise voice play state " + i);
        this.o.putString("mapRequestMethod", "reportCruiseData");
        SafeBundle safeBundle = new SafeBundle();
        safeBundle.putInt("state", i);
        SafeBundle safeBundle2 = new SafeBundle();
        safeBundle2.putString("action", "playAction");
        SafeBundle safeBundle3 = new SafeBundle();
        safeBundle3.putString("action", "muteAction");
        safeBundle.putBundle("playAction", safeBundle2.getBundle());
        safeBundle.putBundle("muteAction", safeBundle3.getBundle());
        this.p.putBundle("voicePlay", safeBundle.getBundle());
        this.o.putBundle("reportData", this.p.getBundle());
        lo.a().b(o41.c(), 1004001001, this.o.getBundle(), new RequestCallBack() {
            public final void onResult(Object obj) {
                a.this.u0((Bundle) obj);
            }
        });
    }

    public final CardBuilder K() {
        return sj0.a(o41.c(), 10, 0).setTitle(R$drawable.appbg, o41.f(R$string.map_petal_maps)).setParam("mapType", 1).setParam("mapState", 4).setCardAutoRemove(true).setPendingIntent(new Intent(T())).setButtons(I());
    }

    public final void K0() {
        fk2.f(new Runnable() {
            @Override
            public final void run() {
                a.this.v0();
            }
        });
    }

    public void L(int i, NaviInfo naviInfo) {
        if (!f0() || naviInfo == null) {
            if (f0()) {
                M(i, "", "", "", null);
            }
        } else {
            String X = X(naviInfo);
            String replaceAll = tha.a(X) ? " " : X.replaceAll("% ", "");
            String str = tha.a(replaceAll) ? " " : replaceAll;
            Distance convertedCurStepRetainDist = naviInfo.getConvertedCurStepRetainDist();
            M(i, str, convertedCurStepRetainDist != null ? sp5.c(convertedCurStepRetainDist) : "", naviInfo.getIconId(), this.g);
        }
    }

    public final void L0() {
        hm4.p("HiCarHelper", "resetCardId");
        this.c = -1;
        this.d = -1;
    }

    public void M(int i, String str, String str2, String str3, Bitmap bitmap) {
        this.r = N(i, str, str2, str3, bitmap);
        try {
            if (this.d == -1) {
                hm4.p("HiCarHelper", "createCardNav");
                fk2.d(this.y);
                fk2.c(this.y, 200L);
            } else {
                hm4.f("HiCarHelper", "updateCard");
                wl0.g(o41.c(), this.d, this.r);
            }
        } catch (vl7 unused) {
            hm4.h("HiCarHelper", "service not running");
        }
    }

    public void M0(final int i) {
        fk2.f(new Runnable() {
            @Override
            public final void run() {
                a.this.w0(i);
            }
        });
    }

    public final CardBuilder N(int i, String str, String str2, String str3, Bitmap bitmap) {
        Bitmap bitmap2;
        SafeBundle safeBundle = new SafeBundle();
        safeBundle.putString("action", "stopNavigation");
        Bundle c2 = new ButtonBuilder(o41.c()).g(ConstantEx.ButtonStyle.WIDGET).h(o41.f(R$string.navi_end)).a(safeBundle.getBundle()).c();
        int d2 = sp5.d("nav_guide_", str3);
        CardBuilder buttons = sj0.a(o41.c(), 1, 0).setTitle(R$drawable.appbg, o41.f(R$string.map_petal_maps)).setParam("mapType", 1).setParam("mapState", i).setParam("isShowMapLane", this.f).setMainText(str2).setSubText(str).setMapTurnDark(sp5.e("nav_guide_", str3)).setMapTurnLight(d2).setInfoImage(d2).setCardAutoRemove(true).setPendingIntent(new Intent(T())).setButtons(new Bundle[]{c2});
        if (this.f && (bitmap2 = this.g) != null && !bitmap2.isRecycled()) {
            buttons.setMapLane(bitmap);
        }
        return buttons;
    }

    public void N0(int i) {
        if (tha.a(this.j)) {
            hm4.h("HiCarHelper", "Cruise request id is null");
            return;
        }
        hm4.p("HiCarHelper", "Send cruise state " + i);
        SafeBundle safeBundle = new SafeBundle();
        safeBundle.putString("requestId", this.j);
        safeBundle.putInt("errorCode", i);
        try {
            sj2.b(o41.b(), 300000, safeBundle.getBundle(), (EventCallBack) null);
        } catch (vl7 unused) {
            hm4.h("HiCarHelper", "on result, remoteServicNotRunning!");
        }
    }

    public final void O(String str, SafeBundle safeBundle) {
        if (str == null) {
            hm4.h("HiCarHelper", "action is null");
            return;
        }
        this.j = safeBundle.getString("requestId");
        if (str.equals("offCruiseMode")) {
            fk2.f(new Runnable() {
                @Override
                public final void run() {
                    a.this.m0();
                }
            });
        } else if (str.equals("onCruiseMode")) {
            W0();
        }
    }

    public void O0(int i) {
        hm4.p("HiCarHelper", "Send navigation state to hiCar " + i);
        p41.g(o41.c(), i);
        if (i == 1) {
            if (F0(this.c)) {
                this.c = -1;
            }
        } else {
            if (F0(this.d)) {
                this.d = -1;
            }
            if (this.e) {
                J();
            }
        }
    }

    public final void P(String str, SafeBundle safeBundle) {
        if (str == null) {
            hm4.h("HiCarHelper", "action is null");
        }
        switch (str) {
            case "cruise":
                this.j = null;
                if (!this.i) {
                    W0();
                    break;
                } else {
                    fk2.f(new Runnable() {
                        @Override
                        public final void run() {
                            a.this.n0();
                        }
                    });
                    break;
                }
            case "canCreateCard":
                H(safeBundle);
                break;
            case "stopNavigation":
                Y0();
                break;
            case "muteAction":
            case "playAction":
                C0();
                break;
        }
    }

    public void P0(ICruiseAudioStataChangeListener iCruiseAudioStataChangeListener) {
        this.u = iCruiseAudioStataChangeListener;
    }

    public final void Q() {
        IHiCarListener iHiCarListener = this.t;
        if (iHiCarListener != null) {
            iHiCarListener.dealPreCommute();
        }
    }

    public void Q0(boolean z) {
        this.i = z;
        d1(z);
        if (z) {
            I0();
        } else {
            H0();
        }
    }

    public void R() {
        this.i = false;
        H0();
        this.h = null;
        this.j = null;
        this.g = null;
        this.o.clear();
        this.p.clear();
    }

    public void R0(IHiCarListener iHiCarListener) {
        this.t = iHiCarListener;
    }

    public final void n0() {
        hm4.p("HiCarHelper", "end cruise nav");
        IHiCarListener iHiCarListener = this.t;
        if (iHiCarListener != null) {
            iHiCarListener.endCruiseNav();
        }
        V().N0(0);
    }

    public void S0(Intent intent) {
        this.a = IntentUtils.safeGetBooleanExtra(intent, "isHiCarMode", false);
        this.b = IntentUtils.safeGetBooleanExtra(intent, "IS_START_FROM_VOICE", false);
        yl3.j(this.a);
        hm4.p("HiCarHelper", "Is hi_car mode : " + this.a);
        if (this.a) {
            fk2.b(new Runnable() {
                @Override
                public final void run() {
                    a.x0();
                }
            });
        }
    }

    public final Intent T() {
        SafeIntent safeIntent = new SafeIntent(new Intent("huawei.intent.action.hicar.MAP"));
        ComponentName componentName = this.w != null ? new ComponentName(o41.c(), (Class<?>) this.w) : null;
        if (componentName != null) {
            safeIntent.setComponent(componentName);
        }
        safeIntent.addCategory("huawei.intent.category.hicar.MAP");
        try {
            safeIntent.setPackage(o41.b().getPackageName());
        } catch (IllegalArgumentException e2) {
            hm4.h("HiCarHelper", "IllegalArgumentException:" + e2.getMessage());
        }
        safeIntent.setFlags(337641472);
        return safeIntent;
    }

    public void T0(boolean z) {
        this.f = z;
        this.g = null;
    }

    public final int U(Bundle bundle) {
        return new SafeBundle(bundle).getInt("errorCode", -1);
    }

    public void U0(boolean z, LaneInfo laneInfo) {
        this.f = z;
        this.g = pz3.b(laneInfo, true);
    }

    public void V0(Class cls) {
        this.w = cls;
    }

    public final CharSequence W(NaviInfo naviInfo) {
        if (naviInfo == null) {
            return "";
        }
        String i = sp5.o(naviInfo) ? sp5.i(naviInfo.getCurrentRoadNames()) : sp5.i(naviInfo.getCurShowRoadNames());
        if (tha.b(naviInfo.getRoadBgs()) || tha.b(naviInfo.getRoadNos())) {
            return i;
        }
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
        boolean z = false;
        for (int i2 = 0; i2 < naviInfo.getRoadNos().size() && i2 < 3; i2++) {
            if (naviInfo.getRoadNos().get(i2) != null) {
                spannableStringBuilder.append((CharSequence) "% ");
                if (!z && ((String) naviInfo.getRoadNos().get(i2)).equals(i)) {
                    z = true;
                }
            }
        }
        if (!z) {
            spannableStringBuilder.append((CharSequence) i);
        }
        return spannableStringBuilder;
    }

    public final void W0() {
        hm4.p("HiCarHelper", "start cruise nav");
        fk2.f(new Runnable() {
            @Override
            public final void run() {
                a.this.y0();
            }
        });
    }

    public final String X(NaviInfo naviInfo) {
        return naviInfo == null ? "" : sp5.n(naviInfo.getIconId()) ? sp5.l() : sp5.o(naviInfo) ? sp5.k(W(naviInfo).toString()) : (sp5.a(naviInfo.getCurShowRoadNames()) && sp5.a(naviInfo.getRoadNos())) ? sp5.a(naviInfo.getDirTexts()) ? sp5.j(naviInfo) : String.format(Locale.ENGLISH, o41.c().getString(o41.b().getResources().getIdentifier("navi_towards", "string", o41.b().getPackageName())), sp5.b(naviInfo.getDirTexts())) : W(naviInfo).toString();
    }

    public final int X0() {
        if (yl7.w().I()) {
            hm4.z("HiCarHelper", "startCruiseNavByHiCar isHuaWeiMapEmpty");
            return -1;
        }
        if (!qk9.r()) {
            hm4.z("HiCarHelper", "startCruiseNavByHiCar no net work");
            if (h0()) {
                cz9.j(R$string.no_network);
            }
            return -1;
        }
        if (c06.b()) {
            hm4.z("HiCarHelper", "startCruiseNavByHiCar isNavigation");
            return -1;
        }
        if (com.huawei.maps.businessbase.manager.location.a.z()) {
            hm4.z("HiCarHelper", "startCruiseNavByHiCar isCruiseNav");
            return -1;
        }
        if (this.l || this.t == null) {
            return -1;
        }
        hm4.p("HiCarHelper", "start cruise nav success");
        this.t.prepareCruiseNav();
        this.l = true;
        fk2.c(new Runnable() {
            @Override
            public final void run() {
                a.this.z0();
            }
        }, 1000L);
        return 0;
    }

    public int Y() {
        Activity activity = this.h;
        int c2 = activity == null ? 0 : p41.c(activity);
        hm4.p("HiCarHelper", "Window mode is " + c2);
        return c2;
    }

    public final void Y0() {
        hm4.p("HiCarHelper", "stop navigation");
        IHiCarListener iHiCarListener = this.t;
        if (iHiCarListener != null) {
            iHiCarListener.stopNavigation();
        }
    }

    public final void Z() {
        hm4.p("HiCarHelper", "go home");
        Q();
        IHiCarListener iHiCarListener = this.t;
        if (iHiCarListener != null) {
            iHiCarListener.goHome();
        }
    }

    public final void y0() {
        V().N0(X0());
    }

    public final void a0() {
        hm4.p("HiCarHelper", "go to work");
        Q();
        IHiCarListener iHiCarListener = this.t;
        if (iHiCarListener != null) {
            iHiCarListener.goToWork();
        }
    }

    public void a1() {
        hm4.p("HiCarHelper", " Unregister HiCar lifecycle");
        CarServiceLifeCycleMgr.c().e(o41.b(), new RequestCallBack() {
            public final void onResult(Object obj) {
                a.this.A0((pn7) obj);
            }
        });
    }

    public void b0() {
        fk2.f(new Runnable() {
            @Override
            public final void run() {
                a.this.o0();
            }
        });
    }

    public void b1() {
        if (h0()) {
            d1(this.i);
        }
    }

    public final void c0(CarDisplayInfo carDisplayInfo) {
        if (carDisplayInfo == null) {
            return;
        }
        hm4.p("HiCarHelper", "carDisplayInfo : dpi : " + carDisplayInfo.c() + " WidthPixels : " + carDisplayInfo.f() + " HeightPixels : " + carDisplayInfo.d());
        yl3.h(carDisplayInfo.c());
        yl3.k(carDisplayInfo.f());
        yl3.i(carDisplayInfo.d());
        yl3.f(carDisplayInfo.b());
        yl3.l(carDisplayInfo.e());
    }

    public void c1() {
        d1(this.i);
    }

    public void d0() {
        com.huawei.hicarsdk.capability.display.a.d().c(o41.c(), new b());
    }

    public final void d1(boolean z) {
        try {
            if (this.c != -1) {
                hm4.p("HiCarHelper", "updateCard");
                wl0.g(o41.c(), this.c, K());
            }
        } catch (vl7 unused) {
            hm4.h("HiCarHelper", "service not running");
        }
    }

    public void e0(Activity activity) {
        this.h = activity;
        if (h0()) {
            qm0.d().c(o41.c(), new C0000a());
        }
    }

    public void e1(int i, NaviInfo naviInfo) {
        if (!f0() || naviInfo == null) {
            return;
        }
        String X = X(naviInfo);
        String replaceAll = tha.a(X) ? " " : X.replaceAll("% ", "");
        String str = tha.a(replaceAll) ? " " : replaceAll;
        Distance convertedCurStepRetainDist = naviInfo.getConvertedCurStepRetainDist();
        f1(i, str, convertedCurStepRetainDist != null ? sp5.c(convertedCurStepRetainDist) : "", naviInfo.getIconId(), this.g);
    }

    public boolean f0() {
        return this.e || !this.v;
    }

    public final void f1(int i, String str, String str2, String str3, Bitmap bitmap) {
        this.r = N(i, str, str2, str3, bitmap);
        try {
            if (this.d != -1) {
                hm4.f("HiCarHelper", "updateCard");
                wl0.g(o41.c(), this.d, this.r);
            }
        } catch (vl7 unused) {
            hm4.h("HiCarHelper", "service not running");
        }
    }

    public boolean g0() {
        return h0() && Y() == 102;
    }

    public final boolean h0() {
        return this.a;
    }

    public boolean i0() {
        return this.k;
    }

    public boolean k0() {
        return this.m;
    }

    public final void l0(Bundle bundle) {
        hm4.p("HiCarHelper", "callBackApp");
        SafeBundle safeBundle = new SafeBundle(bundle);
        String string = safeBundle.getString("action");
        String string2 = safeBundle.getString("hicarMapAction");
        if (!tha.a(string)) {
            P(string, safeBundle);
        }
        if (tha.a(string2)) {
            return;
        }
        O(string2, safeBundle);
    }

    public final void o0() {
        this.k = true;
        this.v = j0(o41.c());
        if (c06.b()) {
            if (this.v) {
                hm4.p("HiCarHelper", "send nav state");
                p41.g(o41.c(), 1);
            } else {
                V().L(5, null);
            }
        }
        d0();
    }

    public final void p0() {
        hm4.p("HiCarHelper", "On voice click");
        if (TextUtils.equals(tg1.c().a(), "normalAudio")) {
            tg1.c().h("noAudio");
            J0(1);
            ICruiseAudioStataChangeListener iCruiseAudioStataChangeListener = this.u;
            if (iCruiseAudioStataChangeListener != null) {
                iCruiseAudioStataChangeListener.onCruiseAudioStataChange(1);
                return;
            }
            return;
        }
        tg1.c().h("normalAudio");
        J0(0);
        ICruiseAudioStataChangeListener iCruiseAudioStataChangeListener2 = this.u;
        if (iCruiseAudioStataChangeListener2 != null) {
            iCruiseAudioStataChangeListener2.onCruiseAudioStataChange(0);
        }
    }

    public final void s0(Bundle bundle) {
        hm4.p("HiCarHelper", "Report cruise off response " + U(bundle));
    }

    public final void t0(Bundle bundle) {
        hm4.p("HiCarHelper", "Report cruise on response " + U(bundle));
    }

    public final void u0(Bundle bundle) {
        hm4.p("HiCarHelper", "Report cruise voice play return code " + U(bundle));
    }

    public final void v0() {
        L0();
        this.j = null;
        this.g = null;
        this.e = false;
        this.k = false;
        this.o.clear();
        this.p.clear();
    }

    public final void w0(int i) {
        hm4.p("HiCarHelper", "resetCardId");
        if (i == this.c) {
            this.c = -1;
        }
        if (i == this.d) {
            if (!this.v) {
                Y0();
            }
            this.d = -1;
        }
    }

    public final void z0() {
        IHiCarListener iHiCarListener = this.t;
        if (iHiCarListener != null) {
            iHiCarListener.startCruiseNav();
        }
        this.l = false;
    }

    public a() {
        this.a = false;
        this.b = false;
        this.c = -1;
        this.d = -1;
        this.e = false;
        this.f = false;
        this.i = false;
        this.k = false;
        this.l = false;
        this.m = false;
        this.n = 0;
        this.o = new SafeBundle();
        this.p = new SafeBundle();
        this.q = false;
        this.s = false;
        this.v = true;
        this.x = new d();
        this.y = new e();
    }

    public static void r0(Bundle bundle) {
    }
}