Files
rr3-apk/decompiled/sources/com/google/firebase/messaging/CommonNotificationBuilder.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

315 lines
15 KiB
Java

package com.google.firebase.messaging;
import android.R;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import androidx.core.view.accessibility.AccessibilityEventCompat;
import com.google.android.gms.cloudmessaging.CloudMessagingReceiver;
import com.google.android.gms.drive.DriveFile;
import com.mbridge.msdk.newreward.player.view.hybrid.util.MRAIDCommunicatorUtil;
import java.util.concurrent.atomic.AtomicInteger;
/* loaded from: classes3.dex */
public abstract class CommonNotificationBuilder {
public static final AtomicInteger requestCodeProvider = new AtomicInteger((int) SystemClock.elapsedRealtime());
public static int getPendingIntentFlags(int i) {
return i | AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL;
}
public static DisplayNotificationInfo createNotificationInfo(Context context, NotificationParams notificationParams) {
Bundle manifestMetadata = getManifestMetadata(context.getPackageManager(), context.getPackageName());
return createNotificationInfo(context, context, notificationParams, getOrCreateChannel(context, notificationParams.getNotificationChannelId(), manifestMetadata), manifestMetadata);
}
public static DisplayNotificationInfo createNotificationInfo(Context context, Context context2, NotificationParams notificationParams, String str, Bundle bundle) {
String packageName = context2.getPackageName();
Resources resources = context2.getResources();
PackageManager packageManager = context2.getPackageManager();
NotificationCompat.Builder builder = new NotificationCompat.Builder(context2, str);
String possiblyLocalizedString = notificationParams.getPossiblyLocalizedString(resources, packageName, "gcm.n.title");
if (!TextUtils.isEmpty(possiblyLocalizedString)) {
builder.setContentTitle(possiblyLocalizedString);
}
String possiblyLocalizedString2 = notificationParams.getPossiblyLocalizedString(resources, packageName, "gcm.n.body");
if (!TextUtils.isEmpty(possiblyLocalizedString2)) {
builder.setContentText(possiblyLocalizedString2);
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(possiblyLocalizedString2));
}
builder.setSmallIcon(getSmallIcon(packageManager, resources, packageName, notificationParams.getString("gcm.n.icon"), bundle));
Uri sound = getSound(packageName, notificationParams, resources);
if (sound != null) {
builder.setSound(sound);
}
builder.setContentIntent(createContentIntent(context, notificationParams, packageName, packageManager));
PendingIntent createDeleteIntent = createDeleteIntent(context, context2, notificationParams);
if (createDeleteIntent != null) {
builder.setDeleteIntent(createDeleteIntent);
}
Integer color = getColor(context2, notificationParams.getString("gcm.n.color"), bundle);
if (color != null) {
builder.setColor(color.intValue());
}
builder.setAutoCancel(!notificationParams.getBoolean("gcm.n.sticky"));
builder.setLocalOnly(notificationParams.getBoolean("gcm.n.local_only"));
String string = notificationParams.getString("gcm.n.ticker");
if (string != null) {
builder.setTicker(string);
}
Integer notificationPriority = notificationParams.getNotificationPriority();
if (notificationPriority != null) {
builder.setPriority(notificationPriority.intValue());
}
Integer visibility = notificationParams.getVisibility();
if (visibility != null) {
builder.setVisibility(visibility.intValue());
}
Integer notificationCount = notificationParams.getNotificationCount();
if (notificationCount != null) {
builder.setNumber(notificationCount.intValue());
}
Long l = notificationParams.getLong("gcm.n.event_time");
if (l != null) {
builder.setShowWhen(true);
builder.setWhen(l.longValue());
}
long[] vibrateTimings = notificationParams.getVibrateTimings();
if (vibrateTimings != null) {
builder.setVibrate(vibrateTimings);
}
int[] lightSettings = notificationParams.getLightSettings();
if (lightSettings != null) {
builder.setLights(lightSettings[0], lightSettings[1], lightSettings[2]);
}
builder.setDefaults(getConsolidatedDefaults(notificationParams));
return new DisplayNotificationInfo(builder, getTag(notificationParams), 0);
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r0v2, types: [int] */
/* JADX WARN: Type inference failed for: r0v6 */
/* JADX WARN: Type inference failed for: r0v7 */
public static int getConsolidatedDefaults(NotificationParams notificationParams) {
boolean z = notificationParams.getBoolean("gcm.n.default_sound");
?? r0 = z;
if (notificationParams.getBoolean("gcm.n.default_vibrate_timings")) {
r0 = (z ? 1 : 0) | 2;
}
return notificationParams.getBoolean("gcm.n.default_light_settings") ? r0 | 4 : r0;
}
public static boolean isValidIcon(Resources resources, int i) {
if (Build.VERSION.SDK_INT != 26) {
return true;
}
try {
if (!(resources.getDrawable(i, null) instanceof AdaptiveIconDrawable)) {
return true;
}
Log.e("FirebaseMessaging", "Adaptive icons cannot be used in notifications. Ignoring icon id: " + i);
return false;
} catch (Resources.NotFoundException unused) {
Log.e("FirebaseMessaging", "Couldn't find resource " + i + ", treating it as an invalid icon");
return false;
}
}
public static int getSmallIcon(PackageManager packageManager, Resources resources, String str, String str2, Bundle bundle) {
if (!TextUtils.isEmpty(str2)) {
int identifier = resources.getIdentifier(str2, "drawable", str);
if (identifier != 0 && isValidIcon(resources, identifier)) {
return identifier;
}
int identifier2 = resources.getIdentifier(str2, "mipmap", str);
if (identifier2 != 0 && isValidIcon(resources, identifier2)) {
return identifier2;
}
Log.w("FirebaseMessaging", "Icon resource " + str2 + " not found. Notification will use default icon.");
}
int i = bundle.getInt("com.google.firebase.messaging.default_notification_icon", 0);
if (i == 0 || !isValidIcon(resources, i)) {
try {
i = packageManager.getApplicationInfo(str, 0).icon;
} catch (PackageManager.NameNotFoundException e) {
Log.w("FirebaseMessaging", "Couldn't get own application info: " + e);
}
}
return (i == 0 || !isValidIcon(resources, i)) ? R.drawable.sym_def_app_icon : i;
}
public static Integer getColor(Context context, String str, Bundle bundle) {
if (!TextUtils.isEmpty(str)) {
try {
return Integer.valueOf(Color.parseColor(str));
} catch (IllegalArgumentException unused) {
Log.w("FirebaseMessaging", "Color is invalid: " + str + ". Notification will use default color.");
}
}
int i = bundle.getInt("com.google.firebase.messaging.default_notification_color", 0);
if (i == 0) {
return null;
}
try {
return Integer.valueOf(ContextCompat.getColor(context, i));
} catch (Resources.NotFoundException unused2) {
Log.w("FirebaseMessaging", "Cannot find the color resource referenced in AndroidManifest.");
return null;
}
}
public static Uri getSound(String str, NotificationParams notificationParams, Resources resources) {
String soundResourceName = notificationParams.getSoundResourceName();
if (TextUtils.isEmpty(soundResourceName)) {
return null;
}
if (!MRAIDCommunicatorUtil.STATES_DEFAULT.equals(soundResourceName) && resources.getIdentifier(soundResourceName, "raw", str) != 0) {
return Uri.parse("android.resource://" + str + "/raw/" + soundResourceName);
}
return RingtoneManager.getDefaultUri(2);
}
public static PendingIntent createContentIntent(Context context, NotificationParams notificationParams, String str, PackageManager packageManager) {
Intent createTargetIntent = createTargetIntent(str, notificationParams, packageManager);
if (createTargetIntent == null) {
return null;
}
createTargetIntent.addFlags(AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL);
createTargetIntent.putExtras(notificationParams.paramsWithReservedKeysRemoved());
if (shouldUploadMetrics(notificationParams)) {
createTargetIntent.putExtra("gcm.n.analytics_data", notificationParams.paramsForAnalyticsIntent());
}
return PendingIntent.getActivity(context, generatePendingIntentRequestCode(), createTargetIntent, getPendingIntentFlags(1073741824));
}
public static Intent createTargetIntent(String str, NotificationParams notificationParams, PackageManager packageManager) {
String string = notificationParams.getString("gcm.n.click_action");
if (!TextUtils.isEmpty(string)) {
Intent intent = new Intent(string);
intent.setPackage(str);
intent.setFlags(DriveFile.MODE_READ_ONLY);
return intent;
}
Uri link = notificationParams.getLink();
if (link != null) {
Intent intent2 = new Intent("android.intent.action.VIEW");
intent2.setPackage(str);
intent2.setData(link);
return intent2;
}
Intent launchIntentForPackage = packageManager.getLaunchIntentForPackage(str);
if (launchIntentForPackage == null) {
Log.w("FirebaseMessaging", "No activity found to launch app");
}
return launchIntentForPackage;
}
public static Bundle getManifestMetadata(PackageManager packageManager, String str) {
try {
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(str, 128);
if (applicationInfo != null) {
Bundle bundle = applicationInfo.metaData;
if (bundle != null) {
return bundle;
}
}
} catch (PackageManager.NameNotFoundException e) {
Log.w("FirebaseMessaging", "Couldn't get own application info: " + e);
}
return Bundle.EMPTY;
}
public static String getOrCreateChannel(Context context, String str, Bundle bundle) {
String string;
try {
if (context.getPackageManager().getApplicationInfo(context.getPackageName(), 0).targetSdkVersion < 26) {
return null;
}
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NotificationManager.class);
if (!TextUtils.isEmpty(str)) {
if (notificationManager.getNotificationChannel(str) != null) {
return str;
}
Log.w("FirebaseMessaging", "Notification Channel requested (" + str + ") has not been created by the app. Manifest configuration, or default, value will be used.");
}
String string2 = bundle.getString("com.google.firebase.messaging.default_notification_channel_id");
if (!TextUtils.isEmpty(string2)) {
if (notificationManager.getNotificationChannel(string2) != null) {
return string2;
}
Log.w("FirebaseMessaging", "Notification Channel set in AndroidManifest.xml has not been created by the app. Default value will be used.");
} else {
Log.w("FirebaseMessaging", "Missing Default Notification Channel metadata in AndroidManifest. Default value will be used.");
}
if (notificationManager.getNotificationChannel("fcm_fallback_notification_channel") == null) {
int identifier = context.getResources().getIdentifier("fcm_fallback_notification_channel_label", "string", context.getPackageName());
if (identifier == 0) {
Log.e("FirebaseMessaging", "String resource \"fcm_fallback_notification_channel_label\" is not found. Using default string channel name.");
string = "Misc";
} else {
string = context.getString(identifier);
}
notificationManager.createNotificationChannel(new NotificationChannel("fcm_fallback_notification_channel", string, 3));
}
return "fcm_fallback_notification_channel";
} catch (PackageManager.NameNotFoundException unused) {
return null;
}
}
public static int generatePendingIntentRequestCode() {
return requestCodeProvider.incrementAndGet();
}
public static PendingIntent createDeleteIntent(Context context, Context context2, NotificationParams notificationParams) {
if (shouldUploadMetrics(notificationParams)) {
return createMessagingPendingIntent(context, context2, new Intent(CloudMessagingReceiver.IntentActionKeys.NOTIFICATION_DISMISS).putExtras(notificationParams.paramsForAnalyticsIntent()));
}
return null;
}
public static PendingIntent createMessagingPendingIntent(Context context, Context context2, Intent intent) {
return PendingIntent.getBroadcast(context, generatePendingIntentRequestCode(), new Intent("com.google.android.c2dm.intent.RECEIVE").setPackage(context2.getPackageName()).putExtra(CloudMessagingReceiver.IntentKeys.WRAPPED_INTENT, intent), getPendingIntentFlags(1073741824));
}
public static boolean shouldUploadMetrics(NotificationParams notificationParams) {
return notificationParams.getBoolean("google.c.a.e");
}
public static String getTag(NotificationParams notificationParams) {
String string = notificationParams.getString("gcm.n.tag");
if (!TextUtils.isEmpty(string)) {
return string;
}
return "FCM-Notification:" + SystemClock.uptimeMillis();
}
public static class DisplayNotificationInfo {
public final int id;
public final NotificationCompat.Builder notificationBuilder;
public final String tag;
public DisplayNotificationInfo(NotificationCompat.Builder builder, String str, int i) {
this.notificationBuilder = builder;
this.tag = str;
this.id = i;
}
}
}