导航菜单

页面标题

页面副标题

Namma Yatri v3.3.7 - GRPCNotificationService.java 源代码

正在查看: Namma Yatri v3.3.7 应用的 GRPCNotificationService.java JAVA 源代码文件

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


package in.juspay.mobility.app;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import in.juspay.hypersdk.core.PaymentConstants;
import in.juspay.mobility.app.NotificationGrpc;
import in.juspay.mobility.app.NotificationUtils;
import in.juspay.mobility.app.RemoteConfigs.MobilityRemoteConfigs;
import io.grpc.p0;
import java.util.Objects;
import org.json.JSONException;
import org.json.JSONObject;

public class GRPCNotificationService extends Service implements NotificationListener {
    private static NotificationGrpc.NotificationStub asyncStub;
    private io.grpc.V channel;
    private Context context;
    private MobilityRemoteConfigs remoteConfig;

    private void closeChannel() {
        io.grpc.V v = this.channel;
        if (v == null || v.m()) {
            return;
        }
        this.channel.p();
    }

    private boolean containsAny(String str, String[] strArr) {
        if (str == null) {
            return false;
        }
        for (String str2 : strArr) {
            if (str.contains(str2)) {
                return true;
            }
        }
        return false;
    }

    private void initialize() {
        throw new UnsupportedOperationException("Method not decompiled: in.juspay.mobility.app.GRPCNotificationService.initialize():void");
    }

    private void startGRPCNotificationService() {
        GRPCNotificationResponseObserver gRPCNotificationResponseObserver = new GRPCNotificationResponseObserver(this);
        gRPCNotificationResponseObserver.startGRPCNotification(asyncStub.streamPayload(gRPCNotificationResponseObserver));
    }

    public void finalize() throws Throwable {
        try {
            closeChannel();
        } finally {
            super.finalize();
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onComplete() {
        android.util.Log.e(NotificationUtils.RequestSource.GRPC, "[Retrying]");
        closeChannel();
        initialize();
    }

    @Override
    public void onCreate() {
        super.onCreate();
        this.context = getApplicationContext();
        this.remoteConfig = new MobilityRemoteConfigs(true, false);
        initialize();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        android.util.Log.i(NotificationUtils.RequestSource.GRPC, "Destroying GRPC service");
        closeChannel();
    }

    @Override
    public void onError(Throwable th) {
        android.util.Log.e(NotificationUtils.RequestSource.GRPC, "[RetryAttempt]");
        if (th instanceof io.grpc.r0) {
            io.grpc.r0 r0Var = (io.grpc.r0) th;
            if (r0Var.a().n() == p0.b.INTERNAL && r0Var.a().o() != null && containsAny(r0Var.a().o(), new String[]{"Rst Stream", "TIMEOUT", "RETRY"})) {
                android.util.Log.e(NotificationUtils.RequestSource.GRPC, "[Retrying]");
                closeChannel();
                initialize();
                return;
            }
        }
        FirebaseCrashlytics.getInstance().recordException(new Throwable("GRPC OnError", th));
        stopSelf();
    }

    @Override
    public void onMessage(NotificationPayload notificationPayload) {
        android.util.Log.e(NotificationUtils.RequestSource.GRPC, "[Processing]");
        try {
            JSONObject jSONObject = new JSONObject(notificationPayload.getEntity().getData());
            android.util.Log.e("onMessageReceived GRPC", String.valueOf(jSONObject));
            JSONObject jSONObject2 = new JSONObject();
            String category = notificationPayload.getCategory();
            String title = notificationPayload.getTitle();
            String body = notificationPayload.getBody();
            String id2 = notificationPayload.getId();
            jSONObject2.put("notification_id", id2);
            jSONObject2.put("notification_type", notificationPayload.getCategory());
            jSONObject2.put("entity_ids", notificationPayload.getEntity().getId());
            jSONObject2.put("entity_type", notificationPayload.getEntity().getType());
            jSONObject2.put("show_notification", Objects.equals(notificationPayload.getShow(), "SHOW") ? "true" : "false");
            jSONObject2.put("title", title);
            jSONObject2.put("body", body);
            jSONObject2.put("imageUrl", "");
            SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(getString(R.string.preference_file_key), 0);
            if (category.equals("NEW_RIDE_AVAILABLE")) {
                JSONObject jSONObject3 = new JSONObject();
                jSONObject3.put("title", title).put("msg", body);
                NotificationUtils.triggerUICallbacks(category, jSONObject3.toString());
                RideRequestUtils.addRideReceivedEvent(jSONObject, null, null, "ride_request_fcm_received", this);
                if (!sharedPreferences.getString("DISABLE_WIDGET", "null").equals("true") || !sharedPreferences.getString("REMOVE_CONDITION", "false").equals("false")) {
                    NotificationUtils.showRR(this, jSONObject, jSONObject2, NotificationUtils.RequestSource.GRPC);
                } else if (sharedPreferences.getString("ACTIVITY_STATUS", "null").equals("onDestroy")) {
                    NotificationUtils.showRR(this, jSONObject, jSONObject2, NotificationUtils.RequestSource.GRPC);
                } else {
                    RideRequestUtils.addRideReceivedEvent(jSONObject, null, null, "ride_request_ignored", this);
                    NotificationUtils.firebaseLogEventWithParams(this, "ride_ignored", PaymentConstants.PAYLOAD, jSONObject.toString());
                }
            } else {
                NotificationUtils.handleNotifications(category, jSONObject2, id2, this, sharedPreferences, true);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}