导航菜单

页面标题

页面副标题

Pulsar v1.0.0 - UBSPushAutoTrackHelper.java 源代码

正在查看: Pulsar v1.0.0 应用的 UBSPushAutoTrackHelper.java JAVA 源代码文件

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


package com.xly.analytics.android.sdk.aop.push;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import com.xly.analytics.android.sdk.AbstractUBSDataAPI;
import com.xly.analytics.android.sdk.UBSDataAPI;
import com.xly.analytics.android.sdk.UBSDataAPIEmptyImplementation;
import com.xly.analytics.android.sdk.UBSLog;
import com.xly.analytics.android.sdk.push.core.UBSPushProcess;
import com.xly.analytics.android.sdk.push.utils.UBSPushUtils;
import com.xly.analytics.android.sdk.realtimedata.UBSRealTimeDataManager;
import com.xly.analytics.android.sdk.util.ReflectUtil;
import org.json.JSONObject;
import v6.a;

public class UBSPushAutoTrackHelper {
    private static final String TAG = "UBS.PushAutoTrackHelper";
    private static long lastPushClickTime;

    private static String getSFData(String str) {
        try {
            return new JSONObject(str).optString("sf_data");
        } catch (Exception unused) {
            UBSLog.i(TAG, "get sf_data failed");
            return null;
        }
    }

    private static void hookIntent(Intent intent) {
        if (isTrackPushEnabled()) {
            try {
                UBSPushProcess.getInstance().hookIntent(intent);
                UBSLog.i(TAG, "hookIntent");
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void hookIntentGetActivity(Context context, int i, Intent intent, int i2) {
        hookIntent(intent);
    }

    public static void hookIntentGetActivityBundle(Context context, int i, Intent intent, int i2, Bundle bundle) {
        hookIntent(intent);
    }

    public static void hookIntentGetBroadcast(Context context, int i, Intent intent, int i2) {
        hookIntent(intent);
    }

    public static void hookIntentGetForegroundService(Context context, int i, Intent intent, int i2) {
        hookIntent(intent);
    }

    public static void hookIntentGetService(Context context, int i, Intent intent, int i2) {
        hookIntent(intent);
    }

    private static void hookPendingIntent(Intent intent, PendingIntent pendingIntent) {
        if (isTrackPushEnabled()) {
            try {
                UBSPushProcess.getInstance().hookPendingIntent(intent, pendingIntent);
                UBSLog.i(TAG, "hookPendingIntent");
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void hookPendingIntentGetActivity(PendingIntent pendingIntent, Context context, int i, Intent intent, int i2) {
        hookPendingIntent(intent, pendingIntent);
    }

    public static void hookPendingIntentGetActivityBundle(PendingIntent pendingIntent, Context context, int i, Intent intent, int i2, Bundle bundle) {
        hookPendingIntent(intent, pendingIntent);
    }

    public static void hookPendingIntentGetBroadcast(PendingIntent pendingIntent, Context context, int i, Intent intent, int i2) {
        hookPendingIntent(intent, pendingIntent);
    }

    public static void hookPendingIntentGetForegroundService(PendingIntent pendingIntent, Context context, int i, Intent intent, int i2) {
        hookPendingIntent(intent, pendingIntent);
    }

    public static void hookPendingIntentGetService(PendingIntent pendingIntent, Context context, int i, Intent intent, int i2) {
        hookPendingIntent(intent, pendingIntent);
    }

    private static boolean isRepeatEvent() {
        long elapsedRealtime = SystemClock.elapsedRealtime();
        UBSLog.i(TAG, "currentTime: " + elapsedRealtime + ",lastPushClickTime: " + lastPushClickTime);
        if (elapsedRealtime - lastPushClickTime <= 2000) {
            return true;
        }
        lastPushClickTime = elapsedRealtime;
        return false;
    }

    private static boolean isTrackPushEnabled() {
        try {
            if (!(UBSDataAPI.sharedInstance() instanceof UBSDataAPIEmptyImplementation) && AbstractUBSDataAPI.getConfigOptions() != null && AbstractUBSDataAPI.getConfigOptions().isEnableTrackPush()) {
                return true;
            }
            UBSLog.i(TAG, "SDK or push disabled.");
            return false;
        } catch (Exception e) {
            UBSLog.printStackTrace(e);
            return false;
        }
    }

    public static void onBroadcastReceiver(BroadcastReceiver broadcastReceiver, Context context, Intent intent) {
        onBroadcastServiceIntent(intent);
    }

    private static void onBroadcastServiceIntent(Intent intent) {
        if (isTrackPushEnabled()) {
            try {
                UBSPushProcess.getInstance().onNotificationClick(null, intent);
                UBSLog.i(TAG, "onBroadcastServiceIntent");
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void onGeTuiNotificationClicked(Object obj) {
        if (obj == null) {
            UBSLog.i(TAG, "gtNotificationMessage is null");
            return;
        }
        if (isTrackPushEnabled()) {
            try {
                String str = (String) ReflectUtil.callMethod(obj, "getMessageId", new Object[0]);
                String str2 = (String) ReflectUtil.callMethod(obj, "getTitle", new Object[0]);
                String str3 = (String) ReflectUtil.callMethod(obj, "getContent", new Object[0]);
                if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2) || TextUtils.isEmpty(str3)) {
                    return;
                }
                UBSPushProcess.getInstance().trackGTClickDelayed(str, str2, str3);
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void onGeTuiReceiveMessageData(Object obj) {
        if (obj == null) {
            UBSLog.i(TAG, "gtNotificationMessage is null");
            return;
        }
        if (isTrackPushEnabled()) {
            try {
                byte[] bArr = (byte[]) ReflectUtil.callMethod(obj, "getPayload", new Object[0]);
                String str = (String) ReflectUtil.callMethod(obj, "getMessageId", new Object[0]);
                if (bArr == null || TextUtils.isEmpty(str)) {
                    return;
                }
                UBSPushProcess.getInstance().trackReceiveMessageData(new String(bArr), str);
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void onNewIntent(Object obj, Intent intent) {
        if (isTrackPushEnabled()) {
            try {
                if (obj instanceof Activity) {
                    UBSPushProcess.getInstance().onNotificationClick((Activity) obj, intent);
                    UBSLog.i(TAG, "onNewIntent");
                }
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void onNotify(NotificationManager notificationManager, int i, Notification notification) {
        if (isTrackPushEnabled()) {
            try {
                onNotify(notificationManager, null, i, notification);
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void onServiceStart(Service service, Intent intent, int i) {
        onBroadcastServiceIntent(intent);
    }

    public static void onServiceStartCommand(Service service, Intent intent, int i, int i2) {
        onBroadcastServiceIntent(intent);
    }

    public static void onUMengActivityMessage(Intent intent) {
        JSONObject jSONObject;
        JSONObject optJSONObject;
        if (intent == null) {
            UBSLog.i(TAG, "intent is null");
            return;
        }
        if (isTrackPushEnabled()) {
            try {
                String stringExtra = intent.getStringExtra("body");
                if (TextUtils.isEmpty(stringExtra) || (optJSONObject = (jSONObject = new JSONObject(stringExtra)).optJSONObject("body")) == null) {
                    return;
                }
                String optString = jSONObject.optString(UBSRealTimeDataManager.JSON_KEY_EXTRA);
                String optString2 = optJSONObject.optString(a.c);
                String optString3 = optJSONObject.optString("text");
                trackNotificationOpenedEvent(getSFData(optString), optString2, optString3, "UMeng", intent.getStringExtra("message_source"));
                UBSLog.i(TAG, String.format("onUMengActivityMessage is called, title is %s, content is %s, extras is %s", optString2, optString3, optString));
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void onUMengNotificationClick(Object obj) {
        if (obj == null) {
            UBSLog.i(TAG, "UMessage is null");
            return;
        }
        if (isTrackPushEnabled()) {
            try {
                JSONObject jSONObject = (JSONObject) ReflectUtil.callMethod(obj, "getRaw", new Object[0]);
                if (jSONObject == null) {
                    UBSLog.i(TAG, "onUMengNotificationClick:raw is null");
                    return;
                }
                JSONObject optJSONObject = jSONObject.optJSONObject("body");
                if (optJSONObject != null) {
                    String optString = jSONObject.optString(UBSRealTimeDataManager.JSON_KEY_EXTRA);
                    String optString2 = optJSONObject.optString(a.c);
                    String optString3 = optJSONObject.optString("text");
                    trackNotificationOpenedEvent(getSFData(optString), optString2, optString3, "UMeng", null);
                    UBSLog.i(TAG, String.format("onUMengNotificationClick is called, title is %s, content is %s, extras is %s", optString2, optString3, optString));
                }
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void trackGeTuiNotificationClicked(String str, String str2, String str3, long j) {
        trackNotificationOpenedEvent(str3, str, str2, "GeTui", null, j);
    }

    public static void trackJPushAppOpenNotification(String str, String str2, String str3, String str4) {
        if (isTrackPushEnabled()) {
            UBSLog.i(TAG, String.format("trackJPushAppOpenNotification is called, title is %s, content is %s, extras is %s, appPushChannel is %s, appPushServiceName is %s", str2, str3, str, str4, "JPush"));
            trackNotificationOpenedEvent(getSFData(str), str2, str3, "JPush", str4);
        }
    }

    public static void trackJPushOpenActivity(Intent intent) {
        if (intent != null && isTrackPushEnabled()) {
            JSONObject jSONObject = null;
            String uri = intent.getData() != null ? intent.getData().toString() : null;
            if (TextUtils.isEmpty(uri) && intent.getExtras() != null) {
                uri = intent.getExtras().getString("JMessageExtra");
            }
            UBSLog.i(TAG, "trackJPushOpenActivity is called, Intent data is " + uri);
            try {
                if (TextUtils.isEmpty(uri)) {
                    return;
                }
                try {
                    jSONObject = new JSONObject(uri);
                } catch (Exception unused) {
                    UBSLog.i(TAG, "Failed to construct JSON");
                }
                if (jSONObject != null) {
                    String optString = jSONObject.optString("n_title");
                    String optString2 = jSONObject.optString("n_content");
                    String optString3 = jSONObject.optString("n_extras");
                    String jPushSDKName = UBSPushUtils.getJPushSDKName((byte) jSONObject.optInt("rom_type"));
                    UBSLog.i(TAG, String.format("trackJPushOpenActivity is called, title is %s, content is %s, extras is %s, appPushChannel is %s", optString, optString2, optString3, jPushSDKName));
                    if (!TextUtils.isEmpty(optString) && !TextUtils.isEmpty(optString2) && !TextUtils.isEmpty(jPushSDKName)) {
                        trackNotificationOpenedEvent(getSFData(optString3), optString, optString2, "JPush", jPushSDKName);
                    }
                }
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    public static void trackMeizuAppOpenNotification(String str, String str2, String str3, String str4) {
        JSONObject jSONObject;
        JSONObject optJSONObject;
        if (isTrackPushEnabled()) {
            UBSLog.i(TAG, String.format("trackMeizuAppOpenNotification is called, title is %s, content is %s, extras is %s, appPushChannel is %s, appPushServiceName is %s", str2, str3, str, "Meizu", str4));
            try {
                try {
                    try {
                        jSONObject = new JSONObject(str);
                    } catch (Exception unused) {
                        UBSLog.i(TAG, "Failed to construct JSON");
                        jSONObject = null;
                    }
                    if (jSONObject != null && jSONObject.has("JMessageExtra")) {
                        JSONObject optJSONObject2 = jSONObject.optJSONObject("JMessageExtra");
                        if (optJSONObject2 != null && (optJSONObject = optJSONObject2.optJSONObject("m_content")) != null) {
                            str = optJSONObject.optString("n_extras");
                        }
                        str4 = "JPush";
                    }
                } catch (Exception e) {
                    UBSLog.printStackTrace(e);
                }
                trackNotificationOpenedEvent(getSFData(str), str2, str3, str4, "Meizu");
            } catch (Exception e2) {
                UBSLog.printStackTrace(e2);
            }
        }
    }

    public static void trackNotificationOpenedEvent(String str, String str2, String str3, String str4, String str5) {
        trackNotificationOpenedEvent(str, str2, str3, str4, str5, 0L);
    }

    public static void onNotify(NotificationManager notificationManager, String str, int i, Notification notification) {
        if (isTrackPushEnabled()) {
            try {
                UBSPushProcess.getInstance().onNotify(str, i, notification);
                UBSLog.i(TAG, "onNotify");
            } catch (Exception e) {
                UBSLog.printStackTrace(e);
            }
        }
    }

    private static void trackNotificationOpenedEvent(java.lang.String r4, java.lang.String r5, java.lang.String r6, java.lang.String r7, java.lang.String r8, long r9) {
        throw new UnsupportedOperationException("Method not decompiled: com.xly.analytics.android.sdk.aop.push.UBSPushAutoTrackHelper.trackNotificationOpenedEvent(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, long):void");
    }
}