导航菜单

页面标题

页面副标题

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

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

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


package com.huawei.maps.businessbase.push;

import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.hms.push.BaseException;
import com.huawei.hms.push.HmsMessageService;
import com.huawei.hms.push.RemoteMessage;
import com.huawei.map.databus.MapDataBus;
import com.huawei.maps.app.common.utils.task.TaskExecutor;
import com.huawei.maps.businessbase.bean.NotificationMessage;
import com.huawei.maps.businessbase.database.config.MapConfigDataTools;
import com.huawei.maps.businessbase.manager.AbstractMapUIController;
import com.huawei.maps.businessbase.manager.location.ILocationListener;
import com.huawei.maps.businessbase.network.DefaultObserver;
import com.huawei.maps.businessbase.network.NetworkConstant;
import com.huawei.maps.businessbase.network.ResponseData;
import com.huawei.maps.businessbase.push.MessagePushService;
import com.huawei.maps.businessbase.report.MapDevOpsReport;
import com.huawei.maps.businessbase.request.PushRequestDTOReport;
import com.huawei.maps.businessbase.servicepermission.PermissionConfigKt;
import com.huawei.maps.businessbase.servicepermission.ServicePermissionManager;
import com.huawei.maps.businessbase.utils.BusinessConstant;
import com.huawei.maps.businessbase.utils.account.OnAccountFailureListener;
import com.huawei.maps.businessbase.utils.account.OnAccountSuccessListener;
import com.huawei.maps.businessbase.utils.account.bean.Account;
import com.huawei.maps.businessbase.viewmodel.CommonAddressRecordsViewModel;
import com.huawei.maps.tasktransfer.model.FlowData;
import com.huawei.maps.tasktransfer.response.PoiInfoMsg;
import com.huawei.secure.android.common.intent.SafeUri;
import com.huawei.uikit.hwadvancednumberpicker.widget.PickerHelper;
import defpackage.c55;
import defpackage.e4;
import defpackage.fy0;
import defpackage.g9a;
import defpackage.k;
import defpackage.k0a;
import defpackage.me;
import defpackage.nwa;
import defpackage.o05;
import defpackage.p19;
import defpackage.q41;
import defpackage.u97;
import defpackage.wk4;
import defpackage.ws4;
import defpackage.xr4;
import defpackage.yg9;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Scheduler;
import io.reactivex.rxjava3.functions.Action;
import io.reactivex.rxjava3.schedulers.Schedulers;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

public class MessagePushService extends HmsMessageService {
    public static String e = "";
    public Location b;
    public OnAccountSuccessListener c;
    public OnAccountFailureListener d;

    @Retention(RetentionPolicy.SOURCE)
    public @interface PushMessageType {
        public static final String PUSH_TYPE_COMMENT_EXPOSURE = "COMMENT_EXPOSURE";
        public static final String PUSH_TYPE_LOCATION_FEEDBACK = "LOCATION_FEEDBACK";
    }

    public class a extends DefaultObserver<ResponseData> {
        public final String a;

        public a(String str) {
            this.a = str;
        }

        @Override
        public void onFail(int i, @NonNull ResponseData responseData, String str) {
            p79.g("Push_Upload_Request_State", true, o41.c());
            o05.g(MapDevOpsReport.SDKCode.PUSH_TOKEN_UPLOAD, new Throwable(str), false);
            hm4.h("MessagePushService", "onFail code:" + i);
        }

        @Override
        public void onSuccess(ResponseData responseData) {
            hm4.p("MessagePushService", "onSuccess response");
            p79.g("Push_Upload_Request_State", false, o41.c());
            MessagePushService.this.A(this.a);
        }
    }

    public class b implements ILocationListener {
        public b() {
        }

        @Override
        public void onLocationResult(Location location) {
            if (location != null && (location.getLatitude() != 0.0d || location.getLongitude() != 0.0d)) {
                com.huawei.maps.businessbase.manager.location.a.I(location);
                MessagePushService.this.b = location;
            }
            hm4.p("MessagePushService", "get myLocation by background requset");
        }
    }

    public static boolean B(String str) {
        if (e.equals(str)) {
            return false;
        }
        e = str;
        return true;
    }

    public static String m() {
        return e;
    }

    public static void w(String str) {
        PushRequestDTOReport.q(str);
        PushRequestDTOReport.o(p19.F().t(), p19.F().r(), p19.F().s());
    }

    public final void A(String str) {
        ws4 ws4Var = new ws4();
        ws4Var.e(1036);
        PushUploadEntity pushUploadEntity = new PushUploadEntity();
        pushUploadEntity.setToken(str);
        if (o()) {
            pushUploadEntity.setUuid(p19.F().r0());
        } else {
            pushUploadEntity.setUuid(PickerHelper.STRING_DRAW_END);
        }
        if (o()) {
            pushUploadEntity.setUid(e4.a().getUid());
        } else {
            pushUploadEntity.setUid(PickerHelper.STRING_DRAW_END);
        }
        ws4Var.d(og3.a(pushUploadEntity));
        MapConfigDataTools.r().x(ws4Var);
    }

    public final void s(String str, String str2) {
        if (k0a.k().m()) {
            return;
        }
        PushUploadEntity pushUploadEntity = (PushUploadEntity) og3.d(str2, PushUploadEntity.class);
        if (pushUploadEntity == null) {
            x(str);
        } else if (p79.b("Push_Upload_Request_State", false, o41.c())) {
            x(str);
            w(str);
            return;
        } else if (p(pushUploadEntity, str)) {
            x(str);
        }
        w(str);
    }

    public final void k() {
        com.huawei.maps.businessbase.manager.location.a.c0();
        Location location = this.b;
        if (location != null && !TextUtils.equals(location.getProvider(), BusinessConstant.LocationSource.FROM_LOCATION_KIT_CURRENT)) {
            CommonAddressRecordsViewModel.a n = n();
            if (n.e() == null && n.f() == null) {
                hm4.p("MessagePushService", "Home Work null ");
            } else {
                this.b = com.huawei.maps.businessbase.manager.location.a.v();
                int commutingType = AbstractMapUIController.getInstance().getCommutingType();
                if (commutingType == 1 && n.f() != null) {
                    this.b.setProvider(BusinessConstant.LocationSource.FROM_AWANESS_PUSH_KIT);
                    this.b.setLatitude(n.f().getLat());
                    this.b.setLongitude(n.f().getLng());
                } else if (commutingType == 2 && n.e() != null) {
                    this.b.setProvider(BusinessConstant.LocationSource.FROM_AWANESS_PUSH_KIT);
                    this.b.setLatitude(n.e().getLat());
                    this.b.setLongitude(n.e().getLng());
                }
                com.huawei.maps.businessbase.manager.location.a.T(this.b);
            }
        }
        Thread.currentThread().setName("CommutePushThread");
        AbstractMapUIController.getInstance().executeCommutePush(this.b);
    }

    public final FlowData l(PoiInfoMsg poiInfoMsg) {
        String str;
        FlowData flowData = new FlowData();
        flowData.setUri(poiInfoMsg.getDeepLink());
        Uri parse = Uri.parse(poiInfoMsg.getDeepLink());
        if (!TextUtils.isEmpty(poiInfoMsg.getTitle()) && !TextUtils.isEmpty(poiInfoMsg.getBody())) {
            hm4.p("MessagePushService", "title and body not empty");
            flowData.setNotificationTitle(poiInfoMsg.getTitle());
            flowData.setNotificationBody(poiInfoMsg.getBody());
        } else {
            if (parse == null) {
                return null;
            }
            String queryParameter = SafeUri.getQueryParameter(parse, "utm_source");
            String E = me.E(parse);
            hm4.p("MessagePushService", "host is " + E);
            if ("route".equals(E)) {
                flowData.setTransferType(2);
                str = c55.b(SafeUri.getQueryParameter(parse, "daddr"));
            } else {
                str = PickerHelper.STRING_DRAW_END;
            }
            if ("poidetail".equals(E)) {
                flowData.setTransferType(1);
                str = c55.b(SafeUri.getQueryParameter(parse, "marker"));
            }
            flowData.setClientName(queryParameter);
            flowData.setDestinationName(str);
        }
        return flowData;
    }

    public final CommonAddressRecordsViewModel.a n() {
        return CommonAddressRecordsViewModel.x(CommonAddressRecordsViewModel.A());
    }

    public final boolean o() {
        String name = NetworkConstant.OperationType.values()[ServicePermissionManager.INSTANCE.getOperationType()].name();
        String U0 = k.U0("Push_Upload_White_List");
        if (tha.a(U0) || !U0.contains(name)) {
            hm4.p("MessagePushService", "not in whiteList");
            return false;
        }
        hm4.p("MessagePushService", "in whiteList");
        return true;
    }

    public void onMessageReceived(RemoteMessage remoteMessage) {
        hm4.p("MessagePushService", "onMessageReceived is called");
        xr4.Q().F2("5");
        if (remoteMessage == null || TextUtils.isEmpty(remoteMessage.getData())) {
            hm4.h("MessagePushService", "Received message entity is null!");
            return;
        }
        NotificationMessage notificationMessage = (NotificationMessage) og3.d(remoteMessage.getData(), NotificationMessage.class);
        if (notificationMessage == null) {
            hm4.h("MessagePushService", "Received message transform data is null!");
            return;
        }
        if (NotificationMessage.PUSH_TYPE_COMMUTE.equals(notificationMessage.getPushType())) {
            AbstractMapUIController.getInstance().queryTimeCategories(o41.c());
            q41.d();
            nwa.i();
            if (o72.f("executePush", 30000L)) {
                hm4.p("MessagePushService", "execute commute push duplicate, out date");
                q41.p(new q41.a().k("0"));
                return;
            }
            Location v = com.huawei.maps.businessbase.manager.location.a.v();
            this.b = v;
            if (TextUtils.equals(v.getProvider(), BusinessConstant.LocationSource.FROM_LOCATION_KIT_CURRENT)) {
                hm4.p("MessagePushService", "get myLocation success");
            } else {
                com.huawei.maps.businessbase.manager.location.a.W(new b());
            }
            hm4.p("MessagePushService", "execute commute push");
            xr4.Q().F2("5");
            AbstractMapUIController.getInstance().startServicePermission(PermissionConfigKt.COMMUTE_PUSH);
            Scheduler from = Schedulers.from(com.huawei.maps.app.common.utils.task.a.b(TaskExecutor.NET_WORK).e());
            Observable.empty().delay(aw8.a().b().nextInt(56) + 5, TimeUnit.SECONDS).subscribeOn(from).observeOn(from).doOnComplete(new Action() {
                public final void run() {
                    MessagePushService.this.k();
                }
            }).subscribe();
        } else if (NotificationMessage.PUSH_TYPE_SHARE_REAL_TIME_LOCATION.equals(notificationMessage.getPushType())) {
            String pushData = notificationMessage.getPushData();
            if (TextUtils.isEmpty(pushData)) {
                return;
            } else {
                w59.a.f(pushData);
            }
        } else if (PushMessageType.PUSH_TYPE_LOCATION_FEEDBACK.equals(notificationMessage.getPushType())) {
            u97.c(notificationMessage.getPushType());
            wk4.a().e(notificationMessage.getPushType());
            return;
        } else if (PushMessageType.PUSH_TYPE_COMMENT_EXPOSURE.equals(notificationMessage.getPushType())) {
            u97.c(notificationMessage.getPushType());
            fy0.a().c(notificationMessage.getPushType(), notificationMessage.getCount());
            return;
        }
        Map dataOfMap = remoteMessage.getDataOfMap();
        if (dataOfMap != null) {
            String str = (String) dataOfMap.get("msgType");
            if ("1".equals(str)) {
                if (o41.b().isAppBackground()) {
                    str = "2";
                }
                hm4.p("MessagePushService", "msg type:" + str);
                MapDataBus.get().with("refresh_wx_account_list", String.class).postValue(str);
                return;
            }
            if ("2".equals(str)) {
                MapDataBus.get().with("refresh_wx_account_list", String.class).postValue(str);
                return;
            }
            if ("3".equals(str)) {
                final PoiInfoMsg poiInfoMsg = (PoiInfoMsg) og3.d((String) dataOfMap.get("poiInfoMsg"), PoiInfoMsg.class);
                if (poiInfoMsg == null) {
                    hm4.h("MessagePushService", "poiInfo is empty");
                    return;
                }
                final FlowData l = l(poiInfoMsg);
                if (l == null) {
                    hm4.h("MessagePushService", "flowData is null");
                    return;
                }
                if (yg9.a(poiInfoMsg.getProfileId())) {
                    u(l);
                    return;
                }
                z();
                this.c = new OnAccountSuccessListener() {
                    @Override
                    public final void onSuccess(Account account) {
                        MessagePushService.this.q(poiInfoMsg, l, account);
                    }
                };
                this.d = new OnAccountFailureListener() {
                    @Override
                    public final void onFailure(Exception exc) {
                        hm4.h("MessagePushService", "sign in fail");
                    }
                };
                e4.a().silentSignIn(this.c, this.d);
                return;
            }
        }
        g9a.a().b(remoteMessage);
    }

    public void onMessageSent(String str) {
        super.onMessageSent(str);
    }

    public void onNewToken(final String str) {
        hm4.p("MessagePushService", "received refresh token");
        if (!TextUtils.isEmpty(str)) {
            if (!B(str)) {
                return;
            }
            v();
            Scheduler from = Schedulers.from(com.huawei.maps.app.common.utils.task.a.b(TaskExecutor.NET_WORK).e());
            Observable.empty().delay(15L, TimeUnit.SECONDS).subscribeOn(from).observeOn(from).doOnComplete(new Action() {
                public final void run() {
                    MessagePushService.this.t(str);
                }
            }).subscribe();
        }
        if (b73.b()) {
            MapDataBus.get().with("push_token_refush", String.class).postValue(str);
        }
    }

    public void onSendError(String str, Exception exc) {
        super.onSendError(str, exc);
        hm4.h("MessagePushService", "onSendError called, errCode:" + (exc instanceof BaseException ? ((BaseException) exc).getErrorCode() : 0));
    }

    public void onTokenError(Exception exc) {
        hm4.h("MessagePushService", "onTokenError called, errCode:" + (exc instanceof BaseException ? ((BaseException) exc).getErrorCode() : 0));
    }

    public final boolean p(PushUploadEntity pushUploadEntity, String str) {
        String str2 = (String) Optional.ofNullable(pushUploadEntity.getToken()).orElse(PickerHelper.STRING_DRAW_END);
        String str3 = (String) Optional.ofNullable(pushUploadEntity.getUuid()).orElse(PickerHelper.STRING_DRAW_END);
        return o() ? (str.equals(str2) && ((String) Optional.ofNullable(e4.a().getUid()).orElse(PickerHelper.STRING_DRAW_END)).equals((String) Optional.ofNullable(pushUploadEntity.getUid()).orElse(PickerHelper.STRING_DRAW_END)) && ((String) Optional.ofNullable(p19.F().r0()).orElse(PickerHelper.STRING_DRAW_END)).equals(str3)) ? false : true : (str.equals(str2) && pushUploadEntity.getUuid().equals(PickerHelper.STRING_DRAW_END) && pushUploadEntity.getUid().equals(PickerHelper.STRING_DRAW_END)) ? false : true;
    }

    public final void q(PoiInfoMsg poiInfoMsg, FlowData flowData, Account account) {
        if (!poiInfoMsg.getProfileId().equals(account.getUid())) {
            hm4.p("MessagePushService", "profile id validate fail");
        } else {
            hm4.p("MessagePushService", "same profile id");
            u(flowData);
        }
    }

    public final void t(final String str) throws Throwable {
        MapConfigDataTools.r().v(1036, new MapConfigDataTools.DbCallBackValue() {
            @Override
            public final void setValue(String str2) {
                MessagePushService.this.s(str, str2);
            }
        });
    }

    public final void u(FlowData flowData) {
        MapDataBus.get().with("task_transfer_data", FlowData.class).postValue(flowData);
    }

    public final void v() {
        p19.F().r0();
        e4.a().silentSignIn();
    }

    public void x(String str) {
        y(str, new a(str));
    }

    public final void y(java.lang.String r6, io.reactivex.rxjava3.core.Observer<com.huawei.maps.businessbase.network.ResponseData> r7) {
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.maps.businessbase.push.MessagePushService.y(java.lang.String, io.reactivex.rxjava3.core.Observer):void");
    }

    public final void z() {
        if (this.c == null && this.d == null) {
            return;
        }
        e4.a().removeListener(this.c, this.d);
    }

    public void onTokenError(Exception exc, Bundle bundle) {
        hm4.h("MessagePushService", "onTokenError called, errCode:" + (exc instanceof BaseException ? ((BaseException) exc).getErrorCode() : 0));
    }

    public void onNewToken(String str, Bundle bundle) {
        onNewToken(str);
    }
}