正在查看: FanCode v7.24.0 应用的 PushTemplateReceiver.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: FanCode v7.24.0 应用的 PushTemplateReceiver.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clevertap.android.pushtemplates;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
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 android.text.Html;
import android.widget.RemoteViews;
import androidx.core.app.q;
import androidx.core.app.q2;
import com.clevertap.android.sdk.CleverTapInstanceConfig;
import com.clevertap.android.sdk.h;
import com.clevertap.android.sdk.pushnotification.CTNotificationIntentService;
import com.clevertap.android.sdk.pushnotification.f;
import com.connectsdk.service.DeviceService;
import com.connectsdk.service.webos.lgcast.common.utils.StringUtil;
import d6.t1;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import y5.g;
public class PushTemplateReceiver extends BroadcastReceiver {
private String A;
private String B;
private String C;
private String D;
private String E;
private boolean F;
private String G;
private String H;
private CleverTapInstanceConfig I;
private h f9275g;
private RemoteViews f9276h;
private RemoteViews f9277i;
private RemoteViews f9278j;
private RemoteViews f9279k;
private String f9280l;
private g f9281m;
private String f9282n;
private String f9283o;
private String f9284p;
private String f9285q;
private String f9291w;
private boolean f9293y;
private NotificationManager f9294z;
boolean f9269a = true;
boolean f9270b = true;
boolean f9271c = true;
boolean f9272d = true;
boolean f9273e = true;
boolean f9274f = true;
private ArrayList<String> f9286r = new ArrayList<>();
private ArrayList<String> f9287s = new ArrayList<>();
private ArrayList<String> f9288t = new ArrayList<>();
private ArrayList<String> f9289u = new ArrayList<>();
private ArrayList<String> f9290v = new ArrayList<>();
private int f9292x = 0;
class a implements Callable<Void> {
final Context f9295a;
final Intent f9296b;
final Bundle f9297c;
a(Context context, Intent intent, Bundle bundle) {
this.f9295a = context;
this.f9296b = intent;
this.f9297c = bundle;
}
@Override
public Void call() throws Exception {
try {
} catch (Throwable th) {
com.clevertap.android.pushtemplates.a.c("Couldn't render notification: " + th.getLocalizedMessage());
}
if (PushTemplateReceiver.this.F) {
d.f(this.f9295a);
d.e(this.f9295a, this.f9296b);
return null;
}
if (PushTemplateReceiver.this.f9281m != null) {
int i9 = b.f9299a[PushTemplateReceiver.this.f9281m.ordinal()];
if (i9 == 1) {
PushTemplateReceiver.this.m(this.f9295a, this.f9297c);
} else if (i9 == 2) {
PushTemplateReceiver.this.h(this.f9295a, this.f9297c);
} else if (i9 == 3) {
PushTemplateReceiver.this.k(this.f9295a, this.f9297c);
} else if (i9 == 4) {
PushTemplateReceiver.this.i(this.f9295a, this.f9297c, this.f9296b);
} else if (i9 == 5) {
PushTemplateReceiver.this.j(this.f9295a, this.f9297c);
}
}
return null;
}
}
static class b {
static final int[] f9299a;
static {
int[] iArr = new int[g.values().length];
f9299a = iArr;
try {
iArr[g.RATING.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
f9299a[g.FIVE_ICONS.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
f9299a[g.PRODUCT_DISPLAY.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
f9299a[g.INPUT_BOX.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
f9299a[g.MANUAL_CAROUSEL.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
}
}
public void h(Context context, Bundle bundle) {
int i9 = bundle.getInt("notificationId");
bundle.putString("wzrk_dl", null);
if (this.f9274f == bundle.getBoolean("close")) {
bundle.putString("wzrk_c2a", "5cta_close");
this.f9294z.cancel(i9);
}
d.N(context, bundle, this.I);
}
public void i(Context context, Bundle bundle, Intent intent) {
Intent launchIntentForPackage;
Bundle k9 = q2.k(intent);
PendingIntent c9 = a6.g.c(context, bundle, new Intent(context, (Class<?>) PushTemplateReceiver.class));
this.I = (CleverTapInstanceConfig) bundle.getParcelable(DeviceService.KEY_CONFIG);
if (k9 != null) {
CharSequence charSequence = k9.getCharSequence("pt_input_reply");
int i9 = bundle.getInt("notificationId");
if (charSequence == null) {
com.clevertap.android.pushtemplates.a.c("PushTemplateReceiver: Input is Empty");
return;
}
com.clevertap.android.pushtemplates.a.c("Processing Input from Input Template");
bundle.putString("pt_input_reply", charSequence.toString());
d.L(context, this.I, bundle, "pt_input_reply");
q.i iVar = this.f9293y ? new q.i(context, "pt_silent_sound_channel") : new q.i(context);
r(context);
int i10 = Build.VERSION.SDK_INT;
if (i10 >= 31) {
iVar.Z(this.H);
}
iVar.T(this.f9292x).w(this.f9282n).v(bundle.getString("pt_input_feedback")).b0(1300L).A(c9).f0(System.currentTimeMillis()).l(true);
s(this.B, bundle, context, iVar);
this.f9294z.notify(i9, iVar.g());
if (i10 < 31) {
if (bundle.getString("pt_input_auto_open") != null || bundle.getBoolean("pt_input_auto_open")) {
try {
Thread.sleep(1300L);
} catch (InterruptedException e9) {
e9.printStackTrace();
}
if (!bundle.containsKey("wzrk_dl") || bundle.getString("wzrk_dl") == null) {
launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
if (launchIntentForPackage == null) {
return;
}
} else {
launchIntentForPackage = new Intent("android.intent.action.VIEW", Uri.parse(intent.getStringExtra("wzrk_dl")));
d.Q(context, launchIntentForPackage);
}
launchIntentForPackage.putExtras(bundle);
launchIntentForPackage.putExtra("pt_reply", charSequence);
launchIntentForPackage.removeExtra("wzrk_acts");
launchIntentForPackage.setFlags(872415232);
context.startActivity(launchIntentForPackage);
}
}
}
}
public void j(Context context, Bundle bundle) {
int size;
try {
int i9 = bundle.getInt("notificationId");
Notification x9 = d.x(context, i9);
if (x9 != null) {
this.f9279k = x9.bigContentView;
this.f9277i = x9.contentView;
}
o(this.f9279k, context);
boolean z9 = bundle.getBoolean("right_swipe");
this.f9286r = bundle.getStringArrayList("pt_image_list");
this.f9287s = bundle.getStringArrayList("pt_deeplink_list");
int i10 = bundle.getInt("pt_manual_carousel_current");
if (z9) {
this.f9279k.showNext(y5.d.f17738c);
this.f9279k.showNext(y5.d.f17740e);
this.f9279k.showNext(y5.d.f17739d);
size = i10 == this.f9286r.size() - 1 ? 0 : i10 + 1;
} else {
this.f9279k.showPrevious(y5.d.f17738c);
this.f9279k.showPrevious(y5.d.f17740e);
this.f9279k.showPrevious(y5.d.f17739d);
size = i10 == 0 ? this.f9286r.size() - 1 : i10 - 1;
}
String str = StringUtil.EMPTY;
ArrayList<String> arrayList = this.f9287s;
if (arrayList == null || arrayList.size() != this.f9286r.size()) {
ArrayList<String> arrayList2 = this.f9287s;
if (arrayList2 == null || arrayList2.size() != 1) {
ArrayList<String> arrayList3 = this.f9287s;
if (arrayList3 == null || arrayList3.size() <= size) {
ArrayList<String> arrayList4 = this.f9287s;
if (arrayList4 != null && arrayList4.size() < size) {
str = this.f9287s.get(0);
}
} else {
str = this.f9287s.get(size);
}
} else {
str = this.f9287s.get(0);
}
} else {
str = this.f9287s.get(size);
}
bundle.putInt("pt_manual_carousel_current", size);
bundle.remove("right_swipe");
bundle.putString("wzrk_dl", str);
bundle.putInt("manual_carousel_from", i10);
this.f9279k.setOnClickPendingIntent(y5.d.f17758w, a6.g.b(context, i9, bundle, false, 4, null));
this.f9279k.setOnClickPendingIntent(y5.d.f17753r, a6.g.b(context, i9, bundle, false, 5, null));
PendingIntent b9 = a6.g.b(context, i9, bundle, true, 3, null);
q.i iVar = x9 != null ? new q.i(context, x9) : n(this.f9293y, "pt_silent_sound_channel", context);
PendingIntent b10 = a6.g.b(context, i9, bundle, false, 6, null);
r(context);
q(iVar, this.f9277i, this.f9279k, this.f9282n, b9, b10);
this.f9294z.notify(i9, iVar.g());
} catch (Throwable th) {
com.clevertap.android.pushtemplates.a.d("Error creating manual carousel notification ", th);
}
}
public void k(android.content.Context r13, android.os.Bundle r14) {
throw new UnsupportedOperationException("Method not decompiled: com.clevertap.android.pushtemplates.PushTemplateReceiver.k(android.content.Context, android.os.Bundle):void");
}
@SuppressLint({"MissingPermission"})
private void l(Context context, Bundle bundle, int i9, String str, CleverTapInstanceConfig cleverTapInstanceConfig) throws InterruptedException {
Intent launchIntentForPackage;
Thread.sleep(1000L);
this.f9294z.cancel(i9);
t(context, this.G, cleverTapInstanceConfig);
context.sendBroadcast(new Intent("android.intent.action.CLOSE_SYSTEM_DIALOGS"));
if (bundle.containsKey("wzrk_dl")) {
launchIntentForPackage = new Intent("android.intent.action.VIEW", Uri.parse(bundle.getString("wzrk_dl")));
t1.B(context, launchIntentForPackage);
} else {
launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
if (launchIntentForPackage == null) {
return;
}
}
launchIntentForPackage.putExtras(bundle);
launchIntentForPackage.putExtra("wzrk_dl", str);
launchIntentForPackage.removeExtra("wzrk_acts");
launchIntentForPackage.putExtra("wzrk_from", "CTPushNotificationReceiver");
launchIntentForPackage.setFlags(872415232);
context.startActivity(launchIntentForPackage);
}
public void m(Context context, Bundle bundle) {
Class<CTNotificationIntentService> cls;
try {
int i9 = bundle.getInt("notificationId");
if (bundle.getBoolean("default_dl", false)) {
this.I = (CleverTapInstanceConfig) bundle.getParcelable(DeviceService.KEY_CONFIG);
this.f9294z.cancel(i9);
try {
cls = CTNotificationIntentService.class;
String str = CTNotificationIntentService.MAIN_ACTION;
} catch (ClassNotFoundException unused) {
com.clevertap.android.pushtemplates.a.a("No Intent Service found");
cls = null;
}
if (t1.x(context, cls)) {
Intent intent = new Intent(CTNotificationIntentService.MAIN_ACTION);
intent.setPackage(context.getPackageName());
intent.putExtra("ct_type", CTNotificationIntentService.TYPE_BUTTON_CLICK);
intent.putExtras(bundle);
intent.putExtra("dl", this.f9285q);
context.startService(intent);
return;
}
Intent intent2 = new Intent("android.intent.action.VIEW", Uri.parse(this.f9285q));
intent2.removeExtra("wzrk_acts");
intent2.putExtra("wzrk_from", "CTPushNotificationReceiver");
intent2.setFlags(872415232);
d.N(context, bundle, this.I);
intent2.putExtras(bundle);
intent2.putExtra("wzrk_dl", this.f9285q);
context.startActivity(intent2);
return;
}
String str2 = this.f9287s.get(0);
if (1 == bundle.getInt("clickedStar", 0)) {
bundle.putString("wzrk_c2a", "rating_1");
if (this.f9287s.size() > 0) {
str2 = this.f9287s.get(0);
}
}
if (2 == bundle.getInt("clickedStar", 0)) {
bundle.putString("wzrk_c2a", "rating_2");
str2 = this.f9287s.size() > 1 ? this.f9287s.get(1) : this.f9287s.get(0);
}
if (3 == bundle.getInt("clickedStar", 0)) {
bundle.putString("wzrk_c2a", "rating_3");
str2 = this.f9287s.size() > 2 ? this.f9287s.get(2) : this.f9287s.get(0);
}
if (4 == bundle.getInt("clickedStar", 0)) {
bundle.putString("wzrk_c2a", "rating_4");
str2 = this.f9287s.size() > 3 ? this.f9287s.get(3) : this.f9287s.get(0);
}
if (5 == bundle.getInt("clickedStar", 0)) {
bundle.putString("wzrk_c2a", "rating_5");
str2 = this.f9287s.size() > 4 ? this.f9287s.get(4) : this.f9287s.get(0);
}
String str3 = str2;
int i10 = Build.VERSION.SDK_INT;
Notification x9 = d.x(context, i9);
if (x9 != null) {
this.f9278j = x9.bigContentView;
this.f9277i = x9.contentView;
}
if (1 == bundle.getInt("clickedStar", 0)) {
this.f9278j.setImageViewResource(y5.d.C, y5.c.f17734b);
this.f9269a = false;
} else {
this.f9278j.setImageViewResource(y5.d.C, y5.c.f17735c);
}
if (2 == bundle.getInt("clickedStar", 0)) {
RemoteViews remoteViews = this.f9278j;
int i11 = y5.d.C;
int i12 = y5.c.f17734b;
remoteViews.setImageViewResource(i11, i12);
this.f9278j.setImageViewResource(y5.d.D, i12);
this.f9270b = false;
} else {
this.f9278j.setImageViewResource(y5.d.D, y5.c.f17735c);
}
if (3 == bundle.getInt("clickedStar", 0)) {
RemoteViews remoteViews2 = this.f9278j;
int i13 = y5.d.C;
int i14 = y5.c.f17734b;
remoteViews2.setImageViewResource(i13, i14);
this.f9278j.setImageViewResource(y5.d.D, i14);
this.f9278j.setImageViewResource(y5.d.E, i14);
this.f9271c = false;
} else {
this.f9278j.setImageViewResource(y5.d.E, y5.c.f17735c);
}
if (4 == bundle.getInt("clickedStar", 0)) {
RemoteViews remoteViews3 = this.f9278j;
int i15 = y5.d.C;
int i16 = y5.c.f17734b;
remoteViews3.setImageViewResource(i15, i16);
this.f9278j.setImageViewResource(y5.d.D, i16);
this.f9278j.setImageViewResource(y5.d.E, i16);
this.f9278j.setImageViewResource(y5.d.F, i16);
this.f9272d = false;
} else {
this.f9278j.setImageViewResource(y5.d.F, y5.c.f17735c);
}
if (5 == bundle.getInt("clickedStar", 0)) {
RemoteViews remoteViews4 = this.f9278j;
int i17 = y5.d.C;
int i18 = y5.c.f17734b;
remoteViews4.setImageViewResource(i17, i18);
this.f9278j.setImageViewResource(y5.d.D, i18);
this.f9278j.setImageViewResource(y5.d.E, i18);
this.f9278j.setImageViewResource(y5.d.F, i18);
this.f9278j.setImageViewResource(y5.d.G, i18);
this.f9273e = false;
} else {
this.f9278j.setImageViewResource(y5.d.G, y5.c.f17735c);
}
bundle.putString("wzrk_dl", str3);
this.f9278j.setOnClickPendingIntent(y5.d.I, f.a(bundle, context));
r(context);
q.i iVar = x9 != null ? new q.i(context, x9) : n(this.f9293y, "pt_silent_sound_channel", context);
PendingIntent c9 = a6.g.c(context, bundle, new Intent(context, (Class<?>) PushTemplateReceiver.class));
if (this.f9294z != null) {
iVar.T(this.f9292x).y(this.f9277i).x(this.f9278j).w(this.f9282n).A(c9).l(true);
this.f9294z.notify(i9, iVar.g());
}
if (i10 < 31) {
d.M(context, this.I, "Rating Submitted", d.c(bundle));
l(context, bundle, i9, str3, this.I);
}
} catch (Throwable th) {
com.clevertap.android.pushtemplates.a.d("Error creating rating notification ", th);
}
}
private q.i n(boolean z9, String str, Context context) {
return z9 ? new q.i(context, str) : new q.i(context);
}
private void o(RemoteViews remoteViews, Context context) {
int i9 = y5.d.f17736a;
remoteViews.setTextViewText(i9, d.l(context));
int i10 = y5.d.J;
remoteViews.setTextViewText(i10, d.B(context));
String str = this.H;
if (str == null || str.isEmpty()) {
remoteViews.setViewVisibility(y5.d.H, 8);
remoteViews.setViewVisibility(y5.d.f17759x, 8);
} else {
remoteViews.setTextViewText(y5.d.H, Html.fromHtml(this.H, 0));
}
String str2 = this.E;
if (str2 == null || str2.isEmpty()) {
return;
}
remoteViews.setTextColor(i9, d.o(this.E, "#A6A6A6"));
remoteViews.setTextColor(i10, d.o(this.E, "#A6A6A6"));
remoteViews.setTextColor(y5.d.H, d.o(this.E, "#A6A6A6"));
}
private void p(Bundle bundle) {
String str = this.f9282n;
if (str == null || str.isEmpty()) {
this.f9282n = bundle.getString("nt");
}
String str2 = this.f9283o;
if (str2 == null || str2.isEmpty()) {
this.f9283o = bundle.getString("nm");
}
String str3 = this.f9284p;
if (str3 == null || str3.isEmpty()) {
this.f9284p = bundle.getString("wzrk_nms");
}
String str4 = this.D;
if (str4 == null || str4.isEmpty()) {
this.D = bundle.getString("wzrk_bp");
}
String str5 = this.f9285q;
if (str5 == null || str5.isEmpty()) {
this.f9285q = bundle.getString("wzrk_dl");
}
String str6 = this.E;
if (str6 == null || str6.isEmpty()) {
this.E = bundle.getString("wzrk_clr");
}
String str7 = this.C;
if (str7 == null || str7.isEmpty()) {
this.C = bundle.getString("wzrk_clr");
}
String str8 = this.H;
if (str8 == null || str8.isEmpty()) {
this.H = bundle.getString("wzrk_st");
}
String str9 = this.C;
if (str9 == null || str9.isEmpty()) {
this.C = bundle.getString("wzrk_clr");
}
}
private void q(q.i iVar, RemoteViews remoteViews, RemoteViews remoteViews2, String str, PendingIntent pendingIntent, PendingIntent pendingIntent2) {
iVar.T(this.f9292x).y(remoteViews).x(remoteViews2).w(Html.fromHtml(str)).A(pendingIntent2).u(pendingIntent).z(5).f0(System.currentTimeMillis()).l(true);
}
private void r(Context context) {
try {
String a9 = d.a(context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData, "CLEVERTAP_NOTIFICATION_ICON");
if (a9 == null) {
throw new IllegalArgumentException();
}
int identifier = context.getResources().getIdentifier(a9, "drawable", context.getPackageName());
this.f9292x = identifier;
if (identifier == 0) {
throw new IllegalArgumentException();
}
} catch (Throwable unused) {
this.f9292x = d.k(context);
}
}
private void s(String str, Bundle bundle, Context context, q.i iVar) {
q.n o9;
if (str == null || !str.startsWith("http")) {
o9 = new q.g().o(bundle.getString("pt_input_feedback"));
} else {
try {
Bitmap w9 = d.w(str, false, context);
if (w9 == null) {
throw new Exception("Failed to fetch big picture!");
}
o9 = new q.f().s(bundle.getString("pt_input_feedback")).q(w9);
} catch (Throwable th) {
q.g o10 = new q.g().o(bundle.getString("pt_input_feedback"));
com.clevertap.android.pushtemplates.a.d("Falling back to big text notification, couldn't fetch big picture", th);
o9 = o10;
}
}
iVar.Y(o9);
}
private void t(Context context, String str, CleverTapInstanceConfig cleverTapInstanceConfig) {
if (str == null || str.isEmpty()) {
return;
}
d.R(context, str, cleverTapInstanceConfig);
}
@Override
public void onReceive(Context context, Intent intent) {
String str;
NotificationChannel notificationChannel;
d.d(context);
if (intent.getExtras() != null) {
Bundle extras = intent.getExtras();
this.f9275g = h.B0(context, extras.getString("wzrk_acct_id"));
this.f9280l = intent.getStringExtra("pt_id");
this.f9283o = extras.getString("pt_msg");
this.f9284p = extras.getString("pt_msg_summary");
this.f9282n = extras.getString("pt_title");
this.f9285q = extras.getString("pt_default_dl");
this.f9286r = d.v(extras);
this.f9287s = d.p(extras);
this.f9288t = d.m(extras);
this.f9289u = d.A(extras);
this.f9290v = d.z(extras);
this.A = extras.getString("pt_product_display_linear");
this.f9294z = (NotificationManager) context.getSystemService("notification");
this.f9291w = extras.getString("wzrk_cid", StringUtil.EMPTY);
this.B = extras.getString("pt_big_img_alt");
this.C = extras.getString("pt_small_icon_clr");
int i9 = Build.VERSION.SDK_INT;
this.f9293y = i9 >= 26;
this.F = extras.getBoolean("pt_dismiss_intent", false);
this.G = extras.getString("pt_rating_toast");
this.H = extras.getString("pt_subtitle");
p(extras);
if (i9 >= 26) {
if (this.f9291w.isEmpty()) {
str = "Unable to render notification, channelId is required but not provided in the notification payload: " + extras.toString();
} else {
NotificationManager notificationManager = this.f9294z;
if (notificationManager != null) {
notificationChannel = notificationManager.getNotificationChannel(this.f9291w);
if (notificationChannel == null) {
str = "Unable to render notification, channelId: " + this.f9291w + " not registered by the app.";
}
}
str = null;
}
if (str != null) {
com.clevertap.android.pushtemplates.a.c(str);
return;
}
}
String str2 = this.f9280l;
if (str2 != null) {
this.f9281m = g.i(str2);
}
h hVar = this.f9275g;
if (hVar == null) {
com.clevertap.android.pushtemplates.a.c("clevertap instance is null, not running PushTemplateReceiver#renderNotification");
return;
}
try {
CleverTapInstanceConfig g9 = hVar.q0().g();
this.I = g9;
h7.a.a(g9).c().g("PushTemplateReceiver#renderNotification", new a(context, intent, extras));
} catch (Exception e9) {
com.clevertap.android.pushtemplates.a.c("Couldn't render notification: " + e9.getLocalizedMessage());
}
}
}
}