正在查看: pg 娱乐 v1.0.7.202506242308 应用的 NotificationUtil.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: pg 娱乐 v1.0.7.202506242308 应用的 NotificationUtil.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.engagelab.privates.push.utils;
import android.app.AppOpsManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Patterns;
import android.webkit.URLUtil;
import android.widget.RemoteViews;
import androidx.core.view.accessibility.AccessibilityEventCompat;
import androidx.vectordrawable.graphics.drawable.PathInterpolatorCompat;
import androidx.webkit.ProxyConfig;
import com.adjust.sdk.Constants;
import com.engagelab.privates.common.component.MTCommonActivity;
import com.engagelab.privates.common.constants.MTCommonConstants;
import com.engagelab.privates.common.f0;
import com.engagelab.privates.common.log.MTCommonLog;
import com.engagelab.privates.common.v0;
import com.engagelab.privates.push.api.NotificationLayout;
import com.engagelab.privates.push.api.NotificationMessage;
import com.engagelab.privates.push.constants.MTPushConstants;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.zip.Adler32;
import org.json.JSONObject;
public class NotificationUtil {
private static final String CHECK_OP_NO_THROW = "checkOpNoThrow";
private static final String JMESSAGE_EXTRA_KEY = "MTInAppExtra";
public static final String NOTIFICATION_ICON = "ic_launcher";
private static final String OP_POST_NOTIFICATION = "OP_POST_NOTIFICATION";
private static final String TAG = "NotificationUtil";
public static class a {
public static final Map<String, String> a = new HashMap();
static {
a();
}
public static int a(int i) {
if (i == 0 || i == 1) {
return -2;
}
if (i != 2) {
return (i == 4 || i == 5) ? 1 : 0;
}
return -1;
}
public static int a(JSONObject jSONObject, int i) {
return i;
}
public static int b(JSONObject jSONObject) {
JSONObject optJSONObject = jSONObject.optJSONObject("n_importance");
if (optJSONObject != null) {
String str = Build.MANUFACTURER;
if (str == null) {
return a(jSONObject, -1);
}
String str2 = a.get(str.toLowerCase());
if (str2 != null) {
int optInt = optJSONObject.optInt(str2, -1);
MTCommonLog.d(NotificationUtil.TAG, "im_v:" + optInt);
return optInt;
}
}
return a(jSONObject, -1);
}
public static int c(JSONObject jSONObject) {
int a2;
int optInt = jSONObject.optInt("n_priority", 0);
int b = b(jSONObject);
return (-1 != b && optInt > (a2 = a(b))) ? a2 : optInt;
}
public static void a() {
Map<String, String> map = a;
map.put(Constants.REFERRER_API_GOOGLE.toLowerCase(), "fc");
map.put(MTPushConstants.Manufacturer.HUAWEI.toLowerCase(), "hw");
map.put(MTPushConstants.Manufacturer.HONOR.toLowerCase(), "hn");
map.put(MTPushConstants.Manufacturer.MEIZU.toLowerCase(), "mz");
map.put("vivo".toLowerCase(), "vi");
map.put(MTPushConstants.Manufacturer.OPPO.toLowerCase(), "op");
map.put(MTPushConstants.Manufacturer.REALME.toLowerCase(), "op");
map.put(MTPushConstants.Manufacturer.ONEPLUS.toLowerCase(), "op");
map.put("xiaomi".toLowerCase(), "xm");
map.put(MTPushConstants.Manufacturer.BLACKSHARK.toLowerCase(), "xm");
}
}
public static String[] convertJsonToArray(String str) {
try {
if (TextUtils.isEmpty(str)) {
return null;
}
JSONObject jSONObject = new JSONObject(str);
Iterator<String> keys = jSONObject.keys();
String[] strArr = new String[jSONObject.length()];
int i = 0;
while (keys.hasNext()) {
strArr[i] = jSONObject.optString(keys.next());
i++;
}
return strArr;
} catch (Throwable th) {
MTCommonLog.w(TAG, "convertJsonToArray failed " + th.getMessage());
return null;
}
}
public static Bundle convertJsonToBundle(JSONObject jSONObject) {
if (jSONObject == null) {
return null;
}
try {
if (TextUtils.isEmpty(jSONObject.toString())) {
return null;
}
Bundle bundle = new Bundle();
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
bundle.putString(next, jSONObject.optString(next));
}
return bundle;
} catch (Throwable th) {
MTCommonLog.w(TAG, "convertJsonToBundle failed " + th.getMessage());
return null;
}
}
public static Bundle convertMapToBundle(Map<String, String> map) {
Bundle bundle = new Bundle();
for (Map.Entry<String, String> entry : map.entrySet()) {
bundle.putString(entry.getKey(), entry.getValue());
}
return bundle;
}
public static String getContent(Context context, NotificationMessage notificationMessage) {
return TextUtils.isEmpty(notificationMessage.getContent()) ? context.getApplicationInfo().loadLabel(context.getPackageManager()).toString() : notificationMessage.getContent();
}
public static int getDefaults(Context context, boolean z, NotificationMessage notificationMessage) {
if (z) {
return (notificationMessage.getDefaults() & 1) == 0 ? notificationMessage.getDefaults() : notificationMessage.getDefaults() - 1;
}
switch (notificationMessage.getDefaults()) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
return notificationMessage.getDefaults();
default:
return -1;
}
}
public static Bitmap getLargeIcon(Context context, String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
return getPictureBitmap(context, str);
}
private static String getLaunchActivityClassName(Context context) {
try {
Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
if (launchIntentForPackage != null && launchIntentForPackage.getComponent() != null) {
return launchIntentForPackage.getComponent().getClassName();
}
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent("android.intent.action.MAIN");
intent.setPackage(context.getPackageName());
intent.addCategory("android.intent.category.LAUNCHER");
ResolveInfo resolveActivity = packageManager.resolveActivity(intent, 65536);
if (resolveActivity == null) {
resolveActivity = packageManager.resolveActivity(launchIntentForPackage, 0);
}
return resolveActivity != null ? resolveActivity.activityInfo.name : "";
} catch (Throwable th) {
MTCommonLog.w(TAG, "getLaunchActivityClassName failed " + th.getMessage());
return "";
}
}
public static String getMessageId(JSONObject jSONObject) {
String optString = jSONObject.optString("ad_id");
if (TextUtils.isEmpty(optString)) {
optString = jSONObject.optString("msg_id");
}
return TextUtils.isEmpty(optString) ? jSONObject.optString("_jmsgid_") : optString;
}
public static int getNotificationId(String str) {
try {
return Integer.parseInt(str);
} catch (Throwable unused) {
MTCommonLog.d(TAG, "the messageId [" + str + "] will convert to adler32");
try {
Adler32 adler32 = new Adler32();
adler32.update(str.getBytes());
int value = (int) adler32.getValue();
return value < 0 ? Math.abs(value) : value;
} catch (Throwable th) {
MTCommonLog.w(TAG, "getNotificationId failed " + th.getMessage());
return 0;
}
}
}
public static int getNotificationImportance(JSONObject jSONObject) throws Throwable {
return a.b(jSONObject);
}
public static RemoteViews getNotificationLayout(Context context, NotificationMessage notificationMessage) {
try {
NotificationLayout a2 = f0.a().a(context, notificationMessage.getBuilderId());
if (a2 == null) {
MTCommonLog.d(TAG, "getNotificationLayout builderId:" + notificationMessage.getBuilderId() + ", notificationLayout is null");
return null;
}
MTCommonLog.d(TAG, "getNotificationLayout builderId:" + notificationMessage.getBuilderId() + ", notificationLayout:" + a2.toString());
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), a2.getLayoutId());
if (a2.getIconViewId() > 0) {
remoteViews.setImageViewResource(a2.getIconViewId(), getSmallIcon(context));
Icon smallIcon = getSmallIcon(context, notificationMessage);
if (smallIcon != null) {
remoteViews.setImageViewIcon(a2.getIconViewId(), smallIcon);
}
}
if (a2.getTitleViewId() > 0) {
remoteViews.setTextViewText(a2.getTitleViewId(), getTitle(context, notificationMessage));
}
if (a2.getContentViewId() > 0) {
remoteViews.setTextViewText(a2.getContentViewId(), getContent(context, notificationMessage));
}
if (a2.getTimeViewId() > 0) {
remoteViews.setLong(a2.getTimeViewId(), "setTime", System.currentTimeMillis());
}
return remoteViews;
} catch (Throwable th) {
MTCommonLog.w(TAG, "getNotificationLayout failed " + th.getMessage());
return null;
}
}
public static NotificationMessage getNotificationMessage(String str) {
try {
if (TextUtils.isEmpty(str)) {
return null;
}
JSONObject jSONObject = new JSONObject(str);
String messageId = getMessageId(jSONObject);
if (TextUtils.isEmpty(messageId)) {
MTCommonLog.d(TAG, "notificationMessage's messageId is null, can't show this notification");
return null;
}
String optString = jSONObject.optString("override_msg_id");
int notificationId = TextUtils.isEmpty(optString) ? getNotificationId(messageId) : getNotificationId(optString);
int optInt = jSONObject.optInt("n_builder_id");
JSONObject optJSONObject = jSONObject.optJSONObject("m_content");
if (optJSONObject == null) {
MTCommonLog.d(TAG, "onMessage failed, can't parse content");
return null;
}
JSONObject optJSONObject2 = jSONObject.optJSONObject("inapp");
long optLong = optJSONObject2 != null ? optJSONObject2.optLong("inapp_end_time", 0L) : 0L;
String optString2 = optJSONObject.optString("n_title");
String optString3 = optJSONObject.optString("n_content");
Bundle convertJsonToBundle = convertJsonToBundle(optJSONObject.optJSONObject("n_extras"));
String optString4 = optJSONObject.optString("n_small_icon");
String optString5 = optJSONObject.optString("n_color");
String optString6 = optJSONObject.optString("n_large_icon");
int optInt2 = optJSONObject.optInt("n_alert_type", -1);
int priority = getPriority(optJSONObject);
try {
int notificationImportance = getNotificationImportance(optJSONObject);
long j = optLong;
String optString7 = optJSONObject.optString("n_category");
int optInt3 = optJSONObject.optInt("n_style");
String optString8 = optJSONObject.optString("n_big_text");
String optString9 = optJSONObject.optString("n_big_pic_path");
String[] convertJsonToArray = convertJsonToArray(optJSONObject.optString("n_inbox"));
String optString10 = optJSONObject.optString("n_channel_id");
return new NotificationMessage().setMessageId(messageId).setOverrideMessageId(optString).setDisplayForeground(optJSONObject.optString("n_display_foreground")).setPlatform((byte) 0).setNotificationId(notificationId).setSmallIcon(optString4).setLargeIcon(optString6).setTitle(optString2).setContent(optString3).setColor(optString5).setBuilderId(optInt).setExtras(convertJsonToBundle).setStyle(optInt3).setBigText(optString8).setInbox(convertJsonToArray).setBigPicture(optString9).setDefaults(optInt2).setPriority(priority).setImportance(notificationImportance).setCategory(optString7).setSound(optJSONObject.optString("n_sound")).setChannelId(optString10).setGroupId(optJSONObject.optString("n_group_id")).setIntentUri(optJSONObject.optString("intent_uri")).setBadge(optJSONObject.optInt("n_badge_add_num")).setInAppEndTime(j);
} catch (Throwable unused) {
return null;
}
} catch (Throwable unused2) {
return null;
}
}
private static Intent getNotificationMessageIntent(Context context, String str, NotificationMessage notificationMessage) {
Intent intent = new Intent();
intent.setClass(context, MTCommonActivity.class);
intent.setAction(str);
intent.addFlags(276824064);
Bundle bundle = new Bundle();
bundle.putParcelable(MTPushConstants.Message.KEY_MESSAGE, notificationMessage);
intent.putExtras(bundle);
return intent;
}
public static Bitmap getPictureBitmap(Context context, String str) {
try {
if (!Patterns.WEB_URL.matcher(str).matches() && !URLUtil.isValidUrl(str)) {
return BitmapFactory.decodeResource(context.getResources(), context.getResources().getIdentifier(str, "drawable", context.getPackageName()));
}
byte[] bArr = HttpUtils.get(context, str, false);
if (bArr != null) {
return BitmapFactory.decodeByteArray(bArr, 0, bArr.length);
}
MTCommonLog.d(TAG, "getPicture bytes is null");
return null;
} catch (Throwable th) {
try {
MTCommonLog.w(TAG, "get pictureBitmap failed " + th.getMessage());
return null;
} finally {
Runtime.getRuntime().gc();
}
}
}
public static int getSmallIcon(Context context) {
int identifier = context.getResources().getIdentifier(NOTIFICATION_ICON, "drawable", context.getPackageName());
if (identifier > 0) {
return identifier;
}
try {
return context.getPackageManager().getApplicationInfo(context.getPackageName(), 0).icon;
} catch (Throwable th) {
MTCommonLog.w(TAG, "get getSmallIcon failed " + th.getMessage());
MTCommonLog.e(TAG, "please put icon [ic_launcher] in res/drawable");
return 0;
}
}
public static Uri getSoundUri(Context context, boolean z, NotificationMessage notificationMessage) {
if (z) {
return null;
}
try {
if (TextUtils.isEmpty(notificationMessage.getSound())) {
return null;
}
if (context.getResources().getIdentifier(notificationMessage.getSound(), "raw", context.getPackageName()) != 0) {
return Uri.parse("android.resource://" + context.getPackageName() + "/raw/" + notificationMessage.getSound());
}
MTCommonLog.d(TAG, "there are no sound resource");
return null;
} catch (Throwable th) {
MTCommonLog.w(TAG, "getSoundUri failed " + th.getMessage());
return null;
}
}
public static String getTitle(Context context, NotificationMessage notificationMessage) {
return TextUtils.isEmpty(notificationMessage.getTitle()) ? context.getApplicationInfo().loadLabel(context.getPackageManager()).toString() : notificationMessage.getTitle();
}
public static boolean isAppInstalled(Context context, String str) {
PackageInfo packageInfo;
if (TextUtils.isEmpty(str)) {
return false;
}
try {
packageInfo = context.getPackageManager().getPackageInfo(str, 0);
} catch (PackageManager.NameNotFoundException unused) {
packageInfo = null;
}
return packageInfo != null;
}
public static boolean jumpDeepLink(Context context, String str, String str2) {
if (TextUtils.isEmpty(str)) {
return false;
}
try {
return str.startsWith(ProxyConfig.MATCH_HTTP) ? jumpWebUrl(context, str, str2) : jumpDeepLinkUrl(context, str, str2);
} catch (Throwable unused) {
return false;
}
}
private static boolean jumpDeepLinkUrl(Context context, String str, String str2) {
try {
Intent parseUri = parseUri(str);
parseUri.setFlags(268435456);
if (context.getPackageManager().resolveActivity(parseUri, 0) == null) {
return false;
}
parseUri.putExtra(JMESSAGE_EXTRA_KEY, str2);
context.startActivity(parseUri);
return true;
} catch (Throwable unused) {
return false;
}
}
private static boolean jumpWebUrl(Context context, String str, String str2) {
if (TextUtils.isEmpty(str)) {
return false;
}
try {
try {
webJumpIntent(context, parseUri(str), str2);
return true;
} catch (ActivityNotFoundException unused) {
webJumpIntent(context, parseUri(str), str2);
return true;
}
} catch (Throwable unused2) {
return false;
}
}
public static Bundle notificationMessageToInApp(NotificationMessage notificationMessage, Bundle bundle) {
try {
String string = bundle.getString(MTPushConstants.Message.KEY_MESSAGE);
if (TextUtils.isEmpty(string)) {
MTCommonLog.w(TAG, "notificationMessageToInApp message is null");
return null;
}
if (notificationMessage == null) {
MTCommonLog.w(TAG, "notificationMessageToInApp notificationMessage is null");
return null;
}
long inAppEndTime = notificationMessage.getInAppEndTime();
if (inAppEndTime <= 0) {
MTCommonLog.w(TAG, "notificationMessageToInApp expired is " + inAppEndTime);
return null;
}
JSONObject jSONObject = new JSONObject();
jSONObject.put("is_notification", true);
jSONObject.put("expired", inAppEndTime);
jSONObject.put("delay", PathInterpolatorCompat.MAX_NUM_POINTS);
jSONObject.put(MTPushConstants.Geofence.KEY_INTERVAL, PathInterpolatorCompat.MAX_NUM_POINTS);
jSONObject.put("duration", 10000);
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("type", 2);
jSONObject2.put("action", notificationMessage.getIntentUri());
jSONObject.put("click", jSONObject2);
jSONObject.put("type", 10);
jSONObject.put("extras", new JSONObject(string));
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("small_image", notificationMessage.getLargeIcon());
JSONObject jSONObject4 = new JSONObject();
jSONObject4.put("text", notificationMessage.getTitle());
jSONObject3.put(MTCommonConstants.Lifecycle.KEY_TITLE, jSONObject4);
JSONObject jSONObject5 = new JSONObject();
jSONObject5.put("text", notificationMessage.getContent());
jSONObject3.put("content", jSONObject5);
jSONObject.put("banner", jSONObject3);
jSONObject.put("location", 0);
String jSONObject6 = jSONObject.toString();
MTCommonLog.w(TAG, "valueInApp:" + jSONObject6);
bundle.putString(MTPushConstants.Message.KEY_MESSAGE, jSONObject6);
return bundle;
} catch (Throwable th) {
MTCommonLog.e(TAG, "notificationMessageToInApp failed:" + th);
return null;
}
}
public static void onClickInAppNotification(Context context, String str) {
try {
String valueOf = String.valueOf(3003);
NotificationMessage notificationMessage = getNotificationMessage(str);
if (notificationMessage == null) {
MTCommonLog.d(TAG, "notificationMessage is null, can't onClick notification");
} else {
context.startActivity(getNotificationMessageIntent(context, valueOf, notificationMessage));
}
} catch (Throwable th) {
MTCommonLog.e(TAG, "onClickInAppNotification failed " + th);
}
}
public static Intent parseUri(String str) throws URISyntaxException {
if (TextUtils.isEmpty(str)) {
return null;
}
Intent parseUri = Intent.parseUri(str, 4);
Intent intent = new Intent(parseUri);
parseUri.addCategory("android.intent.category.BROWSABLE");
parseUri.setComponent(null);
parseUri.setSelector(null);
return intent;
}
public static boolean setHonorBadge(Context context, int i) {
try {
ContentResolver contentResolver = context.getContentResolver();
Uri parse = Uri.parse("content://com.hihonor.android.launcher.settings/badge/");
if (TextUtils.isEmpty(contentResolver.getType(parse))) {
parse = Uri.parse("content://com.huawei.android.launcher.settings/badge/");
if (TextUtils.isEmpty(contentResolver.getType(parse))) {
MTCommonLog.e(TAG, " setHonorBadge fail, uri is null");
return false;
}
}
Bundle bundle = new Bundle();
bundle.putString("package", context.getPackageName());
bundle.putString("class", getLaunchActivityClassName(context));
bundle.putInt("badgenumber", i);
contentResolver.call(parse, "change_badge", (String) null, bundle);
return true;
} catch (Throwable th) {
MTCommonLog.e(TAG, " setHonorBadge wrong error:" + th);
return false;
}
}
public static void setNotificationBadge(Context context, Notification notification, int i) {
int i2;
if (i == 0) {
}
int a2 = f0.a().a(context);
i2 = a2 + i;
v0.b(context, i2);
MTCommonLog.d(TAG, "setNotificationBadge cacheNotificationBadge[" + a2 + "]+currentNotificationBadge[" + i + "]");
String lowerCase = Build.MANUFACTURER.toLowerCase();
lowerCase.hashCode();
lowerCase.hashCode();
switch (lowerCase) {
case "huawei":
setHuaweiBadgeNumber(context, i2);
break;
case "xiaomi":
setXiaomiBadgeNumber(context, notification, i);
break;
case "honor":
setHonorBadge(context, i2);
break;
}
}
public static void setXiaomiBadgeNumber(Context context, Notification notification, int i) {
if (notification == null) {
return;
}
if (i <= 0) {
i = 0;
}
try {
Object obj = notification.getClass().getDeclaredField("extraNotification").get(notification);
obj.getClass().getDeclaredMethod("setMessageCount", Integer.TYPE).invoke(obj, Integer.valueOf(i));
} catch (Throwable th) {
MTCommonLog.w(TAG, "setXiaomiBadgeNumber failed " + th.getMessage());
}
}
private static void webJumpIntent(Context context, Intent intent, String str) throws Throwable {
intent.setFlags(268435456);
intent.putExtra(JMESSAGE_EXTRA_KEY, str);
context.startActivity(intent);
}
public static boolean getNotificationState(Context context) {
try {
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
if (notificationManager == null) {
return false;
}
return notificationManager.areNotificationsEnabled();
} catch (Throwable th) {
MTCommonLog.w(TAG, "getNotificationState failed " + th.getMessage());
try {
AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService("appops");
ApplicationInfo applicationInfo = context.getApplicationInfo();
String packageName = context.getApplicationContext().getPackageName();
int i = applicationInfo.uid;
Class<?> cls = Class.forName(AppOpsManager.class.getName());
Class<?> cls2 = Integer.TYPE;
return ((Integer) cls.getMethod(CHECK_OP_NO_THROW, cls2, cls2, String.class).invoke(appOpsManager, Integer.valueOf(((Integer) cls.getDeclaredField(OP_POST_NOTIFICATION).get(Integer.class)).intValue()), Integer.valueOf(i), packageName)).intValue() == 0;
} catch (Throwable th2) {
MTCommonLog.w(TAG, "getNotificationState failed " + th2.getMessage());
return false;
}
}
}
public static boolean goToAppNotificationSettings(Context context) {
try {
Intent intent = new Intent();
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
intent.putExtra("android.provider.extra.CHANNEL_ID", context.getApplicationInfo().uid);
intent.setFlags(268435456);
context.startActivity(intent);
return true;
} catch (Throwable th) {
MTCommonLog.w(TAG, "goToAppNotificationSettings failed " + th.getMessage());
return false;
}
}
public static Notification.BigPictureStyle getBigPictureStyle(Context context, String str) {
try {
if (TextUtils.isEmpty(str)) {
return null;
}
Notification.BigPictureStyle bigPictureStyle = new Notification.BigPictureStyle();
Bitmap pictureBitmap = getPictureBitmap(context, str);
if (pictureBitmap == null) {
return null;
}
return bigPictureStyle.bigPicture(pictureBitmap);
} catch (Throwable th) {
MTCommonLog.w(TAG, "get bigPictureStyle failed " + th.getMessage());
return null;
}
}
public static Notification.BigTextStyle getBigTextStyle(Context context, String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
return new Notification.BigTextStyle().bigText(str);
}
public static Notification.InboxStyle getInboxStyle(Context context, String[] strArr) {
if (strArr != null) {
try {
if (strArr.length != 0) {
Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
for (String str : strArr) {
inboxStyle.addLine(str);
}
inboxStyle.setSummaryText(" + " + strArr.length + " new messages");
return inboxStyle;
}
} catch (Throwable th) {
MTCommonLog.w(TAG, "getInboxStyle failed " + th.getMessage());
}
}
return null;
}
public static PendingIntent getPendingIntent(Context context, String str, NotificationMessage notificationMessage) {
return PendingIntent.getActivity(context, notificationMessage.getNotificationId(), getNotificationMessageIntent(context, str, notificationMessage), AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL);
}
public static Notification.Style getStyle(Context context, NotificationMessage notificationMessage) {
int style = notificationMessage.getStyle();
if (style == 1) {
return getBigTextStyle(context, notificationMessage.getBigText());
}
if (style == 2) {
return getInboxStyle(context, notificationMessage.getInbox());
}
if (style != 3) {
return null;
}
return getBigPictureStyle(context, notificationMessage.getBigPicture());
}
public static void setHuaweiBadgeNumber(Context context, int i) {
try {
Bundle bundle = new Bundle();
bundle.putString("package", context.getPackageName());
String launchActivityClassName = getLaunchActivityClassName(context);
if (TextUtils.isEmpty(launchActivityClassName)) {
return;
}
MTCommonLog.d(TAG, "setHuaweiBadgeNumber " + i);
bundle.putString("class", launchActivityClassName);
bundle.putInt("badgenumber", i);
context.getContentResolver().call(Uri.parse("content://com.huawei.android.launcher.settings/badge/"), "change_badge", (String) null, bundle);
} catch (Throwable th) {
MTCommonLog.w(TAG, "setHuaweiBadgeNumber failed " + th.getMessage());
}
}
public static int getPriority(Context context, boolean z, NotificationMessage notificationMessage) {
if (z) {
return -1;
}
int priority = notificationMessage.getPriority();
if (priority == -2 || priority == -1 || priority == 0 || priority == 1 || priority == 2) {
return notificationMessage.getPriority();
}
return 0;
}
public static int getVisibility(Context context, boolean z, NotificationMessage notificationMessage) {
int priority;
if (z || (priority = notificationMessage.getPriority()) == -2 || priority == -1) {
return -1;
}
return (priority == 1 || priority == 2) ? 1 : 0;
}
public static int getPriority(JSONObject jSONObject) throws Throwable {
return a.c(jSONObject);
}
public static Icon getSmallIcon(Context context, NotificationMessage notificationMessage) {
Bitmap pictureBitmap;
try {
if (TextUtils.isEmpty(notificationMessage.getSmallIcon()) || (pictureBitmap = getPictureBitmap(context, notificationMessage.getSmallIcon())) == null) {
return null;
}
return Icon.createWithBitmap(pictureBitmap);
} catch (Throwable th) {
MTCommonLog.w(TAG, "getSmallIcon failed " + th.getMessage());
return null;
}
}
}