导航菜单

页面标题

页面副标题

Sandridge Go v2025.2.170190457 - ParsePushBroadcastReceiver.java 源代码

正在查看: Sandridge Go v2025.2.170190457 应用的 ParsePushBroadcastReceiver.java JAVA 源代码文件

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


package com.parse;

import A0.j;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import com.staffbase.capacitor.plugin.podcast.StaffbasePodcast;
import java.util.Random;
import m5.AbstractC0480a;
import org.json.JSONException;
import org.json.JSONObject;

public class ParsePushBroadcastReceiver extends com.microsoft.intune.mam.client.content.a {
    public static final String ACTION_PUSH_DELETE = "com.parse.push.intent.DELETE";
    public static final String ACTION_PUSH_OPEN = "com.parse.push.intent.OPEN";
    public static final String ACTION_PUSH_RECEIVE = "com.parse.push.intent.RECEIVE";
    public static final String KEY_PUSH_CHANNEL = "com.parse.Channel";
    public static final String KEY_PUSH_DATA = "com.parse.Data";
    public static final String PROPERTY_PUSH_ICON = "com.parse.push.notification_icon";
    protected static final int SMALL_NOTIFICATION_MAX_CHARACTER_LIMIT = 38;
    private static final String TAG = "com.parse.ParsePushReceiver";

    @TargetApi(26)
    protected void createNotificationChannel(Context context, NotificationChannel notificationChannel) {
        ((NotificationManager) context.getSystemService("notification")).createNotificationChannel(notificationChannel);
    }

    protected Class<? extends Activity> getActivity(Context context, Intent intent) {
        Intent i = AbstractC0480a.i(context.getPackageManager(), context.getPackageName());
        if (i == null) {
            return null;
        }
        try {
            return Class.forName(i.getComponent().getClassName());
        } catch (ClassNotFoundException unused) {
            return null;
        }
    }

    protected Intent getContentIntent(Bundle bundle, String str) {
        Intent intent = new Intent(ACTION_PUSH_OPEN);
        intent.putExtras(bundle);
        intent.setPackage(str);
        return intent;
    }

    protected Intent getDeleteIntent(Bundle bundle, String str) {
        Intent intent = new Intent(ACTION_PUSH_DELETE);
        intent.putExtras(bundle);
        intent.setPackage(str);
        return intent;
    }

    protected Bitmap getLargeIcon(Context context, Intent intent) {
        return null;
    }

    protected j.e getNotification(Context context, Intent intent) {
        JSONObject pushData = getPushData(intent);
        if (pushData == null) {
            return null;
        }
        if (!pushData.has("alert") && !pushData.has(StaffbasePodcast.KEY_TITLE)) {
            return null;
        }
        String optString = pushData.optString(StaffbasePodcast.KEY_TITLE, ManifestInfo.getDisplayName(context));
        String optString2 = pushData.optString("alert", "Notification received.");
        String format = String.format("%s: %s", optString, optString2);
        Bundle extras = intent.getExtras();
        Random random = new Random();
        int nextInt = random.nextInt();
        int nextInt2 = random.nextInt();
        String packageName = context.getPackageName();
        Intent contentIntent = getContentIntent(extras, packageName);
        Intent deleteIntent = getDeleteIntent(extras, packageName);
        int i = Build.VERSION.SDK_INT >= 30 ? 201326592 : 134217728;
        PendingIntent b = com.microsoft.intune.mam.client.app.Y.b(context, nextInt, contentIntent, i);
        PendingIntent b2 = com.microsoft.intune.mam.client.app.Y.b(context, nextInt2, deleteIntent, i);
        NotificationChannel notificationChannel = getNotificationChannel(context, intent);
        createNotificationChannel(context, notificationChannel);
        j.e eVar = new j.e(context, notificationChannel.getId());
        eVar.k(optString).j(optString2).B(format).y(getSmallIconId(context, intent)).q(getLargeIcon(context, intent)).i(b).m(b2).f(true).l(-1);
        if (optString2 != null && optString2.length() > SMALL_NOTIFICATION_MAX_CHARACTER_LIMIT) {
            eVar.A(new j.c().h(optString2));
        }
        return eVar;
    }

    @TargetApi(26)
    protected NotificationChannel getNotificationChannel(Context context, Intent intent) {
        return new NotificationChannel("parse_push", "Push notifications", 3);
    }

    protected JSONObject getPushData(Intent intent) {
        try {
            return new JSONObject(intent.getStringExtra(KEY_PUSH_DATA));
        } catch (JSONException e) {
            PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e);
            return null;
        }
    }

    protected int getSmallIconId(Context context, Intent intent) {
        Bundle applicationMetadata = ManifestInfo.getApplicationMetadata(context);
        int i = applicationMetadata != null ? applicationMetadata.getInt(PROPERTY_PUSH_ICON) : 0;
        return i != 0 ? i : ManifestInfo.getIconId();
    }

    @Override
    public void onMAMReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action != null) {
            switch (action) {
                case "com.parse.push.intent.DELETE":
                    onPushDismiss(context, intent);
                    break;
                case "com.parse.push.intent.RECEIVE":
                    onPushReceive(context, intent);
                    break;
                case "com.parse.push.intent.OPEN":
                    onPushOpen(context, intent);
                    break;
            }
        }
    }

    protected void onPushDismiss(Context context, Intent intent) {
    }

    protected void onPushOpen(Context context, Intent intent) {
        ParseAnalytics.trackAppOpenedInBackground(intent);
        String str = null;
        try {
            str = new JSONObject(intent.getStringExtra(KEY_PUSH_DATA)).optString("uri", null);
        } catch (JSONException e) {
            PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e);
        }
        Class<? extends Activity> activity = getActivity(context, intent);
        Intent intent2 = str != null ? new Intent("android.intent.action.VIEW", Uri.parse(str)) : new Intent(context, activity);
        intent2.putExtras(intent.getExtras());
        TaskStackBuilderHelper.startActivities(context, activity, intent2);
    }

    protected void onPushReceive(Context context, Intent intent) {
        JSONObject jSONObject;
        String stringExtra = intent.getStringExtra(KEY_PUSH_DATA);
        if (stringExtra == null) {
            PLog.e(TAG, "Can not get push data from intent.");
            return;
        }
        PLog.v(TAG, "Received push data: " + stringExtra);
        try {
            jSONObject = new JSONObject(stringExtra);
        } catch (JSONException e) {
            PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e);
            jSONObject = null;
        }
        String optString = jSONObject != null ? jSONObject.optString("action", null) : null;
        if (optString != null) {
            Bundle extras = intent.getExtras();
            Intent intent2 = new Intent();
            intent2.putExtras(extras);
            intent2.setAction(optString);
            intent2.setPackage(context.getPackageName());
            context.sendBroadcast(intent2);
        }
        j.e notification = getNotification(context, intent);
        Notification c = notification != null ? notification.c() : null;
        if (c != null) {
            ParseNotificationManager.getInstance().showNotification(context, c);
        }
    }
}