正在查看: Tasker v6.5.11 应用的 IpackReceiver.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Tasker v6.5.11 应用的 IpackReceiver.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package net.dinglisch.android.taskerm;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
import java.lang.reflect.Method;
public class IpackReceiver extends BroadcastReceiver {
private void a(Context context, int i) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
if (notificationManager != null) {
try {
notificationManager.cancel(i);
} catch (Exception e) {
Log.e("IpackReceiver", "exception cancelling notification: " + e.toString());
}
}
}
private void b(Context context, int i, Notification notification, String str, String str2, PendingIntent pendingIntent) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
if (notificationManager == null) {
Log.e("IpackReceiver", "no notification manager");
return;
}
d(context, notification);
try {
Method method = Notification.class.getMethod("setLatestEventInfo", Context.class, CharSequence.class, CharSequence.class, PendingIntent.class);
if (method == null) {
Log.e("IpackReceiver", "doNotification: no method setLatestEventInfo");
} else {
method.invoke(notification, context, str, TextUtils.isEmpty(str2) ? "" : str2, pendingIntent);
notificationManager.notify(i, notification);
}
} catch (Exception e) {
Log.e("IpackReceiver", "exception submitting notification: " + e.toString());
}
}
private int c(Notification notification) {
try {
return Build.VERSION.SDK_INT < 23 ? Notification.class.getField("iconID").getInt(notification) : ((Integer) Notification.class.getMethod("getSmallIcon", null).invoke(notification, null)).intValue();
} catch (Exception e) {
Log.w("IpackReceiver", "getNotificationID: " + e.getMessage());
return 0;
}
}
private void d(Context context, Notification notification) {
if (c(notification) != 0) {
Resources resources = context.getResources();
try {
String resourceEntryName = resources.getResourceEntryName(notification.icon);
if (resourceEntryName != null) {
resourceEntryName = resourceEntryName + "_";
}
int identifier = resources.getIdentifier(resourceEntryName, "drawable", context.getPackageName());
if (identifier != 0) {
e(notification, identifier);
}
} catch (Resources.NotFoundException unused) {
Log.e("IpackReceiver", "unknown icon ID: " + notification.icon);
}
}
}
private void e(Notification notification, int i) {
try {
if (Build.VERSION.SDK_INT < 23) {
Notification.class.getField("iconID").setInt(notification, i);
} else {
Notification.class.getMethod("setSmallIcon", Integer.TYPE).invoke(notification, Integer.valueOf(i));
}
} catch (Exception e) {
Log.w("IpackReceiver", "setNotificationID: " + e.getMessage());
}
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null) {
Log.e("IpackReceiver", "null intent");
return;
}
String action = intent.getAction();
if (TextUtils.isEmpty(action)) {
Log.e("IpackReceiver", "null or empty action");
return;
}
if (action.equals("net.dinglisch.android.ipack.actions.NOTIFY")) {
int intExtra = intent.getIntExtra("net.dinglisch.android.ipack.extras.NOTIFICATION_ID", -1);
Parcelable parcelableExtra = intent.getParcelableExtra("net.dinglisch.android.ipack.extras.NOTIFICATION");
Parcelable parcelableExtra2 = intent.getParcelableExtra("net.dinglisch.android.ipack.extras.NOTIFICATION_PI");
String stringExtra = intent.getStringExtra("net.dinglisch.android.ipack.extras.NOTIFICATION_TITLE");
String stringExtra2 = intent.getStringExtra("net.dinglisch.android.ipack.extras.NOTIFICATION_TEXT");
if (parcelableExtra == null) {
Log.e("IpackReceiver", "null notification");
return;
}
if (intExtra == -1) {
Log.e("IpackReceiver", "no notification ID specified");
return;
}
if (parcelableExtra2 == null) {
Log.e("IpackReceiver", "no content intent specified");
return;
} else if (TextUtils.isEmpty(stringExtra)) {
Log.e("IpackReceiver", "no title specified");
return;
} else {
b(context, intExtra, (Notification) parcelableExtra, stringExtra, stringExtra2, (PendingIntent) parcelableExtra2);
return;
}
}
if (action.equals("net.dinglisch.android.ipack.actions.NOTIFY_CANCEL")) {
int intExtra2 = intent.getIntExtra("net.dinglisch.android.ipack.extras.NOTIFICATION_ID", -1);
if (intExtra2 == -1) {
Log.e("IpackReceiver", "no notification ID specified");
return;
} else {
a(context, intExtra2);
return;
}
}
if (action.equals("net.dinglisch.android.ipack.actions.QUERY_PACKS")) {
Bundle bundle = new Bundle();
bundle.putString("net.dinglisch.android.ipack.extras.LABEL", "Tasker Built-In");
bundle.putBoolean("net.dinglisch.android.ipack.extras.ALL_SAME_SIZE", false);
bundle.putString("net.dinglisch.android.ipack.extras.ATTRIBUTION", x5.a);
getResultExtras(true).putBundle(context.getPackageName(), bundle);
return;
}
if (action.equals("net.dinglisch.android.ipack.actions.QUERY_ICONS")) {
x5.a(context.getResources(), getResultExtras(true));
} else {
Log.e("IpackReceiver", "unknown action: " + action);
}
}
}